本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration.ENUM_CONSTANT属性的典型用法代码示例。如果您正苦于以下问题:Java AbstractVariableDeclaration.ENUM_CONSTANT属性的具体用法?Java AbstractVariableDeclaration.ENUM_CONSTANT怎么用?Java AbstractVariableDeclaration.ENUM_CONSTANT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration
的用法示例。
在下文中一共展示了AbstractVariableDeclaration.ENUM_CONSTANT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateOnClosingBrace
public RecoveredElement updateOnClosingBrace(int braceStart, int braceEnd){
if (this.bracketBalance > 0){ // was an array initializer
this.bracketBalance--;
if (this.bracketBalance == 0) {
if(this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
updateSourceEndIfNecessary(braceEnd - 1);
return this.parent;
} else {
if (this.fieldDeclaration.declarationSourceEnd > 0)
this.alreadyCompletedFieldInitialization = true;
}
}
return this;
} else if (this.bracketBalance == 0) {
this.alreadyCompletedFieldInitialization = true;
updateSourceEndIfNecessary(braceEnd - 1);
}
if (this.parent != null){
return this.parent.updateOnClosingBrace(braceStart, braceEnd);
}
return this;
}
示例2: updateOnOpeningBrace
public RecoveredElement updateOnOpeningBrace(int braceStart, int braceEnd){
if (this.fieldDeclaration.declarationSourceEnd == 0) {
if (this.fieldDeclaration.type instanceof ArrayTypeReference || this.fieldDeclaration.type instanceof ArrayQualifiedTypeReference) {
if (!this.alreadyCompletedFieldInitialization) {
this.bracketBalance++;
return null; // no update is necessary (array initializer)
}
} else { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=308980
// in case an initializer bracket is opened in a non-array field
// e.g. int field = {..
this.bracketBalance++;
return null; // no update is necessary (array initializer)
}
}
if (this.fieldDeclaration.declarationSourceEnd == 0
&& this.fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT){
this.bracketBalance++;
return null; // no update is necessary (enum constant)
}
// might be an array initializer
this.updateSourceEndIfNecessary(braceStart - 1, braceEnd - 1);
return this.parent.updateOnOpeningBrace(braceStart, braceEnd);
}
示例3: generateSyntheticBodyForEnumInitializationMethod
public void generateSyntheticBodyForEnumInitializationMethod(SyntheticMethodBinding methodBinding) {
// no local used
this.maxLocals = 0;
// generate all enum constants
SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) methodBinding.declaringClass;
TypeDeclaration typeDeclaration = sourceTypeBinding.scope.referenceContext;
BlockScope staticInitializerScope = typeDeclaration.staticInitializerScope;
FieldDeclaration[] fieldDeclarations = typeDeclaration.fields;
for (int i = methodBinding.startIndex, max = methodBinding.endIndex; i < max; i++) {
FieldDeclaration fieldDecl = fieldDeclarations[i];
if (fieldDecl.isStatic()) {
if (fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
fieldDecl.generateCode(staticInitializerScope, this);
}
}
}
return_();
}
示例4: resolveConstructor
IMethodBinding resolveConstructor(EnumConstantDeclaration enumConstantDeclaration) {
org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(enumConstantDeclaration);
if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
if (fieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT && fieldDeclaration.initialization != null) {
AllocationExpression allocationExpression = (AllocationExpression) fieldDeclaration.initialization;
return getMethodBinding(allocationExpression.binding);
}
}
return null;
}
示例5: buildBodyDeclarations
protected void buildBodyDeclarations(
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration,
AbstractTypeDeclaration typeDecl,
boolean isInterface) {
// add body declaration in the lexical order
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] members = typeDeclaration.memberTypes;
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration[] fields = typeDeclaration.fields;
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration[] methods = typeDeclaration.methods;
int fieldsLength = fields == null? 0 : fields.length;
int methodsLength = methods == null? 0 : methods.length;
int membersLength = members == null ? 0 : members.length;
int fieldsIndex = 0;
int methodsIndex = 0;
int membersIndex = 0;
while ((fieldsIndex < fieldsLength)
|| (membersIndex < membersLength)
|| (methodsIndex < methodsLength)) {
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration nextFieldDeclaration = null;
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration nextMethodDeclaration = null;
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration nextMemberDeclaration = null;
int position = Integer.MAX_VALUE;
int nextDeclarationType = -1;
if (fieldsIndex < fieldsLength) {
nextFieldDeclaration = fields[fieldsIndex];
if (nextFieldDeclaration.declarationSourceStart < position) {
position = nextFieldDeclaration.declarationSourceStart;
nextDeclarationType = 0; // FIELD
}
}
if (methodsIndex < methodsLength) {
nextMethodDeclaration = methods[methodsIndex];
if (nextMethodDeclaration.declarationSourceStart < position) {
position = nextMethodDeclaration.declarationSourceStart;
nextDeclarationType = 1; // METHOD
}
}
if (membersIndex < membersLength) {
nextMemberDeclaration = members[membersIndex];
if (nextMemberDeclaration.declarationSourceStart < position) {
position = nextMemberDeclaration.declarationSourceStart;
nextDeclarationType = 2; // MEMBER
}
}
switch (nextDeclarationType) {
case 0 :
if (nextFieldDeclaration.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT) {
typeDecl.bodyDeclarations().add(convert(nextFieldDeclaration));
} else {
checkAndAddMultipleFieldDeclaration(fields, fieldsIndex, typeDecl.bodyDeclarations());
}
fieldsIndex++;
break;
case 1 :
methodsIndex++;
if (!nextMethodDeclaration.isDefaultConstructor() && !nextMethodDeclaration.isClinit()) {
typeDecl.bodyDeclarations().add(convert(isInterface, nextMethodDeclaration));
}
break;
case 2 :
membersIndex++;
ASTNode node = convert(nextMemberDeclaration);
if (node == null) {
typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED);
} else {
typeDecl.bodyDeclarations().add(node);
}
}
}
// Convert javadoc
convert(typeDeclaration.javadoc, typeDecl);
}
示例6: add
public RecoveredElement add(FieldDeclaration fieldDeclaration, int bracketBalanceValue) {
this.pendingTypeParameters = null;
/* do not consider a field starting passed the type end (if set)
it must be belonging to an enclosing type */
if (this.typeDeclaration.declarationSourceEnd != 0
&& fieldDeclaration.declarationSourceStart > this.typeDeclaration.declarationSourceEnd) {
resetPendingModifiers();
return this.parent.add(fieldDeclaration, bracketBalanceValue);
}
if (this.fields == null) {
this.fields = new RecoveredField[5];
this.fieldCount = 0;
} else {
if (this.fieldCount == this.fields.length) {
System.arraycopy(
this.fields,
0,
(this.fields = new RecoveredField[2 * this.fieldCount]),
0,
this.fieldCount);
}
}
RecoveredField element;
switch (fieldDeclaration.getKind()) {
case AbstractVariableDeclaration.FIELD:
case AbstractVariableDeclaration.ENUM_CONSTANT:
element = new RecoveredField(fieldDeclaration, this, bracketBalanceValue);
break;
case AbstractVariableDeclaration.INITIALIZER:
element = new RecoveredInitializer(fieldDeclaration, this, bracketBalanceValue);
break;
default:
// never happens, as field is always identified
return this;
}
this.fields[this.fieldCount++] = element;
if(this.pendingAnnotationCount > 0) {
element.attach(
this.pendingAnnotations,
this.pendingAnnotationCount,
this.pendingModifiers,
this.pendingModifersSourceStart);
}
resetPendingModifiers();
/* consider that if the opening brace was not found, it is there */
if (!this.foundOpeningBrace){
this.foundOpeningBrace = true;
this.bracketBalance++;
}
/* if field not finished, then field becomes current */
if (fieldDeclaration.declarationSourceEnd == 0) return element;
return this;
}
示例7: resolveTypeFor
public FieldBinding resolveTypeFor(FieldBinding field) {
if ((field.modifiers & ExtraCompilerModifiers.AccUnresolved) == 0)
return field;
if (this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
if ((field.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0)
field.modifiers |= ClassFileConstants.AccDeprecated;
}
if (isViewedAsDeprecated() && !field.isDeprecated())
field.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
if (hasRestrictedAccess())
field.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;
FieldDeclaration[] fieldDecls = this.scope.referenceContext.fields;
int length = fieldDecls == null ? 0 : fieldDecls.length;
for (int f = 0; f < length; f++) {
if (fieldDecls[f].binding != field)
continue;
MethodScope initializationScope = field.isStatic()
? this.scope.referenceContext.staticInitializerScope
: this.scope.referenceContext.initializerScope;
FieldBinding previousField = initializationScope.initializedField;
try {
initializationScope.initializedField = field;
FieldDeclaration fieldDecl = fieldDecls[f];
TypeBinding fieldType =
fieldDecl.getKind() == AbstractVariableDeclaration.ENUM_CONSTANT
? initializationScope.environment().convertToRawType(this, false /*do not force conversion of enclosing types*/) // enum constant is implicitly of declaring enum type
: fieldDecl.type.resolveType(initializationScope, true /* check bounds*/);
field.type = fieldType;
field.modifiers &= ~ExtraCompilerModifiers.AccUnresolved;
if (fieldType == null) {
fieldDecl.binding = null;
return null;
}
if (fieldType == TypeBinding.VOID) {
this.scope.problemReporter().variableTypeCannotBeVoid(fieldDecl);
fieldDecl.binding = null;
return null;
}
if (fieldType.isArrayType() && ((ArrayBinding) fieldType).leafComponentType == TypeBinding.VOID) {
this.scope.problemReporter().variableTypeCannotBeVoidArray(fieldDecl);
fieldDecl.binding = null;
return null;
}
if ((fieldType.tagBits & TagBits.HasMissingType) != 0) {
field.tagBits |= TagBits.HasMissingType;
}
TypeBinding leafType = fieldType.leafComponentType();
if (leafType instanceof ReferenceBinding && (((ReferenceBinding)leafType).modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) {
field.modifiers |= ExtraCompilerModifiers.AccGenericSignature;
}
} finally {
initializationScope.initializedField = previousField;
}
return field;
}
return null; // should never reach this point
}