Example usage for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration parseStatements

List of usage examples for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration parseStatements

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.ast AbstractMethodDeclaration parseStatements.

Prototype

public abstract void parseStatements(Parser parser, CompilationUnitDeclaration unit);

Source Link

Document

Fill up the method body with statement

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocatorParser.java

License:Open Source License

/**
 * Parses the member bodies in the given type.
 * @param type TypeDeclaration// w w  w .j a va2  s  . c  o  m
 * @param unit CompilationUnitDeclaration
 */
protected void parseBodies(TypeDeclaration type, CompilationUnitDeclaration unit) {
    FieldDeclaration[] fields = type.fields;
    if (fields != null) {
        for (int i = 0; i < fields.length; i++) {
            FieldDeclaration field = fields[i];
            if (field instanceof Initializer)
                this.parse((Initializer) field, type, unit);
            field.traverse(this.localDeclarationVisitor, null);
        }
    }

    AbstractMethodDeclaration[] methods = type.methods;
    if (methods != null) {
        for (int i = 0; i < methods.length; i++) {
            AbstractMethodDeclaration method = methods[i];
            if (method.sourceStart >= type.bodyStart) { // if not synthetic
                if (method instanceof MethodDeclaration) {
                    MethodDeclaration methodDeclaration = (MethodDeclaration) method;
                    this.parse(methodDeclaration, unit);
                    methodDeclaration.traverse(this.localDeclarationVisitor, (ClassScope) null);
                } else if (method instanceof ConstructorDeclaration) {
                    ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) method;
                    this.parse(constructorDeclaration, unit, false);
                    constructorDeclaration.traverse(this.localDeclarationVisitor, (ClassScope) null);
                }
            } else if (method.isDefaultConstructor()) {
                method.parseStatements(this, unit);
            }
        }
    }

    TypeDeclaration[] memberTypes = type.memberTypes;
    if (memberTypes != null) {
        for (int i = 0; i < memberTypes.length; i++) {
            TypeDeclaration memberType = memberTypes[i];
            this.parseBodies(memberType, unit);
            memberType.traverse(this.localDeclarationVisitor, (ClassScope) null);
        }
    }
}

From source file:lombok.eclipse.apt.Processor.java

License:Open Source License

private static void fullParseType(Parser parser, CompilationUnitDeclaration cud, TypeDeclaration[] typeDecls) {
    if (typeDecls == null)
        return;//from w  w w .j a  v  a  2  s .  com
    for (TypeDeclaration typeDecl : typeDecls) {
        for (AbstractMethodDeclaration methodDecl : typeDecl.methods) {
            methodDecl.parseStatements(parser, cud);
            methodDecl.bits |= PatchFixes.ALREADY_PROCESSED_FLAG;
        }
        fullParseType(parser, cud, typeDecl.memberTypes);
    }
}