本文整理汇总了Java中org.eclipse.jdt.core.dom.IBinding.VARIABLE属性的典型用法代码示例。如果您正苦于以下问题:Java IBinding.VARIABLE属性的具体用法?Java IBinding.VARIABLE怎么用?Java IBinding.VARIABLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.dom.IBinding
的用法示例。
在下文中一共展示了IBinding.VARIABLE属性的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: 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$
}
}
示例3: consumes
@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);
}
示例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: getUnqualifiedFieldAccessResolveOperation
private static AddThisQualifierOperation getUnqualifiedFieldAccessResolveOperation(
CompilationUnit compilationUnit, IProblemLocation problem) {
SimpleName name = getName(compilationUnit, problem);
if (name == null) return null;
IBinding binding = name.resolveBinding();
if (binding == null || binding.getKind() != IBinding.VARIABLE) return null;
ImportRewrite imports = StubUtility.createImportRewrite(compilationUnit, true);
String replacement =
getThisExpressionQualifier(((IVariableBinding) binding).getDeclaringClass(), imports, name);
if (replacement == null) return null;
if (replacement.length() == 0) replacement = null;
return new AddThisQualifierOperation(replacement, name);
}
示例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: visitExpressionIfName
private void visitExpressionIfName(Expression expression) {
if (!(expression instanceof Name)) {
return;
}
IBinding binding = ((Name) expression).resolveBinding();
if (binding != null && binding.getKind() == IBinding.VARIABLE) {
return;
}
addType(
expression.resolveTypeBinding(),
extractClassNameFromQualifiedName(((Name) expression).getFullyQualifiedName()),
expression.getStartPosition());
}
示例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: 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;
}
示例15: getDeclaringType
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;
}