use of org.eclipse.xtend.ide.refactoring.ExtractMethodRefactoring in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method test_Bug_453376.
@Test
public void test_Bug_453376() {
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("$var x = 1$");
_builder.newLine();
_builder.append("\t\t");
_builder.append("var z = x");
_builder.newLine();
_builder.append("\t\t");
_builder.append("var y = x");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
};
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("var x = bar()");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("var z = x");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("var y = x");
_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("1");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertAfterExtract(_builder, _function, _builder_1);
}
use of org.eclipse.xtend.ide.refactoring.ExtractMethodRefactoring in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testTemplateExpression_11.
@Test
public void testTemplateExpression_11() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(String value) \'");
_builder.append("\'\'");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$Hello ");
_builder.append("�", "\t\t");
_builder.append(" /* prefix */ val$ue /* postfix */ ");
_builder.append("�", "\t\t");
_builder.append("!");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\'");
_builder.append("\'\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
};
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def foo(String value) \'");
_builder_1.append("\'\'");
_builder_1.append("�", "\t");
_builder_1.append("bar(value)");
_builder_1.append("�", "\t");
_builder_1.append("!");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("\'");
_builder_1.append("\'\'");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def bar(String value)");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("\'");
_builder_1.append("\'\'");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("Hello ");
_builder_1.append("�", "\t\t\t");
_builder_1.append(" /* prefix */ value /* postfix */ ");
_builder_1.append("�", "\t\t\t");
_builder_1.append("\'");
_builder_1.append("\'\'");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertAfterExtract(_builder, _function, _builder_1);
}
use of org.eclipse.xtend.ide.refactoring.ExtractMethodRefactoring in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testFailOnReturns.
@Test
public void testFailOnReturns() {
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("$if(true) ");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("return");
_builder.newLine();
_builder.append("\t\t");
_builder.append("else ");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("val y=42$");
_builder.newLine();
_builder.append("\t\t");
_builder.append("y");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
};
this.assertExtractForbidden(_builder, _function, "control flow");
}
use of org.eclipse.xtend.ide.refactoring.ExtractMethodRefactoring in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testClosure_2.
@Test
public void testClosure_2() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(String baz) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("newArrayList(baz).map$[String it|toFirstUpper]$");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
it.setExplicitlyDeclareReturnType(true);
};
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def foo(String baz) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("newArrayList(baz).map(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 (String)=>String bar() {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("[String it|toFirstUpper]");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertAfterExtract(_builder, _function, _builder_1);
}
use of org.eclipse.xtend.ide.refactoring.ExtractMethodRefactoring in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testTemplateExpression_01.
@Test
public void testTemplateExpression_01() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() \'");
_builder.append("\'\'");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$Hello World!$");
_builder.newLine();
_builder.append("\t");
_builder.append("\'");
_builder.append("\'\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
};
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def foo() \'");
_builder_1.append("\'\'");
_builder_1.append("�", "\t");
_builder_1.append("bar()");
_builder_1.append("�", "\t");
_builder_1.append("\'");
_builder_1.append("\'\'");
_builder_1.newLineIfNotEmpty();
_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("\'");
_builder_1.append("\'\'");
_builder_1.newLine();
_builder_1.append("\t\t\t");
_builder_1.append("Hello World!");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("\'");
_builder_1.append("\'\'");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.assertAfterExtract(_builder, _function, _builder_1);
}
Aggregations