本文整理汇总了Java中org.eclipse.jdt.core.dom.NodeFinder.getCoveringNode方法的典型用法代码示例。如果您正苦于以下问题:Java NodeFinder.getCoveringNode方法的具体用法?Java NodeFinder.getCoveringNode怎么用?Java NodeFinder.getCoveringNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.NodeFinder
的用法示例。
在下文中一共展示了NodeFinder.getCoveringNode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDomAST
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
private void initDomAST() {
if (isReadOnly())
return;
ASTParser parser= ASTParser.newParser(AST.JLS8);
parser.setSource(getCompilationUnit());
parser.setResolveBindings(true);
org.eclipse.jdt.core.dom.ASTNode domAst = parser.createAST(new NullProgressMonitor());
// org.eclipse.jdt.core.dom.AST ast = domAst.getAST();
NodeFinder nf = new NodeFinder(domAst, getCompletionOffset(), 1);
org.eclipse.jdt.core.dom.ASTNode cv = nf.getCoveringNode();
bodyDeclaration = ASTResolving.findParentBodyDeclaration(cv);
parentDeclaration = ASTResolving.findParentType(cv);
domInitialized = true;
}
示例2: initDomAST
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
private void initDomAST() {
if (isReadOnly())
return;
ASTParser parser= ASTParser.newParser(AST.JLS4);
parser.setSource(getCompilationUnit());
parser.setResolveBindings(true);
org.eclipse.jdt.core.dom.ASTNode domAst = parser.createAST(new NullProgressMonitor());
// org.eclipse.jdt.core.dom.AST ast = domAst.getAST();
NodeFinder nf = new NodeFinder(domAst, getCompletionOffset(), 1);
org.eclipse.jdt.core.dom.ASTNode cv = nf.getCoveringNode();
bodyDeclaration = ASTResolving.findParentBodyDeclaration(cv);
parentDeclaration = ASTResolving.findParentType(cv);
domInitialized = true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:JavaStatementPostfixContext.java
示例3: getSelectedMethod
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
public static IMethod getSelectedMethod(IFileEditorInput fileEditorInput)
throws JavaModelException {
ITextEditor editor = (ITextEditor) EclipseUIUtils.getActiveEditor();
ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
.getSelection();
ITypeRoot typeRoot = JavaUI.getEditorInputTypeRoot(editor
.getEditorInput());
ICompilationUnit icu = (ICompilationUnit) typeRoot
.getAdapter(ICompilationUnit.class);
CompilationUnit cu = createASTRoot(icu);
NodeFinder finder = new NodeFinder(cu, sel.getOffset(), sel.getLength());
ASTNode node = finder.getCoveringNode();
MethodDeclaration methodDeclaration = getASTMethod(node);
if (methodDeclaration == null) {
return null;
}
IMethodBinding methodBinding = methodDeclaration.resolveBinding();
IMethod selectedMethod = null;
if (methodBinding != null) {
selectedMethod = (IMethod) methodBinding.getJavaElement();
}
return selectedMethod;
}
示例4: getNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
public ASTNode getNode(CompilationUnit rootNode) {
NodeFinder finder =
new NodeFinder(rootNode, fSourceRange.getOffset(), fSourceRange.getLength());
ASTNode result = finder.getCoveringNode();
if (result != null) return result;
return finder.getCoveredNode();
}
示例5: findNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
private static ASTNode findNode(ISourceRange range, CompilationUnit cuNode){
NodeFinder nodeFinder= new NodeFinder(cuNode, range.getOffset(), range.getLength());
ASTNode coveredNode= nodeFinder.getCoveredNode();
if (coveredNode != null)
return coveredNode;
else
return nodeFinder.getCoveringNode();
}
示例6: getNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
public ASTNode getNode(CompilationUnit rootNode) {
NodeFinder finder= new NodeFinder(rootNode, fSourceRange.getOffset(), fSourceRange.getLength());
ASTNode result= finder.getCoveringNode();
if (result != null)
return result;
return finder.getCoveredNode();
}
示例7: getCoveringNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
@Override
public ASTNode getCoveringNode(CompilationUnit astRoot) {
NodeFinder finder = new NodeFinder(astRoot, this.offset, this.length);
return finder.getCoveringNode();
}
示例8: findNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
private static ASTNode findNode(ISourceRange range, CompilationUnit cuNode) {
NodeFinder nodeFinder = new NodeFinder(cuNode, range.getOffset(), range.getLength());
ASTNode coveredNode = nodeFinder.getCoveredNode();
if (coveredNode != null) return coveredNode;
else return nodeFinder.getCoveringNode();
}
示例9: getCoveringNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
public ASTNode getCoveringNode(CompilationUnit astRoot) {
NodeFinder finder = new NodeFinder(astRoot, fOffset, fLength);
return finder.getCoveringNode();
}
示例10: getSelectedElement
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
private Object getSelectedElement(JavaEditor editor) {
ISourceViewer viewer= editor.getViewer();
if (viewer == null)
return null;
Point selectedRange= viewer.getSelectedRange();
int length= selectedRange.y;
int offset= selectedRange.x;
ITypeRoot element= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
if (element == null)
return null;
CompilationUnit ast= SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null);
if (ast == null)
return null;
NodeFinder finder= new NodeFinder(ast, offset, length);
ASTNode node= finder.getCoveringNode();
IBinding binding= null;
if (node instanceof Name) {
binding= getConstructorBindingIfAvailable((Name)node);
if (binding != null)
return binding;
binding= ((Name)node).resolveBinding();
} else if (node instanceof MethodInvocation) {
binding= ((MethodInvocation)node).resolveMethodBinding();
} else if (node instanceof MethodDeclaration) {
binding= ((MethodDeclaration)node).resolveBinding();
} else if (node instanceof Type) {
binding= ((Type)node).resolveBinding();
} else if (node instanceof AnonymousClassDeclaration) {
binding= ((AnonymousClassDeclaration)node).resolveBinding();
} else if (node instanceof TypeDeclaration) {
binding= ((TypeDeclaration)node).resolveBinding();
} else if (node instanceof CompilationUnit) {
return ((CompilationUnit)node).getJavaElement();
} else if (node instanceof Expression) {
binding= ((Expression)node).resolveTypeBinding();
} else if (node instanceof ImportDeclaration) {
binding= ((ImportDeclaration)node).resolveBinding();
} else if (node instanceof MemberRef) {
binding= ((MemberRef)node).resolveBinding();
} else if (node instanceof MemberValuePair) {
binding= ((MemberValuePair)node).resolveMemberValuePairBinding();
} else if (node instanceof PackageDeclaration) {
binding= ((PackageDeclaration)node).resolveBinding();
} else if (node instanceof TypeParameter) {
binding= ((TypeParameter)node).resolveBinding();
} else if (node instanceof VariableDeclaration) {
binding= ((VariableDeclaration)node).resolveBinding();
}
if (binding != null)
return binding.getJavaElement();
return null;
}
示例11: getCoveringNode
import org.eclipse.jdt.core.dom.NodeFinder; //导入方法依赖的package包/类
public ASTNode getCoveringNode(CompilationUnit astRoot) {
NodeFinder finder= new NodeFinder(astRoot, fOffset, fLength);
return finder.getCoveringNode();
}