@Override public void loadAllSources(Set<ModuleEntry> modules) { List<String> sources = new LinkedList<>(); Map<String, ModuleEntry> sourceMap = HashMapFactory.make(); for(ModuleEntry m : modules) { if (m.isSourceFile()) { SourceFileModule s = (SourceFileModule)m; sourceMap.put(s.getAbsolutePath(), s); sources.add(s.getAbsolutePath()); } } String[] sourceFiles = sources.toArray(new String[0]); @SuppressWarnings("deprecation") final ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setResolveBindings(true); parser.setEnvironment(libs, this.sources, null, false); Hashtable<String, String> options = JavaCore.getOptions(); options.put(JavaCore.COMPILER_SOURCE, "1.8"); parser.setCompilerOptions(options); parser.createASTs(sourceFiles, null, new String[0], new ECJAstToIR(sourceMap), new NullProgressMonitor()); }
/** * Return the Set of (ModuleEntry) source files found in a module. * * @param M the module * @return the Set of source files in the module */ @SuppressWarnings("unused") private Set<ModuleEntry> getSourceFiles(Module M) throws IOException { if (DEBUG_LEVEL > 0) { System.err.println("Get source files for " + M); } HashSet<ModuleEntry> result = HashSetFactory.make(); for (ModuleEntry entry : Iterator2Iterable.make(M.getEntries())) { if (DEBUG_LEVEL > 0) { System.err.println("consider entry for source information: " + entry); } if (entry.isSourceFile()) { if (DEBUG_LEVEL > 0) { System.err.println("found source file: " + entry); } result.add(entry); } else if (entry.isModuleFile()) { result.addAll(getSourceFiles(entry.asModule())); } } return result; }
/** * Return the Set of (ModuleEntry) source files found in a module. * * @param M the module * @return the Set of source files in the module */ @SuppressWarnings("unused") private Set<ModuleEntry> getSourceFiles(Module M) throws IOException { if (DEBUG_LEVEL > 0) { System.err.println("Get source files for " + M); } HashSet<ModuleEntry> result = HashSetFactory.make(); for (ModuleEntry entry : Iterator2Iterable.make(M.getEntries())) { if (DEBUG_LEVEL > 0) { System.err.println("consider entry for source information: " + entry); } if (entry.isSourceFile()) { if (DEBUG_LEVEL > 0) { System.err.println("found source file: " + entry); } result.add(entry); } else if (entry.isModuleFile()) { result.addAll(getSourceFiles(entry.asModule())); } } return result; }