Search in sources :

Example 1 with JapidAbstractCompiler

use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.

the class BranLayoutCompilerTest method testHop.

@Test
public void testHop() throws IOException {
    FileInputStream fis = new FileInputStream("JapidSample/app/japidviews/_layouts/Layout.html");
    InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
    BufferedReader br = new BufferedReader(isr);
    String src = "";
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        src += line + "\n";
    }
    JapidTemplate bt = new JapidTemplate("tag/Layout.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with JapidAbstractCompiler

use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.

the class CompilerTests method testOpenBrace.

@Test
public void testOpenBrace() throws IOException {
    String srcFile = "tests/openBrace.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate(srcFile, src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 3 with JapidAbstractCompiler

use of cn.bran.japid.compiler.JapidAbstractCompiler 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);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidLayoutCompiler(cn.bran.japid.compiler.JapidLayoutCompiler) Test(org.junit.Test)

Example 4 with JapidAbstractCompiler

use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.

the class CompilerTests method testSimpleInvoke.

@Test
public void testSimpleInvoke() throws IOException {
    String srcFile = "tests/simpleInvoke.html";
    String src = readFile(srcFile);
    JapidTemplate bt = new JapidTemplate("simpleInvoke.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String code = bt.javaSource;
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    System.out.println(code);
    assertTrue(code.contains("actionRunners.put(getOut().length(), new cn.bran.play.CacheablePlayActionRunner(\"\", MyController.class, \"action\", s + \"2\") {"));
    assertTrue(code.contains("MyController.action(s);"));
    assertTrue(code.contains("MyController.action(s + \"2\");"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 5 with JapidAbstractCompiler

use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.

the class CompilerTests method testActionNotation.

@Test
public void testActionNotation() throws IOException {
    String src = readFile("JapidSample/app/japidviews/templates/Actions.html");
    JapidTemplate bt = new JapidTemplate("japidviews/templates/Actions.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Aggregations

JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)39 JapidTemplate (cn.bran.japid.template.JapidTemplate)39 Test (org.junit.Test)39 JapidTemplateCompiler (cn.bran.japid.compiler.JapidTemplateCompiler)29 CompilationUnit (japa.parser.ast.CompilationUnit)12 JapidLayoutCompiler (cn.bran.japid.compiler.JapidLayoutCompiler)10 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1