Search in sources :

Example 56 with Procedure0

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.

the class ResourceStorageTest method testShouldLoadFromStorage.

@Test
public void testShouldLoadFromStorage() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypack");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class MyClass {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public def void foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString());
        IResourcesSetupUtil.waitForBuild();
        final URI uri = this.uriMapper.getUri(file);
        final ResourceSet resourceSet = this.resourceSetProvider.get(file.getProject());
        SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
        Resource _createResource = resourceSet.createResource(uri);
        final StorageAwareResource resource = ((StorageAwareResource) _createResource);
        final Procedure0 _function = () -> {
            Assert.assertTrue(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
        };
        this.doWorkInJob(_function);
        NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
        file.delete(true, _nullProgressMonitor);
        IResourcesSetupUtil.waitForBuild();
        final Procedure0 _function_1 = () -> {
            Assert.assertFalse(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
        };
        this.doWorkInJob(_function_1);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Resource(org.eclipse.emf.ecore.resource.Resource) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) URI(org.eclipse.emf.common.util.URI) AbsoluteURI(org.eclipse.xtext.generator.trace.AbsoluteURI) SourceRelativeURI(org.eclipse.xtext.generator.trace.SourceRelativeURI) Test(org.junit.Test)

Example 57 with Procedure0

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.

the class TypesChangingQueuedBuildDataTest method createPrimaryAndNestedTypes.

@Test
public void createPrimaryAndNestedTypes() {
    final Procedure0 _function = () -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("public class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("public class Foo3 {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public static class Foo2 {}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.create("Bar.java", _builder.toString());
    };
    this.assertThereAreDeltas(_function, "Bar$Foo$Foo3", "Bar$Foo", "Bar$Foo2", "Bar");
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 58 with Procedure0

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.

the class TypesChangingQueuedBuildDataTest method createPrimaryType2.

@Test
public void createPrimaryType2() {
    final Procedure0 _function = () -> {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.create("/mypackage/Bar.java", _builder.toString());
    };
    this.assertThereAreDeltas(_function, "mypackage.Bar");
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 59 with Procedure0

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.

the class TypesChangingQueuedBuildDataTest method deletePrimaryType.

@Test
public void deletePrimaryType() {
    this.create("Bar.java", "public class Bar {}");
    final Procedure0 _function = () -> {
        this.delete("Bar.java");
    };
    this.assertThereAreDeltas(_function, "Bar");
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 60 with Procedure0

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.

the class TypesChangingQueuedBuildDataTest method deletePrimaryType2.

@Test
public void deletePrimaryType2() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypackage;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class Bar {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.create("/mypackage/Bar.java", _builder.toString());
    final Procedure0 _function = () -> {
        this.delete("/mypackage/Bar.java");
    };
    this.assertThereAreDeltas(_function, "mypackage.Bar");
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Aggregations

Procedure0 (org.eclipse.xtext.xbase.lib.Procedures.Procedure0)63 Test (org.junit.Test)52 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)51 AbstractQueuedBuildDataTest (org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest)50 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)5 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)4 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)4 IFile (org.eclipse.core.resources.IFile)2 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)2 MutableInterfaceDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration)2 MutableMethodDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration)2 MutableTypeParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)1 MutableEnumerationTypeDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableEnumerationTypeDeclaration)1