diff --git a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java index c76f566aa..22db55735 100644 --- a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java +++ b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 Pivotal, Inc. + * Copyright (c) 2016, 2024 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -130,6 +130,25 @@ public class Renderables { }; } + public static Renderable inlineMultiLineSnippet(Renderable text) { + return new Renderable() { + + @Override + public void renderAsMarkdown(StringBuilder buffer) { + buffer.append("```\n"); + text.renderAsMarkdown(buffer); + buffer.append("\n```"); + } + + @Override + public void renderAsHtml(HtmlBuffer buffer) { + buffer.raw("
");
+ text.renderAsHtml(buffer);
+ buffer.raw("");
+ }
+ };
+ }
+
public static Renderable paragraph(Renderable text) {
return new Renderable() {
diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java
index b94a8e1a7..6c5d05f1f 100644
--- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java
+++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/xml/SpringXMLCompletionEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2019, 2020 Pivotal, Inc.
+ * Copyright (c) 2019, 2024 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,6 +43,7 @@ import static org.springframework.ide.vscode.boot.xml.XmlConfigConstants.VALUE_E
import static org.springframework.ide.vscode.boot.xml.XmlConfigConstants.VALUE_REF_ATTRIBUTE;
import static org.springframework.ide.vscode.boot.xml.XmlConfigConstants.VALUE_TYPE_ATTRIBUTE;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -55,17 +56,22 @@ import org.eclipse.lemminx.dom.DOMParser;
import org.eclipse.lemminx.dom.parser.Scanner;
import org.eclipse.lemminx.dom.parser.TokenType;
import org.eclipse.lemminx.dom.parser.XMLScanner;
+import org.eclipse.lsp4j.CompletionItemKind;
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.boot.xml.completions.BeanRefCompletionProposalProvider;
import org.springframework.ide.vscode.boot.xml.completions.ConstructorArgNameCompletionProposalProvider;
+import org.springframework.ide.vscode.boot.xml.completions.GenericXMLCompletionProposal;
import org.springframework.ide.vscode.boot.xml.completions.PropertyNameCompletionProposalProvider;
import org.springframework.ide.vscode.boot.xml.completions.TypeCompletionProposalProvider;
+import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.util.LanguageSpecific;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
+import org.springframework.ide.vscode.commons.util.Renderable;
+import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.util.text.LanguageId;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
@@ -134,7 +140,13 @@ public class SpringXMLCompletionEngine implements ICompletionEngine, LanguageSpe
}
String content = doc.get();
+
+ // if doc is empty, create simple skeleton snippet
+ if (content != null && content.length() == 0) {
+ return emptySpringXMLConfigSnippet(doc);
+ }
+ // if doc is not empty, dive into the details and provide more sophisticated content assist proposals
DOMParser parser = DOMParser.getInstance();
DOMDocument dom = parser.parse(content, "", null);
@@ -177,6 +189,47 @@ public class SpringXMLCompletionEngine implements ICompletionEngine, LanguageSpe
return Collections.emptyList();
}
+ private Collection