Examples of ClassOrInterfaceDeclaration


Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

        final JavaType effectiveType = getJavaType(compilationUnitServices,
                nameExpr, null);

        final List<JavaType> parameterTypes = new ArrayList<JavaType>();
        if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
            final ClassOrInterfaceDeclaration clazz = (ClassOrInterfaceDeclaration) typeDeclaration;
            // Populate JavaType with type parameters
            final List<TypeParameter> typeParameters = clazz
                    .getTypeParameters();
            if (typeParameters != null) {
                final Set<JavaSymbolName> locatedTypeParameters = new HashSet<JavaSymbolName>();
                for (final TypeParameter candidate : typeParameters) {
                    final JavaSymbolName currentTypeParam = new JavaSymbolName(
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

    for (ImportDeclaration d : baseImports) {
      imports.add(d.getName().toString());
    }

    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, true, informerInfos.getInformerName());
    type.setExtends(Arrays.asList(new ClassOrInterfaceType(Informer.class.getSimpleName() + "<" + informerInfos.className + ">")));
    type.setJavaDoc(new JavadocComment("\n" + "Informer for {@link " + informerInfos.className + "}\n" + "@author InformerMojos\n"));
    ASTHelper.addTypeDeclaration(cu, type);
    for (PropertyInfos infos : informerInfos.properties) {
      // create a method
      MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "get" + Utils.uppercaseFirst(infos.name));
      String informerTypeFor = InformerTypeFinder.getInformerTypeFor(resolvedInformers, qualifiedEnums, imports, infos);
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

    for (ImportDeclaration d : baseImports) {
      imports.add(d.getName().toString());
    }

    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, true, informerInfos.getInformerName());
    List<ClassOrInterfaceType> extended = new LinkedList<ClassOrInterfaceType>();
    extended.add(new ClassOrInterfaceType(Informer.class.getSimpleName() + "<" + informerInfos.className + ">"));
    extended.add(new ClassOrInterfaceType(informerInfos.getAbstractInformerName()));
    type.setExtends(extended);
    type.setJavaDoc(new JavadocComment("\n" +
            "Informer for {@link " + informerInfos.className + "}\n" +
            "This is the public Informer class one must use to access dynamic properties methods." +
            "@author InformerMojos\n"));
    List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>();
    // Constructing generated annotation value
    List<MemberValuePair> parameters = new LinkedList<MemberValuePair>();
    parameters.add(new MemberValuePair("date", new StringLiteralExpr(
            javax.xml.bind.DatatypeConverter.printDateTime(GregorianCalendar.getInstance()))));
    parameters.add(new MemberValuePair("comments", new StringLiteralExpr("generated by gaedo-informer-generator")));
    List<Expression> values = new LinkedList<Expression>();
    values.add(new StringLiteralExpr(informerInfos.getQualifiedClassName()));
    parameters.add(new MemberValuePair("value",
            new ArrayInitializerExpr(values)));
    NormalAnnotationExpr generated = new NormalAnnotationExpr(ASTHelper.createNameExpr(Generated.class.getName()), parameters);
    annotations.add(generated);
    type.setAnnotations(annotations);
    ASTHelper.addTypeDeclaration(cu, type);
   
    imports.remove(informerInfos.classPackage);
    imports.remove("java.lang");
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

        }
      }
    }

    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, true, informerInfos.getAbstractInformerName());
    if(informerInfos.superClassName!=null && !"Object".equals(informerInfos.superClassName)) {
      List<ClassOrInterfaceType> extended = new LinkedList<ClassOrInterfaceType>();
      String superInformer = InformerInfos.buildAbstractInformerName(informerInfos.superClassName);
      // do not forget to add import for that class (see https://github.com/Riduidel/gaedo/issues/20)
      if(superClassPackage!=null) {
        imports.add(superClassPackage+"."+superInformer);
      }
      extended.add(new ClassOrInterfaceType(superInformer));
      type.setExtends(extended);
    }
    type.setJavaDoc(new JavadocComment("\n" +
            "Informer method container for {@link " + informerInfos.className + "}\n" +
            "This interface is to be used only by gaedo code. Its only role is to provide consistent method hierarchy.\n" +
            "As a consequence, refering to it directly has not the slightest interest and should never been done in user code." +
            "@author InformerMojos\n"));
    List<AnnotationExpr> annotations = new LinkedList<AnnotationExpr>();
    // Constructing generated annotation value
    List<MemberValuePair> parameters = new LinkedList<MemberValuePair>();
    parameters.add(new MemberValuePair("date", new StringLiteralExpr(
            javax.xml.bind.DatatypeConverter.printDateTime(GregorianCalendar.getInstance()))));
    parameters.add(new MemberValuePair("comments", new StringLiteralExpr("generated by gaedo-informer-generator")));
    List<Expression> values = new LinkedList<Expression>();
    values.add(new StringLiteralExpr(informerInfos.getQualifiedClassName()));
    parameters.add(new MemberValuePair("value",
            new ArrayInitializerExpr(values)));
    NormalAnnotationExpr generated = new NormalAnnotationExpr(ASTHelper.createNameExpr(Generated.class.getName()), parameters);
    annotations.add(generated);
    type.setAnnotations(annotations);
    ASTHelper.addTypeDeclaration(cu, type);
    for (PropertyInfos infos : informerInfos.properties) {
      // create a method
      MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "get" + Utils.uppercaseFirst(infos.name));
      String informerTypeFor = InformerTypeFinder.getInformerTypeFor(resolvedInformers, qualifiedEnums, imports, infos);
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

    public static void main(String[] args) {
        CompilationUnit cu = new CompilationUnit();
        //set the package
        cu.setPackage(new PackageDeclaration(ASTHelper.createNameExpr("cn.shenyanchao.javaparser.test")));
        //create the type declaration
        ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, "HelloWorld");
        ASTHelper.addTypeDeclaration(cu, type);
        //create a method
        MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "main");
        method.setModifiers(ModifierSet.addModifier(method.getModifiers(), ModifierSet.STATIC));
        ASTHelper.addMember(type, method);
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

public class ClassTypeBuilder {

    private ClassOrInterfaceDeclaration type = null;

    public ClassTypeBuilder(String clazzName) {
        type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, false, clazzName);
    }
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

        return Boolean.TRUE;
    }

    public Boolean visit(ClassOrInterfaceDeclaration n1, Node arg) {
        ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg;

        // javadoc are checked at CompilationUnit

        if (n1.getModifiers() != n2.getModifiers()) {
            return Boolean.FALSE;
        }

        if (n1.isInterface() != n2.isInterface()) {
            return Boolean.FALSE;
        }

        if (!objEquals(n1.getName(), n2.getName())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getExtends(), n2.getExtends())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getImplements(), n2.getImplements())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
            return Boolean.FALSE;
        }

        return Boolean.TRUE;
    }
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

                ;
        }
        members = ClassOrInterfaceBody(isInterface);
        {
            if (true) {
                return new ClassOrInterfaceDeclaration(line, column, token.endLine, token.endColumn, popJavadoc(), modifier.modifiers, modifier.annotations, isInterface, name, typePar, extList, impList, members);
            }
        }
        throw new Error("Missing return statement in function");
    }
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

* Classes inside block stametents can only be abstract or final. The semantic must check it.
*/
    final public Statement BlockStatement() throws ParseException {
        Statement ret;
        Expression expr;
        ClassOrInterfaceDeclaration typeDecl;
        Modifier modifier;
        if (jj_2_36(2147483647)) {
            pushJavadoc();
            modifier = Modifiers();
            typeDecl = ClassOrInterfaceDeclaration(modifier);
            ret = new TypeDeclarationStmt(typeDecl.getBeginLine(), typeDecl.getBeginColumn(), token.endLine, token.endColumn, typeDecl);
        } else if (jj_2_37(2147483647)) {
            expr = VariableDeclarationExpression();
            jj_consume_token(SEMICOLON);
            ret = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr);
        } else {
View Full Code Here

Examples of japa.parser.ast.body.ClassOrInterfaceDeclaration

    for (ImportDeclaration d : baseImports) {
      imports.add(d.getName().toString());
    }

    // create the type declaration
    ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC, true, informerInfos.getInformerName());
    type.setExtends(Arrays.asList(new ClassOrInterfaceType(Informer.class.getSimpleName() + "<" + informerInfos.className + ">")));
    type.setJavaDoc(new JavadocComment("\n" + "Informer for {@link " + informerInfos.className + "}\n" + "@author InformerMojos\n"));
    ASTHelper.addTypeDeclaration(cu, type);
    for (PropertyInfos infos : informerInfos.properties) {
      // create a method
      MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.VOID_TYPE, "get" + Utils.uppercaseFirst(infos.name));
      String informerTypeFor = InformerTypeFinder.getInformerTypeFor(resolvedInformers, qualifiedEnums, imports, infos);
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.