Java Code Examples for org.eclipse.jdt.core.dom.IBinding#METHOD
The following examples show how to use
org.eclipse.jdt.core.dom.IBinding#METHOD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoveDeclarationCorrectionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public String getName() { IBinding binding= fName.resolveBinding(); String name= BasicElementLabels.getJavaElementName(fName.getIdentifier()); switch (binding.getKind()) { case IBinding.TYPE: return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedtype_description, name); case IBinding.METHOD: if (((IMethodBinding) binding).isConstructor()) { return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedconstructor_description, name); } else { return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedmethod_description, name); } case IBinding.VARIABLE: if (((IVariableBinding) binding).isField()) { return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedfield_description, name); } else { return Messages.format(CorrectionMessages.RemoveDeclarationCorrectionProposal_removeunusedvar_description, name); } default: return super.getDisplayString(); } }
Example 2
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); boolean isAbstractMethod= binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.ABSTRACT) == Modifier.ABSTRACT; if (!isAbstractMethod) return false; // filter out annotation value references if (binding != null) { ITypeBinding declaringType= ((IMethodBinding)binding).getDeclaringClass(); if (declaringType.isAnnotation()) return false; } return true; }
Example 3
Source File: MethodVisitor.java From repositoryminer with Apache License 2.0 | 6 votes |
@Override public boolean visit(SimpleName node) { IBinding bind = node.resolveBinding(); if (bind == null) { return true; } if (bind.getKind() == IBinding.VARIABLE) { IVariableBinding varBind = (IVariableBinding) bind; if (varBind.isField()) { String type = varBind.getType().getQualifiedName(); statements.add(new AbstractFieldAccess(varBind.getName(), type, varBind.getDeclaringClass() != null ? varBind.getDeclaringClass().getQualifiedName() : null, varBind.getType().isPrimitive(), type.startsWith("java") || type.startsWith("javax") ? true : false)); } } else if (bind.getKind() == IBinding.METHOD) { IMethodBinding mBind = (IMethodBinding) bind; analyzeMethodInvocation(mBind); } return true; }
Example 4
Source File: UnusedCodeFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static Map<String, String> getCleanUpOptions(IBinding binding, boolean removeAll) { Map<String, String> result= new Hashtable<String, String>(); result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS, CleanUpOptions.TRUE); switch (binding.getKind()) { case IBinding.TYPE: result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES, CleanUpOptions.TRUE); break; case IBinding.METHOD: if (((IMethodBinding) binding).isConstructor()) { result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS, CleanUpOptions.TRUE); } else { result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS, CleanUpOptions.TRUE); } break; case IBinding.VARIABLE: if (removeAll) return null; result.put(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS, CleanUpOptions.TRUE); result.put(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES, CleanUpOptions.TRUE); break; } return result; }
Example 5
Source File: UnusedCodeFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static String getDisplayString(SimpleName simpleName, IBinding binding, boolean removeAllAssignements) { String name= BasicElementLabels.getJavaElementName(simpleName.getIdentifier()); switch (binding.getKind()) { case IBinding.TYPE: return Messages.format(FixMessages.UnusedCodeFix_RemoveType_description, name); case IBinding.METHOD: if (((IMethodBinding) binding).isConstructor()) { return Messages.format(FixMessages.UnusedCodeFix_RemoveConstructor_description, name); } else { return Messages.format(FixMessages.UnusedCodeFix_RemoveMethod_description, name); } case IBinding.VARIABLE: if (removeAllAssignements) { return Messages.format(FixMessages.UnusedCodeFix_RemoveFieldOrLocalWithInitializer_description, name); } else { return Messages.format(FixMessages.UnusedCodeFix_RemoveFieldOrLocal_description, name); } default: return ""; //$NON-NLS-1$ } }
Example 6
Source File: UnusedCodeFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private String getDisplayString(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE: return FixMessages.UnusedCodeFix_RemoveUnusedType_description; case IBinding.METHOD: if (((IMethodBinding) binding).isConstructor()) { return FixMessages.UnusedCodeFix_RemoveUnusedConstructor_description; } else { return FixMessages.UnusedCodeFix_RemoveUnusedPrivateMethod_description; } case IBinding.VARIABLE: if (((IVariableBinding) binding).isField()) { return FixMessages.UnusedCodeFix_RemoveUnusedField_description; } else { return FixMessages.UnusedCodeFix_RemoveUnusedVariabl_description; } default: return ""; //$NON-NLS-1$ } }
Example 7
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@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); }
Example 8
Source File: ScopeAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static String getSignature(IBinding binding) { if (binding != null) { switch (binding.getKind()) { case IBinding.METHOD: StringBuffer buf= new StringBuffer(); buf.append('M'); buf.append(binding.getName()).append('('); ITypeBinding[] parameters= ((IMethodBinding) binding).getParameterTypes(); for (int i= 0; i < parameters.length; i++) { if (i > 0) { buf.append(','); } ITypeBinding paramType= parameters[i].getErasure(); buf.append(paramType.getQualifiedName()); } buf.append(')'); return buf.toString(); case IBinding.VARIABLE: return 'V' + binding.getName(); case IBinding.TYPE: return 'T' + binding.getName(); } } return null; }
Example 9
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static String getImportName(IBinding binding) { ITypeBinding declaring= null; switch (binding.getKind()) { case IBinding.TYPE: return getRawQualifiedName((ITypeBinding) binding); case IBinding.PACKAGE: return binding.getName() + ".*"; //$NON-NLS-1$ case IBinding.METHOD: declaring= ((IMethodBinding) binding).getDeclaringClass(); break; case IBinding.VARIABLE: declaring= ((IVariableBinding) binding).getDeclaringClass(); if (declaring == null) { return binding.getName(); // array.length } break; default: return binding.getName(); } return JavaModelUtil.concatenateName(getRawQualifiedName(declaring), binding.getName()); }
Example 10
Source File: SemanticHighlightings.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@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); }
Example 11
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static IBinding getDeclaration(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE: return ((ITypeBinding) binding).getTypeDeclaration(); case IBinding.VARIABLE: return ((IVariableBinding) binding).getVariableDeclaration(); case IBinding.METHOD: return ((IMethodBinding) binding).getMethodDeclaration(); } return binding; }
Example 12
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tests if the given node is a declaration, not a instance of a generic type, method or field. * Declarations can be found in AST with CompilationUnit.findDeclaringNode * @param binding binding to test * @return returns <code>true</code> if the binding is a declaration binding */ public static boolean isDeclarationBinding(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE: return ((ITypeBinding) binding).getTypeDeclaration() == binding; case IBinding.VARIABLE: return ((IVariableBinding) binding).getVariableDeclaration() == binding; case IBinding.METHOD: return ((IMethodBinding) binding).getMethodDeclaration() == binding; } return true; }
Example 13
Source File: ScopeAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static ITypeBinding getDeclaringType(IBinding binding) { switch (binding.getKind()) { case IBinding.VARIABLE: return ((IVariableBinding) binding).getDeclaringClass(); case IBinding.METHOD: return ((IMethodBinding) binding).getDeclaringClass(); case IBinding.TYPE: ITypeBinding typeBinding= (ITypeBinding) binding; if (typeBinding.getDeclaringClass() != null) { return typeBinding; } return typeBinding; } return null; }
Example 14
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
private boolean isStaticMethodCall(ASTNode node) { if (node instanceof SimpleName){ SimpleName simpleName = (SimpleName) node; IBinding binding = simpleName.resolveBinding(); if(binding != null && binding.getKind() == IBinding.METHOD) { IMethodBinding methodBinding = (IMethodBinding)binding; if((methodBinding.getModifiers() & Modifier.STATIC) != 0) return true; } } return false; }
Example 15
Source File: OccurrencesFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IBinding getBindingDeclaration(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE : return ((ITypeBinding)binding).getTypeDeclaration(); case IBinding.METHOD : return ((IMethodBinding)binding).getMethodDeclaration(); case IBinding.VARIABLE : return ((IVariableBinding)binding).getVariableDeclaration(); default: return binding; } }
Example 16
Source File: SemanticHighlightings.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public boolean consumes(SemanticToken token) { SimpleName node = token.getNode(); if (node.getParent() instanceof MemberValuePair) { IBinding binding = token.getBinding(); boolean isAnnotationElement = binding != null && binding.getKind() == IBinding.METHOD; return isAnnotationElement; } return false; }
Example 17
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean consumes(SemanticToken token) { SimpleName node= token.getNode(); if (node.isDeclaration()) return false; IBinding binding= token.getBinding(); return binding != null && binding.getKind() == IBinding.METHOD && (binding.getModifiers() & Modifier.STATIC) == Modifier.STATIC; }
Example 18
Source File: SemanticHighlightings.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public boolean consumes(SemanticToken token) { IBinding binding = getBinding(token); return binding != null && binding.getKind() == IBinding.METHOD; }
Example 19
Source File: SemanticHighlightings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean consumes(SemanticToken token) { IBinding binding= getBinding(token); return binding != null && binding.getKind() == IBinding.METHOD; }
Example 20
Source File: SemanticTokensVisitor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
@Override public boolean visit(SimpleName node) { ASTNode parent = node.getParent(); if (parent instanceof Annotation) { addToken(node, TokenType.ANNOTATION); return false; } IBinding binding = node.resolveBinding(); if (binding == null) { return super.visit(node); } TokenType tokenType = null; switch (binding.getKind()) { case IBinding.VARIABLE: { if (((IVariableBinding) binding).isField()) { tokenType = TokenType.PROPERTY; } else { tokenType = TokenType.VARIABLE; } break; } case IBinding.METHOD: { tokenType = TokenType.FUNCTION; break; } case IBinding.TYPE: { tokenType = TokenType.TYPE; break; } case IBinding.PACKAGE: { tokenType = TokenType.NAMESPACE; break; } default: break; } if (tokenType == null) { return super.visit(node); } switch (tokenType) { case FUNCTION: case VARIABLE: case PROPERTY: case MEMBER: { ITokenModifier[] modifiers = getModifiers(binding); addToken(node, tokenType, modifiers); break; } case TYPE: case NAMESPACE: addToken(node, tokenType, NO_MODIFIERS); break; default: break; } return super.visit(node); }