use of japa.parser.ast.CompilationUnit in project enumerable by hraberg.
the class InMemoryCompilerTest method inMemoryCompilationFromJavaParserAST.
@Test
public void inMemoryCompilationFromJavaParserAST() throws Exception {
CompilationUnit cu = createCU();
assertEquals("Hello World from AST", invokeMain(compiler.compile(getFullyQualifiedName(cu), cu.toString())).trim());
}
use of japa.parser.ast.CompilationUnit in project Japid by branaway.
the class JavaSyntaxToolTest method testHasMathod.
@Test
public void testHasMathod() throws ParseException {
String src = "class A { private static void foo(int i, B b); }";
CompilationUnit cu = JavaSyntaxTool.parse(src);
assertTrue(JavaSyntaxTool.hasMethod(cu, "foo", "static private", "void", " int , B "));
}
use of japa.parser.ast.CompilationUnit in project Japid by branaway.
the class JavaSyntaxValidatorTest method testBuildValidAst.
@Test
public void testBuildValidAst() {
String validSrc = "package testdir.d1;\r\n" + "\r\n" + "public class A {\r\n" + " Boo 不不 = new Boo('不'); \n" + "}\r\n" + "";
CompilationUnit cu = null;
try {
cu = JavaSyntaxTool.parse(validSrc);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertNotNull(cu);
}
use of japa.parser.ast.CompilationUnit in project Japid by branaway.
the class JavaSyntaxValidatorTest method testParamList.
@Test
public void testParamList() throws UnsupportedEncodingException, ParseException {
String src = "class A { void m (String[ ] a, cc.B f) {m(1 + \"s\", 2);}}";
ByteArrayInputStream in = new ByteArrayInputStream(src.getBytes("UTF-8"));
CompilationUnit cu = JavaParser.parse(in, "UTF-8");
assertNotNull(cu);
// System.out.println(cu.toString());
new MethodVisitor().visit(cu, null);
}
use of japa.parser.ast.CompilationUnit in project Japid by branaway.
the class CompilerTests method testNoPlayCommand.
@Test
public void testNoPlayCommand() throws IOException, ParseException {
String src = readFile("JapidSample/app/japidviews/templates/noplay.html");
JapidTemplate bt = new JapidTemplate("japidviews/templates/noplay.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
CompilationUnit cu = JavaSyntaxTool.parse(srccode);
}
Aggregations