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