From c5caf4b35f81a9e451b1d6c806ced3a70c862941 Mon Sep 17 00:00:00 2001 From: Jacob Wallraff Date: Fri, 17 Feb 2023 12:54:59 -0800 Subject: [PATCH] Refactor template job filtering --- actions-languageservice/src/hover.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actions-languageservice/src/hover.ts b/actions-languageservice/src/hover.ts index 4fe554f..3fd85bf 100644 --- a/actions-languageservice/src/hover.ts +++ b/actions-languageservice/src/hover.ts @@ -26,6 +26,7 @@ import {nullTrace} from "./nulltrace"; import {isPotentiallyExpression} from "./utils/expression-detection"; import {findToken, TokenResult} from "./utils/find-token"; import {mapRange} from "./utils/range"; +import { ReusableWorkflowJob } from "@github/actions-workflow-parser/model/workflow-template"; export type HoverConfig = { descriptionProvider?: DescriptionProvider; @@ -206,11 +207,10 @@ function getReusableWorkflowInputDescription(workflowContext: WorkflowContext, t return ""; } - // Filter out just reusable jobs - const templateJobs = template.jobs.filter(isReusableWorkflowJob); - // Find the reusable job in the template that matches the current reusable job - const templateJob = templateJobs.find(job => job.id.value === reusableWorkflowJob!.id.value); + const templateJob = template.jobs.find(job => { + return isReusableWorkflowJob(job) && job.id.value === reusableWorkflowJob.id.value + }) as ReusableWorkflowJob // Find the input description in the template, if any if (templateJob && reusableWorkflowJob["input-definitions"] && templateJob["input-definitions"]) {