当前位置: 首页>>代码示例>>Java>>正文


Java IBinding.getKind方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.IBinding.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java IBinding.getKind方法的具体用法?Java IBinding.getKind怎么用?Java IBinding.getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.IBinding的用法示例。


在下文中一共展示了IBinding.getKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImportName

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:Bindings.java

示例2: visit

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
@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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:LinkedNodeFinder.java

示例3: rewriteAST

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException {
	ASTRewrite rewrite= cuRewrite.getASTRewrite();
	IBinding binding= fUnusedName.resolveBinding();
	CompilationUnit root= (CompilationUnit) fUnusedName.getRoot();
	String displayString= FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
	TextEditGroup group= createTextEditGroup(displayString, cuRewrite);

	if (binding.getKind() == IBinding.TYPE) {
		ITypeBinding decl= ((ITypeBinding) binding).getTypeDeclaration();
		ASTNode declaration= root.findDeclaringNode(decl);
		if (declaration.getParent() instanceof TypeDeclarationStatement) {
			declaration= declaration.getParent();
		}
		rewrite.remove(declaration, group);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:UnusedCodeFix.java

示例4: getDisplayString

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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$
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:UnusedCodeFix.java

示例5: getImportName

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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());
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:Bindings.java

示例6: consumes

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:SemanticHighlightings.java

示例7: visit

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
@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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:LinkedNodeFinder.java

示例8: getDisplayString

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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$
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UnusedCodeFix.java

示例9: visitExpressionIfName

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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());
}
 
开发者ID:bazelbuild,项目名称:BUILD_file_generator,代码行数:14,代码来源:ReferencedClassesParser.java

示例10: isDeclarationBinding

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:18,代码来源:Bindings.java

示例11: getDeclaration

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:12,代码来源:Bindings.java

示例12: findNullnessDefault

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:57,代码来源:Bindings.java

示例13: add

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
/**
 * Tries to find the given type name and add it to the import structure.
 * @param ref the name node
 */
public void add(SimpleName ref) {
	String typeName= ref.getIdentifier();

	if (fImportsAdded.contains(typeName)) {
		return;
	}

	IBinding binding= ref.resolveBinding();
	if (binding != null) {
		if (binding.getKind() != IBinding.TYPE) {
			return;
		}
		ITypeBinding typeBinding= (ITypeBinding) binding;
		if (typeBinding.isArray()) {
			typeBinding= typeBinding.getElementType();
		}
		typeBinding= typeBinding.getTypeDeclaration();
		if (!typeBinding.isRecovered()) {
			if (needsImport(typeBinding, ref)) {
				fImpStructure.addImport(typeBinding);
				fImportsAdded.add(typeName);
			}
			return;
		}
	} else {
		if (fDoIgnoreLowerCaseNames && typeName.length() > 0) {
			char ch= typeName.charAt(0);
			if (Strings.isLowerCase(ch) && Character.isLetter(ch)) {
				return;
			}
		}
	}

	fImportsAdded.add(typeName);
	fUnresolvedTypes.put(typeName, new UnresolvedTypeData(ref));
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:OrganizeImportsOperation.java

示例14: possibleTypeRefFound

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
private void possibleTypeRefFound(Name node) {
	while (node.isQualifiedName()) {
		node= ((QualifiedName) node).getQualifier();
	}
	IBinding binding= node.resolveBinding();
	if (binding == null || binding.getKind() == IBinding.TYPE) {
		// if the binding is null, we cannot determine if
		// we have a type binding or not, so we will assume
		// we do.
		addReference((SimpleName) node);
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:ImportReferencesCollector.java

示例15: getCleanUpOptions

import org.eclipse.jdt.core.dom.IBinding; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:28,代码来源:UnusedCodeFix.java


注:本文中的org.eclipse.jdt.core.dom.IBinding.getKind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。