Search in sources :

Example 71 with XtextResourceSet

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

the class RichStringProcessorTest method richStringWithError.

protected RichString richStringWithError(String string) throws Exception {
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(string);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(getPrefix() + string + "}"), null);
    XtendFile file = (XtendFile) resource.getContents().get(0);
    XtendClass clazz = (XtendClass) file.getXtendTypes().get(0);
    XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
    return (RichString) function.getExpression();
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) StringInputStream(org.eclipse.xtext.util.StringInputStream) RichString(org.eclipse.xtend.core.xtend.RichString) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) RichString(org.eclipse.xtend.core.xtend.RichString)

Example 72 with XtextResourceSet

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

the class TypeProviderErrorTest method file.

@Override
protected XtendFile file(String string, boolean validate) throws Exception {
    if (validate)
        return super.file(string, validate);
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(string);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(string), null);
    XtendFile file = (XtendFile) resource.getContents().get(0);
    return file;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringInputStream(org.eclipse.xtext.util.StringInputStream) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 73 with XtextResourceSet

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

the class XtendValidationTest method testBug378211_NoException.

@Test
public void testBug378211_NoException() throws Exception {
    String model = "@Data class Foo { int id  def }";
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(model);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(model), null);
    helper.validate(resource.getContents().get(0));
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) Test(org.junit.Test)

Example 74 with XtextResourceSet

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

the class InferredJvmModelTest method test_No_Exception_bug395377.

@Test
public void test_No_Exception_bug395377() throws Exception {
    String content = "@Data class Foo {  String extension }";
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(content);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(content), null);
    XtendFile file = (XtendFile) resource.getContents().get(0);
    getInferredType(file);
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringInputStream(org.eclipse.xtext.util.StringInputStream) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) Test(org.junit.Test)

Example 75 with XtextResourceSet

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

the class LinkingErrorTest method file.

@Override
protected XtendFile file(String string, boolean validate) throws Exception {
    if (validate)
        return super.file(string, validate);
    XtextResourceSet set = getResourceSet();
    String fileName = getFileName(string);
    Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
    resource.load(new StringInputStream(string), null);
    XtendFile file = (XtendFile) resource.getContents().get(0);
    return file;
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) StringInputStream(org.eclipse.xtext.util.StringInputStream) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) LazyLinkingResource(org.eclipse.xtext.linking.lazy.LazyLinkingResource) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)123 Resource (org.eclipse.emf.ecore.resource.Resource)72 XtextResource (org.eclipse.xtext.resource.XtextResource)61 Test (org.junit.Test)44 StringInputStream (org.eclipse.xtext.util.StringInputStream)36 URI (org.eclipse.emf.common.util.URI)24 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)19 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)12 EObject (org.eclipse.emf.ecore.EObject)11 File (java.io.File)10 AbstractResourceSetTest (org.eclipse.xtext.resource.AbstractResourceSetTest)10 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 Issue (org.eclipse.xtext.validation.Issue)8 Grammar (org.eclipse.xtext.Grammar)7 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)7 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)7 ArrayList (java.util.ArrayList)5 ClasspathTypeProvider (org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider)5 Before (org.junit.Before)5 Injector (com.google.inject.Injector)4