use of org.eclipse.xtext.ui.editor.selection.AstSelectionProvider in project xtext-eclipse by eclipse.
the class AstSelectionProviderTest method testBug515055_1.
@Test
public void testBug515055_1() throws Exception {
XtextResource res = getResource(getAsStream(" "));
AstSelectionProvider provider = get(AstSelectionProvider.class);
final TextRegion currentEditorSelection = new TextRegion(2, 0);
assertEquals(ITextRegion.EMPTY_REGION, provider.selectEnclosing(res, currentEditorSelection));
assertEquals(ITextRegion.EMPTY_REGION, provider.selectEnclosing(res, currentEditorSelection));
}
use of org.eclipse.xtext.ui.editor.selection.AstSelectionProvider in project xtext-eclipse by eclipse.
the class AstSelectionProviderTest method testBug515055_2.
@Test
public void testBug515055_2() throws Exception {
XtextResource res = getResource(getAsStream(""));
AstSelectionProvider provider = get(AstSelectionProvider.class);
final TextRegion currentEditorSelection = new TextRegion(0, 0);
assertEquals(ITextRegion.EMPTY_REGION, provider.selectEnclosing(res, currentEditorSelection));
}
use of org.eclipse.xtext.ui.editor.selection.AstSelectionProvider in project xtext-eclipse by eclipse.
the class AstSelectionProviderTest method testSelectEnclosing.
@Test
public void testSelectEnclosing() throws Exception {
String zonk = "zonk{}";
String zink = "zink{}";
String baz = "baz{" + zonk + zink + "}";
String bar = "bar{}";
String all = "foo(baz){" + bar + baz + "}";
EObject model = super.getModel(all);
AstSelectionProvider provider = get(AstSelectionProvider.class);
final XtextResource res = (XtextResource) model.eResource();
int indexOfZonk = all.indexOf(zonk);
ITextRegion selection = provider.selectEnclosing(res, new TextRegion(indexOfZonk, 0));
assertEquals(region(all, "zonk"), selection);
selection = provider.selectEnclosing(res, selection);
assertEquals(region(all, zonk), selection);
selection = provider.selectEnclosing(res, selection);
assertEquals(region(all, baz), selection);
selection = provider.selectEnclosing(res, selection);
assertEquals(region(all, all), selection);
assertEquals(ITextRegion.EMPTY_REGION, provider.selectEnclosing(res, selection));
}
use of org.eclipse.xtext.ui.editor.selection.AstSelectionProvider in project xtext-eclipse by eclipse.
the class AstSelectionProviderTest method testSelectComments.
@Test
public void testSelectComments() throws Exception {
String zonk = "/* my coment \n*/\nzonk{}";
String zink = "zink{}";
String baz = "baz{\n" + zonk + zink + "}";
String bar = "bar{}";
String all = "foo(baz){" + bar + baz + "}";
EObject model = super.getModel(all);
AstSelectionProvider provider = get(AstSelectionProvider.class);
final XtextResource res = (XtextResource) model.eResource();
int indexOfZonk = all.indexOf("zonk");
final TextRegion currentEditorSelection = new TextRegion(indexOfZonk, 1);
ITextRegion selection = provider.selectPrevious(res, currentEditorSelection);
assertEquals(region(all, "zonk"), selection);
selection = provider.selectEnclosing(res, selection);
assertEquals(region(all, zonk), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, baz), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, bar + baz), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, all), selection);
assertEquals(ITextRegion.EMPTY_REGION, provider.selectPrevious(res, selection));
}
use of org.eclipse.xtext.ui.editor.selection.AstSelectionProvider in project xtext-eclipse by eclipse.
the class AstSelectionProviderTest method testSelectPrevious.
@Test
public void testSelectPrevious() throws Exception {
String zonk = "zonk{}";
String zink = "zink{}";
String baz = "baz{" + zonk + zink + "}";
String bar = "bar{}";
String all = "foo(baz){" + bar + baz + "}";
EObject model = super.getModel(all);
AstSelectionProvider provider = get(AstSelectionProvider.class);
final XtextResource res = (XtextResource) model.eResource();
int indexOfZonk = all.indexOf(zonk);
ITextRegion selection = provider.selectPrevious(res, new TextRegion(indexOfZonk, 0));
assertEquals(region(all, "zonk"), selection);
selection = provider.selectEnclosing(res, selection);
assertEquals(region(all, zonk), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, baz), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, bar + baz), selection);
selection = provider.selectPrevious(res, selection);
assertEquals(region(all, all), selection);
assertEquals(ITextRegion.EMPTY_REGION, provider.selectPrevious(res, selection));
}
Aggregations