List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants SYNTHETIC_ENUM_VALUES
null SYNTHETIC_ENUM_VALUES
To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants SYNTHETIC_ENUM_VALUES.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public FieldBinding addSyntheticFieldForEnumValues() { if (this.synthetics == null) this.synthetics = new HashMap[MAX_SYNTHETICS]; if (this.synthetics[SourceTypeBinding.FIELD_EMUL] == null) this.synthetics[SourceTypeBinding.FIELD_EMUL] = new HashMap(5); FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.FIELD_EMUL] .get("enumConstantValues"); //$NON-NLS-1$ if (synthField == null) { synthField = new SyntheticFieldBinding(TypeConstants.SYNTHETIC_ENUM_VALUES, this.scope.createArrayType(this, 1), ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic | ClassFileConstants.AccFinal, this, Constant.NotAConstant, this.synthetics[SourceTypeBinding.FIELD_EMUL].size()); this.synthetics[SourceTypeBinding.FIELD_EMUL].put("enumConstantValues", synthField); //$NON-NLS-1$ }/*from w w w . ja va2s .co m*/ // ensure there is not already such a field defined by the user // ensure there is not already such a field defined by the user boolean needRecheck; int index = 0; do { needRecheck = false; FieldBinding existingField; if ((existingField = getField(synthField.name, true /*resolve*/)) != null) { TypeDeclaration typeDecl = this.scope.referenceContext; FieldDeclaration[] fieldDeclarations = typeDecl.fields; int max = fieldDeclarations == null ? 0 : fieldDeclarations.length; for (int i = 0; i < max; i++) { FieldDeclaration fieldDecl = fieldDeclarations[i]; if (fieldDecl.binding == existingField) { synthField.name = CharOperation.concat(TypeConstants.SYNTHETIC_ENUM_VALUES, ("_" + String.valueOf(index++)).toCharArray()); //$NON-NLS-1$ needRecheck = true; break; } } } } while (needRecheck); return synthField; }