@Override protected FileModule makeFile(File file) { String rootPath = root.getAbsolutePath(); if (!rootPath.endsWith(File.separator)) { rootPath = rootPath + File.separator; } String filePath = file.getAbsolutePath(); assert filePath.startsWith(rootPath); return new SourceFileModule(file, filePath.substring(rootPath.length()), this); }
@Override protected FileModule makeFile(File file) { String rootPath = root.getAbsolutePath(); if (!rootPath.endsWith(File.separator)) { rootPath = rootPath + File.separator; } String filePath = file.getAbsolutePath(); assert filePath.startsWith(rootPath); return new SourceFileModule(file, filePath.substring(rootPath.length()), this); }
/** * Add a class file to the scope for a loader */ public void addSourceFileToScope(ClassLoaderReference loader, File file, String fileName) throws IllegalArgumentException { List<Module> s = MapUtil.findOrCreateList(moduleMap, loader); s.add(new SourceFileModule(file, fileName, null)); }
/** * Add a class file to the scope for a loader */ public void addSourceFileToScope(ClassLoaderReference loader, File file, String fileName) throws IllegalArgumentException { List<Module> s = MapUtil.findOrCreateList(moduleMap, loader); s.add(new SourceFileModule(file, fileName, null)); }
protected abstract CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException; protected abstract CorrelationFinder makeCorrelationFinder();
protected abstract CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException;
public static void populateScope(JavaSourceAnalysisEngine<?> engine, Collection<String> sources, List<String> libs) { boolean foundLib = false; for (String lib : libs) { File libFile = new File(lib); if (libFile.exists()) { foundLib = true; try { engine.addSystemModule(new JarFileModule(new JarFile(libFile, false))); } catch (IOException e) { Assert.fail(e.getMessage()); } } } assert foundLib : "couldn't find library file from " + libs; for (String srcFilePath : sources) { String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1); File f = new File(srcFilePath); Assert.assertTrue("couldn't find " + srcFilePath, f.exists()); if (f.isDirectory()) { engine.addSourceModule(new SourceDirectoryTreeModule(f)); } else { engine.addSourceModule(new SourceFileModule(f, srcFileName, null)); } } }