Example usage for org.eclipse.jdt.internal.compiler.ast TypeDeclaration checkConstructors

List of usage examples for org.eclipse.jdt.internal.compiler.ast TypeDeclaration checkConstructors

Introduction

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

Prototype

public boolean checkConstructors(Parser parser) 

Source Link

Document

Check for constructor vs.

Usage

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumeAnnotationTypeDeclaration() {
    int length;//from w ww  . j a va  2 s  .c  o m
    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
        //there are length declarations
        //dispatch according to the type of the declarations
        dispatchDeclarationInto(length);
    }

    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];

    //convert constructor that do not have the type's name into methods
    typeDecl.checkConstructors(this);

    //always add <clinit> (will be remove at code gen time if empty)
    if (this.scanner.containsAssertKeyword) {
        typeDecl.bits |= ASTNode.ContainsAssertion;
    }
    typeDecl.addClinit();
    typeDecl.bodyEnd = this.endStatementPosition;
    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
    }
    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumeClassDeclaration() {
    // ClassDeclaration ::= ClassHeader ClassBody

    int length;//from  ww  w. jav a2s  .c o m
    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
        //there are length declarations
        //dispatch according to the type of the declarations
        dispatchDeclarationInto(length);
    }

    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];

    //convert constructor that do not have the type's name into methods
    boolean hasConstructor = typeDecl.checkConstructors(this);

    //add the default constructor when needed (interface don't have it)
    if (!hasConstructor) {
        switch (TypeDeclaration.kind(typeDecl.modifiers)) {
        case TypeDeclaration.CLASS_DECL:
        case TypeDeclaration.ENUM_DECL:
            boolean insideFieldInitializer = false;
            if (this.diet) {
                for (int i = this.nestedType; i > 0; i--) {
                    if (this.variablesCounter[i] > 0) {
                        insideFieldInitializer = true;
                        break;
                    }
                }
            }
            typeDecl.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
        }
    }
    //always add <clinit> (will be remove at code gen time if empty)
    if (this.scanner.containsAssertKeyword) {
        typeDecl.bits |= ASTNode.ContainsAssertion;
    }
    typeDecl.addClinit();
    typeDecl.bodyEnd = this.endStatementPosition;
    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
    }

    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumeEnumDeclaration() {
    // EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
    int length;// w ww . j ava2s.  c  om
    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
        //there are length declarations
        //dispatch according to the type of the declarations
        dispatchDeclarationIntoEnumDeclaration(length);
    }

    TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr];

    //convert constructor that do not have the type's name into methods
    boolean hasConstructor = enumDeclaration.checkConstructors(this);

    //add the default constructor when needed
    if (!hasConstructor) {
        boolean insideFieldInitializer = false;
        if (this.diet) {
            for (int i = this.nestedType; i > 0; i--) {
                if (this.variablesCounter[i] > 0) {
                    insideFieldInitializer = true;
                    break;
                }
            }
        }
        enumDeclaration.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
    }

    //always add <clinit> (will be remove at code gen time if empty)
    if (this.scanner.containsAssertKeyword) {
        enumDeclaration.bits |= ASTNode.ContainsAssertion;
    }
    enumDeclaration.addClinit();
    enumDeclaration.bodyEnd = this.endStatementPosition;
    if (length == 0 && !containsComment(enumDeclaration.bodyStart, enumDeclaration.bodyEnd)) {
        enumDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
    }

    enumDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
}

From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java

License:Open Source License

protected void consumeInterfaceDeclaration() {
    // see consumeClassDeclaration in case of changes: duplicated code
    // InterfaceDeclaration ::= InterfaceHeader InterfaceBody
    int length;/*from  w  w  w . ja  va 2s .c o  m*/
    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
        //there are length declarations
        //dispatch.....according to the type of the declarations
        dispatchDeclarationInto(length);
    }

    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];

    //convert constructor that do not have the type's name into methods
    typeDecl.checkConstructors(this);

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=212713, 
    // reject initializers that have been tolerated by the grammar.
    FieldDeclaration[] fields = typeDecl.fields;
    int fieldCount = fields == null ? 0 : fields.length;
    for (int i = 0; i < fieldCount; i++) {
        FieldDeclaration field = fields[i];
        if (field instanceof Initializer) {
            problemReporter().interfaceCannotHaveInitializers(typeDecl.name, field);
        }
    }

    //always add <clinit> (will be remove at code gen time if empty)
    if (this.scanner.containsAssertKeyword) {
        typeDecl.bits |= ASTNode.ContainsAssertion;
    }
    typeDecl.addClinit();
    typeDecl.bodyEnd = this.endStatementPosition;
    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
    }
    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
}