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


Java Name.getParent方法代码示例

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


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

示例1: 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

示例2: doesParentQualify

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static boolean doesParentQualify(Name fieldName) {
  ASTNode parent = fieldName.getParent();
  Assert.isNotNull(parent);

  if (parent instanceof FieldAccess && ((FieldAccess) parent).getName() == fieldName)
    return true;

  if (parent instanceof QualifiedName && ((QualifiedName) parent).getName() == fieldName)
    return true;

  if (parent instanceof MethodInvocation && ((MethodInvocation) parent).getName() == fieldName)
    return true;

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

示例3: getTypeName

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static String getTypeName(int typeKind, Name node) {
  String name = ASTNodes.getSimpleNameIdentifier(node);

  if (typeKind == K_CLASS || typeKind == K_INTERFACE) {
    ASTNode parent = node.getParent();
    if (parent.getLocationInParent() == ParameterizedType.TYPE_PROPERTY) {
      String typeArgBaseName =
          name.startsWith(String.valueOf('T'))
              ? String.valueOf('S')
              : String.valueOf('T'); // use 'S' or 'T'

      int nTypeArgs = ((ParameterizedType) parent.getParent()).typeArguments().size();
      StringBuffer buf = new StringBuffer(name);
      buf.append('<');
      if (nTypeArgs == 1) {
        buf.append(typeArgBaseName);
      } else {
        for (int i = 0; i < nTypeArgs; i++) {
          if (i != 0) buf.append(", "); // $NON-NLS-1$
          buf.append(typeArgBaseName).append(i + 1);
        }
      }
      buf.append('>');
      return buf.toString();
    }
  }
  return name;
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:NewCUUsingWizardProposal.java

示例4: addSimilarTypeProposals

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, int relevance,
		Collection<CUCorrectionProposal> proposals) throws CoreException {
	SimilarElement[] elements= SimilarElementsRequestor.findSimilarElement(cu, node, kind);

	// try to resolve type in context -> highest severity
	String resolvedTypeName= null;
	ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node);
	if (binding != null) {
		ITypeBinding simpleBinding= binding;
		if (simpleBinding.isArray()) {
			simpleBinding= simpleBinding.getElementType();
		}
		simpleBinding= simpleBinding.getTypeDeclaration();

		if (!simpleBinding.isRecovered()) {
			resolvedTypeName= simpleBinding.getQualifiedName();
			CUCorrectionProposal proposal= createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2, elements.length);
			proposals.add(proposal);
			if (proposal instanceof AddImportCorrectionProposal) {
				proposal.setRelevance(relevance + elements.length + 2);
			}

			if (binding.isParameterizedType()
					&& (node.getParent() instanceof SimpleType || node.getParent() instanceof NameQualifiedType)
					&& !(node.getParent().getParent() instanceof Type)) {
				proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
			}
		}
	} else {
		ASTNode normalizedNode= ASTNodes.getNormalizedNode(node);
		if (!(normalizedNode.getParent() instanceof Type) && node.getParent() != normalizedNode) {
			ITypeBinding normBinding= ASTResolving.guessBindingForTypeReference(normalizedNode);
			if (normBinding != null && !normBinding.isRecovered()) {
				proposals.add(createTypeRefChangeFullProposal(cu, normBinding, normalizedNode, relevance + 5));
			}
		}
	}

	// add all similar elements
	for (int i= 0; i < elements.length; i++) {
		SimilarElement elem= elements[i];
		if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) {
			String fullName= elem.getName();
			if (!fullName.equals(resolvedTypeName)) {
				proposals.add(createTypeRefChangeProposal(cu, fullName, node, relevance, elements.length));
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:50,代码来源:UnresolvedElementsSubProcessor.java

示例5: getQualifiedReference

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static Expression getQualifiedReference(Name fieldName) {
  if (doesParentQualify(fieldName)) return (Expression) fieldName.getParent();

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

示例6: addSimilarTypeProposals

import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static void addSimilarTypeProposals(
    int kind, ICompilationUnit cu, Name node, int relevance, Collection<ICommandAccess> proposals)
    throws CoreException {
  SimilarElement[] elements = SimilarElementsRequestor.findSimilarElement(cu, node, kind);

  // try to resolve type in context -> highest severity
  String resolvedTypeName = null;
  ITypeBinding binding = ASTResolving.guessBindingForTypeReference(node);
  if (binding != null) {
    ITypeBinding simpleBinding = binding;
    if (simpleBinding.isArray()) {
      simpleBinding = simpleBinding.getElementType();
    }
    simpleBinding = simpleBinding.getTypeDeclaration();

    if (!simpleBinding.isRecovered()) {
      resolvedTypeName = simpleBinding.getQualifiedName();
      CUCorrectionProposal proposal =
          createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2, elements.length);
      proposals.add(proposal);
      if (proposal instanceof AddImportCorrectionProposal)
        proposal.setRelevance(relevance + elements.length + 2);

      if (binding.isParameterizedType()
          && (node.getParent() instanceof SimpleType
              || node.getParent() instanceof NameQualifiedType)
          && !(node.getParent().getParent() instanceof Type)) {
        proposals.add(createTypeRefChangeFullProposal(cu, binding, node, relevance + 5));
      }
    }
  } else {
    ASTNode normalizedNode = ASTNodes.getNormalizedNode(node);
    if (!(normalizedNode.getParent() instanceof Type) && node.getParent() != normalizedNode) {
      ITypeBinding normBinding = ASTResolving.guessBindingForTypeReference(normalizedNode);
      if (normBinding != null && !normBinding.isRecovered()) {
        proposals.add(
            createTypeRefChangeFullProposal(cu, normBinding, normalizedNode, relevance + 5));
      }
    }
  }

  // add all similar elements
  for (int i = 0; i < elements.length; i++) {
    SimilarElement elem = elements[i];
    if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) {
      String fullName = elem.getName();
      if (!fullName.equals(resolvedTypeName)) {
        proposals.add(
            createTypeRefChangeProposal(cu, fullName, node, relevance, elements.length));
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:54,代码来源:UnresolvedElementsSubProcessor.java


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