@Override public int read(char[] cbuf, int off, int len) throws IOException { if (currentReader == null) { if (index < constituents.length) { currentName = constituents[index].getURL(); currentReader = new LineNumberReader(new InputStreamReader(constituents[index++].getInputStream())); } else { return -1; } } int x; if ((x = currentReader.read(cbuf, off, len)) == -1) { line += currentReader.getLineNumber(); locations.add(Pair.make(line, currentName)); currentReader.close(); currentReader = null; return read(cbuf, off, len); } return x; }
@Override public int read() throws IOException { if (currentStream == null) { if (index < constituents.length) { currentStream = constituents[index++].getInputStream(); } else { return -1; } } int b = currentStream.read(); if (b == -1) { currentStream = null; return read(); } return b; } };
private Position makePosition(AstNode n) { if (n != null) { URL url = ((SourceModule)sourceModule).getURL(); int line = n.getLineno(); Position pos = new RangePosition(url, line, n.getAbsolutePosition(), n.getAbsolutePosition()+n.getLength()); if (sourceModule instanceof MappedSourceModule) { Position np = ((MappedSourceModule) sourceModule).getMapping().getIncludedPosition(pos); if (np != null) { return np; } } return pos; } else { return null; } }
@Override protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException { RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false); CAstEntity entity = null; try { entity = translator.translateToCAst(); } catch (Error e) { e.printStackTrace(); assert false; } return entity; } }
File workingDir = new File(receiver.getSourceFileName()).getParentFile(); SourceModule sourceModule = resolve(rootDir, workingDir, target); if (previouslyRequired.containsKey(sourceModule.getClassName())) { return previouslyRequired.get(sourceModule.getClassName()); String className = 'L' + sourceModule.getClassName() + "/nodejsModule"; if (sourceModule instanceof NodejsRequiredSourceModule && ((NodejsRequiredSourceModule) sourceModule).getFile().toString().endsWith(".json")) { className = 'L' + sourceModule.getClassName() + "/jsonModule"; previouslyRequired.put(sourceModule.getClassName(), method);
@Override public int read() throws IOException { if (currentStream == null) { if (index < constituents.length) { currentStream = constituents[index++].getInputStream(); } else { return -1; } } int b = currentStream.read(); if (b == -1) { currentStream = null; return read(); } return b; } };
@Override protected CAstEntity parseJS(CAstImpl ast, SourceModule module) throws IOException { RhinoToAstTranslator translator = new RhinoToAstTranslator(ast, module, module.getName(), false); CAstEntity entity = null; try { entity = translator.translateToCAst(); } catch (Error e) { e.printStackTrace(); assert false; } return entity; } }
@Override public int read(char[] cbuf, int off, int len) throws IOException { if (currentReader == null) { if (index < constituents.length) { currentName = constituents[index].getURL(); currentReader = new LineNumberReader(new InputStreamReader(constituents[index++].getInputStream())); } else { return -1; } } int x; if ((x = currentReader.read(cbuf, off, len)) == -1) { line += currentReader.getLineNumber(); locations.add(Pair.make(line, currentName)); currentReader.close(); currentReader = null; return read(cbuf, off, len); } return x; }
protected File getLocalFile(SourceModule M) throws IOException { if (M instanceof SourceFileModule) { return ((SourceFileModule) M).getFile(); } else { File f = File.createTempFile("module", ".txt"); f.deleteOnExit(); TemporaryFile.streamToFile(f, M.getInputStream()); return f; } }
protected File getLocalFile(SourceModule M) throws IOException { if (M instanceof SourceFileModule) { return ((SourceFileModule) M).getFile(); } else { File f = File.createTempFile("module", ".txt"); f.deleteOnExit(); TemporaryFile.streamToFile(f, M.getInputStream()); return f; } }