Search in sources :

Example 91 with QuickfixTestBuilder

use of org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder in project xtext-xtend by eclipse.

the class QuickfixTest method missingClass.

@Test
public void missingClass() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Bar| bar");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabelsSubset = this.builder.create("Foo.xtend", _builder).assertIssueCodes(Diagnostic.LINKING_DIAGNOSTIC).assertResolutionLabelsSubset("Create Xtend class \'Bar\'", "Create Java class \'Bar\'", "Create Java interface \'Bar\'", "Create local Xtend class \'Bar\'", "Create local Xtend interface \'Bar\'");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Bar bar");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Bar {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabelsSubset.assertModelAfterQuickfix("Create local Xtend class \'Bar\'", _builder_1);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Foo {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("Bar bar");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("interface Bar {");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertModelAfterQuickfix.assertModelAfterQuickfix("Create local Xtend interface \'Bar\'", _builder_2);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 92 with QuickfixTestBuilder

use of org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder in project xtext-xtend by eclipse.

the class QuickfixTest method unreachableIfBlock_5.

@Test
public void unreachableIfBlock_5() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.io.IOException");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("Object y");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(Object x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (x instanceof Exception) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} else if (y instanceof Exception) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} else if (Bar.z instanceof Exception) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("1");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} else if (x instanceof IOException) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} else if (y instanceof IOException) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} else if (Bar.z instanceof IOExc|eption) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("2");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static Object z");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.UNREACHABLE_IF_BLOCK).assertResolutionLabels("Remove if block", "Move if block up");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.io.IOException");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("Object y");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo(Object x) {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("if (x instanceof Exception) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("1");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} else if (y instanceof Exception) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("2");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} else if (Bar.z instanceof IOException) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("2");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} else if (Bar.z instanceof Exception) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("1");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} else if (x instanceof IOException) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("2");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} else if (y instanceof IOException) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("2");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("public static Object z");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix("Move if block up", _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 93 with QuickfixTestBuilder

use of org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder in project xtext-xtend by eclipse.

the class QuickfixTest method duplicateImport_8.

@Test
public void duplicateImport_8() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.lang.String.*");
    _builder.newLine();
    _builder.append("import static extension java.lang.String.valueOf|");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("valueOf(1)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.IMPORT_UNUSED).assertResolutionLabels("Organize imports");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import static java.lang.String.*");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("valueOf(1)");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix(_builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 94 with QuickfixTestBuilder

use of org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder in project xtext-xtend by eclipse.

the class QuickfixTest method unreachableCatchBlock.

@Test
public void unreachableCatchBlock() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("try {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch (Exception e) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch (java.io.IOExc|eption e) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch (java.io.FileNotFoundException e) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.UNREACHABLE_CATCH_BLOCK).assertResolutionLabels("Remove catch block", "Move catch block up");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("try {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} catch (Exception e) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("} catch (java.io.FileNotFoundException e) {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabels.assertModelAfterQuickfix("Remove catch block", _builder_1);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Foo {");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def foo() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("try {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("} catch (java.io.IOException e) {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("} catch (Exception e) {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("} catch (java.io.FileNotFoundException e) {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertModelAfterQuickfix.assertModelAfterQuickfix("Move catch block up", _builder_2);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 95 with QuickfixTestBuilder

use of org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder in project xtext-xtend by eclipse.

the class QuickfixTest method missingMethodInInterface.

@Test
public void missingMethodInInterface() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(Bar bar) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("bar.bar|()");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("interface Bar {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabelsSubset = this.builder.create("Foo.xtend", _builder).assertFeatureCallLinkingIssue().assertResolutionLabelsSubset("Create method \'bar()\' in \'Bar\'");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo(Bar bar) {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("bar.bar()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("interface Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def void bar()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _assertResolutionLabelsSubset.assertModelAfterQuickfix("Create method \'bar()\' in \'Bar\'", _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Aggregations

QuickfixTestBuilder (org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder)122 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)122 Test (org.junit.Test)122 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 XtextEditor (org.eclipse.xtext.ui.editor.XtextEditor)1