use of org.eclipse.jdt.internal.corext.refactoring.ParameterInfo in project xtext-xtend by eclipse.
the class ExtractMethodUserInputPage method createParameterControl.
protected void createParameterControl(Composite result) {
if (!refactoring.getParameterInfos().isEmpty()) {
ChangeParametersControl cp = new ChangeParametersControl(result, SWT.NONE, "Parameters", new IParameterListChangeListener() {
@Override
public void parameterChanged(ParameterInfo parameter) {
parameterModified();
}
@Override
public void parameterListChanged() {
parameterModified();
}
@Override
public void parameterAdded(ParameterInfo parameter) {
updatePreview();
}
}, ChangeParametersControl.Mode.EXTRACT_METHOD);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
cp.setLayoutData(gridData);
cp.setInput(refactoring.getParameterInfos());
}
}
use of org.eclipse.jdt.internal.corext.refactoring.ParameterInfo in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testSwapParameterNames.
@Test
public void testSwapParameterNames() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(int i, int j) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$i-j$");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
ParameterInfo _get = it.getParameterInfos().get(0);
_get.setNewName("j");
ParameterInfo _get_1 = it.getParameterInfos().get(1);
_get_1.setNewName("i");
};
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def foo(int i, int j) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("bar(i, j)");
_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(int j, int i) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("j-i");
_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.jdt.internal.corext.refactoring.ParameterInfo in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testFailOnDuplicateParameterName.
@Test
public void testFailOnDuplicateParameterName() {
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("val x = 4");
_builder.newLine();
_builder.append("\t\t");
_builder.append("val y = 2");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$x+y$");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
ParameterInfo _get = it.getParameterInfos().get(1);
_get.setNewName("x");
};
this.assertExtractForbidden(_builder, _function, "duplicate");
}
use of org.eclipse.jdt.internal.corext.refactoring.ParameterInfo in project xtext-xtend by eclipse.
the class ExtractMethodIntegrationTest method testRenameParameter.
@Test
public void testRenameParameter() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(int shrinkMe, int expandMe) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$shrinkMe + expandMe - shrinkMe- expandMe$");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final Procedure1<ExtractMethodRefactoring> _function = (ExtractMethodRefactoring it) -> {
ParameterInfo _get = it.getParameterInfos().get(0);
_get.setNewName("s");
ParameterInfo _get_1 = it.getParameterInfos().get(1);
_get_1.setNewName("expandMeMore");
};
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("class Foo {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("def foo(int shrinkMe, int expandMe) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("bar(shrinkMe, expandMe)");
_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(int s, int expandMeMore) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("s + expandMeMore - s- expandMeMore");
_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.jdt.internal.corext.refactoring.ParameterInfo in project che by eclipse.
the class RenameParametersTest method modifyInfos.
private void modifyInfos(List list, String[] newNames) {
int i = 0;
for (Iterator iter = list.iterator(); iter.hasNext(); i++) {
ParameterInfo info = (ParameterInfo) iter.next();
info.setNewName(newNames[i]);
}
}
Aggregations