Search in sources :

Example 61 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.

the class TypeUsageCollectorTest method hasUnresolvedTypesWithErrors.

private void hasUnresolvedTypesWithErrors(final CharSequence xtendFile, final String... typeNames) {
    try {
        final Resource resource = this.fileWithErrors(xtendFile.toString()).eResource();
        this.hasUnresolvedType(resource, typeNames);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 62 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.

the class JavaDocTypeReferenceProviderTest method testComputation_5.

@Test
public void testComputation_5() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class Foo{");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("/**");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("* @param string - a fancy string");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("* @param anotherString-even more fancy");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("* @param zonk");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("*/");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def bar(String string, String anotherString, Integer zonk){}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final String input = _builder.toString();
        Resource _eResource = this.clazz(input).eResource();
        final XtextResource resource = ((XtextResource) _eResource);
        final ICompositeNode rootNode = resource.getParseResult().getRootNode();
        final List<ReplaceRegion> regions = this.javaDocTypeReferenceProvider.computeParameterTypeRefRegions(rootNode);
        Assert.assertEquals(3, regions.size());
        Assert.assertEquals("string", IterableExtensions.<ReplaceRegion>head(regions).getText());
        Assert.assertEquals(input.indexOf("string"), IterableExtensions.<ReplaceRegion>head(regions).getOffset());
        Assert.assertEquals("string".length(), IterableExtensions.<ReplaceRegion>head(regions).getLength());
        Assert.assertEquals("anotherString", regions.get(1).getText());
        Assert.assertEquals(input.indexOf("anotherString"), regions.get(1).getOffset());
        Assert.assertEquals("anotherString".length(), regions.get(1).getLength());
        Assert.assertEquals("zonk", regions.get(2).getText());
        Assert.assertEquals(input.indexOf("zonk"), regions.get(2).getOffset());
        Assert.assertEquals("zonk".length(), regions.get(2).getLength());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 63 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.

the class JavaDocTypeReferenceProviderTest method testComputation_3.

@Test
public void testComputation_3() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/**");
        _builder.newLine();
        _builder.append("* {@link java.util.ArrayList");
        _builder.newLine();
        _builder.append("*/");
        _builder.newLine();
        _builder.append("class Foo{}");
        _builder.newLine();
        final String input = _builder.toString();
        Resource _eResource = this.clazz(input).eResource();
        final XtextResource resource = ((XtextResource) _eResource);
        final ICompositeNode rootNode = resource.getParseResult().getRootNode();
        final List<ReplaceRegion> regions = this.javaDocTypeReferenceProvider.computeTypeRefRegions(rootNode);
        Assert.assertEquals(0, regions.size());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 64 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.

the class JavaDocTypeReferenceProviderTest method testComputation_8.

@Test
public void testComputation_8() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/**");
        _builder.newLine();
        _builder.append("* @see    String");
        _builder.newLine();
        _builder.append("*/");
        _builder.newLine();
        _builder.append("class Foo{}");
        _builder.newLine();
        final String input = _builder.toString();
        Resource _eResource = this.clazz(input).eResource();
        final XtextResource resource = ((XtextResource) _eResource);
        final ICompositeNode rootNode = resource.getParseResult().getRootNode();
        final List<ReplaceRegion> regions = this.javaDocTypeReferenceProvider.computeTypeRefRegions(rootNode);
        Assert.assertEquals(1, regions.size());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 65 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.

the class JavaDocTypeReferenceProviderTest method testComputation_7.

@Test
public void testComputation_7() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package foo");
        _builder.newLine();
        _builder.newLine();
        _builder.append("/**");
        _builder.newLine();
        _builder.append("* {@link    String}");
        _builder.newLine();
        _builder.append("*/");
        _builder.newLine();
        _builder.append("class Foo{}");
        _builder.newLine();
        final String input = _builder.toString();
        Resource _eResource = this.clazz(input).eResource();
        final XtextResource resource = ((XtextResource) _eResource);
        final ICompositeNode rootNode = resource.getParseResult().getRootNode();
        final List<ReplaceRegion> regions = this.javaDocTypeReferenceProvider.computeTypeRefRegions(rootNode);
        Assert.assertEquals(1, regions.size());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)448 Test (org.junit.Test)210 XtextResource (org.eclipse.xtext.resource.XtextResource)157 EObject (org.eclipse.emf.ecore.EObject)109 URI (org.eclipse.emf.common.util.URI)85 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)76 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)71 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)66 StringInputStream (org.eclipse.xtext.util.StringInputStream)50 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)45 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)36 IOException (java.io.IOException)26 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)24 List (java.util.List)23 EClass (org.eclipse.emf.ecore.EClass)23 EPackage (org.eclipse.emf.ecore.EPackage)23 InternalEObject (org.eclipse.emf.ecore.InternalEObject)23 DerivedStateAwareResource (org.eclipse.xtext.resource.DerivedStateAwareResource)21 ArrayList (java.util.ArrayList)19 IFile (org.eclipse.core.resources.IFile)18