Search in sources :

Example 46 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method makeFieldPublic.

@Test
public void makeFieldPublic() {
    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 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", "private String bar;", "public 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 47 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method changeImports4.

@Test
public void changeImports4() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("import java.util.List;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public static class Bar2 {");
        _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", "import java.util.List;", "import java.awt.List;");
        };
        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)

Example 48 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method removePrimaryTopLevelType.

@Test
public void removePrimaryTopLevelType() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Bar {}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            this.save("/mypackage/Bar.java", "public class 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 49 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method addNestedTypesWithinDefaultPackage2.

@Test
public void addNestedTypesWithinDefaultPackage2() {
    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("// nested types");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("Bar.java", _builder.toString());
        final Procedure0 _function = () -> {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("public class Foo3 {}");
            this.save("Bar.java", "// nested types", _builder_1.toString());
        };
        this.assertThereAreDeltas(_function, "Bar$Foo", "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 50 with Procedure0

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

the class AbstractSingleEditorQueuedBuildTest method renameMethod.

@Test
public void renameMethod() {
    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\t");
        _builder.append("System.out.println(\"Hello world!\");");
        _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", "bar()", "bar2()");
        };
        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)

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