use of org.eclipse.n4js.ui.changes.IChange in project n4js by eclipse.
the class ImportsRemovalChangesComputer2 method getImportDeletionChanges.
/**
* Compute changes that will remove all imports.
*
* @param resource
* the resource to modify
* @param document
* the document connected to the xtextResource, for textual changes.
* @return list of changes to the document.
*/
public static List<IChange> getImportDeletionChanges(XtextResource resource, IXtextDocument document) throws BadLocationException {
List<IChange> changes = new ArrayList<>();
List<ScriptElement> elements = XtextResourceUtils.getScript(resource).getScriptElements();
// elements.filter(ImportDeclaration).map[findActualNodeFor(it)].forEach[changes.add(document.removeNodeButKeepComments(it))]
for (ScriptElement el : elements) {
if (el instanceof ImportDeclaration) {
INode nodeToRemove = NodeModelUtils.findActualNodeFor(el);
changes.add(removeNodeButKeepComments(document, nodeToRemove));
}
}
return changes;
}
Aggregations