Search in sources :

Example 26 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.

the class SeveralEditorsQueuedBuildTest method undoEditorChangesAndClose.

@Test
public void undoEditorChangesAndClose() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public void foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypackage;");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("public class Bar {");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public void bar() {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
        this.reset();
        final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.reconcile(fooEditor, "foo2", "foo");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.close(fooEditor);
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.save(barEditor);
        this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this.confirmDeltas();
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 27 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.

the class SeveralEditorsQueuedBuildTest method undoEditorChangesAndSave.

@Test
public void undoEditorChangesAndSave() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public void foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypackage;");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("public class Bar {");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public void bar() {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
        this.reset();
        final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.reconcile(fooEditor, "foo2", "foo");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.save(fooEditor);
        this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Foo");
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this.confirmDeltas();
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.save(barEditor);
        this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this.confirmDeltas();
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 28 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.

the class SeveralEditorsQueuedBuildTest method saveSeveralEditorsOneByOne.

@Test
public void saveSeveralEditorsOneByOne() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("package mypackage;");
        _builder.newLine();
        _builder.newLine();
        _builder.append("public class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("public void foo() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("package mypackage;");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("public class Bar {");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("public void bar() {");
        _builder_1.newLine();
        _builder_1.append("\t");
        _builder_1.append("}");
        _builder_1.newLine();
        _builder_1.newLine();
        _builder_1.append("}");
        _builder_1.newLine();
        this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
        this.reset();
        final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this._javaEditorExtension.save(barEditor);
        this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this.confirmDeltas();
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
        this._javaEditorExtension.save(fooEditor);
        this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Foo");
        this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
        this.confirmDeltas();
        this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
        this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Foo");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractQueuedBuildDataTest(org.eclipse.xtend.ide.tests.builder.AbstractQueuedBuildDataTest) Test(org.junit.Test)

Example 29 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor 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 30 with ITextEditor

use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.

the class AbstractSingleEditorQueuedBuildTest method removeNestedTypesWithinDefaultPackage.

@Test
public void removeNestedTypesWithinDefaultPackage() {
    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, "public class Foo { public class Foo3 {} }", "");
                    _xblockexpression = this._javaEditorExtension.changeContent(it, "public static class Foo2 {}", "");
                }
                return _xblockexpression;
            };
            this.save("Bar.java", _function_1);
        };
        this.assertThereAreDeltas(_function, "Bar", "Bar$Foo", "Bar$Foo2", "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)

Aggregations

ITextEditor (org.eclipse.ui.texteditor.ITextEditor)233 IEditorPart (org.eclipse.ui.IEditorPart)91 IDocument (org.eclipse.jface.text.IDocument)73 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)39 ITextSelection (org.eclipse.jface.text.ITextSelection)34 IFile (org.eclipse.core.resources.IFile)33 Test (org.junit.Test)31 BadLocationException (org.eclipse.jface.text.BadLocationException)27 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)25 PartInitException (org.eclipse.ui.PartInitException)23 ISelection (org.eclipse.jface.viewers.ISelection)19 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)17 IRegion (org.eclipse.jface.text.IRegion)16 Annotation (org.eclipse.jface.text.source.Annotation)16 ArrayList (java.util.ArrayList)15 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)15 IResource (org.eclipse.core.resources.IResource)14 IEditorInput (org.eclipse.ui.IEditorInput)14 CoreException (org.eclipse.core.runtime.CoreException)13 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)12