use of org.eclipse.xtext.ui.refactoring.IRenameStrategy in project xtext-xtend by eclipse.
the class RenameStrategyTest method testInferredClassRenamed.
@Test
public void testInferredClassRenamed() throws Exception {
XtendClass fooClass = (XtendClass) testHelper.xtendFile("Foo", "class Foo { }").getXtendTypes().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(fooClass);
renameStrategy.applyDeclarationChange("Bar", fooClass.eResource().getResourceSet());
JvmGenericType inferredType = associations.getInferredType(fooClass);
JvmConstructor inferredConstructor = associations.getInferredConstructor(fooClass);
assertEquals("Bar", fooClass.getName());
assertEquals("Bar", inferredType.getSimpleName());
assertEquals("Bar", inferredConstructor.getSimpleName());
renameStrategy.revertDeclarationChange(fooClass.eResource().getResourceSet());
inferredType = associations.getInferredType(fooClass);
inferredConstructor = associations.getInferredConstructor(fooClass);
assertEquals("Foo", fooClass.getName());
assertEquals("Foo", inferredType.getSimpleName());
assertEquals("Foo", inferredConstructor.getSimpleName());
}
use of org.eclipse.xtext.ui.refactoring.IRenameStrategy in project xtext-xtend by eclipse.
the class RenameStrategyTest method testDispatchMethods.
@Test
public void testDispatchMethods() throws Exception {
XtendClass fooClass = (XtendClass) testHelper.xtendFile("Foo", "class Foo { def dispatch foo(Number it) {} def dispatch foo(String it) {} }").getXtendTypes().get(0);
IResourcesSetupUtil.waitForBuild();
XtendFunction fooMethod0 = (XtendFunction) fooClass.getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(fooMethod0);
assertNotNull(renameStrategy);
renameStrategy.applyDeclarationChange("bar", fooMethod0.eResource().getResourceSet());
for (XtendFunction f : filter(fooClass.getMembers(), XtendFunction.class)) {
assertEquals("bar", f.getName());
assertEquals("_bar", associations.getDirectlyInferredOperation(f).getSimpleName());
assertEquals("bar", associations.getDispatchOperation(f).getSimpleName());
}
renameStrategy.revertDeclarationChange(fooMethod0.eResource().getResourceSet());
for (XtendFunction f : filter(fooClass.getMembers(), XtendFunction.class)) {
assertEquals("foo", f.getName());
assertEquals("_foo", associations.getDirectlyInferredOperation(f).getSimpleName());
assertEquals("foo", associations.getDispatchOperation(f).getSimpleName());
}
}
use of org.eclipse.xtext.ui.refactoring.IRenameStrategy in project xtext-xtend by eclipse.
the class RenameStrategyTest method testInferredMethodRenamed.
@Test
public void testInferredMethodRenamed() throws Exception {
XtendFunction fooMethod = (XtendFunction) ((XtendClass) testHelper.xtendFile("Foo", "class Foo { def Foo foo() {this} }").getXtendTypes().get(0)).getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(fooMethod);
renameStrategy.applyDeclarationChange("bar", fooMethod.eResource().getResourceSet());
assertEquals("bar", fooMethod.getName());
JvmOperation inferredOperation = associations.getDirectlyInferredOperation(fooMethod);
assertEquals("bar", inferredOperation.getSimpleName());
renameStrategy.revertDeclarationChange(fooMethod.eResource().getResourceSet());
inferredOperation = associations.getDirectlyInferredOperation(fooMethod);
assertEquals("foo", fooMethod.getName());
assertEquals("foo", inferredOperation.getSimpleName());
}
use of org.eclipse.xtext.ui.refactoring.IRenameStrategy in project xtext-xtend by eclipse.
the class RenameStrategyTest method testXtendConstructorIgnored.
@Test
public void testXtendConstructorIgnored() throws Exception {
XtendConstructor constructor = (XtendConstructor) ((XtendClass) testHelper.xtendFile("Foo", "class Foo { new() {} }").getXtendTypes().get(0)).getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(constructor);
assertNull(renameStrategy);
}
Aggregations