Search in sources :

Example 16 with QuickfixTestBuilder

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

the class QuickfixTest method fixPackageName_3.

@Test
public void fixPackageName_3() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("|import static C.D.*");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("staticM");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class D {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("static def void staticM() {}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("test/Foo.xtend", _builder).assertIssueCodes(org.eclipse.xtend.core.validation.IssueCodes.WRONG_PACKAGE).assertResolutionLabels("Change package declaration to \'test\'");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package test");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import static test.C.D.*");
    _builder_1.newLine();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def void m() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("staticM");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("class C {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("static class D {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("static def void staticM() {}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _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 17 with QuickfixTestBuilder

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

the class QuickfixTest method unusedImport.

@Test
public void unusedImport() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.List|");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _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("class Foo {");
    _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 18 with QuickfixTestBuilder

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

the class QuickfixTest method redundantModifiers_05.

@Test
public void redundantModifiers_05() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("p|ublic def m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(org.eclipse.xtend.core.validation.IssueCodes.REDUNDANT_MODIFIER).assertResolutionLabels("Remove the redundant modifier.");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def m() {}");
    _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 19 with QuickfixTestBuilder

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

the class QuickfixTest method redundantModifiers_11.

@Test
public void redundantModifiers_11() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def m(){}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class B extends A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override de|f m() {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(org.eclipse.xtend.core.validation.IssueCodes.REDUNDANT_MODIFIER).assertResolutionLabels("Remove the redundant modifier.");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def m(){}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("class B extends A {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override m() {}");
    _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 20 with QuickfixTestBuilder

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

the class QuickfixTest method incompleteCasesOnEnum.

@Test
public void incompleteCasesOnEnum() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo(Color x) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("switch |x {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("case RED: {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _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("enum Color {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("RED, GREEN, BLUE");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.INCOMPLETE_CASES_ON_ENUM).assertResolutionLabels("Add \'default\' case", "Add missing cases");
    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(Color x) {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("switch x {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("case RED: {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("default: {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("}");
    _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("enum Color {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("RED, GREEN, BLUE");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabels.assertModelAfterQuickfix("Add \'default\' case", _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(Color x) {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("switch x {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("case RED: {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("case GREEN: {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("case BLUE: {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("}");
    _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();
    _builder_2.newLine();
    _builder_2.append("enum Color {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("RED, GREEN, BLUE");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertModelAfterQuickfix.assertModelAfterQuickfix("Add missing cases", _builder_2);
}
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