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


Java ASTResolving.findAncestor方法代码示例

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


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

示例1: createProposalsForProblemOnAsyncType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnAsyncType(
    ASTNode problemNode, String extraSyncMethodBindingKey) {
  TypeDeclaration asyncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      problemNode, ASTNode.TYPE_DECLARATION);
  assert (asyncTypeDecl != null);

  IType syncType = RemoteServiceUtilities.findSyncType(asyncTypeDecl);
  if (syncType == null) {
    return null;
  }

  MethodDeclaration extraSyncMethodDecl = JavaASTUtils.findMethodDeclaration(
      syncType.getCompilationUnit(), extraSyncMethodBindingKey);
  if (extraSyncMethodDecl == null) {
    return null;
  }

  return Collections.<IJavaCompletionProposal> singletonList(new DeleteMethodProposal(
      syncType.getCompilationUnit(), extraSyncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:DeleteMethodProposal.java

示例2: createProposalsForProblemOnSyncType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnSyncType(
    ASTNode problemNode, String extraAsyncMethodBindingKey) {
  TypeDeclaration syncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      problemNode, ASTNode.TYPE_DECLARATION);
  assert (syncTypeDecl != null);

  IType asyncType = RemoteServiceUtilities.findAsyncType(syncTypeDecl);
  if (asyncType == null) {
    return null;
  }

  MethodDeclaration extraAsyncMethodDecl = JavaASTUtils.findMethodDeclaration(
      asyncType.getCompilationUnit(), extraAsyncMethodBindingKey);
  if (extraAsyncMethodDecl == null) {
    return null;
  }

  return Collections.<IJavaCompletionProposal> singletonList(new DeleteMethodProposal(
      asyncType.getCompilationUnit(), extraAsyncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:21,代码来源:DeleteMethodProposal.java

示例3: createProposalsForProblemOnAsyncType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnAsyncType(
    ICompilationUnit asyncCompilationUnit, ASTNode problemNode,
    String syncMethodBindingKey) {
  TypeDeclaration asyncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      problemNode, ASTNode.TYPE_DECLARATION);
  assert (asyncTypeDecl != null);
  String asyncQualifiedTypeName = asyncTypeDecl.resolveBinding().getQualifiedName();

  // Lookup the sync version of the interface
  IType syncType = RemoteServiceUtilities.findSyncType(asyncTypeDecl);
  if (syncType == null) {
    return Collections.emptyList();
  }

  MethodDeclaration syncMethodDecl = JavaASTUtils.findMethodDeclaration(
      syncType.getCompilationUnit(), syncMethodBindingKey);
  if (syncMethodDecl == null) {
    return Collections.emptyList();
  }

  return Collections.<IJavaCompletionProposal> singletonList(new CreateAsyncMethodProposal(
      asyncCompilationUnit, asyncQualifiedTypeName, syncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:CreateAsyncMethodProposal.java

示例4: createProposalsForProblemOnSyncMethod

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnSyncMethod(
    ASTNode problemNode) {
  // Find the problematic sync method declaration and its declaring type
  MethodDeclaration syncMethodDecl = ASTResolving.findParentMethodDeclaration(problemNode);
  TypeDeclaration syncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      syncMethodDecl, ASTNode.TYPE_DECLARATION);
  assert (syncTypeDecl != null);

  // Lookup the async version of the interface
  IType asyncType = RemoteServiceUtilities.findAsyncType(syncTypeDecl);
  if (asyncType == null) {
    return Collections.emptyList();
  }

  return Collections.<IJavaCompletionProposal> singletonList(new CreateAsyncMethodProposal(
      asyncType.getCompilationUnit(), asyncType.getFullyQualifiedName('.'),
      syncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:19,代码来源:CreateAsyncMethodProposal.java

示例5: createProposalsForProblemOnAsyncMethod

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnAsyncMethod(
    ASTNode problemNode) {
  // Find the problematic async method declaration and its declaring type
  MethodDeclaration asyncMethodDecl = ASTResolving.findParentMethodDeclaration(problemNode);
  TypeDeclaration asyncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      asyncMethodDecl, ASTNode.TYPE_DECLARATION);
  assert (asyncTypeDecl != null);

  // Lookup the sync version of the interface
  IType syncType = RemoteServiceUtilities.findSyncType(asyncTypeDecl);
  if (syncType == null) {
    return Collections.emptyList();
  }

  return Collections.<IJavaCompletionProposal> singletonList(new CreateSyncMethodProposal(
      syncType.getCompilationUnit(), syncType.getFullyQualifiedName('.'),
      asyncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:19,代码来源:CreateSyncMethodProposal.java

示例6: createProposalsForProblemOnSyncType

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnSyncType(
    ICompilationUnit syncCompilationUnit, ASTNode problemNode,
    String asyncMethodBindingKey) {
  TypeDeclaration syncTypeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      problemNode, ASTNode.TYPE_DECLARATION);
  assert (syncTypeDecl != null);
  String syncQualifiedTypeName = syncTypeDecl.resolveBinding().getQualifiedName();

  // Lookup the async version of the interface
  IType asyncType = RemoteServiceUtilities.findAsyncType(syncTypeDecl);
  if (asyncType == null) {
    return Collections.emptyList();
  }

  MethodDeclaration asyncMethodDecl = JavaASTUtils.findMethodDeclaration(
      asyncType.getCompilationUnit(), asyncMethodBindingKey);
  if (asyncMethodDecl == null) {
    return Collections.emptyList();
  }

  return Collections.<IJavaCompletionProposal> singletonList(new CreateSyncMethodProposal(
      syncCompilationUnit, syncQualifiedTypeName, asyncMethodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:CreateSyncMethodProposal.java

示例7: computeProposals

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
@Override
protected Expression computeProposals(AST ast, ITypeBinding returnBinding, int returnOffset, CompilationUnit root, Expression result) {
	ScopeAnalyzer analyzer= new ScopeAnalyzer(root);
	IBinding[] bindings= analyzer.getDeclarationsInScope(returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY);

	org.eclipse.jdt.core.dom.NodeFinder finder= new org.eclipse.jdt.core.dom.NodeFinder(root, returnOffset, 0);
	ASTNode varDeclFrag= ASTResolving.findAncestor(finder.getCoveringNode(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
	IVariableBinding varDeclFragBinding= null;
	if (varDeclFrag != null)
		varDeclFragBinding= ((VariableDeclarationFragment) varDeclFrag).resolveBinding();
	for (int i= 0; i < bindings.length; i++) {
		IVariableBinding curr= (IVariableBinding) bindings[i];
		ITypeBinding type= curr.getType();
		// Bindings are compared to make sure that a lambda does not return a variable which is yet to be initialised.
		if (type != null && type.isAssignmentCompatible(returnBinding) && testModifier(curr) && !Bindings.equals(curr, varDeclFragBinding)) {
			if (result == null) {
				result= ast.newSimpleName(curr.getName());
			}
			addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName(), null);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:MissingReturnTypeInLambdaCorrectionProposal.java

示例8: computeProposals

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
@Override
protected Expression computeProposals(
    AST ast,
    ITypeBinding returnBinding,
    int returnOffset,
    CompilationUnit root,
    Expression result) {
  ScopeAnalyzer analyzer = new ScopeAnalyzer(root);
  IBinding[] bindings =
      analyzer.getDeclarationsInScope(
          returnOffset, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY);

  org.eclipse.jdt.core.dom.NodeFinder finder =
      new org.eclipse.jdt.core.dom.NodeFinder(root, returnOffset, 0);
  ASTNode varDeclFrag =
      ASTResolving.findAncestor(finder.getCoveringNode(), ASTNode.VARIABLE_DECLARATION_FRAGMENT);
  IVariableBinding varDeclFragBinding = null;
  if (varDeclFrag != null)
    varDeclFragBinding = ((VariableDeclarationFragment) varDeclFrag).resolveBinding();
  for (int i = 0; i < bindings.length; i++) {
    IVariableBinding curr = (IVariableBinding) bindings[i];
    ITypeBinding type = curr.getType();
    // Bindings are compared to make sure that a lambda does not return a variable which is yet to
    // be initialised.
    if (type != null
        && type.isAssignmentCompatible(returnBinding)
        && testModifier(curr)
        && !Bindings.equals(curr, varDeclFragBinding)) {
      if (result == null) {
        result = ast.newSimpleName(curr.getName());
      }
      addLinkedPositionProposal(RETURN_EXPRESSION_KEY, curr.getName(), null);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:MissingReturnTypeInLambdaCorrectionProposal.java

示例9: resolveRpcPair

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * Finds the related RPC components for a given method: declaring type & peer
 * type.
 * 
 * @param node the method's SimpleName AST node.
 * @param peerResolver mapping function for the associated type.
 * @return the {@link RpcPair} encapsulation of the related components.
 */
protected static RpcPair resolveRpcPair(ASTNode node,
    PeerTypeResolver peerResolver) {

  // Find the source method declaration and its declaring type
  MethodDeclaration methodDecl = ASTResolving.findParentMethodDeclaration(node);
  TypeDeclaration typeDecl = (TypeDeclaration) ASTResolving.findAncestor(
      node, ASTNode.TYPE_DECLARATION);
  assert (typeDecl != null);

  // Find the associated sync/async peer type declaration (update target)
  IType dstType = peerResolver.getPeerType(typeDecl);
  if (dstType == null) {
    return null;
  }

  CompilationUnit astRoot = ASTResolving.createQuickFixAST(
      dstType.getCompilationUnit(), null);
  TypeDeclaration dstTypeDecl = JavaASTUtils.findTypeDeclaration(astRoot,
      dstType.getFullyQualifiedName('.'));

  if (dstTypeDecl == null) {
    return null;
  }

  return new RpcPair(typeDecl, methodDecl, dstTypeDecl);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:35,代码来源:AbstractUpdateSignatureProposal.java


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