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


Java ASTResolving.findParentMethodDeclaration方法代码示例

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


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

示例1: getCatchBodyContent

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static String getCatchBodyContent(
    ICompilationUnit cu,
    String exceptionType,
    String variableName,
    ASTNode locationInAST,
    String lineDelimiter)
    throws CoreException {
  String enclosingType = ""; // $NON-NLS-1$
  String enclosingMethod = ""; // $NON-NLS-1$

  if (locationInAST != null) {
    MethodDeclaration parentMethod = ASTResolving.findParentMethodDeclaration(locationInAST);
    if (parentMethod != null) {
      enclosingMethod = parentMethod.getName().getIdentifier();
      locationInAST = parentMethod;
    }
    ASTNode parentType = ASTResolving.findParentType(locationInAST);
    if (parentType instanceof AbstractTypeDeclaration) {
      enclosingType = ((AbstractTypeDeclaration) parentType).getName().getIdentifier();
    }
  }
  return getCatchBodyContent(
      cu, exceptionType, variableName, enclosingType, enclosingMethod, lineDelimiter);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:StubUtility.java

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

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

示例4: getCatchBodyContent

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, ASTNode locationInAST, String lineDelimiter) throws CoreException {
	String enclosingType= ""; //$NON-NLS-1$
	String enclosingMethod= ""; //$NON-NLS-1$

	if (locationInAST != null) {
		MethodDeclaration parentMethod= ASTResolving.findParentMethodDeclaration(locationInAST);
		if (parentMethod != null) {
			enclosingMethod= parentMethod.getName().getIdentifier();
			locationInAST= parentMethod;
		}
		ASTNode parentType= ASTResolving.findParentType(locationInAST);
		if (parentType instanceof AbstractTypeDeclaration) {
			enclosingType= ((AbstractTypeDeclaration)parentType).getName().getIdentifier();
		}
	}
	return getCatchBodyContent(cu, exceptionType, variableName, enclosingType, enclosingMethod, lineDelimiter);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:StubUtility.java

示例5: initialize

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
/**
 * @param root the AST root
 * @param node the selected node
 * @return returns a message if there is a problem
 */
public String initialize(CompilationUnit root, ASTNode node) {
	fASTRoot= root;

	if (node instanceof ReturnStatement) {
		fMethodDeclaration= ASTResolving.findParentMethodDeclaration(node);
		if (fMethodDeclaration == null)
			return SearchMessages.MethodExitsFinder_no_return_type_selected;
		return null;

	}

	Type type= ASTNodes.getTopMostType(node);
	if (type == null)
		return SearchMessages.MethodExitsFinder_no_return_type_selected;
	if (type.getLocationInParent() != MethodDeclaration.RETURN_TYPE2_PROPERTY)
		return SearchMessages.MethodExitsFinder_no_return_type_selected;
	fMethodDeclaration= (MethodDeclaration)type.getParent();

	fExitDescription= Messages.format(SearchMessages.MethodExitsFinder_occurrence_exit_description, BasicElementLabels.getJavaElementName(fMethodDeclaration.getName().toString()));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:MethodExitsFinder.java

示例6: createProposalsForProblemOnExtraMethod

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposalsForProblemOnExtraMethod(
    ASTNode problemNode) {
  MethodDeclaration methodDecl = ASTResolving.findParentMethodDeclaration(problemNode);

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

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

示例8: createProposals

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public static List<IJavaCompletionProposal> createProposals(
    ASTNode problemNode) {
  MethodDeclaration methodDecl = ASTResolving.findParentMethodDeclaration(problemNode);
  return Collections.<IJavaCompletionProposal> singletonList(new ChangeAsyncMethodReturnTypeProposal(
      methodDecl));
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:7,代码来源:ChangeAsyncMethodReturnTypeProposal.java

示例9: initialize

import org.eclipse.jdt.internal.ui.text.correction.ASTResolving; //导入方法依赖的package包/类
public String initialize(CompilationUnit root, ASTNode node) {
	fASTRoot= root;
	if (node == null)
		return SearchMessages.ExceptionOccurrencesFinder_no_exception;
	
	MethodDeclaration method= ASTResolving.findParentMethodDeclaration(node);
	if (method == null)
		return SearchMessages.ExceptionOccurrencesFinder_no_exception;
	
	// The ExceptionOccurrencesFinder selects the whole type, no matter what part of it was selected. MethodExitsFinder behaves similar.
	
	if (node instanceof Name) {
		node= ASTNodes.getTopMostName((Name) node);
	}
	ASTNode parent= node.getParent();
	if (node.getLocationInParent() == TagElement.FRAGMENTS_PROPERTY) {
		// in Javadoc tag:
		TagElement tagElement= (TagElement) parent;
		String tagName= tagElement.getTagName();
		if (node instanceof Name
				&& node == tagElement.fragments().get(0)
				&& (TagElement.TAG_EXCEPTION.equals(tagName) || TagElement.TAG_THROWS.equals(tagName))) {
			fSelectedNode= node;
			fException= ((Name) node).resolveTypeBinding();
			fStart= method;
		}
		
	} else {
		Type type= ASTNodes.getTopMostType(node);
		if (type == null) {
			return SearchMessages.ExceptionOccurrencesFinder_no_exception;
		}
		
		// in method's "throws" list:
		if (type.getLocationInParent() == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) {
			fSelectedNode= type;
			fException= type.resolveBinding();
			fStart= method;
		}
		
		// in catch clause:
		Type topType= type;
		if (type.getLocationInParent() == UnionType.TYPES_PROPERTY) {
			topType= (Type) type.getParent();
		}
		if (topType.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY
				&& topType.getParent().getLocationInParent() == CatchClause.EXCEPTION_PROPERTY) {
			fSelectedNode= type;
			fException= type.resolveBinding();
			fTryStatement= (TryStatement) topType.getParent().getParent().getParent();
			fStart= fTryStatement.getBody();
		}
	}
	if (fException == null || fStart == null)
		return SearchMessages.ExceptionOccurrencesFinder_no_exception;
	fDescription= Messages.format(SearchMessages.ExceptionOccurrencesFinder_occurrence_description, BasicElementLabels.getJavaElementName(fException.getName()));
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:59,代码来源:ExceptionOccurrencesFinder.java


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