本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
示例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);
}