/** * Builds a qualified type reference from a {@link TypeReference}. * * @param type Qualified type from JDT. * @param scope Scope of the parent element. * @return */ <T> CtTypeReference<T> buildTypeReference(QualifiedTypeReference type, Scope scope) { CtTypeReference<T> accessedType = buildTypeReference((TypeReference) type, scope); final TypeBinding receiverType = type != null ? type.resolvedType : null; if (receiverType != null) { final CtTypeReference<T> ref = getQualifiedTypeReference(type.tokens, receiverType, receiverType.enclosingType(), new JDTTreeBuilder.OnAccessListener() { @Override public boolean onAccess(char[][] tokens, int index) { return true; } }); if (ref != null) { accessedType = ref; } } return accessedType; }
} else { ref.setSimpleName(String.valueOf(binding.sourceName())); if (binding.enclosingType() != null) { ref.setDeclaringType(getTypeReference(binding.enclosingType())); } else { ref.setPackage(getPackageReference(binding.getPackage())); if (binding.enclosingType() != null) { ref.setDeclaringType(getTypeReference(binding.enclosingType())); } else { ref.setPackage(getPackageReference(binding.getPackage())); if (binding.isAnonymousType()) { ref.setSimpleName(JDTTreeBuilderHelper.computeAnonymousName(((SourceTypeBinding) binding).constantPoolName())); ref.setDeclaringType(getTypeReference(binding.enclosingType())); } else { ref.setSimpleName(new String(binding.sourceName())); if (((LocalTypeBinding) binding).enclosingMethod == null && binding.enclosingType() != null && binding.enclosingType() instanceof LocalTypeBinding) { ref.setDeclaringType(getTypeReference(binding.enclosingType())); } else if (binding.enclosingMethod() != null) { ref.setSimpleName(JDTTreeBuilderHelper.computeAnonymousName(((SourceTypeBinding) binding).constantPoolName())); ref.setDeclaringType(getTypeReference(binding.enclosingType())); if (binding.isAnonymousType()) { ref.setSimpleName(JDTTreeBuilderHelper.computeAnonymousName(((SourceTypeBinding) binding).constantPoolName())); ref.setDeclaringType(getTypeReference(binding.enclosingType())); } else { ref.setSimpleName(new String(binding.sourceName())); if (binding.enclosingType() != null) {
@NonNull @Override public String getName() { String name = new String(mBinding.readableName()); if (name.indexOf('.') == -1 && mBinding.enclosingType() != null) { name = new String(mBinding.enclosingType().readableName()) + '.' + name; } return stripTypeVariables(name); }
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
public void illegalQualifiedParameterizedTypeAllocation(TypeReference qualifiedTypeReference, TypeBinding allocatedType) { this.handle( IProblem.IllegalQualifiedParameterizedTypeAllocation, new String[] { new String(allocatedType.readableName()), new String(allocatedType.enclosingType().readableName()), }, new String[] { new String(allocatedType.shortReadableName()), new String(allocatedType.enclosingType().shortReadableName()), }, qualifiedTypeReference.sourceStart, qualifiedTypeReference.sourceEnd); } public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding)binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] {'.', '1', '.'}, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); } } return binding != null ? binding.qualifiedSourceName() : null; } /*