use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testNestedTypePackageFragment.
@Test
public void testNestedTypePackageFragment() throws Exception {
String modelAsString = "class C { val x = java.util.Map.Entry }";
XtextResource resource = (XtextResource) testHelper.xtendFile("C", modelAsString).eResource();
IHyperlink[] hyperlinks = hyperlinkHelper.createHyperlinksByOffset(resource, modelAsString.indexOf("util"), true);
assertEquals(1, hyperlinks.length);
assertEquals("Map<K, V>", hyperlinks[0].getHyperlinkText());
assertEquals(modelAsString.indexOf("java"), hyperlinks[0].getHyperlinkRegion().getOffset());
assertEquals("java.util.Map".length(), hyperlinks[0].getHyperlinkRegion().getLength());
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testStaticFeatureCallWithColon.
@Test
public void testStaticFeatureCallWithColon() throws Exception {
String modelAsString = "class C { val x = java.lang.String::valueOf('') }";
XtextResource resource = (XtextResource) testHelper.xtendFile("C", modelAsString).eResource();
IHyperlink[] hyperlinks = hyperlinkHelper.createHyperlinksByOffset(resource, modelAsString.indexOf("lang"), true);
assertEquals(1, hyperlinks.length);
assertEquals("String", hyperlinks[0].getHyperlinkText());
assertEquals(modelAsString.indexOf("java"), hyperlinks[0].getHyperlinkRegion().getOffset());
assertEquals("java.lang.String".length(), hyperlinks[0].getHyperlinkRegion().getLength());
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testNestedTypeLiteralWithDollar.
@Test
public void testNestedTypeLiteralWithDollar() throws Exception {
String modelAsString = "class C { val x = java.util.Map$Entry }";
XtextResource resource = (XtextResource) testHelper.xtendFile("C", modelAsString).eResource();
IHyperlink[] hyperlinks = hyperlinkHelper.createHyperlinksByOffset(resource, modelAsString.indexOf("Entry"), true);
assertEquals(1, hyperlinks.length);
assertEquals("Entry<K, V>", hyperlinks[0].getHyperlinkText());
assertEquals(modelAsString.indexOf("java"), hyperlinks[0].getHyperlinkRegion().getOffset());
assertEquals("java.util.Map$Entry".length(), hyperlinks[0].getHyperlinkRegion().getLength());
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testStaticFeatureCallWithAllColon.
@Test
public void testStaticFeatureCallWithAllColon() throws Exception {
String modelAsString = "class C { val x = java::lang::String::valueOf('') }";
XtextResource resource = (XtextResource) testHelper.xtendFile("C", modelAsString).eResource();
IHyperlink[] hyperlinks = hyperlinkHelper.createHyperlinksByOffset(resource, modelAsString.indexOf("lang"), true);
assertEquals(1, hyperlinks.length);
assertEquals("String", hyperlinks[0].getHyperlinkText());
assertEquals(modelAsString.indexOf("java"), hyperlinks[0].getHyperlinkRegion().getOffset());
assertEquals("java::lang::String".length(), hyperlinks[0].getHyperlinkRegion().getLength());
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class DetectImplHyperlinksTest method testComputeHyperlink_3.
@Test
public void testComputeHyperlink_3() throws Exception {
String content = "package foo class Foo { def bar(S|tring a) { foo() } def foo(){}}";
XtextEditor xtextEditor = openEditor(content.replace("|", ""));
int offset = content.indexOf("|");
IHyperlink[] detectHyperlinks = hyperlinkDetector.detectHyperlinks(xtextEditor.getInternalSourceViewer(), new Region(offset, 1), true);
assertEquals(1, detectHyperlinks.length);
List<XbaseImplementatorsHyperlink> list = Lists.newArrayList(Iterables.filter(Lists.newArrayList(detectHyperlinks), XbaseImplementatorsHyperlink.class));
assertEquals(0, list.size());
}
Aggregations