Search in sources :

Example 6 with ConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel 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;
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ArrayList(java.util.ArrayList) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder)

Example 7 with ConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel in project intellij-tekton by redhat-developer.

the class SingleInputInTaskCompletionProvider method getSingleInputLookups.

/**
 * Get lookups for all possible variables matching the prefix
 *
 * @param parameters
 * @return
 */
private List<LookupElementBuilder> getSingleInputLookups(CompletionParameters parameters) {
    String configuration = parameters.getEditor().getDocument().getText();
    ConfigurationModel model = ConfigurationModelFactory.getModel(configuration);
    if (model == null)
        return Collections.emptyList();
    return getLookupsByKind(parameters, model);
}
Also used : ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel)

Example 8 with ConfigurationModel

use of com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel in project intellij-tekton by redhat-developer.

the class TaskReferencesInspector 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> tasKNotFoundPsiElements = new ArrayList<>();
    if (model instanceof PipelineConfigurationModel) {
        List<String> tasksOnCluster = getTasksOnCluster(file.getProject(), model.getNamespace());
        tasKNotFoundPsiElements = findTaskElementsNotFoundOnCluster(file, tasksOnCluster);
    }
    return tasKNotFoundPsiElements.stream().map(item -> manager.createProblemDescriptor(item, item, "No task named " + StringHelper.getUnquotedValueFromPsi(item) + " found on cluster.", ProblemHighlightType.GENERIC_ERROR, isOnTheFly)).toArray(ProblemDescriptor[]::new);
}
Also used : PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) Logger(org.slf4j.Logger) TreeHelper(com.redhat.devtools.intellij.tektoncd.utils.TreeHelper) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ArrayList(java.util.ArrayList) ASTNode(com.intellij.lang.ASTNode) Tkn(com.redhat.devtools.intellij.tektoncd.tkn.Tkn) Nullable(org.jetbrains.annotations.Nullable) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) List(java.util.List) InspectionManager(com.intellij.codeInspection.InspectionManager) ProblemDescriptor(com.intellij.codeInspection.ProblemDescriptor) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) StringHelper(com.redhat.devtools.intellij.common.utils.StringHelper) ProblemHighlightType(com.intellij.codeInspection.ProblemHighlightType) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) PipelineConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel) ConfigurationModel(com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.ConfigurationModel)8 PipelineConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.PipelineConfigurationModel)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 InspectionManager (com.intellij.codeInspection.InspectionManager)3 ProblemDescriptor (com.intellij.codeInspection.ProblemDescriptor)3 ProblemHighlightType (com.intellij.codeInspection.ProblemHighlightType)3 PsiElement (com.intellij.psi.PsiElement)3 PsiFile (com.intellij.psi.PsiFile)3 TaskConfigurationModel (com.redhat.devtools.intellij.tektoncd.utils.model.resources.TaskConfigurationModel)3 Collections (java.util.Collections)3 Pattern (java.util.regex.Pattern)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 ASTNode (com.intellij.lang.ASTNode)2 StringHelper (com.redhat.devtools.intellij.common.utils.StringHelper)2 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)2 Output (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output)2 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)2 IOException (java.io.IOException)2