char[] identifierName = this.identifierStack[this.identifierPtr];
long namePosition = this.identifierPositionStack[this.identifierPtr];
int extendedDimensions = this.intStack[this.intPtr--];
// pop any annotations on extended dimensions now, so they don't pollute the base dimensions.
Annotation [][] annotationsOnExtendedDimensions = extendedDimensions == 0 ? null : getAnnotationsOnDimensions(extendedDimensions);
AbstractVariableDeclaration declaration;
// create the ast node
boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0;
if (isLocalDeclaration) {
// create the local variable declarations
declaration =
createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
} else {
// create the field declaration
declaration =
createFieldDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
}
this.identifierPtr--;
this.identifierLengthPtr--;
TypeReference type;
int variableIndex = this.variablesCounter[this.nestedType];
if (variableIndex == 0) {
// first variable of the declaration (FieldDeclaration or LocalDeclaration)
if (isLocalDeclaration) {
declaration.declarationSourceStart = this.intStack[this.intPtr--];
declaration.modifiers = this.intStack[this.intPtr--];
// consume annotations
int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
System.arraycopy(
this.expressionStack,
(this.expressionPtr -= length) + 1,
declaration.annotations = new Annotation[length],
0,
length);
}
type = getTypeReference(this.intStack[this.intPtr--]); // type dimension
if (declaration.declarationSourceStart == -1) {
// this is true if there is no modifiers for the local variable declaration
declaration.declarationSourceStart = type.sourceStart;
}
pushOnAstStack(type);
} else {
type = getTypeReference(this.intStack[this.intPtr--]); // type dimension
pushOnAstStack(type);
declaration.declarationSourceStart = this.intStack[this.intPtr--];
declaration.modifiers = this.intStack[this.intPtr--];
// consume annotations
int length;
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
System.arraycopy(
this.expressionStack,
(this.expressionPtr -= length) + 1,
declaration.annotations = new Annotation[length],
0,
length);
}
// Store javadoc only on first declaration as it is the same for all ones
FieldDeclaration fieldDeclaration = (FieldDeclaration) declaration;
fieldDeclaration.javadoc = this.javadoc;
}
this.javadoc = null;
} else {
type = (TypeReference) this.astStack[this.astPtr - variableIndex];
AbstractVariableDeclaration previousVariable =
(AbstractVariableDeclaration) this.astStack[this.astPtr];
declaration.declarationSourceStart = previousVariable.declarationSourceStart;
declaration.modifiers = previousVariable.modifiers;
final Annotation[] annotations = previousVariable.annotations;
if (annotations != null) {