Search in sources :

Example 26 with QuickfixTestBuilder

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

the class QuickfixTest method duplicateImport_3.

@Test
public void duplicateImport_3() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.lang.String.valueOf");
    _builder.newLine();
    _builder.append("import static extension java.lang.String.*|");
    _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.valueOf");
    _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 27 with QuickfixTestBuilder

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

the class QuickfixTest method missingTypeAsAnnotationValue.

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

Example 28 with QuickfixTestBuilder

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

the class QuickfixTest method missingSynchronized.

@Test
public void missingSynchronized() {
    this.builder.setSeverity(org.eclipse.xtend.core.validation.IssueCodes.MISSING_SYNCHRONIZED, "warning");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def synchronized int doSth() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("0");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class Foo extends Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override int doSth|() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("0");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("XXX.xtend", _builder).assertIssueCodes(org.eclipse.xtend.core.validation.IssueCodes.MISSING_SYNCHRONIZED).assertResolutionLabels("Mark operation as synchronized");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def synchronized int doSth() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("0");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("class Foo extends Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("override synchronized int doSth() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("0");
    _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 29 with QuickfixTestBuilder

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

the class QuickfixTest method unreachableCase_2.

@Test
public void unreachableCase_2() {
    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("switch x : new Exception {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("Exception: 1");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("java.io.IOException: 2");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("java.io.FileNo|tFoundException: 3");
    _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_CASE).assertResolutionLabels("Remove case", "Move case 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("switch x : new Exception {");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("Exception: 1");
    _builder_1.newLine();
    _builder_1.append("\t\t\t");
    _builder_1.append("java.io.IOException: 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();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabels.assertModelAfterQuickfix("Remove 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() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("switch x : new Exception {");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("java.io.FileNotFoundException: 3");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("Exception: 1");
    _builder_2.newLine();
    _builder_2.append("\t\t\t");
    _builder_2.append("java.io.IOException: 2");
    _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 case up", _builder_2);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 30 with QuickfixTestBuilder

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

the class QuickfixTest method ambiguousImplicitMethodCallWithIsAndGet.

@Test
public void ambiguousImplicitMethodCallWithIsAndGet() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def foo() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("|name");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def boolean isName() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("true");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def String getName() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("null");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.AMBIGUOUS_FEATURE_CALL).assertResolutionLabels("Change to \'isName()\'", "Change to \'getName()\'");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("isName()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def boolean isName() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("true");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def String getName() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("null");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabels.assertModelAfterQuickfix("Change to \'isName()\'", _builder_1);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Foo {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def foo() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("getName()");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def boolean isName() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("true");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def String getName() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("null");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertModelAfterQuickfix.assertModelAfterQuickfix("Change to \'getName()\'", _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