use of org.eclipse.jdt.ls.core.internal.TextEditConverter in project eclipse.jdt.ls by eclipse.
the class CodeActionHandler method textEditToCommand.
private static Command textEditToCommand(ICompilationUnit unit, String label, TextEdit textEdit) {
TextEditConverter converter = new TextEditConverter(unit, textEdit);
String uri = JDTUtils.toURI(unit);
WorkspaceEdit $ = new WorkspaceEdit();
$.getChanges().put(uri, converter.convert());
return new Command(label, COMMAND_ID_APPLY_EDIT, Arrays.asList($));
}
use of org.eclipse.jdt.ls.core.internal.TextEditConverter in project eclipse.jdt.ls by eclipse.
the class CompletionProposalReplacementProvider method addImports.
/**
* Adds imports collected by importRewrite to item
* @param item
*/
private void addImports(List<org.eclipse.lsp4j.TextEdit> additionalEdits) {
if (this.importRewrite != null) {
try {
TextEdit edit = this.importRewrite.rewriteImports(new NullProgressMonitor());
TextEditConverter converter = new TextEditConverter(this.compilationUnit, edit);
List<org.eclipse.lsp4j.TextEdit> edits = converter.convert();
if (ChangeUtil.hasChanges(edits)) {
additionalEdits.addAll(edits);
}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Error adding imports", e);
}
}
}
use of org.eclipse.jdt.ls.core.internal.TextEditConverter in project eclipse.jdt.ls by eclipse.
the class RenameProcessor method convert.
protected void convert(WorkspaceEdit root, ICompilationUnit unit, TextEdit edits) {
TextEditConverter converter = new TextEditConverter(unit, edits);
String uri = JDTUtils.toURI(unit);
Map<String, List<org.eclipse.lsp4j.TextEdit>> changes = root.getChanges();
if (changes.containsKey(uri)) {
changes.get(uri).addAll(converter.convert());
} else {
changes.put(uri, converter.convert());
}
}
use of org.eclipse.jdt.ls.core.internal.TextEditConverter in project eclipse.jdt.ls by eclipse.
the class OrganizeImportsCommand method addWorkspaceEdit.
private void addWorkspaceEdit(ICompilationUnit cu, CUCorrectionProposal proposal, WorkspaceEdit rootEdit) throws CoreException {
TextChange textChange = proposal.getTextChange();
TextEdit edit = textChange.getEdit();
TextEditConverter converter = new TextEditConverter(cu, edit);
List<org.eclipse.lsp4j.TextEdit> edits = converter.convert();
if (ChangeUtil.hasChanges(edits)) {
rootEdit.getChanges().put(JDTUtils.toURI(cu), edits);
}
}
use of org.eclipse.jdt.ls.core.internal.TextEditConverter in project eclipse.jdt.ls by eclipse.
the class SourceAssistProcessor method convertToWorkspaceEdit.
public static WorkspaceEdit convertToWorkspaceEdit(ICompilationUnit cu, TextEdit edit) {
if (cu == null || edit == null) {
return null;
}
WorkspaceEdit workspaceEdit = new WorkspaceEdit();
TextEditConverter converter = new TextEditConverter(cu, edit);
String uri = JDTUtils.toURI(cu);
workspaceEdit.getChanges().put(uri, converter.convert());
return workspaceEdit;
}
Aggregations