public static SourceFileModule makeSourceModule(URL script, String dir, String name) { // DO NOT use File.separator here, since this name is matched against // URLs. It seems that, in DOS, URL.getFile() does not return a // \-separated file name, but rather one with /'s. Rather makes one // wonder why the function is called get_File_ :( return makeSourceModule(script, dir + '/' + name); }
public static SourceFileModule makeSourceModule(URL script, String dir, String name) { // DO NOT use File.separator here, since this name is matched against // URLs. It seems that, in DOS, URL.getFile() does not return a // \-separated file name, but rather one with /'s. Rather makes one // wonder why the function is called get_File_ :( return makeSourceModule(script, dir + '/' + name); }
public static SourceFileModule[] handleFileNames(String[] fileNameArgs) { SourceFileModule[] fileNames = new SourceFileModule[fileNameArgs.length]; for (int i = 0; i < fileNameArgs.length; i++) { if (new File(fileNameArgs[i]).exists()) { try { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(fileNameArgs[i]).toURI().toURL(), fileNameArgs[i]); } catch (MalformedURLException e) { Assertions.UNREACHABLE(e.toString()); } } else { URL url = CAstCallGraphUtil.class.getClassLoader().getResource(fileNameArgs[i]); fileNames[i] = CAstCallGraphUtil.makeSourceModule(url, fileNameArgs[i]); } } return fileNames; }
public static SourceFileModule[] handleFileNames(String[] fileNameArgs) { SourceFileModule[] fileNames = new SourceFileModule[fileNameArgs.length]; for (int i = 0; i < fileNameArgs.length; i++) { if (new File(fileNameArgs[i]).exists()) { try { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(fileNameArgs[i]).toURI().toURL(), fileNameArgs[i]); } catch (MalformedURLException e) { Assertions.UNREACHABLE(e.toString()); } } else { URL url = CAstCallGraphUtil.class.getClassLoader().getResource(fileNameArgs[i]); fileNames[i] = CAstCallGraphUtil.makeSourceModule(url, fileNameArgs[i]); } } return fileNames; }
public static NodejsRequiredCoreModule make(String name) throws IOException { if (! names.containsKey(name)) { java.nio.file.Path p = Files.createTempDirectory("nodejs"); File f = new File(p.toFile(), name + ".js"); f.deleteOnExit(); p.toFile().deleteOnExit(); names.put(name, f); } File file = names.get(name); TemporaryFile.streamToFile(file, getModule(name)); SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(), file.getName()); return new NodejsRequiredCoreModule(file, sourceFileModule); }
public static NodejsRequiredSourceModule make(File rootDir, File file) throws IOException { String className = convertFileToClassName(rootDir, file); SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(), file.getName()); return new NodejsRequiredSourceModule(className, file, sourceFileModule); } }
protected void testInternal(String[] args, TranslatorAssertions assertions) throws Exception { String testPath = getTestPath(); SourceFileModule[] fileNames = new SourceFileModule[args.length]; for (int i = 0; i < args.length; i++) { if (new File(args[i]).exists()) { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(args[i]).toURI().toURL(), args[i]); } else if (new File(testPath + args[i]).exists()) { fileNames[i] = CAstCallGraphUtil.makeSourceModule(new File(testPath + args[i]).toURI().toURL(), args[i]); } else { URL url = getClass().getClassLoader().getResource(args[i]); fileNames[i] = CAstCallGraphUtil.makeSourceModule(url, args[i]); } Assert.assertTrue(args[i], fileNames[i] != null); } ClassHierarchy cha = runTranslator(fileNames); dump(cha); if (assertions != null) { checkAssertions(cha, assertions); } else { System.err.println(("WARNING: no assertions for " + getClass())); } }
SourceFileModule mainSourceModule = CAstCallGraphUtil.makeSourceModule(mainFile.toURI().toURL(), mainFile.getName()); String mainFileClassName = NodejsRequiredSourceModule.convertFileToClassName(workingDir, mainFile);