Search in sources :

Example 86 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method renameLocalVariable.

@Test
public void renameLocalVariable() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("private void bar() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("int x = 3;");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            this.save("/mypackage/Bar.java", "x", "y");
        };
        this.assertThereAreNotDeltas(_function);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 87 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 88 with Procedure0

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

the class Bug464136Processor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    final Procedure0 _function = () -> {
        throw new LinkageError("Just a test :-/");
    };
    context.validateLater(_function);
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0)

Example 89 with Procedure0

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

the class CheckMutableClassDeclarationProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    final Procedure0 _function = () -> {
        annotatedClass.setImplementedInterfaces(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot be null", _function);
    final Procedure0 _function_1 = () -> {
        annotatedClass.setImplementedInterfaces(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot contain null", _function_1);
    annotatedClass.setImplementedInterfaces(CollectionLiterals.<TypeReference>emptyList());
    final Procedure1<String> _function_2 = (String identifier) -> {
        annotatedClass.addTypeParameter(identifier).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_2);
    final Procedure0 _function_3 = () -> {
        annotatedClass.addTypeParameter("T", ((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_3);
    final Procedure0 _function_4 = () -> {
        annotatedClass.addTypeParameter("T", new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_4);
    final MutableTypeParameterDeclaration typeParameter = annotatedClass.addTypeParameter("T");
    final Procedure1<String> _function_5 = (String identifier) -> {
        typeParameter.setSimpleName(identifier);
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_5);
    final Procedure0 _function_6 = () -> {
        typeParameter.setUpperBounds(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_6);
    final Procedure0 _function_7 = () -> {
        typeParameter.setUpperBounds(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_7);
    typeParameter.setUpperBounds(CollectionLiterals.<TypeReference>emptyList());
    final Procedure0 _function_8 = () -> {
        annotatedClass.setSimpleName(null);
    };
    MutableAssert.<UnsupportedOperationException>assertThrowable(UnsupportedOperationException.class, "The type cannot be renamed.", _function_8);
    final Procedure1<String> _function_9 = (String identifier) -> {
        final Procedure1<MutableFieldDeclaration> _function_10 = (MutableFieldDeclaration it) -> {
            it.setType(context.newTypeReference(String.class));
        };
        annotatedClass.addField(identifier, _function_10).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_9);
    final Procedure0 _function_10 = () -> {
        annotatedClass.addField("foo", null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_10);
    final Procedure1<String> _function_11 = (String identifier) -> {
        final Procedure1<MutableMethodDeclaration> _function_12 = (MutableMethodDeclaration it) -> {
        };
        annotatedClass.addMethod(identifier, _function_12).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_11);
    final Procedure0 _function_12 = () -> {
        annotatedClass.addMethod("foo", null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_12);
    final Procedure0 _function_13 = () -> {
        annotatedClass.addConstructor(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_13);
    final Procedure1<MutableMethodDeclaration> _function_14 = (MutableMethodDeclaration it) -> {
    };
    final MutableMethodDeclaration method = annotatedClass.addMethod("foo", _function_14);
    annotatedClass.findDeclaredMethod(null);
    annotatedClass.findDeclaredMethod("foo");
    final Procedure0 _function_15 = () -> {
        annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_15);
    final Procedure0 _function_16 = () -> {
        annotatedClass.findDeclaredMethod("foo", new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_16);
    annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
    method.remove();
    final Procedure0 _function_17 = () -> {
        annotatedClass.findDeclaredConstructor(((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_17);
    final Procedure0 _function_18 = () -> {
        annotatedClass.findDeclaredConstructor(new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_18);
    annotatedClass.findDeclaredConstructor(((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) MutableFieldDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) MutableMethodDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) MutableTypeParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration)

Example 90 with Procedure0

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

the class XtendEditorChangingClasspathTest method assertAddLibsToClasspath.

public void assertAddLibsToClasspath(final IJavaProject project) {
    final Procedure0 _function = () -> {
        this._xtendLibClasspathAdder.addLibsToClasspath(project, null);
    };
    Assert.assertNotNull(this.waitForCoarseGrainedEvent(_function));
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0)

Aggregations

Procedure0 (org.eclipse.xtext.xbase.lib.Procedures.Procedure0)97 Test (org.junit.Test)76 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)52 BadLocationException (org.eclipse.jface.text.BadLocationException)11 AbstractBuilderParticipantTest (org.eclipse.xtext.builder.impl.AbstractBuilderParticipantTest)10 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)10 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)6 LocalArgumentsVariable (org.eclipse.n4js.n4JS.LocalArgumentsVariable)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)5 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)4 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)3 IFile (org.eclipse.core.resources.IFile)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)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 HashMap (java.util.HashMap)1 List (java.util.List)1