use of org.eclipse.xtext.ui.refactoring.impl.RenamedElementTracker in project xtext-eclipse by eclipse.
the class RenamedElementTrackerTest method testResolveElements.
@Test
public void testResolveElements() throws Exception {
URI resourceURI = URI.createFileURI("testresource.refactoringtestlanguage");
String textualModel = "A { B { C { ref A.B } } ref B }";
XtextResource resource = getResource(textualModel, resourceURI.toString());
Element elementA = (Element) resource.getContents().get(0).eContents().get(0);
Element elementB = elementA.getContained().get(0);
Element elementC = elementB.getContained().get(0);
URI uriB = EcoreUtil.getURI(elementB);
URI uriC = EcoreUtil.getURI(elementC);
String newName = "newB";
List<URI> renamedElementURIs = newArrayList(uriB, uriC);
IRenameStrategy renameStrategy = getInjector().getInstance(IRenameStrategy.Provider.class).get(elementB, null);
IRenamedElementTracker renamedElementTracker = new RenamedElementTracker();
Map<URI, URI> original2newElementURIs = renamedElementTracker.renameAndTrack(renamedElementURIs, newName, resource.getResourceSet(), renameStrategy, new NullProgressMonitor());
assertEquals("B", elementB.getName());
assertEquals(2, original2newElementURIs.size());
assertEquals(resourceURI.appendFragment(newName), original2newElementURIs.get(uriB));
assertEquals(uriC, original2newElementURIs.get(uriC));
}
Aggregations