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


Java Name.resolveBinding方法代码示例

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


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

示例1: getInvalidQualificationProposals

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
public static void getInvalidQualificationProposals(IInvocationContext context, IProblemLocation problem,
		Collection<CUCorrectionProposal> proposals) {
	ASTNode node= problem.getCoveringNode(context.getASTRoot());
	if (!(node instanceof Name)) {
		return;
	}
	Name name= (Name) node;
	IBinding binding= name.resolveBinding();
	if (!(binding instanceof ITypeBinding)) {
		return;
	}
	ITypeBinding typeBinding= (ITypeBinding)binding;

	AST ast= node.getAST();
	ASTRewrite rewrite= ASTRewrite.create(ast);
	rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null);

	String label= CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description;
	ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(),
			rewrite, IProposalRelevance.QUALIFY_INNER_TYPE_NAME);

	proposals.add(proposal);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:JavadocTagsSubProcessor.java

示例2: findTempDeclaration

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
/**
 * @return <code>null</code> if the selection is invalid or does not cover a temp declaration or
 *     reference.
 */
public static VariableDeclaration findTempDeclaration(
    CompilationUnit cu, int selectionOffset, int selectionLength) {
  TempSelectionAnalyzer analyzer = new TempSelectionAnalyzer(selectionOffset, selectionLength);
  cu.accept(analyzer);

  ASTNode[] selected = analyzer.getSelectedNodes();
  if (selected == null || selected.length != 1) return null;

  ASTNode selectedNode = selected[0];
  if (selectedNode instanceof VariableDeclaration) return (VariableDeclaration) selectedNode;

  if (selectedNode instanceof Name) {
    Name reference = (Name) selectedNode;
    IBinding binding = reference.resolveBinding();
    if (binding == null) return null;
    ASTNode declaringNode = cu.findDeclaringNode(binding);
    if (declaringNode instanceof VariableDeclaration) return (VariableDeclaration) declaringNode;
    else return null;
  } else if (selectedNode instanceof VariableDeclarationStatement) {
    VariableDeclarationStatement vds = (VariableDeclarationStatement) selectedNode;
    if (vds.fragments().size() != 1) return null;
    return (VariableDeclaration) vds.fragments().get(0);
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:TempDeclarationFinder.java

示例3: findConstantNameNode

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private Name findConstantNameNode() {
  ASTNode node =
      NodeFinder.perform(fSelectionCuRewrite.getRoot(), fSelectionStart, fSelectionLength);
  if (node == null) return null;
  if (node instanceof FieldAccess) node = ((FieldAccess) node).getName();
  if (!(node instanceof Name)) return null;
  Name name = (Name) node;
  IBinding binding = name.resolveBinding();
  if (!(binding instanceof IVariableBinding)) return null;
  IVariableBinding variableBinding = (IVariableBinding) binding;
  if (!variableBinding.isField() || variableBinding.isEnumConstant()) return null;
  int modifiers = binding.getModifiers();
  if (!(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers))) return null;

  return name;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:InlineConstantRefactoring.java

示例4: visitNameNode

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private boolean visitNameNode(Name node) {
	IBinding binding = node.resolveBinding();
	if (binding instanceof IVariableBinding) {
		IVariableBinding variableBindig = (IVariableBinding) binding;
		if (variableBindig.isField()) {
			ITypeBinding declaringClass = variableBindig.getDeclaringClass();
			handleTypeBinding(node, declaringClass, false);
			handleFieldBinding(node, variableBindig);
		} else if (!variableBindig.isEnumConstant()) {
			handleVariableBinding(node, variableBindig);
		}
	}
	return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:15,代码来源:DependenciesAstVisitor.java

示例5: getMethodBinding

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
public static IMethodBinding getMethodBinding(Name node) {
	IBinding binding= node.resolveBinding();
	if (binding instanceof IMethodBinding) {
		return (IMethodBinding)binding;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:ASTNodes.java

示例6: getVariableBinding

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
public static IVariableBinding getVariableBinding(Name node) {
	IBinding binding= node.resolveBinding();
	if (binding instanceof IVariableBinding) {
		return (IVariableBinding)binding;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:ASTNodes.java

示例7: getTypeBinding

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
public static ITypeBinding getTypeBinding(Name node) {
	IBinding binding= node.resolveBinding();
	if (binding instanceof ITypeBinding) {
		return (ITypeBinding)binding;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:ASTNodes.java

示例8: possibleTypeRefFound

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的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

示例9: getMethodBinding

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private IMethodBinding getMethodBinding(Name name) {
	if (name == null) {
		return null;
	}
	IBinding binding = name.resolveBinding();
	if (binding instanceof IMethodBinding) {
		return (IMethodBinding) binding;
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:FlowAnalyzer.java

示例10: addStaticImports

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private void addStaticImports(List<SimpleName> staticReferences, ImportRewrite importsStructure) {
  for (int i = 0; i < staticReferences.size(); i++) {
    Name name = staticReferences.get(i);
    IBinding binding = name.resolveBinding();
    if (binding != null) { // paranoia check
      importsStructure.addStaticImport(binding);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:OrganizeImportsOperation.java

示例11: possibleTypeRefFound

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的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,项目名称:che,代码行数:13,代码来源:ImportReferencesCollector.java

示例12: visit

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean visit(final MethodInvocation node) {
  if (!fRemoveMethodQualifiers) return true;

  Expression expression = node.getExpression();
  if (!(expression instanceof ThisExpression)) return true;

  final SimpleName name = node.getName();
  if (name.resolveBinding() == null) return true;

  if (hasConflict(
      expression.getStartPosition(),
      name,
      ScopeAnalyzer.METHODS | ScopeAnalyzer.CHECK_VISIBILITY)) return true;

  Name qualifier = ((ThisExpression) expression).getQualifier();
  if (qualifier != null) {
    ITypeBinding declaringClass = ((IMethodBinding) name.resolveBinding()).getDeclaringClass();
    if (declaringClass == null) return true;

    ITypeBinding caller = getDeclaringType(node);
    if (caller == null) return true;

    ITypeBinding callee = (ITypeBinding) qualifier.resolveBinding();
    if (callee == null) return true;

    if (callee.isAssignmentCompatible(declaringClass)
        && caller.isAssignmentCompatible(declaringClass)) return true;
  }

  fOperations.add(
      new CompilationUnitRewriteOperation() {
        @Override
        public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model)
            throws CoreException {
          ASTRewrite rewrite = cuRewrite.getASTRewrite();
          TextEditGroup group =
              createTextEditGroup(
                  FixMessages.CodeStyleFix_removeThis_groupDescription, cuRewrite);
          rewrite.remove(node.getExpression(), group);
        }
      });
  return super.visit(node);
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:CodeStyleFix.java

示例13: collectImports

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
/**
 * Collects the necessary imports for an element represented by the specified AST node.
 *
 * @param project the java project containing the element
 * @param node the AST node specifying the element for which imports should be collected
 * @param typeBindings the set of type bindings (element type: Set <ITypeBinding>).
 * @param staticBindings the set of bindings (element type: Set <IBinding>).
 * @param excludeBindings the set of bindings to exclude (element type: Set <IBinding>).
 * @param declarations <code>true</code> if method declarations are treated as abstract, <code>
 *     false</code> otherwise
 */
public static void collectImports(
    final IJavaProject project,
    final ASTNode node,
    final Collection<ITypeBinding> typeBindings,
    final Collection<IBinding> staticBindings,
    final Collection<IBinding> excludeBindings,
    final boolean declarations) {
  Assert.isNotNull(project);
  Assert.isNotNull(node);
  Assert.isNotNull(typeBindings);
  Assert.isNotNull(staticBindings);
  final Set<SimpleName> types = new HashSet<SimpleName>();
  final Set<SimpleName> members = new HashSet<SimpleName>();

  ImportReferencesCollector.collect(node, project, null, declarations, types, members);

  Name name = null;
  IBinding binding = null;
  for (final Iterator<SimpleName> iterator = types.iterator(); iterator.hasNext(); ) {
    name = iterator.next();
    binding = name.resolveBinding();
    if (binding instanceof ITypeBinding) {
      final ITypeBinding type = (ITypeBinding) binding;
      if (excludeBindings == null || !excludeBindings.contains(type)) typeBindings.add(type);
    }
  }
  for (final Iterator<SimpleName> iterator = members.iterator(); iterator.hasNext(); ) {
    name = iterator.next();
    binding = name.resolveBinding();
    if (binding != null && (excludeBindings == null || !excludeBindings.contains(binding)))
      staticBindings.add(binding);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:ImportRewriteUtil.java

示例14: getVariableDeclaration

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static VariableDeclaration getVariableDeclaration(Name node) {
  IBinding binding = node.resolveBinding();
  if (binding == null && node.getParent() instanceof VariableDeclaration)
    return (VariableDeclaration) node.getParent();

  if (binding != null && binding.getKind() == IBinding.VARIABLE) {
    CompilationUnit cu = (CompilationUnit) ASTNodes.getParent(node, CompilationUnit.class);
    return ASTNodes.findVariableDeclaration(((IVariableBinding) binding), cu);
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:RenameAnalyzeUtil.java

示例15: isEnumCase

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
public static boolean isEnumCase(ASTNode node) {
  if (node instanceof SwitchCase) {
    final SwitchCase caze = (SwitchCase) node;
    final Expression expression = caze.getExpression();
    if (expression instanceof Name) {
      final Name name = (Name) expression;
      final IBinding binding = name.resolveBinding();
      if (binding instanceof IVariableBinding) {
        IVariableBinding variableBinding = (IVariableBinding) binding;
        return variableBinding.isEnumConstant();
      }
    }
  }
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:Checks.java


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