本文整理汇总了Java中japa.parser.ast.CompilationUnit.accept方法的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnit.accept方法的具体用法?Java CompilationUnit.accept怎么用?Java CompilationUnit.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类japa.parser.ast.CompilationUnit
的用法示例。
在下文中一共展示了CompilationUnit.accept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import japa.parser.ast.CompilationUnit; //导入方法依赖的package包/类
public static void compile(InputStream in, OutputStream out) throws ParseException, IOException {
// Parse the compilation unit.
CompilationUnit cu = JavaParser.parse(in);
// Do some semantic analysis.
if (!CompilerSettings.noSemantic) {
if (!CompilerSettings.semanticError) {
System.err.println("WARNING: Semantic analysis is pretty bad.");
System.err.println(" Use -fno-semantic to disable.");
System.err.println(" Use -Wsemantic-error to turn all semantic errors into compiler errors (you probably don't want this).");
}
try {
cu.accept(new SemanticAnalysis(), null);
} catch (SemanticException e) {
if (CompilerSettings.semanticError) {
System.err.println("ERROR: " + e.toString());
System.err.println(" Aborted compilation.");
return;
}
System.err.println("WARNING: " + e.toString());
}
}
if (CompilerSettings.semanticOnly) return;
// Now do the compilation. Unfortunately, the compiler uses different
// data to perform compilation. Oh well.
cu.accept(new Compiler(), null);
DumpVisitor d = new DumpVisitor();
cu.accept(d, null);
out.write(d.getSource().getBytes());
out.flush();
}
示例2: visit
import japa.parser.ast.CompilationUnit; //导入方法依赖的package包/类
@Override
public void visit(CompilationUnit n, Void arg) {
n.accept(new ScopeCollector(), ROOT_SCOPE);
if (CompilerSettings.dumpSemScopes) {
System.out.println(n.getData());
}
super.visit(n, arg);
}
示例3: doTest
import japa.parser.ast.CompilationUnit; //导入方法依赖的package包/类
private void doTest(VoidVisitor< ? > visitor) throws ParseException {
CompilationUnit cu = Helper.parserClass("./test", DumperTestClass.class);
cu.accept(visitor, null);
cu = Helper.parserClass("./test", JavadocTestClass.class);
cu.accept(visitor, null);
}
示例4: testNodePositions
import japa.parser.ast.CompilationUnit; //导入方法依赖的package包/类
@Test
public void testNodePositions() throws Exception {
String source = Helper.readClass("./test", DumperTestClass.class);
CompilationUnit cu = Helper.parserString(source);
cu.accept(new TestVisitor(source), null);
}
示例5: visit
import japa.parser.ast.CompilationUnit; //导入方法依赖的package包/类
@Override
public void visit(CompilationUnit n, Scope arg) {
super.visit(n, arg);
n.setData(arg);
n.accept(new InheritanceResolution(), null);
}