private TypeReference getMostOuterTypeRefBySlowLookuping(TypeReference typeRef) { String name = typeRef.getName(); if (name == null) return typeRef; String packageName = typeRef.getPackageName(); if (packageName == null) return typeRef; String[] nameParts = name.split("\\$"); String newName = ""; String sep = ""; for (int i = 0; i < nameParts.length - 1; i++) { newName = newName + sep + nameParts[i]; sep = "$"; String newInternalName = packageName.replaceAll("\\.", "/") + "/" + newName; TypeReference newTypeRef = metadataSystem.lookupType(newInternalName); if (newTypeRef != null) { TypeDefinition newTypeDef = newTypeRef.resolve(); if (newTypeDef != null) { return newTypeRef; } } } return typeRef; }
if (sameTitledOpen != null && path.equals(sameTitledOpen.path) && type.equals(sameTitledOpen.getType()) && sameTitledOpen.isContentValid()) { sameTitledOpen.setInitialNavigationLink(navigatonLink); if (type == null || ((resolvedType = type.resolve()) == null)) { throw new Exception("Unable to resolve type.");
private TypeReference getMostOuterTypeRef(TypeReference typeRef) { int maxDecraringDepth = typeRef.getFullName().split("(\\.|\\$)").length; for (int i = 0; i < maxDecraringDepth; i++) { TypeReference declaringTypeRef = typeRef.getDeclaringType(); if (declaringTypeRef == null) { break; } else { typeRef = declaringTypeRef; } } if (typeRef.getName().contains("$")) { return getMostOuterTypeRefBySlowLookuping(typeRef); } return typeRef; }
private String getPathAndTypeStr(TypeReference typeRef) { String name = typeRef.getName(); String packageStr = typeRef.getPackageName(); TypeReference mostOuterTypeRef = getMostOuterTypeRef(typeRef); String mostOuterTypeName = mostOuterTypeRef.getName(); if (name != null && packageStr != null && mostOuterTypeName != null && name.trim().length() > 0 && mostOuterTypeName.trim().length() > 0) { String pathStr = packageStr.replaceAll("\\.", "/") + "/" + mostOuterTypeName; String typeStr = packageStr + "." + name.replace(".", "$"); return pathStr + "|" + typeStr; } return null; }
private TypeReference U(final TypeReference t) { TypeReference current = t; while (current.isWildcardType()) { if (current.isUnbounded()) { return BuiltinTypes.Object; } if (current.hasSuperBound()) { return current.getSuperBound(); } current = current.getExtendsBound(); } return current; }
@Override public TypeReference visitType(final TypeReference t, final Void ignored) { if (t.isWildcardType() || t.isGenericParameter() || t instanceof ICapturedType) { return t.isUnbounded() || t.hasSuperBound() ? BuiltinTypes.Object : visit(t.getExtendsBound()); } return t; }
@Override protected StringBuilder appendDescription(final StringBuilder sb) { sb.append(getFullName()); final TypeReference upperBound = getExtendsBound(); if (upperBound != null && !upperBound.equals(BuiltinTypes.Object)) { sb.append(" extends "); if (upperBound.isGenericParameter() || upperBound.equals(getDeclaringType())) { return sb.append(upperBound.getFullName()); } return upperBound.appendErasedDescription(sb); } return sb; }
@Override protected StringBuilder appendBriefDescription(final StringBuilder sb) { sb.append(getFullName()); final TypeReference upperBound = getExtendsBound(); if (upperBound != null && !upperBound.equals(BuiltinTypes.Object)) { sb.append(" extends "); if (upperBound.isGenericParameter() || upperBound.equals(getDeclaringType())) { return sb.append(upperBound.getName()); } return upperBound.appendErasedDescription(sb); } return sb; }
@Override protected StringBuilder appendSimpleDescription(final StringBuilder sb) { sb.append(getFullName()); final TypeReference upperBound = getExtendsBound(); if (upperBound != null && !upperBound.equals(BuiltinTypes.Object)) { sb.append(" extends "); if (upperBound.isGenericParameter() || upperBound.equals(getOwner())) { return sb.append(upperBound.getSimpleName()); } return upperBound.appendSimpleDescription(sb); } return sb; }
private TypeReference toRawType(TypeReference type) { if(type.hasExtendsBound()) return toRawType(type.getExtendsBound()); if(type.hasSuperBound()) return BuiltinTypes.Object; if(type instanceof GenericParameter) return toRawType(type.getUnderlyingType()); if(!type.isGenericType()) return type; try { return type.getRawType(); } catch (UnsupportedOperationException e) { return BuiltinTypes.Object; } }
public static int getArrayRank(final TypeReference t) { if (t == null) { return 0; } int rank = 0; TypeReference current = t; while (current.isArray()) { ++rank; current = current.getElementType(); } return rank; }
public boolean hasExtendsBound() { return isGenericParameter() || (isWildcardType() && !BuiltinTypes.Object.equals(getExtendsBound()) && MetadataResolver.areEquivalent(BuiltinTypes.Bottom, getSuperBound())); }
public TypeReference getRawType() { if (isGenericType()) { final TypeReference underlyingType = getUnderlyingType(); if (underlyingType != this) { return underlyingType.getRawType(); } return new RawType(this); } throw ContractUtils.unsupported(); }
public static TypeReference getElementType(final TypeReference t) { if (t.isArray()) { return t.getElementType(); } if (t.isWildcardType()) { return getElementType(getUpperBound(t)); } return null; }
if (typeRef == null) return false; TypeDefinition typeDef = typeRef.resolve(); if (typeDef == null) return false;
if (typeRef == null) return null; TypeDefinition typeDef = typeRef.resolve(); if (typeDef == null) return null; TypeReference declaringTypeRef = typeRef.getDeclaringType(); if (declaringTypeRef != null) { TypeDefinition declaringTypeDef = declaringTypeRef.resolve(); if (declaringTypeDef != null) { String declaringTypeName = declaringTypeDef.getName();
public String getFullName() { if (_fullName == null) { _fullName = _elementType.getFullName() + "[]"; } return _fullName; }
public String getPackageName() { final TypeReference declaringType = getDeclaringType(); if (declaringType != null) { return declaringType.getPackageName(); } return _packageName != null ? _packageName : StringUtilities.EMPTY; }
protected StringBuilder appendErasedDescription(final StringBuilder sb) { StringBuilder s = sb; for (final Modifier modifier : Flags.asModifierSet(getModifiers())) { s.append(modifier.toString()); s.append(' '); } s = getFieldType().getRawType().appendErasedDescription(s); s.append(' '); s.append(getName()); return s; }
@Override public Boolean visitRawType(final RawType t, final TypeReference s) { return s.getSimpleType() == JvmType.Object && !s.isGenericType() && StringUtilities.equals(t.getInternalName(), s.getInternalName()); }