use of org.eclipse.xtext.ide.server.rename.ChangeConverter2 in project xtext-core by eclipse.
the class DiagnosticResolution method apply.
public WorkspaceEdit apply() {
DiagnosticModificationContext modificationContext = factory.createModificationContext();
try {
XtextResource resource = options.getResource();
URI uri = resource.getURI();
ILanguageServerAccess access = options.getLanguageServerAccess();
WorkspaceEdit edit = new WorkspaceEdit();
ChangeConverter2 changeConverter = modificationContext.getConverterFactory().create(edit, access);
ResourceSet resourceSet = access.newLiveScopeResourceSet(uri);
XtextResource tmpResource = (XtextResource) resourceSet.getResource(uri, true);
CodeActionParams params = options.getCodeActionParams();
int offset = options.getDocument().getOffSet(params.getRange().getStart());
EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();
EObject obj = helper.resolveContainedElementAt(tmpResource, offset);
IChangeSerializer serializer = modificationContext.getSerializer();
serializer.addModification(obj, modification);
serializer.applyModifications(changeConverter);
return edit;
} catch (Exception exc) {
throw new WrappedException(exc);
}
}
Aggregations