Use primary properties in a few places in bosh manifest schema
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user