use of org.eclipse.jface.text.ITextSelection in project linuxtools by eclipse.
the class STPToggleCommentTest method getTextBlockFromSelectionTest.
@Test
public void getTextBlockFromSelectionTest() throws BadLocationException {
int i = 0;
int curPos = 0;
for (String scriptLine : PARTITIONED_SCRIPT) {
int lineLength = scriptLine.length();
int offset = stpScript.indexOf(scriptLine, curPos);
ITextSelection selection = new MockTextSelection(offset, lineLength, i, i, scriptLine);
IRegion actualRegion = cmdHandler.getTextBlockFromSelection(selection, document);
IRegion expectedRegion = new Region(offset, lineLength);
assertEquals(scriptLine + " :", expectedRegion, actualRegion);
curPos = offset + lineLength;
i++;
}
}
use of org.eclipse.jface.text.ITextSelection in project linuxtools by eclipse.
the class CParser method parseCurrentFunction.
@Override
public String parseCurrentFunction(IEditorPart editor) throws CoreException {
// Check for correct editor type
if (!(editor instanceof AbstractTextEditor))
return "";
// Get the editor, test selection and input.
AbstractTextEditor a_editor = (AbstractTextEditor) editor;
ITextSelection selection = (ITextSelection) (a_editor).getSelectionProvider().getSelection();
IEditorInput input = a_editor.getEditorInput();
// Parse it and return the function.
return parseCurrentFunction(input, selection.getOffset());
}
use of org.eclipse.jface.text.ITextSelection in project linuxtools by eclipse.
the class JavaParser method parseCurrentFunction.
@Override
public String parseCurrentFunction(IEditorPart editor) throws CoreException {
// Check for correct editor type
if (!(editor instanceof AbstractDecoratedTextEditor)) {
return "";
}
// Get the editor, test selection and input.
AbstractDecoratedTextEditor java_editor = (AbstractDecoratedTextEditor) editor;
ITextSelection selection = (ITextSelection) (java_editor.getSelectionProvider().getSelection());
IEditorInput input = java_editor.getEditorInput();
// Parse it and return the function.
return parseCurrentFunction(input, selection.getOffset());
}
use of org.eclipse.jface.text.ITextSelection in project dbeaver by dbeaver.
the class SQLEditorSourceViewer method refreshTextSelection.
void refreshTextSelection() {
ITextSelection selection = (ITextSelection) getSelection();
fireSelectionChanged(selection.getOffset(), selection.getLength());
}
use of org.eclipse.jface.text.ITextSelection in project erlide_eclipse by erlang.
the class MarkOccurencesSupport method installOccurrencesFinder.
protected void installOccurrencesFinder(final boolean forceUpdate) {
fMarkOccurrenceAnnotations = true;
fPostSelectionListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) selection, editor.getModule());
}
};
final ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider != null) {
((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fPostSelectionListener);
if (forceUpdate) {
fForcedMarkOccurrencesSelection = selectionProvider.getSelection();
final IErlModule module = editor.getModule();
if (module != null) {
editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, module);
}
}
}
if (fOccurrencesFinderJobCanceler == null) {
fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
fOccurrencesFinderJobCanceler.install();
}
}
Aggregations