use of org.springframework.ide.vscode.boot.java.jdt.imports.ImportRewrite in project sts4 by spring-projects.
the class JavaSnippetCompletion method getAdditionalEdit.
@Override
public Optional<DocumentEdits> getAdditionalEdit() {
ImportRewrite rewrite = ImportRewrite.create(cu, true);
javaSnippet.getImports().ifPresent((imprts -> {
for (String imprt : imprts) {
rewrite.addImport(imprt);
}
}));
DocumentEdits edit = rewrite.createEdit(query.getDocument());
return edit != null ? Optional.of(edit) : Optional.empty();
}
Also used :
CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit)
CompletionItemKind(org.eclipse.lsp4j.CompletionItemKind)
ImportRewrite(org.springframework.ide.vscode.boot.java.jdt.imports.ImportRewrite)
DocumentEdits(org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits)
ICompletionProposal(org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal)
DocumentRegion(org.springframework.ide.vscode.commons.util.text.DocumentRegion)
Renderables(org.springframework.ide.vscode.commons.util.Renderables)
Supplier(com.google.common.base.Supplier)
Optional(java.util.Optional)
Renderable(org.springframework.ide.vscode.commons.util.Renderable)
SnippetBuilder(org.springframework.ide.vscode.commons.languageserver.util.SnippetBuilder)
ImportRewrite(org.springframework.ide.vscode.boot.java.jdt.imports.ImportRewrite)
DocumentEdits(org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits)