use of org.springframework.ide.vscode.commons.languageserver.completion.IndentUtil in project sts4 by spring-projects.
the class JavaSnippetBuilder method createEdit.
public DocumentEdits createEdit(DocumentRegion query, String template) {
IDocument doc = query.getDocument();
IndentUtil indentUtil = new IndentUtil(doc);
DocumentEdits edit = new DocumentEdits(doc);
String snippet = createSnippet(template);
String referenceIndent = indentUtil.getReferenceIndent(query.getStart(), doc);
if (!referenceIndent.contains("\t")) {
snippet = indentUtil.covertTabsToSpace(snippet);
}
String indentedSnippet = indentUtil.applyIndentation(snippet, referenceIndent);
edit.replace(query.getStart(), query.getEnd(), indentedSnippet);
return edit;
}
Aggregations