Java Code Examples for org.eclipse.jdt.internal.ui.javaeditor.EditorUtility#getEditorInputJavaElement()
The following examples show how to use
org.eclipse.jdt.internal.ui.javaeditor.EditorUtility#getEditorInputJavaElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaDebugElementCodeMiningProvider.java From jdt-codemining with Eclipse Public License 1.0 | 5 votes |
@Override protected List provideCodeMinings(ITextViewer viewer, IJavaStackFrame frame, IProgressMonitor monitor) { List<ICodeMining> minings = new ArrayList<>(); ITextEditor textEditor = super.getAdapter(ITextEditor.class); ITypeRoot unit = EditorUtility.getEditorInputJavaElement(textEditor, true); if (unit == null) { return minings; } CompilationUnit cu = SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_YES, null); JavaDebugElementCodeMiningASTVisitor visitor = new JavaDebugElementCodeMiningASTVisitor(frame, cu, viewer, minings, this); cu.accept(visitor); return minings; }
Example 2
Source File: StructureSelectionAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final void run() { IJavaElement inputElement= EditorUtility.getEditorInputJavaElement(fEditor, false); if (!(inputElement instanceof ITypeRoot && inputElement.exists())) return; ITypeRoot typeRoot= (ITypeRoot) inputElement; ISourceRange sourceRange; try { sourceRange= typeRoot.getSourceRange(); if (sourceRange == null || sourceRange.getLength() == 0) { MessageDialog.openInformation(fEditor.getEditorSite().getShell(), SelectionActionMessages.StructureSelect_error_title, SelectionActionMessages.StructureSelect_error_message); return; } } catch (JavaModelException e) { } ITextSelection selection= getTextSelection(); ISourceRange newRange= getNewSelectionRange(createSourceRange(selection), typeRoot); // Check if new selection differs from current selection if (selection.getOffset() == newRange.getOffset() && selection.getLength() == newRange.getLength()) return; fSelectionHistory.remember(new SourceRange(selection.getOffset(), selection.getLength())); try { fSelectionHistory.ignoreSelectionChanges(); fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength()); } finally { fSelectionHistory.listenToSelectionChanges(); } }
Example 3
Source File: JavaReconciler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void install(ITextViewer textViewer) { super.install(textViewer); fPartListener= new PartListener(); IWorkbenchPartSite site= fTextEditor.getSite(); IWorkbenchWindow window= site.getWorkbenchWindow(); window.getPartService().addPartListener(fPartListener); fActivationListener= new ActivationListener(textViewer.getTextWidget()); Shell shell= window.getShell(); shell.addShellListener(fActivationListener); fJavaElementChangedListener= new ElementChangedListener(); JavaCore.addElementChangedListener(fJavaElementChangedListener); fResourceChangeListener= new ResourceChangeListener(); IWorkspace workspace= JavaPlugin.getWorkspace(); workspace.addResourceChangeListener(fResourceChangeListener); fPropertyChangeListener= new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (SpellingService.PREFERENCE_SPELLING_ENABLED.equals(event.getProperty()) || SpellingService.PREFERENCE_SPELLING_ENGINE.equals(event.getProperty())) forceReconciling(); } }; JavaPlugin.getDefault().getCombinedPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); fReconciledElement= EditorUtility.getEditorInputJavaElement(fTextEditor, false); }
Example 4
Source File: RenameLinkedMode.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private ICompilationUnit getCompilationUnit() { return (ICompilationUnit) EditorUtility.getEditorInputJavaElement(fEditor, false); }
Example 5
Source File: DefaultJavaFoldingStructureProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private IJavaElement getInputElement() { if (fEditor == null) return null; return EditorUtility.getEditorInputJavaElement(fEditor, false); }
Example 6
Source File: AbstractJavaEditorTextHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
protected ITypeRoot getEditorInputJavaElement() { IEditorPart editor= getEditor(); if (editor != null) return EditorUtility.getEditorInputJavaElement(editor, false); return null; }
Example 7
Source File: SelectionConverter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the input element of the given editor. * * @param editor the Java editor * @param primaryOnly if <code>true</code> only primary working copies will be returned * @return the type root which is the editor input, or <code>null</code> if none * @since 3.2 */ private static ITypeRoot getInput(JavaEditor editor, boolean primaryOnly) { if (editor == null) return null; return EditorUtility.getEditorInputJavaElement(editor, primaryOnly); }