Autoinsert single required proerty after '- '.

This commit is contained in:
Kris De Volder
2017-04-26 16:50:56 -07:00
parent 66704bec00
commit d47fa48e43
6 changed files with 143 additions and 37 deletions

View File

@@ -102,16 +102,13 @@ public class ConcourseModel {
* Get the job with given name. If there is no such job, or if there is more than one, this will return null.
*/
private JobModel getJob(IDocument doc, String jobName) {
List<JobModel> jobs = getFromAst(doc, ast ->
JOBS_PATH.traverseAmbiguously(ast)
.filter(node -> jobName.equals(NodeUtil.getScalarProperty(node, "name")))
.map(JobModel::new)
)
.limit(2) //We only need 2 elements at most to determine if there is more than one
.collect(Collectors.toList());
return jobs.size()==1
? jobs.get(0)
: null;
return Streams.getSingle(
getFromAst(doc, ast ->
JOBS_PATH.traverseAmbiguously(ast)
.filter(node -> jobName.equals(NodeUtil.getScalarProperty(node, "name")))
.map(JobModel::new)
)
);
}
public StepModel newStep(Node _node) {

View File

@@ -452,7 +452,7 @@ public class ConcourseEditorTest {
editor = harness.newEditor(CURSOR);
editor.assertCompletions(
"groups:\n" +
"- <*>"
"- name: <*>"
, // --------------
"jobs:\n" +
"- <*>"
@@ -2552,10 +2552,10 @@ public class ConcourseEditorTest {
" <*>"
,
"inputs:\n" +
"- <*>"
"- name: <*>"
,
"outputs:\n" +
"- <*>"
"- name: <*>"
,
"params:\n" +
" <*>"