Examples of JapidAbstractCompiler


Examples of cn.bran.japid.compiler.JapidAbstractCompiler

    String fileName = srcFile.getProjectRelativePath().toString().substring("app/".length());
    // the compiler assumes the path separator is system specific separator
    fileName = fileName.replace('/', File.separatorChar);
    JapidTemplate temp = new JapidTemplate(fileName, src);
    JapidAbstractCompiler c = null;
    if (JapidTemplateTransformer.looksLikeLayout(src)) {
      c = new JapidLayoutCompiler();
    } else {
      // regular template and tag are the same thing
      c = new JapidTemplateCompiler();
    }

    c.compile(temp);
    // now we have the derived source
    String text = temp.javaSource;

    String newline = "\n";// System.getProperty("line.separator");
    String[] lines = text.split("[" + newline + "]");
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

    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);
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

  @Test
  public void testOpenFor() throws IOException {
    String src = readFile("tests/openFor.html");
    JapidTemplate bt = new JapidTemplate("tests/openFor.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

  @Test
  public void testCompileLayout() throws IOException {
    String src = readFile("JapidSample/app/japidviews/_layouts/Layout.html");
    JapidTemplate bt = new JapidTemplate("tag/Layout.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

 
  @Test
  public void testIfCommand() throws IOException {
    String src = readFile("JapidSample/app/japidviews/Application/ifs.html");
    JapidTemplate bt = new JapidTemplate("Application/ifs.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    String javaSource = bt.javaSource;
    System.out.println(javaSource);
    assertTrue(javaSource.contains("if(!asBoolean(ss))"));
    assertTrue(javaSource.contains("else if(!asBoolean(ss))"));
    assertTrue("invalid java code", JavaSyntaxTool.isValid(javaSource));
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

 
  @Test
  public void testOpenIfCommand() throws IOException {
    String src = readFile("JapidSample/app/japidviews/Application/ifs2.html");
    JapidTemplate bt = new JapidTemplate("Application/ifs2.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

 
  @Test
  public void testLayoutWithArgs() throws IOException {
    String src = readFile("JapidSample/app/japidviews/more/Perf/perfmain.html");
    JapidTemplate bt = new JapidTemplate("more/Perf/perfmain.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

 
  @Test
  public void testExtendsLayoutWithArgs() throws IOException {
    String src = readFile("JapidSample/app/japidviews/more/Perf/perf.html");
    JapidTemplate bt = new JapidTemplate("more/Perf/perf.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
  }
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

  @Test
  public void testReverse() throws IOException {
    String path = "tests/reverse.html";
    String src = readFile(path);
    JapidTemplate bt = new JapidTemplate(path, src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srccode = bt.javaSource;
    System.out.println(srccode);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(srccode));
    assertTrue(srccode.contains("p(lookupStatic(\"/x/y.html\"))"));
    assertTrue(srccode.contains("p(lookupStatic(\"/a/b/c.html\"))"));
View Full Code Here

Examples of cn.bran.japid.compiler.JapidAbstractCompiler

 
  @Test
  public void testAnotherLayout() throws IOException, ParseException {
    String src = readFile("JapidSample/app/japidviews/_layouts/TagLayout.html");
    JapidTemplate bt = new JapidTemplate("japidviews/_layouts/TagLayout.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    String srccode = bt.javaSource;
    System.out.println(srccode);
    CompilationUnit cu = JavaSyntaxTool.parse(srccode);
    assertTrue(srccode.contains("package japidviews._layouts;"));
    assertTrue(srccode.contains("public abstract class TagLayout extends cn.bran.play.JapidTemplateBase"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.