本文整理汇总了Java中org.eclipse.jdt.ui.JavaUI.getEditorInputTypeRoot方法的典型用法代码示例。如果您正苦于以下问题:Java JavaUI.getEditorInputTypeRoot方法的具体用法?Java JavaUI.getEditorInputTypeRoot怎么用?Java JavaUI.getEditorInputTypeRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.JavaUI
的用法示例。
在下文中一共展示了JavaUI.getEditorInputTypeRoot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launch
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
@Override
public void launch(IEditorPart editor, String mode) {
ITypeRoot element= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
if (element != null) {
launch(new Object[] { element }, mode);
}
}
示例2: computeFieldConstant
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
/**
* Compute the textual representation of a 'static' 'final' field's constant initializer value.
*
* @param activePart the part that triggered the computation, or <code>null</code>
* @param selection the selection that references the field, or <code>null</code>
* @param resolvedField the filed whose constant value will be computed
* @param monitor the progress monitor
*
* @return the textual representation of the constant, or <code>null</code> if the
* field is not a constant field, the initializer value could not be computed, or
* the progress monitor was cancelled
* @since 3.4
*/
private String computeFieldConstant(IWorkbenchPart activePart, ISelection selection, IField resolvedField, IProgressMonitor monitor) {
if (!JavadocHover.isStaticFinal(resolvedField))
return null;
Object constantValue;
IJavaProject preferenceProject;
if (selection instanceof ITextSelection && activePart instanceof JavaEditor) {
IEditorPart editor= (IEditorPart) activePart;
ITypeRoot activeType= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
preferenceProject= activeType.getJavaProject();
constantValue= getConstantValueFromActiveEditor(activeType, resolvedField, (ITextSelection) selection, monitor);
if (constantValue == null) // fall back - e.g. when selection is inside Javadoc of the element
constantValue= computeFieldConstantFromTypeAST(resolvedField, monitor);
} else {
constantValue= computeFieldConstantFromTypeAST(resolvedField, monitor);
preferenceProject= resolvedField.getJavaProject();
}
if (constantValue != null)
return JavadocHover.getFormattedAssignmentOperator(preferenceProject) + formatCompilerConstantValue(constantValue);
return null;
}
示例3: getSelectedMethod
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的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: installOnActiveEditor
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private void installOnActiveEditor(IWorkbenchPage page) {
IEditorPart activeEditor= page.getActiveEditor();
if (activeEditor instanceof ITextEditor) {
editorActive(activeEditor);
ISelection selection= activeEditor.getSite().getSelectionProvider().getSelection();
ITypeRoot typeRoot= JavaUI.getEditorInputTypeRoot(activeEditor.getEditorInput());
if (typeRoot != null && selection instanceof ITextSelection) {
CompilationUnit astRoot= SharedASTProvider.getAST(typeRoot, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
if (astRoot != null) {
preformEditorSelectionChanged((ITextSelection) selection, astRoot);
}
}
}
}
示例5: getEditorInput
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private static ITypeRoot getEditorInput(JavaEditor editor) {
return JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:FindImplementOccurrencesAction.java
示例6: getEditorInput
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private ITypeRoot getEditorInput() {
return JavaUI.getEditorInputTypeRoot(fEditor.getEditorInput());
}
示例7: getInputJavaElement
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private ITypeRoot getInputJavaElement(ITextEditor editor) {
return JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
}
示例8: doCutCopyWithImportsOperation
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的package包/类
private void doCutCopyWithImportsOperation() {
ITextEditor editor= getTextEditor();
ITypeRoot inputElement= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
ISelection selection= editor.getSelectionProvider().getSelection();
Object clipboardData= null;
if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
ITextSelection textSelection= (ITextSelection) selection;
if (isNonTrivialSelection(textSelection)) {
clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
}
}
fOperationTarget.doOperation(fOperationCode);
if (clipboardData != null) {
/*
* We currently make assumptions about what the styled text widget sets,
* see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61876
*/
Clipboard clipboard= new Clipboard(getDisplay());
try {
Object textData= clipboard.getContents(TextTransfer.getInstance());
/*
* Don't add if we didn't get any text data from the clipboard, see:
* - https://bugs.eclipse.org/bugs/show_bug.cgi?id=70077
* - https://bugs.eclipse.org/bugs/show_bug.cgi?id=200743
*/
if (textData == null)
return;
ArrayList<Object> datas= new ArrayList<Object>(3);
ArrayList<ByteArrayTransfer> transfers= new ArrayList<ByteArrayTransfer>(3);
datas.add(textData);
transfers.add(TextTransfer.getInstance());
Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
if (rtfData != null) {
datas.add(rtfData);
transfers.add(RTFTransfer.getInstance());
}
datas.add(clipboardData);
transfers.add(fgTransferInstance);
Transfer[] dataTypes= transfers.toArray(new Transfer[transfers.size()]);
Object[] data= datas.toArray();
setClipboardContents(clipboard, data, dataTypes);
} finally {
clipboard.dispose();
}
}
}
示例9: getSelectedElement
import org.eclipse.jdt.ui.JavaUI; //导入方法依赖的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;
}