Search in sources :

Example 36 with IHyperlink

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());
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 37 with IHyperlink

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());
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 38 with IHyperlink

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());
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 39 with IHyperlink

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());
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 40 with IHyperlink

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());
}
Also used : IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) XbaseImplementatorsHyperlink(org.eclipse.xtext.xbase.ui.navigation.XbaseImplementatorsHyperlink) Region(org.eclipse.jface.text.Region) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Aggregations

IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)47 Test (org.junit.Test)35 XtextResource (org.eclipse.xtext.resource.XtextResource)20 IRegion (org.eclipse.jface.text.IRegion)19 Region (org.eclipse.jface.text.Region)19 IEditorPart (org.eclipse.ui.IEditorPart)9 SourcesFileHyperlinkDetector (org.eclipse.linuxtools.internal.rpm.ui.editor.hyperlink.SourcesFileHyperlinkDetector)5 IFile (org.eclipse.core.resources.IFile)4 JdtHyperlink (org.eclipse.xtext.common.types.xtext.ui.JdtHyperlink)4 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)4 AbstractEditorTest (org.eclipse.xtext.ui.testing.AbstractEditorTest)4 IDocument (org.eclipse.jface.text.IDocument)3 URLHyperlink (org.eclipse.jface.text.hyperlink.URLHyperlink)3 SpecfileEditor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor)3 XtextHyperlink (org.eclipse.xtext.ui.editor.hyperlinking.XtextHyperlink)3 XbaseImplementatorsHyperlink (org.eclipse.xtext.xbase.ui.navigation.XbaseImplementatorsHyperlink)3 JsonPointer (com.fasterxml.jackson.core.JsonPointer)2 SwaggerHyperlink (com.reprezen.swagedit.core.hyperlinks.SwaggerHyperlink)2 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2