Package org.springframework.roo.classpath.details.comments

Examples of org.springframework.roo.classpath.details.comments.CommentStructure


                final JavaType type = new JavaType(fullName);
                final JavaPackage typePackage = importDeclaration.isAsterisk() ? new JavaPackage(
                        fullName) : type.getPackage();

                // Process any comments for the import
                final CommentStructure commentStructure = new CommentStructure();
                JavaParserCommentMetadataBuilder.updateCommentsToRoo(
                        commentStructure, importDeclaration);

                final ImportMetadataBuilder newImport = new ImportMetadataBuilder(
                        declaredByMetadataId, 0, typePackage, type,
                        importDeclaration.isStatic(),
                        importDeclaration.isAsterisk());

                newImport.setCommentStructure(commentStructure);

                cidBuilder.add(newImport.build());
            }
        }

        // Convert Java Parser modifier into JDK modifier
        cidBuilder.setModifier(JavaParserUtils.getJdkModifier(typeDeclaration
                .getModifiers()));

        // Type parameters
        final Set<JavaSymbolName> typeParameterNames = new HashSet<JavaSymbolName>();
        for (final JavaType param : name.getParameters()) {
            final JavaSymbolName arg = param.getArgName();
            // Fortunately type names can only appear at the top-level
            if (arg != null && !JavaType.WILDCARD_NEITHER.equals(arg)
                    && !JavaType.WILDCARD_EXTENDS.equals(arg)
                    && !JavaType.WILDCARD_SUPER.equals(arg)) {
                typeParameterNames.add(arg);
            }
        }

        List<ClassOrInterfaceType> implementsList;
        List<AnnotationExpr> annotationsList = null;
        List<BodyDeclaration> members = null;

        if (clazz != null) {
            final List<ClassOrInterfaceType> extendsList = clazz.getExtends();
            if (extendsList != null) {
                for (final ClassOrInterfaceType candidate : extendsList) {
                    final JavaType javaType = JavaParserUtils.getJavaTypeNow(
                            compilationUnitServices, candidate,
                            typeParameterNames);
                    cidBuilder.addExtendsTypes(javaType);
                }
            }

            final List<JavaType> extendsTypes = cidBuilder.getExtendsTypes();
            // Obtain the superclass, if this is a class and one is available
            if (physicalTypeCategory == PhysicalTypeCategory.CLASS
                    && extendsTypes.size() == 1) {
                final JavaType superclass = extendsTypes.get(0);
                final String superclassId = typeLocationService
                        .getPhysicalTypeIdentifier(superclass);
                PhysicalTypeMetadata superPtm = null;
                if (superclassId != null) {
                    superPtm = (PhysicalTypeMetadata) metadataService
                            .get(superclassId);
                }
                if (superPtm != null
                        && superPtm.getMemberHoldingTypeDetails() != null) {
                    cidBuilder.setSuperclass(superPtm
                            .getMemberHoldingTypeDetails());
                }
            }

            implementsList = clazz.getImplements();
            if (implementsList != null) {
                for (final ClassOrInterfaceType candidate : implementsList) {
                    final JavaType javaType = JavaParserUtils.getJavaTypeNow(
                            compilationUnitServices, candidate,
                            typeParameterNames);
                    cidBuilder.addImplementsType(javaType);
                }
            }

            annotationsList = typeDeclaration.getAnnotations();
            members = clazz.getMembers();
        }

        if (enumClazz != null) {
            final List<EnumConstantDeclaration> constants = enumClazz
                    .getEntries();
            if (constants != null) {
                for (final EnumConstantDeclaration enumConstants : constants) {
                    cidBuilder.addEnumConstant(new JavaSymbolName(enumConstants
                            .getName()));
                }
            }

            implementsList = enumClazz.getImplements();
            annotationsList = enumClazz.getAnnotations();
            members = enumClazz.getMembers();
        }

        if (annotationsList != null) {
            for (final AnnotationExpr candidate : annotationsList) {
                final AnnotationMetadata md = JavaParserAnnotationMetadataBuilder
                        .getInstance(candidate, compilationUnitServices)
                        .build();

                final CommentStructure commentStructure = new CommentStructure();
                JavaParserCommentMetadataBuilder.updateCommentsToRoo(
                        commentStructure, candidate);
                md.setCommentStructure(commentStructure);

                cidBuilder.addAnnotation(md);
            }
        }

        if (members != null) {
            // Now we've finished declaring the type, we should introspect for
            // any inner types that can thus be referred to in other body
            // members
            // We defer this until now because it's illegal to refer to an inner
            // type in the signature of the enclosing type
            for (final BodyDeclaration bodyDeclaration : members) {
                if (bodyDeclaration instanceof TypeDeclaration) {
                    // Found a type
                    innerTypes.add((TypeDeclaration) bodyDeclaration);
                }
            }

            for (final BodyDeclaration member : members) {
                if (member instanceof FieldDeclaration) {
                    final FieldDeclaration castMember = (FieldDeclaration) member;
                    for (final VariableDeclarator var : castMember
                            .getVariables()) {
                        final FieldMetadata field = JavaParserFieldMetadataBuilder
                                .getInstance(declaredByMetadataId, castMember,
                                        var, compilationUnitServices,
                                        typeParameterNames).build();

                        final CommentStructure commentStructure = new CommentStructure();
                        JavaParserCommentMetadataBuilder.updateCommentsToRoo(
                                commentStructure, member);
                        field.setCommentStructure(commentStructure);

                        cidBuilder.addField(field);
                    }
                }
                if (member instanceof MethodDeclaration) {
                    final MethodDeclaration castMember = (MethodDeclaration) member;
                    final MethodMetadata method = JavaParserMethodMetadataBuilder
                            .getInstance(declaredByMetadataId, castMember,
                                    compilationUnitServices, typeParameterNames)
                            .build();

                    final CommentStructure commentStructure = new CommentStructure();
                    JavaParserCommentMetadataBuilder.updateCommentsToRoo(
                            commentStructure, member);
                    method.setCommentStructure(commentStructure);

                    cidBuilder.addMethod(method);
                }
                if (member instanceof ConstructorDeclaration) {
                    final ConstructorDeclaration castMember = (ConstructorDeclaration) member;
                    final ConstructorMetadata constructor = JavaParserConstructorMetadataBuilder
                            .getInstance(declaredByMetadataId, castMember,
                                    compilationUnitServices, typeParameterNames)
                            .build();

                    final CommentStructure commentStructure = new CommentStructure();
                    JavaParserCommentMetadataBuilder.updateCommentsToRoo(
                            commentStructure, member);
                    constructor.setCommentStructure(commentStructure);

                    cidBuilder.addConstructor(constructor);
View Full Code Here


        this(fieldDetails.getPhysicalTypeIdentifier(), fieldDetails
                .getModifiers(), fieldDetails.getAnnotations(), fieldDetails
                .getFieldName(), fieldDetails.getFieldType());

        if (fieldDetails.getComment() != null) {
            commentStructure = new CommentStructure();
            JavadocComment javadocComment = new JavadocComment(
                    fieldDetails.getComment());
            commentStructure.addComment(javadocComment,
                    CommentStructure.CommentLocation.BEGINNING);
        }
View Full Code Here

                    p.getValue(), compilationUnitServices);
            attributeValues.add(value);
        }
        this.attributeValues = attributeValues;

        commentStructure = new CommentStructure();
        JavaParserCommentMetadataBuilder.updateCommentsToRoo(commentStructure,
                annotationExpr);
    }
View Full Code Here

TOP

Related Classes of org.springframework.roo.classpath.details.comments.CommentStructure

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.