Search in sources :

Example 66 with QuickfixTestBuilder

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

the class QuickfixTest method missingConstructorOtherClassTwoFiles.

@Test
public void missingConstructorOtherClassTwoFiles() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo| {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    this.builder.create("Foo.xtend", _builder);
    final XtextEditor myEditor = this.builder.getEditor();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def foo() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("new Foo(1)|");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Bar.xtend", _builder_1).assertIssueCodes(IssueCodes.INVALID_NUMBER_OF_ARGUMENTS).assertResolutionLabels("Create constructor \'new(int)\' in \'Foo\'");
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Bar {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def foo() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("new Foo(1)");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix(_builder_2);
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("class Foo {");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.append("new(int i) {");
    _builder_3.newLine();
    _builder_3.append("\t\t");
    _builder_3.append(QuickfixTest.defaultBody, "\t\t");
    _builder_3.newLineIfNotEmpty();
    _builder_3.append("\t");
    _builder_3.append("}");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.newLine();
    _builder_3.append("}");
    _builder_3.newLine();
    Assert.assertEquals(_builder_3.toString(), myEditor.getDocument().get());
}
Also used : XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 67 with QuickfixTestBuilder

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

the class QuickfixTest method missingMemberOtherClass.

@Test
public void missingMemberOtherClass() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo {}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def bar(Foo foo) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("foo.foo|");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertFeatureCallLinkingIssue().assertResolutionLabels("Create method \'foo()\' in \'Foo\'", "Create method \'getFoo()\' in \'Foo\'", "Create extension method \'foo(Foo)\'", "Create extension method \'getFoo(Foo)\'");
    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(QuickfixTest.defaultBody, "\t\t");
    _builder_1.newLineIfNotEmpty();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def bar(Foo foo) {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("foo.foo");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix = _assertResolutionLabels.assertModelAfterQuickfix("Create method \'foo()\' in \'Foo\'", _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 getFoo() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append(QuickfixTest.defaultBody, "\t\t");
    _builder_2.newLineIfNotEmpty();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("class Bar {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def bar(Foo foo) {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("foo.foo");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix_1 = _assertModelAfterQuickfix.assertModelAfterQuickfix("Create method \'getFoo()\' in \'Foo\'", _builder_2);
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("class Foo {}");
    _builder_3.newLine();
    _builder_3.newLine();
    _builder_3.append("class Bar {");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.append("def bar(Foo foo) {");
    _builder_3.newLine();
    _builder_3.append("\t\t");
    _builder_3.append("foo.foo");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.append("}");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.append("def foo(Foo foo) {");
    _builder_3.newLine();
    _builder_3.append("\t\t");
    _builder_3.append(QuickfixTest.defaultBody, "\t\t");
    _builder_3.newLineIfNotEmpty();
    _builder_3.append("\t");
    _builder_3.append("}");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.newLine();
    _builder_3.append("}");
    _builder_3.newLine();
    QuickfixTestBuilder _assertModelAfterQuickfix_2 = _assertModelAfterQuickfix_1.assertModelAfterQuickfix("Create extension method \'foo(Foo)\'", _builder_3);
    StringConcatenation _builder_4 = new StringConcatenation();
    _builder_4.append("class Foo {}");
    _builder_4.newLine();
    _builder_4.newLine();
    _builder_4.append("class Bar {");
    _builder_4.newLine();
    _builder_4.append("\t");
    _builder_4.append("def bar(Foo foo) {");
    _builder_4.newLine();
    _builder_4.append("\t\t");
    _builder_4.append("foo.foo");
    _builder_4.newLine();
    _builder_4.append("\t");
    _builder_4.append("}");
    _builder_4.newLine();
    _builder_4.append("\t");
    _builder_4.newLine();
    _builder_4.append("\t");
    _builder_4.append("def getFoo(Foo foo) {");
    _builder_4.newLine();
    _builder_4.append("\t\t");
    _builder_4.append(QuickfixTest.defaultBody, "\t\t");
    _builder_4.newLineIfNotEmpty();
    _builder_4.append("\t");
    _builder_4.append("}");
    _builder_4.newLine();
    _builder_4.append("\t");
    _builder_4.newLine();
    _builder_4.append("}");
    _builder_4.newLine();
    _assertModelAfterQuickfix_2.assertModelAfterQuickfix("Create extension method \'getFoo(Foo)\'", _builder_4);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 68 with QuickfixTestBuilder

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

the class QuickfixTest method wildcardImport.

@Test
public void wildcardImport() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.*|");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("List foo");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.IMPORT_WILDCARD_DEPRECATED).assertResolutionLabels("Organize imports");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("import java.util.List");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class Foo {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("List 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 69 with QuickfixTestBuilder

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

the class QuickfixTest method invalidTypeArgsOnTypeLiteral_02.

@Test
public void invalidTypeArgsOnTypeLiteral_02() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class C {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def Object m() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("java.util.  < /* |comments are not preserved, WS not removed */ String>List");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertResolutionLabels = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.INVALID_TYPE_ARGUMENTS_ON_TYPE_LITERAL).assertResolutionLabels("Remove invalid type argument");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class C {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def Object m() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("java.util.  List");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix("Remove invalid type argument", _builder_1);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 70 with QuickfixTestBuilder

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

the class QuickfixTest method unreachableIfBlock_3.

@Test
public void unreachableIfBlock_3() {
    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 IOExc|eption) {");
    _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 IOException) {");
    _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 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 (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 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 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 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)

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