public static ITypeBinding getTopLevelType(ITypeBinding type) { ITypeBinding parent= type.getDeclaringClass(); while (parent != null) { type= parent; parent= type.getDeclaringClass(); } return type; }
public static ITypeBinding getTopLevelType(ITypeBinding type) { ITypeBinding parent= type.getDeclaringClass(); while (parent != null) { type= parent; parent= type.getDeclaringClass(); } return type; }
public TypeReferenceQualifier(final ITypeBinding type, final TextEditGroup group) { Assert.isNotNull(type); Assert.isNotNull(type.getDeclaringClass()); fTypeBinding= type; fGroup= group; }
private int nameSpaceLength(ITypeBinding type, String fullName, int pos) { while (type.isNested()) { pos = fullName.lastIndexOf(".", pos - 1); type = type.getDeclaringClass(); } return pos; }
private static boolean isTypeInScope(ITypeBinding declaring, ITypeBinding context, boolean includeHierarchy) { ITypeBinding curr= context; while (curr != null && curr != declaring) { if (includeHierarchy && Bindings.isSuperType(declaring, curr)) { return true; } curr= curr.getDeclaringClass(); } return curr == declaring; }
private static boolean isTypeInScope(ITypeBinding declaring, ITypeBinding context, boolean includeHierarchy) { ITypeBinding curr= context.getTypeDeclaration(); while (curr != null && curr != declaring) { if (includeHierarchy && isInSuperTypeHierarchy(declaring, curr)) { return true; } curr= curr.getDeclaringClass(); } return curr == declaring; }
private boolean classNameHidesEnclosingType() { ITypeBinding type= ((AbstractTypeDeclaration) ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class)).resolveBinding(); while (type != null) { if (fClassName.equals(type.getName())) return true; type= type.getDeclaringClass(); } return false; }
private boolean classNameHidesEnclosingType() { ITypeBinding type= ((AbstractTypeDeclaration) ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class)).resolveBinding(); while (type != null) { if (fClassName.equals(type.getName())) return true; type= type.getDeclaringClass(); } return false; }
private boolean classNameHidesEnclosingType() { ITypeBinding type= ASTNodes.getParent(fAnonymousInnerClassNode, AbstractTypeDeclaration.class).resolveBinding(); while (type != null) { if (fClassName.equals(type.getName())) return true; type= type.getDeclaringClass(); } return false; }
private ContainerEntity ensureContainerEntityForTypeBinding(ITypeBinding binding) { if (binding.getDeclaringClass() != null) return ensureTypeFromTypeBinding(binding.getDeclaringClass()); if (binding.getPackage() != null) return ensureNamespaceFromPackageBinding(binding.getPackage()); return unknownNamespace(); }
private boolean isInsideTypeNestedInDeclaringType(ASTNode node) { Assert.isTrue((node instanceof ClassInstanceCreation) || (node instanceof SuperConstructorInvocation)); final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(node, AbstractTypeDeclaration.class); Assert.isNotNull(declaration); ITypeBinding enclosing= declaration.resolveBinding(); while (enclosing != null) { if (isCorrespondingTypeBinding(enclosing, fType.getDeclaringType())) return true; enclosing= enclosing.getDeclaringClass(); } return false; }
private Type buildType(ITypeBinding binding, ITypeBinding bindingPoint, AST ast, ImportRewriteContext context, Type qualifier, TypeLocation location) { if (binding.equals(bindingPoint)) { return qualifier; } // build the type recursively from left to right Type type = binding.isMember() ? buildType(binding.getDeclaringClass(), bindingPoint, ast, context, qualifier, TypeLocation.OTHER) : null; type = internalAddImport(binding, ast, context, type, false, location); return type; }
private static boolean isInterfaceOrAnnotationMember(IBinding binding) { ITypeBinding declaringType= null; if (binding instanceof IVariableBinding) { declaringType= ((IVariableBinding) binding).getDeclaringClass(); } else if (binding instanceof IMethodBinding) { declaringType= ((IMethodBinding) binding).getDeclaringClass(); } else if (binding instanceof ITypeBinding) { declaringType= ((ITypeBinding) binding).getDeclaringClass(); } return declaringType != null && (declaringType.isInterface() || declaringType.isAnnotation()); }
private static ITypeBinding getDeclaringClassBinding(SimpleName memberName) { IBinding binding= memberName.resolveBinding(); if (binding instanceof IMethodBinding) return ((IMethodBinding) binding).getDeclaringClass(); if (binding instanceof IVariableBinding) return ((IVariableBinding) binding).getDeclaringClass(); if (binding instanceof ITypeBinding) return ((ITypeBinding) binding).getDeclaringClass(); Assert.isTrue(false); return null; }
private Type buildType(ITypeBinding binding, ITypeBinding bindingPoint, AST ast, ImportRewriteContext context, Type qualifier, TypeLocation location) { if (binding.equals(bindingPoint)) { return qualifier; } // build the type recursively from left to right Type type = binding.isMember() ? buildType(binding.getDeclaringClass(), bindingPoint, ast, context, qualifier, TypeLocation.OTHER) : null; type = internalAddImport(binding, ast, context, type, false, location); return type; }
private Type buildType(ITypeBinding binding, ITypeBinding bindingPoint, AST ast, ImportRewriteContext context, Type qualifier) { if (binding.equals(bindingPoint)) { return qualifier; } // build the type recursively from left to right Type type = binding.isMember() ? buildType(binding.getDeclaringClass(), bindingPoint, ast, context, qualifier) : null; type = internalAddImport(binding, ast, context, type, false); return type; }
private static boolean isInterfaceOrAnnotationMember(IBinding binding) { ITypeBinding declaringType= null; if (binding instanceof IVariableBinding) { declaringType= ((IVariableBinding) binding).getDeclaringClass(); } else if (binding instanceof IMethodBinding) { declaringType= ((IMethodBinding) binding).getDeclaringClass(); } else if (binding instanceof ITypeBinding) { declaringType= ((ITypeBinding) binding).getDeclaringClass(); } return declaringType != null && (declaringType.isInterface() || declaringType.isAnnotation()); }
private static ITypeBinding getDeclaringClassBinding(SimpleName memberName) { IBinding binding= memberName.resolveBinding(); if (binding instanceof IMethodBinding) return ((IMethodBinding) binding).getDeclaringClass(); if (binding instanceof IVariableBinding) return ((IVariableBinding) binding).getDeclaringClass(); if (binding instanceof ITypeBinding) return ((ITypeBinding) binding).getDeclaringClass(); Assert.isTrue(false); return null; }
private CSExpression createEnclosingThisReference( ITypeBinding enclosingClassBinding, boolean ignoreSuperclass) { CSExpression enclosing = new CSThisExpression(); ITypeBinding binding = nestedTypeBinding(); ITypeBinding to = enclosingClassBinding; while (binding != to && (ignoreSuperclass || !isSuperclass(binding, to))) { requireEnclosingReference(); enclosing = new CSMemberReferenceExpression(enclosing, "_enclosing"); binding = binding.getDeclaringClass(); if (null == binding) break; } return enclosing; }
public String anonLocalTypeToTypeID(ITypeBinding type) { String outerTypeID = typeToTypeID(type.getDeclaringClass()); String metSelectorName; IMethodBinding metBinding = type.getDeclaringMethod(); if (metBinding == null) // anonymous class declared in initializer or static initializer (rare case...) metSelectorName = "<init>"; else metSelectorName = getMethodRef(metBinding).getSelector().toString(); String shortName = (type.isAnonymous()) ? JDT2CAstUtils.anonTypeName(type) : type.getName(); return outerTypeID + '/' + metSelectorName + '/' + shortName; }