Search in sources :

Example 86 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project applause by applause.

the class EntityDataAccessExtensions method parameterList.

public String parameterList(final DataSourceAccessMethod it) {
    EList<Parameter> _declaredParameters = it.getDeclaredParameters();
    final Function1<Parameter, String> _function = new Function1<Parameter, String>() {

        public String apply(final Parameter param) {
            Type _type = param.getType();
            String _typeName = EntityDataAccessExtensions.this._typeExtensions.typeName(_type);
            String _plus = (_typeName + " *");
            Type _type_1 = param.getType();
            String _parameterName = EntityDataAccessExtensions.this.parameterName(_type_1);
            String _plus_1 = (_plus + _parameterName);
            return _plus_1;
        }
    };
    List<String> _map = ListExtensions.<Parameter, String>map(_declaredParameters, _function);
    String _join = IterableExtensions.join(_map, ", ");
    return _join;
}
Also used : Type(org.applause.lang.applauseDsl.Type) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Parameter(org.applause.lang.applauseDsl.Parameter)

Example 87 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-xtend by eclipse.

the class DependentElementsCalculatorTests method testPolymorphicDispatch.

@Test
public void testPolymorphicDispatch() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def dispatch foo(Number it) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def dispatch foo(String it) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile fooFile = this.testHelper.xtendFile("Foo", _builder.toString());
        IResourcesSetupUtil.waitForBuild();
        XtendTypeDeclaration _get = fooFile.getXtendTypes().get(0);
        final XtendClass fooClass = ((XtendClass) _get);
        final XtendMember fooMethod1 = fooClass.getMembers().get(1);
        NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
        final Iterable<URI> dependentElementURIs = this.dependentElementsCalculator.getDependentElementURIs(fooMethod1, _nullProgressMonitor);
        Assert.assertEquals(5, IterableExtensions.size(dependentElementURIs));
        EList<XtendMember> _members = fooClass.getMembers();
        EList<JvmMember> _members_1 = this.associations.getInferredType(fooClass).getMembers();
        final Function1<EObject, Boolean> _function = (EObject it) -> {
            return Boolean.valueOf((!(it instanceof JvmConstructor)));
        };
        final Consumer<EObject> _function_1 = (EObject it) -> {
            final Function1<URI, Boolean> _function_2 = (URI element) -> {
                URI _uRI = EcoreUtil.getURI(it);
                return Boolean.valueOf(Objects.equal(element, _uRI));
            };
            Assert.assertTrue(it.toString(), IterableExtensions.<URI>exists(dependentElementURIs, _function_2));
        };
        IterableExtensions.<EObject>toList(IterableExtensions.<EObject>filter(Iterables.<EObject>concat(_members, _members_1), _function)).forEach(_function_1);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) URI(org.eclipse.emf.common.util.URI) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) JvmMember(org.eclipse.xtext.common.types.JvmMember) Test(org.junit.Test)

Example 88 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-xtend by eclipse.

the class AbstractSingleEditorQueuedBuildTest method removeNestedTypes.

@Test
public void removeNestedTypes() {
    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("public class Foo { public class Foo3 {} }");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public static class Foo2 {}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            final Function1<ITextEditor, ITextEditor> _function_1 = (ITextEditor it) -> {
                ITextEditor _xblockexpression = null;
                {
                    this._javaEditorExtension.changeContent(it, "public class Foo { public class Foo3 {} }", "");
                    _xblockexpression = this._javaEditorExtension.changeContent(it, "public static class Foo2 {}", "");
                }
                return _xblockexpression;
            };
            this.save("/mypackage/Bar.java", _function_1);
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar", "mypackage.Bar$Foo", "mypackage.Bar$Foo2", "mypackage.Bar$Foo$Foo3");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 89 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-xtend by eclipse.

the class AbstractSingleEditorQueuedBuildTest method renameNestedTypes.

@Test
public void renameNestedTypes() {
    try {
        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.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.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            final Function1<ITextEditor, ITextEditor> _function_1 = (ITextEditor it) -> {
                ITextEditor _xblockexpression = null;
                {
                    this._javaEditorExtension.changeContent(it, " Foo ", " NewFoo ");
                    this._javaEditorExtension.changeContent(it, " Foo2 ", " NewFoo2 ");
                    _xblockexpression = this._javaEditorExtension.changeContent(it, " Foo3 ", " NewFoo3 ");
                }
                return _xblockexpression;
            };
            this.save("/mypackage/Bar.java", _function_1);
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar", "mypackage.Bar$Foo", "mypackage.Bar$Foo2", "mypackage.Bar$NewFoo", "mypackage.Bar$NewFoo2", "mypackage.Bar$NewFoo$NewFoo3", "mypackage.Bar$Foo$Foo3");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 90 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-xtend by eclipse.

the class AbstractSingleEditorQueuedBuildTest method removePublicAndPrivateMethods.

@Test
public void removePublicAndPrivateMethods() {
    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("public void bar() {}");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("private void bar2() {}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            final Function1<ITextEditor, ITextEditor> _function_1 = (ITextEditor it) -> {
                return this._javaEditorExtension.changeContent(this._javaEditorExtension.changeContent(it, "public void bar() {}", ""), "private void bar2() {}", "");
            };
            this.save("/mypackage/Bar.java", _function_1);
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Aggregations

Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)131 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)80 Test (org.junit.Test)54 List (java.util.List)20 ArrayList (java.util.ArrayList)19 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)17 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)17 EList (org.eclipse.emf.common.util.EList)14 EObject (org.eclipse.emf.ecore.EObject)14 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)13 Method (java.lang.reflect.Method)12 Set (java.util.Set)10 IMethod (org.eclipse.jdt.core.IMethod)10 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)9 ScreenListItemCell (org.applause.lang.applauseDsl.ScreenListItemCell)8 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)8 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)8 ColumnType (com.robotoworks.mechanoid.db.sqliteModel.ColumnType)7 URI (org.eclipse.emf.common.util.URI)7 Resource (org.eclipse.emf.ecore.resource.Resource)7