/** * A debug-printer that includes comments (at the end). */ @Override public String debugPrint() { DebugPrintVisitor dpv = new DebugPrintVisitor(new StringBuilder(1000)); visitAll(dpv); return dpv.toString(); }
/** * A debug-printer that includes comments (at the end). */ @Override public String debugPrint() { DebugPrintVisitor dpv = new DebugPrintVisitor(new StringBuilder(1000)); visitAll(dpv); return dpv.toString(); }
/** * A debug-printer that includes comments (at the end). */ @Override public String debugPrint() { DebugPrintVisitor dpv = new DebugPrintVisitor(new StringBuilder(1000)); visitAll(dpv); return dpv.toString(); }
/** * A debug-printer that includes comments (at the end). */ @Override public String debugPrint() { DebugPrintVisitor dpv = new DebugPrintVisitor(new StringBuilder(1000)); visitAll(dpv); return dpv.toString(); }
@Override public TreeContext generate(Reader r) throws IOException { CompilerEnvirons env = new CompilerEnvirons(); env.setRecordingLocalJsDocComments(true); env.setAllowSharpComments(true); env.setRecordingComments(true); Parser p = new Parser(env); AstRoot root = p.parse(r, null, 1); RhinoTreeVisitor visitor = new RhinoTreeVisitor(root); root.visitAll(visitor); return visitor.getTree(root); } }
/** * Compiles Text and resolves the type. * e.g * "Hello World".length; //resolve as a Number * * @param text to compile and resolve */ @Override public JavaScriptType compileText(String text) throws IOException { CompilerEnvirons env = JavaScriptParser.createCompilerEnvironment(new JavaScriptParser.JSErrorReporter(), provider.getLanguageSupport()); String parseText = JavaScriptHelper.removeLastDotFromText(text); int charIndex = JavaScriptHelper.findIndexOfFirstOpeningBracket(parseText); env.setRecoverFromErrors(true); Parser parser = new Parser(env); StringReader r = new StringReader(parseText); AstRoot root = parser.parse(r, null, 0); CompilerNodeVisitor visitor = new CompilerNodeVisitor(charIndex == 0); root.visitAll(visitor); return lastJavaScriptType; }
root.visitAll(new NodeVisitor()
AstRoot ast = jsParser.parse(script, "script", 1); ast.getType(); ast.visitAll(new NodeVisitor() { @Override public boolean visit(AstNode node) {
AstRoot root = parser.parse(r, null, 0); ParseTextVisitor visitor = new ParseTextVisitor(text); root.visitAll(visitor); pt.isNew = visitor.isNew(); pt.text = visitor.getLastNodeSource();
/** * Resolve node type to TypeDeclaration. Called instead of #compileText(String text) when document is already parsed * @param text The node to resolve * @return TypeDeclaration for node or null if not found. */ @Override public TypeDeclaration resolveParamNode(String text) throws IOException { if(text != null) { CompilerEnvirons env = JavaScriptParser.createCompilerEnvironment(new JavaScriptParser.JSErrorReporter(), provider.getLanguageSupport()); int charIndex = JavaScriptHelper.findIndexOfFirstOpeningBracket(text); env.setRecoverFromErrors(true); Parser parser = new Parser(env); StringReader r = new StringReader(text); AstRoot root = parser.parse(r, null, 0); CompilerNodeVisitor visitor = new CompilerNodeVisitor(charIndex == 0); root.visitAll(visitor); } return lastJavaScriptType != null ? lastJavaScriptType.getType() : provider.getTypesFactory().getDefaultTypeDeclaration(); }