public String run(ITypeRoot input, int offset, int length) throws JavaModelException { if (input.getSourceRange() == null) { return SearchMessages.FindOccurrencesEngine_noSource_text; } final CompilationUnit root= SharedASTProviderCore.getAST(input, SharedASTProviderCore.WAIT_YES, null); if (root == null) { return SearchMessages.FindOccurrencesEngine_cannotParse_text; } return run(root, offset, length); }
public String run(ITypeRoot input, int offset, int length) throws JavaModelException { if (input.getSourceRange() == null) { return SearchMessages.FindOccurrencesEngine_noSource_text; } final CompilationUnit root= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_YES, null); if (root == null) { return SearchMessages.FindOccurrencesEngine_cannotParse_text; } return run(root, offset, length); }
@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(); } }
@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(); } }