private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType) { ITypeBinding currNodeBinding= Bindings.getBindingOfParentType(currNode); if (currNodeBinding == null) { // import return Modifier.PUBLIC; } if (Bindings.isSuperType(targetType, currNodeBinding)) { return Modifier.PROTECTED; } if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) { return 0; } return Modifier.PUBLIC; }
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType, IBinding binding) { ITypeBinding currNodeBinding= Bindings.getBindingOfParentType(currNode); if (currNodeBinding == null) { // import return Modifier.PUBLIC; } if (Bindings.isSuperType(targetType, currNodeBinding)) { if (binding != null && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) { return Modifier.PUBLIC; } return Modifier.PROTECTED; } if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) { return 0; } return Modifier.PUBLIC; }
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType, IBinding binding) { ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode); if (currNodeBinding == null) { // import return Modifier.PUBLIC; } if (Bindings.isSuperType(targetType, currNodeBinding)) { if (binding != null && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) { return Modifier.PUBLIC; } return Modifier.PROTECTED; } if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) { return 0; } return Modifier.PUBLIC; }
private boolean addOuterDeclarationsForLocalType(ITypeBinding localBinding, int flags, IBindingRequestor requestor) { ASTNode node= fRoot.findDeclaringNode(localBinding); if (node == null) { return false; } if (node instanceof AbstractTypeDeclaration || node instanceof AnonymousClassDeclaration) { if (addLocalDeclarations(node.getParent(), flags, requestor)) return true; ITypeBinding parentTypeBinding= Bindings.getBindingOfParentType(node.getParent()); if (parentTypeBinding != null) { if (addTypeDeclarations(parentTypeBinding, flags, requestor)) return true; } } return false; }
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType, IBinding binding) { ITypeBinding currNodeBinding= Bindings.getBindingOfParentType(currNode); if (currNodeBinding == null) { // import return Modifier.PUBLIC; } if (Bindings.isSuperType(targetType, currNodeBinding)) { if (binding != null && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) { return Modifier.PUBLIC; } return Modifier.PROTECTED; } if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) { return 0; } return Modifier.PUBLIC; }
private boolean addOuterDeclarationsForLocalType(ITypeBinding localBinding, int flags, IBindingRequestor requestor) { ASTNode node= fRoot.findDeclaringNode(localBinding); if (node == null) { return false; } if (node instanceof AbstractTypeDeclaration || node instanceof AnonymousClassDeclaration) { if (addLocalDeclarations(node.getParent(), flags, requestor)) return true; ITypeBinding parentTypeBinding= Bindings.getBindingOfParentType(node.getParent()); if (parentTypeBinding != null) { if (addTypeDeclarations(parentTypeBinding, flags, requestor)) return true; } } return false; }
private boolean addOuterDeclarationsForLocalType(ITypeBinding localBinding, int flags, IBindingRequestor requestor) { ASTNode node= fRoot.findDeclaringNode(localBinding); if (node == null) { return false; } if (node instanceof AbstractTypeDeclaration || node instanceof AnonymousClassDeclaration) { if (addLocalDeclarations(node.getParent(), flags, requestor)) return true; ITypeBinding parentTypeBinding= Bindings.getBindingOfParentType(node.getParent()); if (parentTypeBinding != null) { if (addTypeDeclarations(parentTypeBinding, flags, requestor)) return true; } } return false; }
public IBinding[] getDeclarationsInScope(int offset, int flags) { org.eclipse.jdt.core.dom.NodeFinder finder= new org.eclipse.jdt.core.dom.NodeFinder(fRoot, offset, 0); ASTNode node= finder.getCoveringNode(); if (node == null) { return NO_BINDING; } if (node instanceof SimpleName) { return getDeclarationsInScope((SimpleName) node, flags); } try { ITypeBinding binding= Bindings.getBindingOfParentType(node); DefaultBindingRequestor requestor= new DefaultBindingRequestor(binding, flags); addLocalDeclarations(node, offset, flags, requestor); if (binding != null) { addTypeDeclarations(binding, flags, requestor); } List<IBinding> result= requestor.getResult(); return result.toArray(new IBinding[result.size()]); } finally { clearLists(); } }
public IBinding[] getDeclarationsInScope(int offset, int flags) { org.eclipse.jdt.core.dom.NodeFinder finder= new org.eclipse.jdt.core.dom.NodeFinder(fRoot, offset, 0); ASTNode node= finder.getCoveringNode(); if (node == null) { return NO_BINDING; } if (node instanceof SimpleName) { return getDeclarationsInScope((SimpleName) node, flags); } try { ITypeBinding binding= Bindings.getBindingOfParentType(node); DefaultBindingRequestor requestor= new DefaultBindingRequestor(binding, flags); addLocalDeclarations(node, offset, flags, requestor); if (binding != null) { addTypeDeclarations(binding, flags, requestor); } List<IBinding> result= requestor.getResult(); return result.toArray(new IBinding[result.size()]); } finally { clearLists(); } }
public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); if (binding == null || binding.getKind() != IBinding.METHOD) return false; ITypeBinding currentType= Bindings.getBindingOfParentType(node); ITypeBinding declaringType= ((IMethodBinding) binding).getDeclaringClass(); if (currentType == declaringType || currentType == null) return false; return Bindings.isSuperType(declaringType, currentType); } }
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); if (binding == null || binding.getKind() != IBinding.METHOD) return false; ITypeBinding currentType= Bindings.getBindingOfParentType(node); ITypeBinding declaringType= ((IMethodBinding) binding).getDeclaringClass(); if (currentType == declaringType || currentType == null) return false; return Bindings.isSuperType(declaringType, currentType); } }
@Override public boolean consumes(SemanticToken token) { SimpleName node = token.getNode(); if (node.isDeclaration()) { return false; } IBinding binding = token.getBinding(); if (binding == null || binding.getKind() != IBinding.METHOD) { return false; } ITypeBinding currentType = Bindings.getBindingOfParentType(node); ITypeBinding declaringType = ((IMethodBinding) binding).getDeclaringClass(); if (currentType == declaringType || currentType == null) { return false; } return Bindings.isSuperType(declaringType, currentType); } }
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); if (binding == null || binding.getKind() != IBinding.METHOD) return false; ITypeBinding currentType= Bindings.getBindingOfParentType(node); ITypeBinding declaringType= ((IMethodBinding) binding).getDeclaringClass(); if (currentType == declaringType || currentType == null) return false; return Bindings.isSuperType(declaringType, currentType); } }
@Override public boolean consumes(final SemanticToken token) { final SimpleName node= token.getNode(); if (node.isDeclaration()) { return false; } final IBinding binding= token.getBinding(); if (binding == null || binding.getKind() != IBinding.VARIABLE) { return false; } ITypeBinding currentType= Bindings.getBindingOfParentType(node); ITypeBinding declaringType= ((IVariableBinding) binding).getDeclaringClass(); if (declaringType == null || currentType == declaringType) return false; return Bindings.isSuperType(declaringType, currentType); } }
public IBinding[] getDeclarationsInScope(int offset, int flags) { NodeFinder finder= new NodeFinder(offset, 0); fRoot.accept(finder); ASTNode node= finder.getCoveringNode(); if (node == null) { return NO_BINDING; } if (node instanceof SimpleName) { return getDeclarationsInScope((SimpleName) node, flags); } try { ITypeBinding binding= Bindings.getBindingOfParentType(node); DefaultBindingRequestor requestor= new DefaultBindingRequestor(binding, flags); addLocalDeclarations(node, offset, flags, requestor); if (binding != null) { addTypeDeclarations(binding, flags, requestor); } List result= requestor.getResult(); return (IBinding[]) result.toArray(new IBinding[result.size()]); } finally { clearLists(); } }
@Override public boolean consumes(final SemanticToken token) { final SimpleName node = token.getNode(); if (node.isDeclaration()) { return false; } final IBinding binding = token.getBinding(); if (binding == null || binding.getKind() != IBinding.VARIABLE) { return false; } ITypeBinding currentType = Bindings.getBindingOfParentType(node); ITypeBinding declaringType = ((IVariableBinding) binding).getDeclaringClass(); if (declaringType == null || currentType == declaringType) { return false; } return Bindings.isSuperType(declaringType, currentType); } }
@Override public boolean consumes(final SemanticToken token) { final SimpleName node= token.getNode(); if (node.isDeclaration()) { return false; } final IBinding binding= token.getBinding(); if (binding == null || binding.getKind() != IBinding.VARIABLE) { return false; } ITypeBinding currentType= Bindings.getBindingOfParentType(node); ITypeBinding declaringType= ((IVariableBinding) binding).getDeclaringClass(); if (declaringType == null || currentType == declaringType) return false; return Bindings.isSuperType(declaringType, currentType); } }
private static String getThisExpressionQualifier(ITypeBinding declaringClass, ImportRewrite imports, SimpleName name) { ITypeBinding parentType= Bindings.getBindingOfParentType(name); ITypeBinding currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } if (currType == null) { declaringClass= declaringClass.getTypeDeclaration(); currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } } if (currType != parentType) { if (currType == null) return null; if (currType.isAnonymous()) //If we access a field of a super class of an anonymous class //then we can only qualify with 'this' but not with outer.this //see bug 115277 return null; return imports.addImport(currType); } else { return ""; //$NON-NLS-1$ } }
private static String getThisExpressionQualifier(ITypeBinding declaringClass, ImportRewrite imports, SimpleName name) { ITypeBinding parentType= Bindings.getBindingOfParentType(name); ITypeBinding currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } if (currType == null) { declaringClass= declaringClass.getTypeDeclaration(); currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } } if (currType != parentType) { if (currType == null) return null; if (currType.isAnonymous()) //If we access a field of a super class of an anonymous class //then we can only qualify with 'this' but not with outer.this //see bug 115277 return null; return imports.addImport(currType); } else { return ""; //$NON-NLS-1$ } }
private static String getNonStaticQualifier(ITypeBinding declaringClass, ImportRewrite imports, SimpleName name) { ITypeBinding parentType= Bindings.getBindingOfParentType(name); ITypeBinding currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } if (currType == null) { declaringClass= declaringClass.getTypeDeclaration(); currType= parentType; while (currType != null && !Bindings.isSuperType(declaringClass, currType)) { currType= currType.getDeclaringClass(); } } if (currType != parentType) { if (currType == null) return null; if (currType.isAnonymous()) //If we access a field of a super class of an anonymous class //then we can only qualify with 'this' but not with outer.this //see bug 115277 return null; String outer= imports.addImport(currType); return outer + ".this"; //$NON-NLS-1$ } else { return "this"; //$NON-NLS-1$ } }