Search in sources :

Example 1 with QuickfixTestBuilder

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

the class QuickfixTest method missingMemberStaticFieldContext.

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

Example 2 with QuickfixTestBuilder

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

the class QuickfixTest method constructorCallWithoutParentheses02.

@Test
public void constructorCallWithoutParentheses02() {
    this.builder.setSeverity(IssueCodes.OPERATION_WITHOUT_PARENTHESES, "error");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import java.util.ArrayList");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val foo = new ArrayList<String   >|");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertIssueCodes = this.builder.create("Foo.xtend", _builder).assertIssueCodes(IssueCodes.OPERATION_WITHOUT_PARENTHESES);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("Add parentheses");
    QuickfixTestBuilder _assertResolutionLabels = _assertIssueCodes.assertResolutionLabels(_builder_1.toString());
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("import java.util.ArrayList");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("class Foo {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("val foo = new ArrayList<String   >()");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix(_builder_2);
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) QuickfixTestBuilder(org.eclipse.xtend.ide.tests.quickfix.QuickfixTestBuilder) Test(org.junit.Test)

Example 3 with QuickfixTestBuilder

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

the class QuickfixTest method duplicateImport_7.

@Test
public void duplicateImport_7() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("import static java.lang.String.*");
    _builder.newLine();
    _builder.append("import static 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.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def bar() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("valueOf(2)");
    _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.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def bar() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("valueOf(2)");
    _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 4 with QuickfixTestBuilder

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

the class QuickfixTest method missingMemberExplicitThis.

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

Example 5 with QuickfixTestBuilder

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

the class QuickfixTest method apiTypeInference02.

@Test
public void apiTypeInference02() {
    this.builder.setSeverity(org.eclipse.xtend.core.validation.IssueCodes.API_TYPE_INFERENCE, "error");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Foo<T> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public val |foo = <T>newArrayList");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    QuickfixTestBuilder _assertIssueCodes = this.builder.create("Foo.xtend", _builder).assertIssueCodes(org.eclipse.xtend.core.validation.IssueCodes.API_TYPE_INFERENCE);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("Infer type");
    QuickfixTestBuilder _assertResolutionLabels = _assertIssueCodes.assertResolutionLabels(_builder_1.toString());
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("import java.util.ArrayList");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("class Foo<T> {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("public val ArrayList<T> foo = <T>newArrayList");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    _assertResolutionLabels.assertModelAfterQuickfix(_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