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


Java JavaEditor.getViewer方法代码示例

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


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

示例1: registerHelper

import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; //导入方法依赖的package包/类
private void registerHelper(IEditingSupport helper, JavaEditor editor) {
	ISourceViewer viewer= editor.getViewer();
	if (viewer instanceof IEditingSupportRegistry) {
		IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
		registry.register(helper);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:OrganizeImportsAction.java

示例2: deregisterHelper

import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; //导入方法依赖的package包/类
private void deregisterHelper(IEditingSupport helper, JavaEditor editor) {
	ISourceViewer viewer= editor.getViewer();
	if (viewer instanceof IEditingSupportRegistry) {
		IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
		registry.unregister(helper);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:OrganizeImportsAction.java

示例3: getSelectedElement

import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; //导入方法依赖的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


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