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


Java NodeFinder.getCoveringNode方法代码示例

本文整理汇总了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;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:JavaStatementPostfixContext.java

示例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;
}
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:29,代码来源:JDTUtils.java

示例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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:CompilationUnitRange.java

示例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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:ASTNodeSearchUtil.java

示例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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:CompilationUnitRange.java

示例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();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:6,代码来源:ProblemLocation.java

示例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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:ASTNodeSearchUtil.java

示例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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:5,代码来源:ProblemLocation.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:60,代码来源:CopyQualifiedNameAction.java

示例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();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:ProblemLocation.java


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