Better handling of union types in Yaml completions

Schema-based completion engine provides the
completions for every subtype of a union type
(unless more specific subtype can be inferred).

See: https://github.com/spring-projects/sts4/issues/345#issuecomment-523069469

Signed-off-by: Kris De Volder <kdevolder@pivotal.io>
This commit is contained in:
Kris De Volder
2019-08-20 10:21:20 -07:00
parent 577901c8a1
commit 01c0498f8e
5 changed files with 205 additions and 44 deletions

View File

@@ -612,7 +612,84 @@ public class ConcourseEditorTest {
" <*>"
);
}
@Test
public void inParallelStepCompletionInList() throws Exception {
Editor editor = harness.newEditor(
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" - <*>"
);
editor.assertCompletionWithLabel("get",
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" - get: <*>"
);
}
@Test
public void inParallelStepCompletionOptions() throws Exception {
assertContextualCompletions(PLAIN_COMPLETION,
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" <*>"
, // ------------
"<*>"
, // ==>
"fail_fast: <*>"
,
"limit: <*>"
,
"steps:\n"+
" - <*>"
);
assertContextualCompletions(c -> {
String l = c.getLabel();
boolean isDedentedStep = l.startsWith(Unicodes.LEFT_ARROW+" -");
return isDedentedStep && (l.contains("get") || l.contains("put"));
},
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" <*>"
, // ------------
" <*>"
, // ==>
"- get: <*>"
,
"- put: <*>"
);
}
@Test
public void inParallelStepCompletionInObject() throws Exception {
Editor editor = harness.newEditor(
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" steps:\n" +
" - <*>"
);
editor.assertCompletionWithLabel("get",
"jobs:\n" +
"- name: some-job\n" +
" plan:\n" +
" - in_parallel:\n" +
" steps:\n" +
" - get: <*>"
);
}
@Test
public void reconcileSimpleTypes() throws Exception {
Editor editor;