Use primary properties in a few places in bosh manifest schema
This commit is contained in:
@@ -54,7 +54,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
TYPE_UTIL = f.TYPE_UTIL;
|
||||
|
||||
TOPLEVEL_TYPE = f.ybean("BoshDeploymentManifest");
|
||||
addProp(TOPLEVEL_TYPE, "name", t_ne_string).isRequired(true);
|
||||
addProp(TOPLEVEL_TYPE, "name", t_ne_string).isPrimary(true);
|
||||
addProp(TOPLEVEL_TYPE, "director_uuid", t_uuid)
|
||||
.isRequired(true);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
t_version.parseWith(ValueParsers.NE_STRING);
|
||||
|
||||
YBeanType t_release = f.ybean("Release");
|
||||
addProp(t_release, "name", t_ne_string).isRequired(true);
|
||||
addProp(t_release, "name", t_ne_string).isPrimary(true);
|
||||
addProp(t_release, "version", t_version).isRequired(true);
|
||||
addProp(TOPLEVEL_TYPE, "releases", f.yseq(t_release)).isRequired(true);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
|
||||
import static org.springframework.ide.vscode.languageserver.testharness.Editor.*;
|
||||
|
||||
public class BoshEditorTest {
|
||||
|
||||
LanguageServerHarness harness;
|
||||
@@ -116,14 +118,37 @@ public class BoshEditorTest {
|
||||
"<*>"
|
||||
);
|
||||
editor.assertCompletions(
|
||||
"director_uuid: <*>",
|
||||
"instance_groups:\n- <*>",
|
||||
"name: <*>",
|
||||
"releases:\n- <*>",
|
||||
"stemcells:\n- <*>",
|
||||
"tags:\n <*>",
|
||||
"update:\n <*>",
|
||||
"variables:\n- <*>",
|
||||
"name: <*>"
|
||||
);
|
||||
|
||||
editor = harness.newEditor(
|
||||
"name: blah\n" +
|
||||
"<*>"
|
||||
);
|
||||
|
||||
editor.assertCompletions(
|
||||
"name: blah\n" +
|
||||
"director_uuid: <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"instance_groups:\n- <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"releases:\n- <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"stemcells:\n- <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"tags:\n <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"update:\n <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"variables:\n- <*>"
|
||||
, // ============
|
||||
"name: blah\n" +
|
||||
"properties:\n <*>"
|
||||
);
|
||||
}
|
||||
@@ -174,9 +199,17 @@ public class BoshEditorTest {
|
||||
editor.assertCompletions(
|
||||
"releases:\n" +
|
||||
"- name: <*>"
|
||||
, //========
|
||||
"releases:\n" +
|
||||
"- version: <*>"
|
||||
);
|
||||
|
||||
editor = harness.newEditor(
|
||||
"releases:\n" +
|
||||
"- name: foo\n" +
|
||||
" <*>"
|
||||
);
|
||||
editor.assertCompletions(PLAIN_COMPLETION,
|
||||
"releases:\n" +
|
||||
"- name: foo\n" +
|
||||
" version: <*>"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,4 +236,12 @@ public class BoshEditorTest {
|
||||
editor.assertCompletionLabels("latest");
|
||||
}
|
||||
|
||||
@Test public void instanceGroupsCompletions() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"instance_groups:\n" +
|
||||
"- <*>"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -162,27 +162,28 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
||||
* in theory they would be free to define the properties in any order they want.
|
||||
*/
|
||||
protected List<List<YTypedProperty>> sortIntoTiers(List<YTypedProperty> properties) {
|
||||
if (typeUtil.isEnabledTieredProposals()) {
|
||||
if (properties.isEmpty()) {
|
||||
//Nothing to sort
|
||||
return ImmutableList.of();
|
||||
} else {
|
||||
ImmutableList.Builder<YTypedProperty> primary = ImmutableList.builder();
|
||||
ImmutableList.Builder<YTypedProperty> required = ImmutableList.builder();
|
||||
ImmutableList.Builder<YTypedProperty> other = ImmutableList.builder();
|
||||
for (YTypedProperty p : properties) {
|
||||
if (p.isPrimary()) {
|
||||
primary.add(p);
|
||||
} else if (p.isRequired()) {
|
||||
required.add(p);
|
||||
} else {
|
||||
other.add(p);
|
||||
}
|
||||
}
|
||||
return ImmutableList.of(primary.build(), required.build(), other.build());
|
||||
}
|
||||
boolean tieredOptionals = typeUtil.tieredOptionalPropertyProposals();
|
||||
if (properties.isEmpty()) {
|
||||
//Nothing to sort
|
||||
return ImmutableList.of();
|
||||
} else {
|
||||
return ImmutableList.of(properties);
|
||||
ImmutableList.Builder<YTypedProperty> primary = ImmutableList.builder();
|
||||
ImmutableList.Builder<YTypedProperty> tier2 = ImmutableList.builder();
|
||||
ImmutableList.Builder<YTypedProperty> tier3 = ImmutableList.builder();
|
||||
for (YTypedProperty p : properties) {
|
||||
if (p.isPrimary()) {
|
||||
primary.add(p);
|
||||
} else if (!tieredOptionals || p.isRequired()) {
|
||||
tier2.add(p);
|
||||
} else {
|
||||
tier3.add(p);
|
||||
}
|
||||
}
|
||||
if (tieredOptionals) {
|
||||
return ImmutableList.of(primary.build(), tier2.build(), tier3.build());
|
||||
} else {
|
||||
return ImmutableList.of(primary.build(), tier2.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class YTypeFactory {
|
||||
/**
|
||||
* Configuration option for the type-based completion engine.
|
||||
*/
|
||||
private boolean enableTieredProposals = true;
|
||||
private boolean enableTieredOptionalPropertyProposals = true;
|
||||
|
||||
private static class Deprecation {
|
||||
final String errorMsg;
|
||||
@@ -158,11 +158,6 @@ public class YTypeFactory {
|
||||
* YTypeFactory
|
||||
*/
|
||||
public final YTypeUtil TYPE_UTIL = new YTypeUtil() {
|
||||
|
||||
@Override
|
||||
public boolean isEnabledTieredProposals() {
|
||||
return enableTieredProposals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSequencable(YType type) {
|
||||
@@ -239,6 +234,11 @@ public class YTypeFactory {
|
||||
public ISubCompletionEngine getCustomContentAssistant(YType type) {
|
||||
return ((AbstractType)type).getCustomContentAssistant();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tieredOptionalPropertyProposals() {
|
||||
return enableTieredOptionalPropertyProposals;
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -912,7 +912,7 @@ public class YTypeFactory {
|
||||
}
|
||||
|
||||
public YTypeFactory enableTieredProposals(boolean enable) {
|
||||
this.enableTieredProposals = enable;
|
||||
this.enableTieredOptionalPropertyProposals = enable;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,5 +55,5 @@ public interface YTypeUtil {
|
||||
* 'tiered' proposals feature (so that optional properties are not
|
||||
* suggested until required ones are all defined)
|
||||
*/
|
||||
boolean isEnabledTieredProposals();
|
||||
boolean tieredOptionalPropertyProposals();
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.junit.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.Unicodes;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -54,6 +55,15 @@ import reactor.core.publisher.Flux;
|
||||
|
||||
public class Editor {
|
||||
|
||||
public static final Predicate<CompletionItem> RELAXED_COMPLETION
|
||||
= c -> c.getLabel().startsWith("- ")
|
||||
|| c.getLabel().startsWith(Unicodes.LEFT_ARROW+" ")
|
||||
|| c.getLabel().startsWith(Unicodes.RIGHT_ARROW+" ")
|
||||
;
|
||||
public static final Predicate<CompletionItem> PLAIN_COMPLETION = c -> !RELAXED_COMPLETION.test(c);
|
||||
public static final Predicate<CompletionItem> DEDENTED_COMPLETION = c -> c.getLabel().startsWith(Unicodes.LEFT_ARROW+" ");
|
||||
public static final Predicate<CompletionItem> INDENTED_COMPLETION = c -> c.getLabel().startsWith(Unicodes.RIGHT_ARROW+" ");
|
||||
|
||||
static class EditorState {
|
||||
String documentContents;
|
||||
int selectionStart;
|
||||
|
||||
@@ -34,6 +34,8 @@ import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.SynchronizationPoint;
|
||||
|
||||
import static org.springframework.ide.vscode.languageserver.testharness.Editor.*;
|
||||
|
||||
public class ConcourseEditorTest {
|
||||
|
||||
private static final YamlCompletionEngineOptions OPTIONS = YamlCompletionEngineOptions.TEST_DEFAULT;
|
||||
@@ -3915,14 +3917,4 @@ public class ConcourseEditorTest {
|
||||
assertContextualCompletions(LanguageId.CONCOURSE_TASK, c -> true, conText, textBefore, textAfter);
|
||||
}
|
||||
|
||||
public static final Predicate<CompletionItem> RELAXED_COMPLETION
|
||||
= c -> c.getLabel().startsWith("- ")
|
||||
|| c.getLabel().startsWith(Unicodes.LEFT_ARROW+" ")
|
||||
|| c.getLabel().startsWith(Unicodes.RIGHT_ARROW+" ")
|
||||
;
|
||||
|
||||
public static final Predicate<CompletionItem> PLAIN_COMPLETION = c -> !RELAXED_COMPLETION.test(c);
|
||||
public static final Predicate<CompletionItem> DEDENTED_COMPLETION = c -> c.getLabel().startsWith(Unicodes.LEFT_ARROW+" ");
|
||||
public static final Predicate<CompletionItem> INDENTED_COMPLETION = c -> c.getLabel().startsWith(Unicodes.RIGHT_ARROW+" ");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user