private boolean checkBinding(List<AbstractTypeDeclaration> declarations, ITypeBinding binding) { for (Iterator<AbstractTypeDeclaration> iter = declarations.iterator(); iter.hasNext();) { AbstractTypeDeclaration declaration = iter.next(); if (declaration.resolveBinding() == binding) { return true; } } return false; }
private boolean checkBinding(List declarations, ITypeBinding binding) { for (Iterator iter= declarations.iterator(); iter.hasNext();) { AbstractTypeDeclaration declaration= (AbstractTypeDeclaration)iter.next(); if (declaration.resolveBinding() == binding) { return true; } } return false; }
private ITypeBinding getDeclaringType(MethodInvocation node) { ASTNode p= node; while (p != null) { p= p.getParent(); if (p instanceof AbstractTypeDeclaration) { return ((AbstractTypeDeclaration)p).resolveBinding(); } } return null; }
private ITypeBinding getDeclaringType(MethodInvocation node) { ASTNode p= node; while (p != null) { p= p.getParent(); if (p instanceof AbstractTypeDeclaration) { return ((AbstractTypeDeclaration)p).resolveBinding(); } } return null; }
private ITypeBinding getContainingTypeBinding() throws JavaModelException { ITypeBinding result = getContainingTypeDeclarationNode().resolveBinding(); Assert.isNotNull(result); return result; }
private ITypeBinding getContainingTypeBinding() throws JavaModelException { ITypeBinding result= getContainingTypeDeclarationNode().resolveBinding(); Assert.isNotNull(result); return result; }
private ITypeBinding getDeclaringType(MethodInvocation node) { ASTNode p= node; while (p != null) { p= p.getParent(); if (p instanceof AbstractTypeDeclaration) { return ((AbstractTypeDeclaration)p).resolveBinding(); } } return null; }
public static ITypeBinding getEnclosingType(ASTNode node) { while(node != null) { if (node instanceof AbstractTypeDeclaration) { return ((AbstractTypeDeclaration)node).resolveBinding(); } else if (node instanceof AnonymousClassDeclaration) { return ((AnonymousClassDeclaration)node).resolveBinding(); } node= node.getParent(); } return null; }
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 ITypeBinding typeToBinding(IType type, CompilationUnit root) throws JavaModelException { ASTNode typeNode= typeToDeclaration(type, root); if (type.isAnonymous()) { return ((AnonymousClassDeclaration) typeNode).resolveBinding(); } else { return ((AbstractTypeDeclaration) typeNode).resolveBinding(); } }
private boolean isTypeDeclarationSubTypeCompatible(ASTNode typeDeclaration, ITypeBinding supertype) { if (typeDeclaration instanceof AbstractTypeDeclaration) { ITypeBinding binding= ((AbstractTypeDeclaration) typeDeclaration).resolveBinding(); return binding != null && binding.isSubTypeCompatible(supertype); } else if (typeDeclaration instanceof AnonymousClassDeclaration) { ITypeBinding binding= ((AnonymousClassDeclaration) typeDeclaration).resolveBinding(); return binding != null && binding.isSubTypeCompatible(supertype); } else { return false; } }
private boolean isTypeDeclarationSubTypeCompatible(ASTNode typeDeclaration, ITypeBinding supertype) { if (typeDeclaration instanceof AbstractTypeDeclaration) { ITypeBinding binding= ((AbstractTypeDeclaration) typeDeclaration).resolveBinding(); return binding != null && binding.isSubTypeCompatible(supertype); } else if (typeDeclaration instanceof AnonymousClassDeclaration) { ITypeBinding binding= ((AnonymousClassDeclaration) typeDeclaration).resolveBinding(); return binding != null && binding.isSubTypeCompatible(supertype); } else { return false; } }
private void createInheritedAbstractMemberStubs(AbstractTypeDeclaration node) { if (node instanceof TypeDeclaration && ((TypeDeclaration)node).isInterface()) return; ITypeBinding binding = node.resolveBinding(); if (!Modifier.isAbstract(node.getModifiers())) return; Set<ITypeBinding> interfaces = new LinkedHashSet<ITypeBinding>(); collectInterfaces(interfaces, binding); for (ITypeBinding baseType : interfaces) { createInheritedAbstractMemberStubs(binding, baseType); } }
private boolean isInsideTypeNestedInDeclaringType(ASTNode node) { Assert.isTrue((node instanceof ClassInstanceCreation) || (node instanceof SuperConstructorInvocation)); final AbstractTypeDeclaration declaration= 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 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 boolean isInsideSubclassOfDeclaringType(ASTNode node) { Assert.isTrue((node instanceof ClassInstanceCreation) || (node instanceof SuperConstructorInvocation)); final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(node, AbstractTypeDeclaration.class); Assert.isNotNull(declaration); final AnonymousClassDeclaration anonymous= (AnonymousClassDeclaration) ASTNodes.getParent(node, AnonymousClassDeclaration.class); boolean isAnonymous= anonymous != null && ASTNodes.isParent(anonymous, declaration); if (isAnonymous) return anonymous != null && isSubclassBindingOfEnclosingType(anonymous.resolveBinding()); return isSubclassBindingOfEnclosingType(declaration.resolveBinding()); }
void initialize(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); fTypeBinding= null; // type cannot be anonymous final AbstractTypeDeclaration declaration= ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) fTypeBinding= declaration.resolveBinding(); }
void initialize(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL); fUnit= parser.parse(type.getCompilationUnit(), true); fTypeBinding= null; // type cannot be anonymous final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) fTypeBinding= declaration.resolveBinding(); }
private void checkInHierarchy(RefactoringStatus status, boolean usingLocalGetter, boolean usingLocalSetter) { AbstractTypeDeclaration declaration = ASTNodes.getParent(fFieldDeclaration, AbstractTypeDeclaration.class); ITypeBinding type = declaration.resolveBinding(); if (type != null) { ITypeBinding fieldType = fFieldDeclaration.resolveBinding().getType(); checkMethodInHierarchy(type, fGetterName, fieldType, new ITypeBinding[0], status, usingLocalGetter); checkMethodInHierarchy(type, fSetterName, fFieldDeclaration.getAST().resolveWellKnownType("void"), //$NON-NLS-1$ new ITypeBinding[] { fieldType }, status, usingLocalSetter); } }
public AddUnimplementedConstructorsContentProvider(IType type) throws JavaModelException { RefactoringASTParser parser= new RefactoringASTParser(AST.JLS3); fUnit= parser.parse(type.getCompilationUnit(), true); AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(NodeFinder.perform(fUnit, type.getNameRange()), AbstractTypeDeclaration.class); if (declaration != null) { ITypeBinding binding= declaration.resolveBinding(); if (binding != null) fMethodsList= StubUtility2.getVisibleConstructors(binding, true, false); } }