Search in sources :

Example 36 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method addNestedTypes.

@Test
public void addNestedTypes() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("public class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("// nested types");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("public class Foo {");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("public class Foo3 {}");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("}");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("public static class Foo2 {}");
            _builder_1.newLine();
            this.save("/mypackage/Bar.java", "// nested types", _builder_1.toString());
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar", "mypackage.Bar$Foo", "mypackage.Bar$Foo2", "mypackage.Bar$Foo$Foo3");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
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 37 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method addPublicMethod.

@Test
public void addPublicMethod() {
    try {
        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.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("public class Bar {");
            _builder_1.newLine();
            _builder_1.newLine();
            _builder_1.append("\t");
            _builder_1.append("public void bar2() {}");
            _builder_1.newLine();
            _builder_1.newLine();
            this.save("/mypackage/Bar.java", "public class Bar {", _builder_1.toString());
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
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 38 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method makeFieldPrivate.

@Test
public void makeFieldPrivate() {
    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 String bar;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            this.save("/mypackage/Bar.java", "public String bar;", "private String bar;");
        };
        this.assertThereAreDeltas(_function, "mypackage.Bar");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
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 39 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method renameNestedTypesWithinDefaultPackage.

@Test
public void renameNestedTypesWithinDefaultPackage() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _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("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("Bar.java", _function_1);
        };
        this.assertThereAreDeltas(_function, "Bar", "Bar$Foo", "Bar$Foo2", "Bar$NewFoo", "Bar$NewFoo2", "Bar$NewFoo$NewFoo3", "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 40 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method changePackageDeclaration.

@Test
public void changePackageDeclaration() {
    try {
        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.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            this.save("/mypackage/Bar.java", "package mypackage;", "package mypackage2;");
        };
        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) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Aggregations

Procedure0 (org.eclipse.xtext.xbase.lib.Procedures.Procedure0)102 Test (org.junit.Test)79 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)53 AbstractQueuedBuildDataTest (org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest)50 AbstractBuilderParticipantTest (org.eclipse.xtext.builder.impl.AbstractBuilderParticipantTest)13 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)13 BadLocationException (org.eclipse.jface.text.BadLocationException)11 IFile (org.eclipse.core.resources.IFile)6 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 List (java.util.List)4 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)4 File (java.io.File)3 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)3 Matcher (java.util.regex.Matcher)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