Package japa.parser.ast

Examples of japa.parser.ast.CompilationUnit


    JapidTemplate bt = new JapidTemplate("tests/switchCase.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
    CompilationUnit cu = JavaSyntaxTool.parse(srcCode);
  }
View Full Code Here


    JapidTemplate bt = new JapidTemplate("tagline.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler ();
    cp.compile(bt);
    String code = bt.javaSource;
    System.out.println(code);
    CompilationUnit cu = JavaSyntaxTool.parse(code);
//    System.out.println(cu);

  }
View Full Code Here

    String src = readFile(srcFile);
   
    JapidTemplate bt = new JapidTemplate("japidviews/templates/Actions.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler ();
    cp.compile(bt);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
  }
View Full Code Here

    String src = readFile(srcFile);
   
    JapidTemplate bt = new JapidTemplate("japidviews/Application/verbatim.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler ();
    cp.compile(bt);
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
  }
View Full Code Here

    JapidTemplate bt = new JapidTemplate("tests/getTag.html", src);
    JapidAbstractCompiler cp = new JapidLayoutCompiler();
    cp.compile(bt);
    System.out.println(bt.javaSource);
//    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "title", Modifier.PROTECTED, "void", ""));
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "footer", Modifier.PROTECTED, "void", ""));
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "doLayout", Modifier.PROTECTED | Modifier.ABSTRACT, "void", ""));
    assertTrue("method is never called", JavaSyntaxTool.hasMethodInvocatioin(cu, "title"));
    assertTrue("method is never called", JavaSyntaxTool.hasMethodInvocatioin(cu, "footer"));
View Full Code Here

    JapidTemplate bt = new JapidTemplate("japidviews/templates/def.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
//    System.out.println(bt.javaSource);
//    assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
    CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
    System.out.println(cu);
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "foo", "public", "String", null));
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "foo2", "public", "String", "String"));
    assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "bar", "public", "String", null));
//    assertTrue("method is never called", JavaSyntaxTool.hasMethodInvocatioin(cu, "title"));
View Full Code Here

  public static CompilationUnit parse(String src) throws ParseException {
    ByteArrayInputStream in;
    try {
      in = new ByteArrayInputStream(src.getBytes(UTF_8));
      CompilationUnit cu;
      cu = JavaParser.parse(in, UTF_8);
      return cu;
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

    return null;
  }

  public static boolean isValid(String src) {
    try {
      CompilationUnit cu = parse(src);
      return true;
    } catch (ParseException e) {
      String m = e.getMessage() + "\n";
      System.out.println(m.substring(0, m.indexOf('\n')));
      return false;
View Full Code Here

    // make it tolerant of lowercase default
    line = line.replace("@default(", "@Default(");
    String cl = String.format(classTempForParams, line);
    try {
      CompilationUnit cu = parse(cl);
      VoidVisitorAdapter visitor = new VoidVisitorAdapter() {
        @Override
        public void visit(Parameter p, Object arg) {
          ret.add(p);
        }
      };
      cu.accept(visitor, null);
    } catch (ParseException e) {
      throw new RuntimeException(
          "the line does not seem to be a valid param list declaration: "
              + line);
    }
View Full Code Here

    line = line.trim();
    if (line.startsWith("(")){
      // perhaps it's in the form of (...)
      String cl = String.format(classTempForArgsNoParenthesis, line);
      try {
        CompilationUnit cu = parse(cl);
        cu.accept(visitor, null);
        return ret;
      } catch (ParseException e) {
        // perhaps not really (...). fall through
      }
    }
   
    String cl = String.format(classTempForArgs, line);
    try {
      CompilationUnit cu = parse(cl);
      cu.accept(visitor, null);
    } catch (ParseException e) {
      throw new RuntimeException(
          "the line does not seem to be a valid arg list: " + line);
    }
    return ret;
View Full Code Here

TOP

Related Classes of japa.parser.ast.CompilationUnit

Copyright © 2018 www.massapicom. 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.