Search in sources :

Example 71 with XtextResource

use of org.eclipse.xtext.resource.XtextResource in project xtext-xtend by eclipse.

the class EObjectLocationTests method testResolveAnonymousClassConstructorCall_2.

@Test
public void testResolveAnonymousClassConstructorCall_2() throws Exception {
    String model = "class Foo { val bar = new Bar() {} } class Bar { new(String x) {} new() {} }";
    XtendFile file = file(model);
    XtextResource resource = (XtextResource) file.eResource();
    EObject constructor = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, model.indexOf("Bar"));
    assertTrue(constructor instanceof JvmConstructor);
    assertEquals("Bar", ((JvmConstructor) constructor).getDeclaringType().getSimpleName());
    assertEquals(0, ((JvmConstructor) constructor).getParameters().size());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) EObject(org.eclipse.emf.ecore.EObject) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 72 with XtextResource

use of org.eclipse.xtext.resource.XtextResource in project xtext-xtend by eclipse.

the class EObjectLocationTests method testResolveAnonymousClassConstructorCall_1.

@Test
public void testResolveAnonymousClassConstructorCall_1() throws Exception {
    String model = "class Foo { val bar = new Bar() {} } class Bar {}";
    XtendFile file = file(model);
    XtextResource resource = (XtextResource) file.eResource();
    EObject constructor = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, model.indexOf("Bar"));
    assertTrue(constructor instanceof JvmConstructor);
    assertEquals("Bar", ((JvmConstructor) constructor).getDeclaringType().getSimpleName());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) EObject(org.eclipse.emf.ecore.EObject) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 73 with XtextResource

use of org.eclipse.xtext.resource.XtextResource in project xtext-xtend by eclipse.

the class EObjectLocationTests method testResolveAnonymousClassConstructorCall_5.

@Test
public void testResolveAnonymousClassConstructorCall_5() throws Exception {
    String model = "class Foo { val bar = new Bar() {} } class Bar { new(String x) {} }";
    XtendFile file = file(model);
    XtextResource resource = (XtextResource) file.eResource();
    EObject constructor = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, model.indexOf("Bar"));
    assertTrue(constructor instanceof JvmConstructor);
    assertEquals("Bar", ((JvmConstructor) constructor).getDeclaringType().getSimpleName());
    assertEquals(1, ((JvmConstructor) constructor).getParameters().size());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) EObject(org.eclipse.emf.ecore.EObject) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 74 with XtextResource

use of org.eclipse.xtext.resource.XtextResource in project xtext-xtend by eclipse.

the class EObjectLocationTests method testResolveAnonymousClassConstructorCall_3.

@Test
public void testResolveAnonymousClassConstructorCall_3() throws Exception {
    String model = "class Foo { val bar = new Bar('') {} } class Bar { new(String x) {} new() {} }";
    XtendFile file = file(model);
    XtextResource resource = (XtextResource) file.eResource();
    EObject constructor = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, model.indexOf("Bar"));
    assertTrue(constructor instanceof JvmConstructor);
    assertEquals("Bar", ((JvmConstructor) constructor).getDeclaringType().getSimpleName());
    assertEquals(1, ((JvmConstructor) constructor).getParameters().size());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) EObject(org.eclipse.emf.ecore.EObject) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 75 with XtextResource

use of org.eclipse.xtext.resource.XtextResource in project xtext-xtend by eclipse.

the class LinkingErrorTest method testNoExceptionInValidator_03.

@Test
public void testNoExceptionInValidator_03() throws Exception {
    XtendClass clazz = clazz("package pack class Case_4 {\n" + "	richStrings_01() {\n" + "		'''foobar'''\n" + "	}\n" + "	richStrings_02() {\n" + "		'''�'start'�\n" + "		  first line\n'''" + "");
    assertNoExceptions(clazz);
    XtextResource resource = (XtextResource) clazz.eResource();
    validateWithoutException(resource);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Aggregations

XtextResource (org.eclipse.xtext.resource.XtextResource)627 Test (org.junit.Test)367 Resource (org.eclipse.emf.ecore.resource.Resource)107 EObject (org.eclipse.emf.ecore.EObject)99 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)67 StringInputStream (org.eclipse.xtext.util.StringInputStream)67 URI (org.eclipse.emf.common.util.URI)62 Diagnostic (org.eclipse.emf.common.util.Diagnostic)55 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)55 ICompositeNode (org.eclipse.xtext.nodemodel.ICompositeNode)46 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)40 Grammar (org.eclipse.xtext.Grammar)32 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)31 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)30 IFile (org.eclipse.core.resources.IFile)29 Issue (org.eclipse.xtext.validation.Issue)29 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)28 List (java.util.List)26 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)26 INode (org.eclipse.xtext.nodemodel.INode)23