diff options
author | Shevek <[email protected]> | 2014-09-10 19:05:59 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2014-09-10 19:06:17 -0700 |
commit | aefac8ce01aee2f538db413d5812613facee9c55 (patch) | |
tree | 18750850b15328903f95f5927250c51a2a806d32 /src/main/java | |
parent | b5bc0ba45a398457a686806889a62eabcbefa45f (diff) |
Fix #18: Give access to list of includes.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/anarres/cpp/Preprocessor.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index f96eb4a..3569b86 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -107,6 +107,7 @@ public class Preprocessor implements Closeable { /* Miscellaneous support. */ private int counter; private final Set<String> onceseenpaths = new HashSet<String>(); + private final List<VirtualFile> includes = new ArrayList<VirtualFile>(); /* Support junk to make it work like cpp */ private List<String> quoteincludepath; /* -iquote */ @@ -466,6 +467,18 @@ public class Preprocessor implements Closeable { return macros.get(name); } + /** + * Returns the list of {@link VirtualFile VirtualFiles} which have been + * included by this Preprocessor. + * + * This does not include any {@link Source} provided to the constructor + * or {@link #addInput(java.io.File)} or {@link #addInput(Source)}. + */ + @Nonnull + public List<? extends VirtualFile> getIncludes() { + return includes; + } + /* States */ private void push_state() { State top = states.peek(); @@ -1098,6 +1111,7 @@ public class Preprocessor implements Closeable { return false; if (getFeature(Feature.DEBUG)) System.err.println("pp: including " + file); + includes.add(file); push_source(file.getSource(), true); return true; } @@ -1109,7 +1123,7 @@ public class Preprocessor implements Closeable { throws IOException, LexerException { for (String dir : path) { - VirtualFile file = filesystem.getFile(dir, name); + VirtualFile file = getFileSystem().getFile(dir, name); if (include(file)) return true; } |