Fix for PT-167494938
Snippet completion was broken for concourse resource type 'extra insertions'.
This commit is contained in:
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.ScoreableProposal;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.PlaceHolderString;
|
||||
import org.springframework.ide.vscode.commons.util.CollectionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMatcher;
|
||||
@@ -279,9 +280,14 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
||||
edits.insert(offset, " ");
|
||||
}
|
||||
edits.insert(offset, value.getValue());
|
||||
String extraInsertion = value.getExtraInsertion();
|
||||
PlaceHolderString extraInsertion = value.getExtraInsertion();
|
||||
if (extraInsertion!=null) {
|
||||
edits.insert(offset, indenter.applyIndentation(extraInsertion, referenceIndent));
|
||||
String insertText = indenter.applyIndentation(extraInsertion.toString(), referenceIndent);
|
||||
if (extraInsertion.hasPlaceHolders()) {
|
||||
edits.insertSnippet(offset, insertText);
|
||||
} else {
|
||||
edits.insert(offset, insertText);
|
||||
}
|
||||
}
|
||||
completions.add(completionFactory().valueProposal(
|
||||
value.getValue(), query, value.getLabel(), type,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.yaml.schema;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.PlaceHolderString;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class BasicYValueHint implements YValueHint {
|
||||
|
||||
private final String value;
|
||||
private String label;
|
||||
private Supplier<String> extraInsertion = null;
|
||||
private Supplier<PlaceHolderString> extraInsertion = null;
|
||||
private Renderable documentation;
|
||||
|
||||
public BasicYValueHint(String value, String label) {
|
||||
@@ -85,12 +86,12 @@ public class BasicYValueHint implements YValueHint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtraInsertion() {
|
||||
Supplier<String> ei = this.extraInsertion;
|
||||
public PlaceHolderString getExtraInsertion() {
|
||||
Supplier<PlaceHolderString> ei = this.extraInsertion;
|
||||
return ei==null ? null : ei.get();
|
||||
}
|
||||
|
||||
public BasicYValueHint setExtraInsertion(Supplier<String> insertions) {
|
||||
public BasicYValueHint setExtraInsertion(Supplier<PlaceHolderString> insertions) {
|
||||
Assert.isLegal(this.extraInsertion==null);
|
||||
this.extraInsertion = insertions;
|
||||
return this;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.yaml.schema;
|
||||
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.PlaceHolderString;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
|
||||
public interface YValueHint {
|
||||
@@ -22,7 +23,7 @@ public interface YValueHint {
|
||||
* on the next line and indented to line-up relative to the indentation of
|
||||
* the line where the value itself is being inserted.
|
||||
*/
|
||||
String getExtraInsertion();
|
||||
PlaceHolderString getExtraInsertion();
|
||||
|
||||
/**
|
||||
* An optional documentation string (i.e. shown in javadoc side hover in Eclipse style
|
||||
|
||||
Reference in New Issue
Block a user