private void computeDeclaringTypes(List<NdTypeSignature> result) { NdComplexTypeSignature declaringType = getGenericDeclaringType(); if (declaringType != null) { declaringType.computeDeclaringTypes(result); } result.add(this); }
/** * If this type is a type variable, this returns the variable's identifier. */ public IString getVariableIdentifier() { return VARIABLE_IDENTIFIER.get(getNd(), this.address); }
@Override public List<NdType> getSubTypes() { List<NdType> result = new ArrayList<>(); result.addAll(super.getSubTypes()); for (NdComplexTypeSignature next : getComplexTypes()) { result.addAll(next.getSubTypes()); } return result; }
@Override public void getSignature(CharArrayBuffer result, boolean includeTrailingSemicolon) { NdComplexTypeSignature parentSignature = getGenericDeclaringType(); if (isTypeVariable()) { result.append('T'); result.append(getVariableIdentifier().getChars()); if (includeTrailingSemicolon) { result.append(';'); NdTypeSignature arrayDimension = getArrayDimensionType(); if (arrayDimension != null) { result.append('['); parentSignature.getSignature(result, false); result.append('.'); char[] simpleName = getRawType().getSimpleName().getChars(); result.append(simpleName); } else { result.append(getRawType().getFieldDescriptorWithoutTrailingSemicolon()); List<NdTypeArgument> arguments = getTypeArguments(); if (!arguments.isEmpty()) { result.append('<');
parentTypeOrNull.getRawType().getFieldDescriptorWithoutTrailingSemicolon(), INNER_TYPE_SEPARATOR, identifier, FIELD_DESCRIPTOR_SUFFIX); } else { NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); typeSignature.setRawType(rawType); typeSignature.setGenericDeclaringType(parentTypeOrNull);
NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); char[] fieldDescriptor = fieldDescriptorIfVariable; if (fieldDescriptor == null) { fieldDescriptor = JAVA_LANG_OBJECT_FIELD_DESCRIPTOR; typeSignature.setRawType(createTypeIdFromFieldDescriptor(fieldDescriptor)); typeSignature.setVariableIdentifier(genericSignature.nextWord()); NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); typeSignature.setRawType(rawType); NdTypeArgument typeArgument = new NdTypeArgument(getNd(), typeSignature); typeArgument.setType(elementType);
@Override public NdTypeSignature getArrayDimensionType() { if (isArrayType()) { long size = TYPE_ARGUMENTS.size(getNd(), this.address); if (size != 1) { throw getNd().describeProblem() .addProblemAddress(TYPE_ARGUMENTS, this.address) .build("Array types should have exactly one argument"); //$NON-NLS-1$ } return TYPE_ARGUMENTS.get(getNd(), this.address, 0).getType(); } return null; }
@Override public boolean isArrayType() { NdTypeId rawType = getRawType(); if (rawType == null) { return false; } if (rawType.getFieldDescriptor().comparePrefix(JavaNames.ARRAY_FIELD_DESCRIPTOR_PREFIX, true) == 0) { // $NON-NLS-1$ return true; } return false; } }
@Override public boolean isTypeVariable() { return getVariableIdentifier().length() != 0; }
@Override public void getSignature(CharArrayBuffer result, boolean includeTrailingSemicolon) { NdComplexTypeSignature parentSignature = getGenericDeclaringType(); if (isTypeVariable()) { result.append('T'); result.append(getVariableIdentifier().getChars()); if (includeTrailingSemicolon) { result.append(';'); NdTypeSignature arrayDimension = getArrayDimensionType(); if (arrayDimension != null) { result.append('['); parentSignature.getSignature(result, false); result.append('.'); char[] simpleName = getRawType().getSimpleName().getChars(); result.append(simpleName); } else { result.append(getRawType().getFieldDescriptorWithoutTrailingSemicolon()); List<NdTypeArgument> arguments = getTypeArguments(); if (!arguments.isEmpty()) { result.append('<');
parentTypeOrNull.getRawType().getFieldDescriptorWithoutTrailingSemicolon(), INNER_TYPE_SEPARATOR, identifier, FIELD_DESCRIPTOR_SUFFIX); } else { NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); typeSignature.setRawType(rawType); typeSignature.setGenericDeclaringType(parentTypeOrNull);
NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); char[] fieldDescriptor = fieldDescriptorIfVariable; if (fieldDescriptor == null) { fieldDescriptor = JAVA_LANG_OBJECT_FIELD_DESCRIPTOR; typeSignature.setRawType(createTypeIdFromFieldDescriptor(fieldDescriptor)); typeSignature.setVariableIdentifier(genericSignature.nextWord()); NdComplexTypeSignature typeSignature = new NdComplexTypeSignature(getNd()); typeSignature.setRawType(rawType); NdTypeArgument typeArgument = new NdTypeArgument(getNd(), typeSignature); typeArgument.setType(elementType);
@Override public NdTypeSignature getArrayDimensionType() { if (isArrayType()) { long size = TYPE_ARGUMENTS.size(getNd(), this.address); if (size != 1) { throw getNd().describeProblem() .addProblemAddress(TYPE_ARGUMENTS, this.address) .build("Array types should have exactly one argument"); //$NON-NLS-1$ } return TYPE_ARGUMENTS.get(getNd(), this.address, 0).getType(); } return null; }
@Override public boolean isArrayType() { NdTypeId rawType = getRawType(); if (rawType == null) { return false; } if (rawType.getFieldDescriptor().comparePrefix(JavaNames.ARRAY_FIELD_DESCRIPTOR_PREFIX, true) == 0) { // $NON-NLS-1$ return true; } return false; } }
@Override public boolean isTypeVariable() { return getVariableIdentifier().length() != 0; }
private void computeDeclaringTypes(List<NdTypeSignature> result) { NdComplexTypeSignature declaringType = getGenericDeclaringType(); if (declaringType != null) { declaringType.computeDeclaringTypes(result); } result.add(this); }
/** * Returns the declaring type (as reported by the type's generic signature). * Not to be confused with the declaring type as stored in the class file. * That is stored in {@link NdType#getDeclaringType}. Any class that is * nested inside another class with generic arguments will have one of * these. Classes nested inside non-generic classes won't have one of these, * and neither will non-nested classes. */ public NdComplexTypeSignature getGenericDeclaringType() { return DECLARING_TYPE.get(getNd(), this.address); }
@Override public List<NdType> getSubTypes() { List<NdType> result = new ArrayList<>(); result.addAll(super.getSubTypes()); for (NdComplexTypeSignature next : getComplexTypes()) { result.addAll(next.getSubTypes()); } return result; }
@Override public List<NdTypeSignature> getDeclaringTypeChain() { NdComplexTypeSignature declaringType = getGenericDeclaringType(); if (declaringType == null) { return Collections.singletonList((NdTypeSignature)this); } List<NdTypeSignature> result = new ArrayList<>(); computeDeclaringTypes(result); return result; }
/** * If this type is a type variable, this returns the variable's identifier. */ public IString getVariableIdentifier() { return VARIABLE_IDENTIFIER.get(getNd(), this.address); }