本文整理汇总了Java中org.eclipse.jdt.core.dom.IBinding.METHOD属性的典型用法代码示例。如果您正苦于以下问题:Java IBinding.METHOD属性的具体用法?Java IBinding.METHOD怎么用?Java IBinding.METHOD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.dom.IBinding
的用法示例。
在下文中一共展示了IBinding.METHOD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImportName
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());
}
示例2: visit
@Override
public boolean visit(SimpleName node) {
IBinding binding= node.resolveBinding();
if (binding == null) {
return false;
}
binding= getDeclaration(binding);
if (fBinding == binding) {
fResult.add(node);
} else if (binding.getKind() != fBinding.getKind()) {
return false;
} else if (binding.getKind() == IBinding.METHOD) {
IMethodBinding curr= (IMethodBinding) binding;
IMethodBinding methodBinding= (IMethodBinding) fBinding;
if (methodBinding.overrides(curr) || curr.overrides(methodBinding)) {
fResult.add(node);
}
}
return false;
}
示例3: getDisplayString
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$
}
}
示例4: getImportName
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());
}
示例5: getSignature
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;
}
示例6: visit
@Override
public boolean visit(SimpleName node) {
IBinding binding = node.resolveBinding();
if (binding == null) {
return false;
}
binding = getDeclaration(binding);
if (fBinding == binding) {
fResult.add(node);
} else if (binding.getKind() != fBinding.getKind()) {
return false;
} else if (binding.getKind() == IBinding.METHOD) {
IMethodBinding curr = (IMethodBinding) binding;
IMethodBinding methodBinding = (IMethodBinding) fBinding;
if (methodBinding.overrides(curr) || curr.overrides(methodBinding)) {
fResult.add(node);
}
}
return false;
}
示例7: getDisplayString
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$
}
}
示例8: getCleanUpOptions
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;
}
示例9: consumes
@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;
}
示例10: isDeclarationBinding
/**
* 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;
}
示例11: getDeclaration
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;
}
示例12: findNullnessDefault
/**
* Answer the annotation binding representing a nullness default
* effective at the point denoted by 'contextBinding'.
* @param contextBinding method binding or type binding denoting the location of interest
* @param javaProject the containing java project, consulted for the actual name of
* the annotation used for nullness defaults (default: <code>@NonNullByDefault</code>).
* @return binding for the effective nullness default annotation
* or null if no nullness default is effective at the context location.
*/
public static IAnnotationBinding findNullnessDefault(IBinding contextBinding, IJavaProject javaProject) {
if (JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true))) {
String annotationName= javaProject.getOption(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, true);
while (contextBinding != null) {
for (IAnnotationBinding annotation : contextBinding.getAnnotations()) {
ITypeBinding annotationType= annotation.getAnnotationType();
if (annotationType != null && annotationType.getQualifiedName().equals(annotationName)) {
return annotation;
}
}
// travel out:
switch (contextBinding.getKind()) {
case IBinding.METHOD:
IMethodBinding methodBinding= (IMethodBinding) contextBinding;
contextBinding= methodBinding.getDeclaringMember();
if (contextBinding == null) {
contextBinding= methodBinding.getDeclaringClass();
}
break;
case IBinding.VARIABLE:
IVariableBinding variableBinding= (IVariableBinding) contextBinding;
contextBinding= variableBinding.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= variableBinding.getDeclaringClass();
}
break;
case IBinding.TYPE:
ITypeBinding currentClass= (ITypeBinding) contextBinding;
contextBinding= currentClass.getDeclaringMember();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringMethod();
if (contextBinding == null) {
contextBinding= currentClass.getDeclaringClass();
if (contextBinding == null) {
contextBinding= currentClass.getPackage();
}
}
}
break;
default:
contextBinding= null;
break;
}
}
}
return null;
}
示例13: getCleanUpOptions
private static Map<String, String> getCleanUpOptions(IBinding binding, boolean removeAll) {
Map<String, String> result= new Hashtable<>();
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;
}
示例14: isDeclarationBinding
/**
* 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;
}
示例15: getDeclaration
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;
}