use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testStaticFeatureCall.
@Test
public void testStaticFeatureCall() 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 testPackageFragment.
@Test
public void testPackageFragment() throws Exception {
String modelAsString = "class C { val x = java.lang.String }";
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 testSuperClass.
@Test
public void testSuperClass() throws Exception {
String modelAsString = "class Foo extends Object {\n" + "}";
XtextResource resource = (XtextResource) testHelper.xtendFile("Foo", modelAsString).eResource();
IHyperlink[] hyperlinks = hyperlinkHelper.createHyperlinksByOffset(resource, modelAsString.indexOf("Object"), true);
assertEquals(1, hyperlinks.length);
assertEquals("Object", hyperlinks[0].getHyperlinkText());
}
use of org.eclipse.jface.text.hyperlink.IHyperlink in project xtext-xtend by eclipse.
the class HyperlinkingTest method testOuterTypeLiteral.
@Test
public void testOuterTypeLiteral() 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("Map"), 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 testNestedTypeLiteral.
@Test
public void testNestedTypeLiteral() 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("Entry"), hyperlinks[0].getHyperlinkRegion().getOffset());
assertEquals("Entry".length(), hyperlinks[0].getHyperlinkRegion().getLength());
}
Aggregations