List of usage examples for org.eclipse.jdt.internal.compiler.ast ASTNode UndocumentedEmptyBlock
int UndocumentedEmptyBlock
To view the source code for org.eclipse.jdt.internal.compiler.ast ASTNode UndocumentedEmptyBlock.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void classInstanceCreation(boolean isQualified) { // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt // ClassBodyopt produces a null item on the astStak if it produces NO class body // An empty class body produces a 0 on the length stack..... AllocationExpression alloc;//from w w w. j av a2 s. co m int length; if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) { //NO ClassBody this.astPtr--; if (isQualified) { alloc = new QualifiedAllocationExpression(); } else { alloc = new AllocationExpression(); } alloc.sourceEnd = this.endPosition; //the position has been stored explicitly if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { this.expressionPtr -= length; System.arraycopy(this.expressionStack, this.expressionPtr + 1, alloc.arguments = new Expression[length], 0, length); } alloc.type = getTypeReference(0); checkForDiamond(alloc.type); //the default constructor with the correct number of argument //will be created and added by the TC (see createsInternalConstructorWithBinding) alloc.sourceStart = this.intStack[this.intPtr--]; pushOnExpressionStack(alloc); } else { dispatchDeclarationInto(length); TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration) this.astStack[this.astPtr]; anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition; anonymousTypeDeclaration.bodyEnd = this.endStatementPosition; if (anonymousTypeDeclaration.allocation != null) { anonymousTypeDeclaration.allocation.sourceEnd = this.endStatementPosition; checkForDiamond(anonymousTypeDeclaration.allocation.type); } if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) { anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock; } this.astPtr--; this.astLengthPtr--; } }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeAnnotationTypeDeclaration() { int length;/*from ww w . j av a 2 s. co 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 consumeBlock() { // Block ::= OpenBlock '{' BlockStatementsopt '}' // simpler action for empty blocks int statementsLength = this.astLengthStack[this.astLengthPtr--]; Block block;/*from www. j av a 2 s . co m*/ if (statementsLength == 0) { // empty block block = new Block(0); block.sourceStart = this.intStack[this.intPtr--]; block.sourceEnd = this.endStatementPosition; // check whether this block at least contains some comment in it if (!containsComment(block.sourceStart, block.sourceEnd)) { block.bits |= ASTNode.UndocumentedEmptyBlock; } this.realBlockPtr--; // still need to pop the block variable counter } else { block = new Block(this.realBlockStack[this.realBlockPtr--]); this.astPtr -= statementsLength; System.arraycopy(this.astStack, this.astPtr + 1, block.statements = new Statement[statementsLength], 0, statementsLength); block.sourceStart = this.intStack[this.intPtr--]; block.sourceEnd = this.endStatementPosition; } pushOnAstStack(block); }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeClassBodyDeclaration() { // ClassBodyDeclaration ::= Diet NestedMethod CreateInitializer Block //push an Initializer //optimize the push/pop this.nestedMethod[this.nestedType]--; Block block = (Block) this.astStack[this.astPtr--]; this.astLengthPtr--; if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlock; // clear bit since was diet Initializer initializer = (Initializer) this.astStack[this.astPtr]; initializer.declarationSourceStart = initializer.sourceStart = block.sourceStart; initializer.block = block;//from w w w . jav a 2 s . c o m this.intPtr--; // pop sourcestart left on the stack by consumeNestedMethod. initializer.bodyStart = this.intStack[this.intPtr--]; this.realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod int javadocCommentStart = this.intStack[this.intPtr--]; if (javadocCommentStart != -1) { initializer.declarationSourceStart = javadocCommentStart; initializer.javadoc = this.javadoc; this.javadoc = null; } initializer.bodyEnd = this.endPosition; initializer.sourceEnd = this.endStatementPosition; initializer.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;// w w w .j a v a 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 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 consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() { // ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt QualifiedAllocationExpression alloc; int length;/*from ww w.j a v a 2s . c o m*/ if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) { //NO ClassBody this.astPtr--; alloc = new QualifiedAllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { this.expressionPtr -= length; System.arraycopy(this.expressionStack, this.expressionPtr + 1, alloc.arguments = new Expression[length], 0, length); } alloc.type = getTypeReference(0); checkForDiamond(alloc.type); length = this.genericsLengthStack[this.genericsLengthPtr--]; this.genericsPtr -= length; System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length); this.intPtr--; //the default constructor with the correct number of argument //will be created and added by the TC (see createsInternalConstructorWithBinding) alloc.sourceStart = this.intStack[this.intPtr--]; pushOnExpressionStack(alloc); } else { dispatchDeclarationInto(length); TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration) this.astStack[this.astPtr]; anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition; anonymousTypeDeclaration.bodyEnd = this.endStatementPosition; if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) { anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock; } this.astPtr--; this.astLengthPtr--; QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation; if (allocationExpression != null) { allocationExpression.sourceEnd = this.endStatementPosition; // handle type arguments length = this.genericsLengthStack[this.genericsLengthPtr--]; this.genericsPtr -= length; System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length); allocationExpression.sourceStart = this.intStack[this.intPtr--]; checkForDiamond(allocationExpression.type); } } QualifiedAllocationExpression qae = (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr]; if (qae.anonymousType == null) { this.expressionLengthPtr--; this.expressionPtr--; qae.enclosingInstance = this.expressionStack[this.expressionPtr]; this.expressionStack[this.expressionPtr] = qae; } qae.sourceStart = qae.enclosingInstance.sourceStart; }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeClassInstanceCreationExpressionWithTypeArguments() { // ClassInstanceCreationExpression ::= 'new' TypeArguments ClassType '(' ArgumentListopt ')' ClassBodyopt AllocationExpression alloc;/*from w w w . j a v a 2 s .co m*/ int length; if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) { //NO ClassBody this.astPtr--; alloc = new AllocationExpression(); alloc.sourceEnd = this.endPosition; //the position has been stored explicitly if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) { this.expressionPtr -= length; System.arraycopy(this.expressionStack, this.expressionPtr + 1, alloc.arguments = new Expression[length], 0, length); } alloc.type = getTypeReference(0); checkForDiamond(alloc.type); length = this.genericsLengthStack[this.genericsLengthPtr--]; this.genericsPtr -= length; System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length); this.intPtr--; //the default constructor with the correct number of argument //will be created and added by the TC (see createsInternalConstructorWithBinding) alloc.sourceStart = this.intStack[this.intPtr--]; pushOnExpressionStack(alloc); } else { dispatchDeclarationInto(length); TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration) this.astStack[this.astPtr]; anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition; anonymousTypeDeclaration.bodyEnd = this.endStatementPosition; if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) { anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock; } this.astPtr--; this.astLengthPtr--; QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation; if (allocationExpression != null) { allocationExpression.sourceEnd = this.endStatementPosition; // handle type arguments length = this.genericsLengthStack[this.genericsLengthPtr--]; this.genericsPtr -= length; System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length); allocationExpression.sourceStart = this.intStack[this.intPtr--]; checkForDiamond(allocationExpression.type); } } }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeConstructorDeclaration() { // ConstructorDeclaration ::= ConstructorHeader ConstructorBody /*/*from w w w .ja v a 2s. co m*/ this.astStack : MethodDeclaration statements this.identifierStack : name ==> this.astStack : MethodDeclaration this.identifierStack : */ //must provide a default constructor call when needed int length; // pop the position of the { (body of the method) pushed in block decl this.intPtr--; this.intPtr--; //statements this.realBlockPtr--; ExplicitConstructorCall constructorCall = null; Statement[] statements = null; if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) { this.astPtr -= length; if (!this.options.ignoreMethodBodies) { if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) { //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? System.arraycopy(this.astStack, this.astPtr + 2, statements = new Statement[length - 1], 0, length - 1); constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1]; } else { //need to add explicitly the super(); System.arraycopy(this.astStack, this.astPtr + 1, statements = new Statement[length], 0, length); constructorCall = SuperReference.implicitSuperConstructorCall(); } } } else { boolean insideFieldInitializer = false; if (this.diet) { for (int i = this.nestedType; i > 0; i--) { if (this.variablesCounter[i] > 0) { insideFieldInitializer = true; break; } } } if (!this.diet || insideFieldInitializer) { // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere. constructorCall = SuperReference.implicitSuperConstructorCall(); } } // now we know that the top of stack is a constructorDeclaration ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr]; cd.constructorCall = constructorCall; cd.statements = statements; //highlight of the implicit call on the method name if (constructorCall != null && cd.constructorCall.sourceEnd == 0) { cd.constructorCall.sourceEnd = cd.sourceEnd; cd.constructorCall.sourceStart = cd.sourceStart; } if (!(this.diet && this.dietInt == 0) && statements == null && (constructorCall == null || constructorCall.isImplicitSuper()) && !containsComment(cd.bodyStart, this.endPosition)) { cd.bits |= ASTNode.UndocumentedEmptyBlock; } //watch for } that could be given as a unicode ! ( u007D is '}' ) // store the this.endPosition (position just before the '}') in case there is // a trailing comment behind the end of the method cd.bodyEnd = this.endPosition; cd.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;//from w w w . j a va 2 s. co m 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 .j a v a 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); // 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); }