/** @since 2.4 */ protected URI getFullURI(ITypeBinding typeBinding, SegmentSequence.Builder builder) { if (typeBinding.isPrimitive()) { builder.append(PRIMITIVE_URIS[typeBinding.getKey().charAt(0) - 'B'].fragment()); return PRIMITIVES_URI; } if (typeBinding.isClass() || typeBinding.isInterface() || typeBinding.isAnnotation() || typeBinding.isEnum()) { ITypeBinding declaringClass = typeBinding.getDeclaringClass(); if (declaringClass != null) { URI uri = getFullURI(declaringClass, builder); builder.append("$"); builder.append(typeBinding.getName()); return uri; } String qualifiedName = typeBinding.getErasure().getQualifiedName(); URI uri = COMMON_URIS.get(qualifiedName); if (uri == null) { uri = OBJECTS_URI.appendSegment(qualifiedName); } builder.append(uri.lastSegment()); return uri; } if (typeBinding.isArray()) { URI uri = getFullURI(typeBinding.getComponentType(), builder); builder.append("[]"); return uri; } if (typeBinding.isTypeVariable()) { ITypeBinding declaringClass = typeBinding.getDeclaringClass(); if (declaringClass != null) { URI uri = getFullURI(declaringClass, builder); builder.append("/"); builder.append(typeBinding.getName()); return uri; } IMethodBinding declaringMethod = typeBinding.getDeclaringMethod(); URI uri = getFullURI(declaringMethod.getDeclaringClass(), builder); builder.append("."); builder.append(declaringMethod.getName()); builder.append("("); ITypeBinding[] parameterTypes = declaringMethod.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { if (i != 0) { builder.append(","); } getQualifiedName(parameterTypes[i], builder); } builder.append(")"); builder.append("/"); builder.append(typeBinding.getName()); return uri; } throw new IllegalStateException("Unexpected type: " + typeBinding); }
/** @since 2.4 */ protected SegmentSequence.Builder getQualifiedName( ITypeBinding binding, SegmentSequence.Builder builder) { if (binding.isParameterizedType()) { getQualifiedName(binding.getErasure(), builder); } else if (binding.isArray()) { getQualifiedName(binding.getComponentType(), builder).append("[]"); } else if (binding.isTopLevel() || binding.isTypeVariable() || binding.isPrimitive()) { builder.append(binding.getQualifiedName()); } else { getQualifiedName(binding.getDeclaringClass(), builder).append('$').append(binding.getName()); } return builder; }
/** @since 2.4 */ public StringBuilder getQualifiedName(ITypeBinding binding, StringBuilder stringBuilder) { if (binding.isParameterizedType()) { getQualifiedName(binding.getErasure(), stringBuilder); } else if (binding.isArray()) { getQualifiedName(binding.getComponentType(), stringBuilder).append("[]"); } else if (binding.isTopLevel() || binding.isTypeVariable() || binding.isPrimitive()) { stringBuilder.append(binding.getQualifiedName()); } else { getQualifiedName(binding.getDeclaringClass(), stringBuilder) .append('$') .append(binding.getName()); } return stringBuilder; }
protected void createFragmentForMethod(IMethodBinding method, StringBuilder uriBuilder) { ITypeBinding declaringType = method.getDeclaringClass(); createFragmentForClass(declaringType, uriBuilder); uriBuilder.append('.'); uriBuilder.append(method.getName()); uriBuilder.append('('); ITypeBinding[] parameterTypes = method.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { if (i != 0) { uriBuilder.append(','); } getQualifiedName(parameterTypes[i], uriBuilder); } uriBuilder.append(')'); }