List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding constantPoolName
null constantPoolName
To view the source code for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding constantPoolName.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonExceptionTypeNames(ReferenceBinding[] thrownExceptions) { if (thrownExceptions == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding exception : thrownExceptions) { array.add(new JsonPrimitive(new String(exception.constantPoolName()))); }//from www .ja v a2s.c o m return array; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonMemberType(ReferenceBinding type) { JsonObject object = new JsonObject(); object.add("enclosingTypeName", type.enclosingType() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.enclosingType().constantPoolName()))); object.addProperty("modifiers", type.modifiers); object.add("name", type.constantPoolName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(type.constantPoolName()))); return object; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonInterfaces(ReferenceBinding[] interfaces) { if (interfaces == null) return JsonNull.INSTANCE; JsonArray array = new JsonArray(); for (ReferenceBinding anInterface : interfaces) { array.add(new JsonPrimitive(new String(anInterface.constantPoolName()))); }//from w ww . java 2s . c o m return array; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java
License:Open Source License
/** * Searches for a matching Roleclass in the destination Team which is given by the site of reference. * For this the method will compare all roles from destination Team with the referenced Role. * If one matching role ist found, this role will be returned * The Role exists in this Team, because we have copied it before. * * @param template the referenced TypeBinding which must be a Roleclass of the dstTeamBinding-Superclass * @param site the site where the new type reference is needed, either the team or one of its nested types. * @return the found TypeBinding or null if no matching Role is found *//*from w w w . jav a 2 s. c om*/ public static ReferenceBinding searchRoleClass(ReferenceBinding template, ReferenceBinding site) { if (!template.isRole()) // possible on external calls. return template; ReferenceBinding srcTeam = TeamModel.getEnclosingTeam(template); // different names are used depending on the kind of type: if (template.isLocalType()) return searchRoleClass(template.constantPoolName(), srcTeam, site); else return searchRoleClass(template.internalName(), srcTeam, site); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java
License:Open Source License
/** * Implementation of the above./*from ww w . j a v a2 s . c o m*/ * * TODO (SH): searching by simple name is not exact for nested teams! * * @return null ProblemReferenceBinding or a valid type in the context of 'site' */ private static ReferenceBinding searchRoleClass(char[] roleName, ReferenceBinding srcTeam, ReferenceBinding site) { // check the site type if (site.isLocalType() && CharOperation.equals(site.constantPoolName(), roleName)) return site; // check its member types ReferenceBinding[] members = site.memberTypes(); // TODO(SH): We observe binary and source of the same type. // As a workaround prefer source over binary here: ReferenceBinding candidate = null; for (int i = 0; i < members.length; i++) { if (CharOperation.equals(members[i].internalName(), roleName)) if (members[i].isBinaryBinding() && candidate == null) candidate = members[i]; else return members[i]; } if (candidate != null) return candidate; for (int i = 0; i < members.length; i++) { ReferenceBinding result = searchRoleClass(roleName, srcTeam, members[i]); if (result != null && result.isValidBinding()) return result; } // delegate to role model, which can handle local types, too. if (site.isRole()) return site.roleModel.findTypeRelative(TypeAnalyzer.constantPoolNameRelativeToTeam(srcTeam, roleName)); return null; // caller in recursion may still find the type. }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectReader.java
License:Open Source License
private FieldBinding getFieldRef(int index) { int start = getConstantPoolStartPosition(index); assert (u1At(start) == FieldRefTag); int class_index = u2At(start + 1); int name_index = u2At(start + 3); ReferenceBinding class_rb = getClassBinding(class_index); ReferenceBinding actualReceiver = class_rb; if (class_rb == null) return null; char[][] nameandtype = getNameAndType(name_index); char[] name = nameandtype[0]; char[] type = nameandtype[1]; FieldBinding fb = null;//from www.j av a2 s. c o m if (class_rb.erasure() instanceof SourceTypeBinding) { SourceTypeBinding sourceType = (SourceTypeBinding) class_rb.erasure(); // can't find synthetics in 'fields'. if (CharOperation.prefixEquals(TypeConstants.SYNTHETIC_OUTER_LOCAL_PREFIX, name)) return sourceType.getSyntheticOuterLocal(name); if (CharOperation.prefixEquals(TypeConstants.SYNTHETIC_CLASS, name)) return sourceType.getSyntheticClassLiteral(name); } // FIXME(SH): else read from RoleModel?? do { fb = findFieldBinding(class_rb, name, type); if (fb != null) { if (TypeBinding.notEquals(actualReceiver, class_rb)) // return sourceType.getUpdatedFieldBinding(fb, actualReceiver); // no sourceType available so directly create the updated binding: return new FieldBinding(fb, actualReceiver); return fb; } class_rb = class_rb.superclass(); } while (!CharOperation.equals(class_rb.constantPoolName(), ConstantPool.JavaLangObjectConstantPoolName)); return fb; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.RoleLocalTypesAttribute.java
License:Open Source License
protected void writeElementValue(int i) { ReferenceBinding typeBinding = this._localTypes[i]; writeName(typeBinding.constantPoolName()); // don't use attribute name here (has $Local$ prefix ...) }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.model.TeamModel.java
License:Open Source License
/** * Get the most suitable RoleTypeBinding for roleType in a tthis context defined by scope. * Strengthening reverses the effect of signature weakening. * * (Used for determining the statically known role type for lifting) * * @param site (guaranteed to be within the context of a team) * @param roleType (guaranteed to be a role or an array thereof) * @return found role - need not be a RoleTypeBinding *//*from w w w. j a v a 2 s . c o m*/ public static TypeBinding strengthenRoleType(ReferenceBinding site, TypeBinding roleType) { ReferenceBinding enclosingTeam = site; enclosingTeam = normalizeTeam(enclosingTeam); if (!enclosingTeam.isTeam()) enclosingTeam = getEnclosingTeam(site); if (enclosingTeam == null) return roleType; // this site cannot strengthen the role type. if (roleType.isLocalType()) return roleType; int dimensions = roleType.dimensions(); ReferenceBinding roleRefType = (ReferenceBinding) roleType.leafComponentType(); ReferenceBinding roleEnclosing = roleRefType.enclosingType(); if (roleEnclosing.isRole() && TypeBinding.notEquals(roleEnclosing.erasure(), site.erasure())) { // first strengthen enclosing team if it is nested: ReferenceBinding strengthenedEnclosing = null; if (TypeBinding.notEquals(roleEnclosing.erasure().enclosingType(), enclosingTeam.erasure().enclosingType())) strengthenedEnclosing = (ReferenceBinding) strengthenRoleType(site, roleEnclosing); if (strengthenedEnclosing != null && TypeBinding.notEquals(strengthenedEnclosing.erasure(), site.erasure())) { // we indeed found a better site, so start over: return strengthenRoleType(strengthenedEnclosing, roleType); } } // check success: if (!(roleRefType.isRole() // need a role && areCompatibleEnclosings(enclosingTeam, roleEnclosing))) // teams must be compatible { if (enclosingTeam.isRole()) // try via outer team: return strengthenRoleType(enclosingTeam.enclosingType(), roleType); return roleType; } if (roleRefType instanceof RoleTypeBinding) { RoleTypeBinding rtb = (RoleTypeBinding) roleRefType; if (!(rtb._teamAnchor instanceof TThisBinding)) return roleType; // don't instantiate explicit team anchor. } // lookup adjusted role type: roleRefType = enclosingTeam.getMemberType(roleRefType.internalName()); if (roleRefType == null) { if (enclosingTeam.isBinaryBinding()) { ReferenceBinding current = enclosingTeam; // search a role type to report against (for aborting): while (current != null && current.isBinaryBinding()) current = current.enclosingType(); if (current != null) { Scope scope = ((SourceTypeBinding) current).scope; if (scope != null) { scope.problemReporter().missingRoleInBinaryTeam(roleType.constantPoolName(), enclosingTeam); return null; } } } if (Protections.hasClassKindProblem(enclosingTeam)) return roleType; // can't do better.. if (!enclosingTeam.isBinaryBinding()) { Scope scope = ((SourceTypeBinding) enclosingTeam.getRealType()).scope; scope.problemReporter().missingCopiedRole(roleType, enclosingTeam); } else if (!site.isBinaryBinding()) { Scope scope = ((SourceTypeBinding) site.getRealType()).scope; scope.problemReporter().missingCopiedRole(roleType, enclosingTeam); } else { throw new InternalCompilerError("could not find role " + String.valueOf(roleType.constantPoolName()) //$NON-NLS-1$ + " in " + String.valueOf(site.constantPoolName()) + " and could not report regularly"); //$NON-NLS-1$ //$NON-NLS-2$ } return roleType; // can't do better, but shouldn't reach here, because missingCopiedRole triggers AbortType. } VariableBinding anchor = enclosingTeam.getTeamModel().getTThis(); if (roleType.isParameterizedType()) { // consult original role type for type arguments & type annotations: ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) roleType; TypeBinding parameterized = ptb.environment.createParameterizedType(roleRefType, ptb.arguments, anchor, -1, roleRefType.enclosingType(), ptb.getTypeAnnotations()); if (dimensions > 0) return ptb.environment.createArrayType(parameterized, dimensions); return parameterized; } return anchor.getRoleTypeBinding(roleRefType, dimensions); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.copyinheritance.CopyInheritance.java
License:Open Source License
/** * @param destTeamModel/*from w w w.j av a 2 s. c om*/ * @param destRole * @param tsuperNestedBinding */ private static TypeDeclaration copyRoleNestedInternal(TeamModel destTeamModel, RoleModel destRole, ReferenceBinding tsuperNestedBinding) { TypeDeclaration subRoleType = copyRole(tsuperNestedBinding, true, destTeamModel.getAst(), false); if (subRoleType != null) { RoleModel subRoleModel = subRoleType.getRoleModel(); subRoleModel.connect(destTeamModel, tsuperNestedBinding); if (tsuperNestedBinding.isLocalType()) destRole.addLocalType(tsuperNestedBinding.constantPoolName(), subRoleModel); } return subRoleType; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.copyinheritance.CopyInheritance.java
License:Open Source License
/** * If a tsuper role is not overriden in the current team, * create a fresh new role type declaration. * Always copy all inheritance information to the tsub role * (extends, implements, playedBy).//from w ww . j a v a 2 s . co m * No difference, whether we are looking at a role class or interface. * * @param superRole * @param subTeamDecl this declaration is being edited. * @return the new or modified type declaration */ private static TypeDeclaration copyRole(ReferenceBinding superRole, boolean isNestedType, TypeDeclaration subTeamDecl, boolean isTsuperTeam) { subTeamDecl.getTeamModel()._isCopyingLateRole = true; try { if (superRole instanceof MissingTypeBinding) return null; // don't copy missing type! if (superRole.sourceName == null) return null; // local types have null name String name = new String(superRole.sourceName); if ((name.startsWith(TSUPER_OT) || CharOperation.equals(superRole.sourceName, ROFI_CACHE))) return null; // don't copy these special roles if (subTeamDecl.isRole() && superRole.roleModel.equals(subTeamDecl.getRoleModel())) return null; // can happen in case of a role extending its enclosing TypeDeclaration subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName); ReferenceBinding subRoleBinding = subTeamDecl.binding.getMemberType(superRole.internalName()); if (subRoleBinding != null) { // don't copy binary tsuper, if a binary exists already here. if (shouldPreserveBinaryRole(subRoleBinding, subTeamDecl.compilationResult)) { if (isNestedType) subRoleBinding.roleModel.maybeAddLocalToEnclosing(); // no further processing needed except for connecting tsuper and copyInheritanceSrc: connectBinaryNested(superRole, subTeamDecl, subRoleBinding); return null; } // try again, memberType lookup might have introduced a role file to subTeamDecl: if (subRoleDecl == null) subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName); if (subRoleDecl != null && (subRoleDecl.binding.tagBits & TagBits.BeginHierarchyCheck) == 0) subRoleDecl.scope.connectTypeHierarchyWithoutMembers(); if (subRoleDecl == null) // still? return null; // assume recompile has been scheduled } // If type doesn't exist, create now if (subRoleDecl == null) { char[] superRoleName = superRole.internalName(); if (superRole.isLocalType()) { if (!superRole.isBinaryBinding()) ((LocalTypeBinding) superRole).computeConstantPoolName(); int lastDollar = CharOperation.lastIndexOf('$', superRole.sourceName); if (lastDollar >= 0) { superRoleName = CharOperation.subarray(superRole.sourceName, lastDollar + 1, -1); } else { char[] superConstantPoolName = superRole.constantPoolName(); lastDollar = CharOperation.lastIndexOf('$', superConstantPoolName); if (lastDollar >= 0) superRoleName = CharOperation.subarray(superConstantPoolName, lastDollar + 1, -1); } } subRoleDecl = AstConverter.createNestedType(superRoleName, superRole.modifiers, isNestedType, true, // purely copied subTeamDecl, superRole); if (subRoleDecl.isInterface()) { // purely copied interface now copies superinterfaces (not handled in connectRolesFromTeam()): ReferenceBinding[] tsuperSupers = superRole.superInterfaces(); subRoleDecl.binding.superInterfaces = new ReferenceBinding[tsuperSupers.length]; int j = 0; for (int i = 0; i < tsuperSupers.length; i++) { char[] tsuperSuperName = tsuperSupers[i].internalName(); if (!CharOperation.equals(tsuperSuperName, superRoleName)) { ReferenceBinding tsubRole = subTeamDecl.binding.getMemberType(tsuperSuperName); if (tsubRole != null) subRoleDecl.binding.superInterfaces[j++] = tsubRole; } } if (j < tsuperSupers.length) System.arraycopy(subRoleDecl.binding.superInterfaces, 0, subRoleDecl.binding.superInterfaces = new ReferenceBinding[j], 0, j); } } else { if (subRoleDecl.isRegularInterface() != superRole.isRegularInterface()) { subRoleDecl.scope.problemReporter().roleClassIfcConflict(subRoleDecl); // overwrite existing type with tsuper copy: subRoleDecl.isGenerated = true; subRoleDecl.isPurelyCopied = true; subRoleDecl.modifiers = superRole.modifiers; subRoleDecl.fields = null; subRoleDecl.methods = null; subRoleDecl.superclass = null; subRoleDecl.superInterfaces = null; SourceTypeBinding roleBinding = subRoleDecl.binding; roleBinding.modifiers = superRole.modifiers; roleBinding.setFields(Binding.NO_FIELDS); roleBinding.setMethods(Binding.NO_METHODS); roleBinding.baseclass = null; roleBinding.superclass = subTeamDecl.scope.getJavaLangObject(); roleBinding.superInterfaces = Binding.NO_SUPERINTERFACES; return subRoleDecl; } if (superRole.isTeam() && !subRoleDecl.isTeam()) { if (!Protections.hasClassKindProblem(subRoleDecl.binding)) subRoleDecl.scope.problemReporter().regularOverridesTeam(subRoleDecl, superRole); subRoleDecl.modifiers |= ClassFileConstants.AccTeam; if (subRoleBinding != null) subRoleBinding.modifiers |= ClassFileConstants.AccTeam; } if (!isTsuperTeam) { if (CharOperation.equals(subRoleDecl.name, OTCONFINED)) { subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "Confined"); //$NON-NLS-1$ return null; } if (CharOperation.equals(subRoleDecl.name, ICONFINED)) { subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "IConfined"); //$NON-NLS-1$ return null; } if (superRole.isFinal()) { subRoleDecl.scope.problemReporter().overridingFinalRole(subRoleDecl, superRole); return null; } } } superRole.roleModel.hasBaseclassProblem(); // just trigger propagation from super-role to current // if (subRoleBinding != null && subRoleBinding.isBinaryBinding()) // subRoleDecl.scope.problemReporter().mismatchingRoleParts(subRoleBinding, subRoleDecl); return subRoleDecl; } finally { subTeamDecl.getTeamModel()._isCopyingLateRole = false; } }