use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.
the class FinallyReferencesInspector method checkFile.
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ConfigurationModel model = getTektonModelFromFile(file);
if (model == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
List<PsiElement> errorPsiElements = new ArrayList<>();
if (model instanceof PipelineConfigurationModel) {
errorPsiElements = findFinallySectionErrors(file);
}
return errorPsiElements.stream().map(item -> manager.createProblemDescriptor(item, item, "No runAfter can be specified in final tasks.", ProblemHighlightType.GENERIC_ERROR, isOnTheFly)).toArray(ProblemDescriptor[]::new);
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.
the class VariableReferencesInspector method checkFile.
@Nullable
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
ConfigurationModel model = getTektonModelFromFile(file);
if (model == null) {
return ProblemDescriptor.EMPTY_ARRAY;
}
List<PsiElement> unusedPsiElements = new ArrayList<>();
if (model instanceof PipelineConfigurationModel) {
unusedPsiElements = highlightInPipeline(file, (PipelineConfigurationModel) model);
} else if (model instanceof TaskConfigurationModel) {
unusedPsiElements = highlightInTask(file, (TaskConfigurationModel) model);
}
return unusedPsiElements.stream().map(item -> manager.createProblemDescriptor(item, item, "Variable " + StringHelper.getUnquotedValueFromPsi(item.getContext()) + " is never used", ProblemHighlightType.WEAK_WARNING, isOnTheFly, LocalQuickFix.EMPTY_ARRAY)).toArray(ProblemDescriptor[]::new);
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.
the class GeneralCompletionProvider method getLookupsPipeline.
/**
* Get lookups for the opened pipeline configuration
*
* @param parameters
* @param model the model built by the configuration
* @param prefix the prefix we are really using. E.g the line we are in is "value: test -f $(params." -> the prefix is "$(params."
* @param completionPrefix the prefix we need to add to the lookup to make it be shown by IJ. E.g the line we are in is "value: test -f $(params." -> the completionPrefix is "test -f $(params."
* @param insertOffset the position where the lookup has to be copied on
* @return
*/
private List<LookupElementBuilder> getLookupsPipeline(CompletionParameters parameters, ConfigurationModel model, String prefix, String completionPrefix, int insertOffset) {
List<LookupElementBuilder> lookups = new ArrayList<>();
// get lookups for params
lookups.addAll(getParamLookups(((PipelineConfigurationModel) model).getParams(), prefix, completionPrefix, insertOffset));
// get lookups for tasks result
String headPrefix_8 = prefix.length() > 8 ? prefix.substring(0, 8) : prefix;
if ("$(tasks.".contains(headPrefix_8)) {
String namespace = model.getNamespace();
if (Strings.isNullOrEmpty(namespace)) {
VirtualFile vf = FileDocumentManager.getInstance().getFile(parameters.getEditor().getDocument());
namespace = vf.getUserData(NAMESPACE);
}
lookups.addAll(getTasksInPipelineLookups(parameters, namespace, prefix, completionPrefix, insertOffset));
}
return lookups;
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.
the class PipelineConfigurationModelTest method checkPipelineModelWithWorkspaces.
@Test
public void checkPipelineModelWithWorkspaces() throws IOException {
String configuration = load("pipeline5.yaml");
PipelineConfigurationModel model = (PipelineConfigurationModel) ConfigurationModelFactory.getModel(configuration);
assertEquals(model.getName(), "foo");
assertEquals(model.getNamespace(), "tekton");
assertEquals(model.getKind(), "Pipeline");
assertTrue(model.getParams().isEmpty());
assertTrue(model.getInputResources().isEmpty());
assertTrue(model.getOutputResources().isEmpty());
assertTrue(model.getWorkspaces().size() == 2);
assertEquals(model.getWorkspaces().get(0).getName(), "password-vault");
assertEquals(model.getWorkspaces().get(1).getName(), "recipe-store");
}
use of com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel in project intellij-tekton by redhat-developer.
the class ResourceInPipelineCompletionProvider method getResourcesLookups.
private List<LookupElementBuilder> getResourcesLookups(CompletionParameters parameters) {
String configuration = parameters.getEditor().getDocument().getText();
ConfigurationModel model = ConfigurationModelFactory.getModel(configuration);
if (model == null || !(model instanceof PipelineConfigurationModel))
return Collections.emptyList();
List<LookupElementBuilder> lookups = new ArrayList<>();
((PipelineConfigurationModel) model).getInputResources().forEach(resource -> {
lookups.add(LookupElementBuilder.create(resource.name()).withPresentableText(resource.name()).withLookupString(resource.name()));
});
return lookups;
}
Aggregations