@Test public void after_pipeline_agent_is_suggested() { Set<ProposalProvider> result = completion.calculate(source1, source1_pipeline_block_index); assertLabelFound("agent",result); }
@Override public Set<ProposalProvider> calculate(String source, int offset) { if (source.trim().length()==0){ return Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); } String parentAsText = ""; JenkinsModelBuilder builder = new JenkinsModelBuilder(new ByteArrayInputStream(source.getBytes())); BuildContext builderContext = new BuildContext(); Item item = null; try { Model model = builder.build(builderContext); item = model.getParentItemOf(offset); } catch (ModelBuilderException e) { EclipseUtil.logError("Cannot build proposal model", e, JenkinsEditorActivator.getDefault()); return Collections.emptySet(); } if (item.isRoot()){ Set<ProposalProvider> set = Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); return set; } parentAsText=item.getIdentifier(); List<Node> foundParents = model.findByKeyword(parentAsText); if (foundParents.isEmpty()){ return Collections.emptySet(); } return fetchChildrenProposalsForParents(source, offset, foundParents); }
JenkinsWordCompletion extends AbstractWordCodeCompletition { @Override public Set<ProposalProvider> calculate(String source, int offset) { if (source.trim().length()==0){ return Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); } String parentAsText = ""; JenkinsModelBuilder builder = new JenkinsModelBuilder(new ByteArrayInputStream(source.getBytes())); BuildContext builderContext = new BuildContext(); Item item = null; try { Model model = builder.build(builderContext); item = model.getParentItemOf(offset); } catch (ModelBuilderException e) { EclipseUtil.logError("Cannot build proposal model", e, JenkinsEditorActivator.getDefault()); return Collections.emptySet(); } if (item.isRoot()){ Set<ProposalProvider> set = Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); return set; } parentAsText=item.getIdentifier(); List<Node> foundParents = model.findByKeyword(parentAsText); if (foundParents.isEmpty()){ return Collections.emptySet(); } return fetchChildrenProposalsForParents(source, offset, foundParents); } }
JenkinsWordCompletion extends AbstractWordCodeCompletition { @Override public Set<ProposalProvider> calculate(String source, int offset) { if (source.trim().length()==0){ return Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); } String parentAsText = ""; JenkinsModelBuilder builder = new JenkinsModelBuilder(new ByteArrayInputStream(source.getBytes())); BuildContext builderContext = new BuildContext(); Item item = null; try { Model model = builder.build(builderContext); item = model.getParentItemOf(offset); } catch (ModelBuilderException e) { EclipseUtil.logError("Cannot build proposal model", e, JenkinsEditorActivator.getDefault()); return Collections.emptySet(); } if (item.isRoot()){ Set<ProposalProvider> set = Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); return set; } parentAsText=item.getIdentifier(); List<Node> foundParents = model.findByKeyword(parentAsText); if (foundParents.isEmpty()){ return Collections.emptySet(); } return fetchChildrenProposalsForParents(source, offset, foundParents); } JenkinsWordCompletion(); }
JenkinsWordCompletion extends AbstractWordCodeCompletition { @Override public Set<ProposalProvider> calculate(String source, int offset) { if (source.trim().length()==0){ return Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); } String parentAsText = ""; JenkinsModelBuilder builder = new JenkinsModelBuilder(new ByteArrayInputStream(source.getBytes())); BuildContext builderContext = new BuildContext(); Item item = null; try { Model model = builder.build(builderContext); item = model.getParentItemOf(offset); } catch (ModelBuilderException e) { EclipseUtil.logError("Cannot build proposal model", e, JenkinsEditorActivator.getDefault()); return Collections.emptySet(); } if (item.isRoot()){ Set<ProposalProvider> set = Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); return set; } parentAsText=item.getIdentifier(); List<Node> foundParents = model.findByKeyword(parentAsText); if (foundParents.isEmpty()){ return Collections.emptySet(); } return fetchChildrenProposalsForParents(source, offset, foundParents); } JenkinsWordCompletion(); @Override Set<ProposalProvider> calculate(String source, int offset); @Override void reset(); }
JenkinsWordCompletion extends AbstractWordCodeCompletition { @Override public Set<ProposalProvider> calculate(String source, int offset) { if (source.trim().length()==0){ return Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); } String parentAsText = ""; JenkinsModelBuilder builder = new JenkinsModelBuilder(new ByteArrayInputStream(source.getBytes())); BuildContext builderContext = new BuildContext(); Item item = null; try { Model model = builder.build(builderContext); item = model.getParentItemOf(offset); } catch (ModelBuilderException e) { EclipseUtil.logError("Cannot build proposal model", e, JenkinsEditorActivator.getDefault()); return Collections.emptySet(); } if (item.isRoot()){ Set<ProposalProvider> set = Collections.singleton(new JenkinsDSLTypeProposalProvider(JenkinsDefaultClosureKeyWords.PIPELINE)); return set; } parentAsText=item.getIdentifier(); List<Node> foundParents = model.findByKeyword(parentAsText); if (foundParents.isEmpty()){ return Collections.emptySet(); } return fetchChildrenProposalsForParents(source, offset, foundParents); } JenkinsWordCompletion(); @Override Set<ProposalProvider> calculate(String source, int offset); @Override void reset();  }