List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding depth
@Override public int depth()
From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java
License:Open Source License
public FieldBinding addSyntheticFieldForInnerclass(ReferenceBinding enclosingType) { 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(enclosingType); if (synthField == null) { synthField = new SyntheticFieldBinding( CharOperation.concat(TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX, String.valueOf(enclosingType.depth()).toCharArray()), enclosingType,/* ww w. j a v a2 s. co m*/ ClassFileConstants.AccDefault | ClassFileConstants.AccFinal | ClassFileConstants.AccSynthetic, this, Constant.NotAConstant, this.synthetics[SourceTypeBinding.FIELD_EMUL].size()); this.synthetics[SourceTypeBinding.FIELD_EMUL].put(enclosingType, synthField); } // ensure there is not already such a field defined by the user boolean needRecheck; 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) { if (this.scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5) { synthField.name = CharOperation.concat(synthField.name, "$".toCharArray()); //$NON-NLS-1$ needRecheck = true; } else { this.scope.problemReporter().duplicateFieldInType(this, fieldDecl); } break; } } } } while (needRecheck); return synthField; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java
License:Open Source License
public static FieldBinding findFieldByBinding(ReferenceBinding clazz, FieldBinding refField) { char[] thisPrefix = TypeConstants.SYNTHETIC_ENCLOSING_INSTANCE_PREFIX; char[] classPrefix = TypeConstants.SYNTHETIC_CLASS; char[] name = refField.name; if (CharOperation.prefixEquals(thisPrefix, name)) { int distance = refField.declaringClass.depth() - ((ReferenceBinding) refField.type).depth(); if (clazz instanceof NestedTypeBinding) { {/*ww w . j av a 2s.c om*/ NestedTypeBinding mtb = (NestedTypeBinding) clazz; ReferenceBinding dstFieldType = clazz; while (distance-- > 0) { dstFieldType = dstFieldType.enclosingType(); } return mtb.addSyntheticFieldForInnerclass(dstFieldType); } } else { // BinaryTypeBinding int depth = clazz.depth() - distance; name = CharOperation.concat(thisPrefix, String.valueOf(depth).toCharArray()); } } else if (CharOperation.prefixEquals(classPrefix, name)) { // assume the synthetic field is present, just create a new binding. return new FieldBinding(refField.name, refField.type, 0, clazz, null); } // directly find field in clazz or superclass(es) ReferenceBinding current = clazz; while (current != null) { FieldBinding f = current.getField(name, true); if (f != null) return f; current = current.superclass(); } return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.AbstractOTReferenceBinding.java
License:Open Source License
/** Any form: (1) source/generated, (2) class/interface, (3) direct/nested */ public boolean isRole() { if (isEnum()) return false; if (this.isRolish) return true; ReferenceBinding enclosingTeam = TeamModel.getEnclosingTeam(_this()); if (enclosingTeam == null) return false; if (isLocalType() && (depth() - enclosingTeam.depth()) == 1 // direct local of team is not a role! && !enclosingTeam.isRole()) // .. unless enclosing team is also a role return false; this.isRolish = true; return true;/* ww w.j av a2 s.com*/ }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.RoleTypeBinding.java
License:Open Source License
public ReferenceBinding superclass() { // 0. a stored superclass: if (this._superClass != null) return this._superClass; // 1. a direct super-role is found as the superclass of this role's class: if (this._staticallyKnownRoleClass != null) { ReferenceBinding superClass = this._staticallyKnownRoleClass.superclass(); if ((superClass != null) && (superClass.isDirectRole())) { // 1.a: a confined type "as-is": don't instantiate/strengthen if (OTNameUtils.isPredefinedConfined(superClass.compoundName) || CharOperation.equals(IOTConstants.OTCONFINED, superClass.sourceName)) return this._superClass = superClass; // 1.b: instantiate superclass to the current team anchor: superClass = (ReferenceBinding) this._teamAnchor .getRoleTypeBinding(superClass.roleModel.getInterfacePartBinding(), 0); // dimensions=0 => the above cast is safe. // 1.c: strengthen weakened type: if (superClass instanceof WeakenedTypeBinding) { // TODO(SH): comment: how come this is possible? why is depth relevant? if (superClass.depth() >= depth()) { return null; // FIXME(SH): find a witness or delete this branch } else { // using "extends" accross team border: superClass = ((WeakenedTypeBinding) superClass).type; }/*from www .j a v a 2 s. c om*/ } return this._superClass = superClass; } } // 2. non-role superclass as the superclass of the role's interfaces: if (this._staticallyKnownRoleType != null) return this._superClass = this._staticallyKnownRoleType.superclass(); return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.copyinheritance.CopyInheritance.java
License:Open Source License
private static ReferenceBinding findCommonSuper(ReferenceBinding type1, ReferenceBinding type2) { ReferenceBinding current = type1; while (current != null && current.depth() == type1.depth()) // don't accept super class from outer scope {/*w w w . j a v a2s .c o m*/ if (type2.isCompatibleWith(current)) return current; current = current.superclass(); } ReferenceBinding[] superInterfaces = type1.superInterfaces(); for (int i = 0; i < superInterfaces.length; i++) { ReferenceBinding common = findCommonSuper(superInterfaces[i], type2); if (common != null) return common; } return null; }