diff --git a/actions-languageservice/src/complete.ts b/actions-languageservice/src/complete.ts index 3074a45..f2d89f1 100644 --- a/actions-languageservice/src/complete.ts +++ b/actions-languageservice/src/complete.ts @@ -14,7 +14,6 @@ import {ContextProviderConfig} from "./context-providers/config"; import {getContext, Mode} from "./context-providers/default"; import {getWorkflowContext, WorkflowContext} from "./context/workflow-context"; import {nullTrace} from "./nulltrace"; -import {getAllowedContext} from "./utils/allowed-context"; import {findToken} from "./utils/find-token"; import {mapRange} from "./utils/range"; import {transform} from "./utils/transform"; @@ -85,7 +84,7 @@ export async function complete( const expressionInput = (getExpressionInput(currentInput, relCharPos) || "").trim(); - const allowedContext = getAllowedContext(token, parent); + const allowedContext = token.definitionInfo?.allowedContext || []; const context = await getContext(allowedContext, contextProviderConfig, workflowContext, Mode.Completion); return completeExpression(expressionInput, context, []); diff --git a/actions-languageservice/src/utils/allowed-context.ts b/actions-languageservice/src/utils/allowed-context.ts deleted file mode 100644 index 36a5d91..0000000 --- a/actions-languageservice/src/utils/allowed-context.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token"; - -export function getAllowedContext(token: TemplateToken, parent: TemplateToken | null | undefined): string[] { - // Workaround for https://github.com/github/c2c-actions-experience/issues/6876 - // Context is inherited from the parent - const allowedContext = new Set(); - for (const t of [token, parent]) { - if (t?.definition?.readerContext) { - for (const context of t.definition.readerContext) { - allowedContext.add(context); - } - } - } - return Array.from(allowedContext); -} diff --git a/actions-languageservice/src/validate.ts b/actions-languageservice/src/validate.ts index 8d2a0b4..d5e9884 100644 --- a/actions-languageservice/src/validate.ts +++ b/actions-languageservice/src/validate.ts @@ -24,7 +24,6 @@ import {getWorkflowContext, WorkflowContext} from "./context/workflow-context"; import {AccessError, wrapDictionary} from "./expression-validation/error-dictionary"; import {error} from "./log"; import {nullTrace} from "./nulltrace"; -import {getAllowedContext} from "./utils/allowed-context"; import {findToken} from "./utils/find-token"; import {mapRange} from "./utils/range"; import {validateAction} from "./validate-action"; @@ -94,14 +93,12 @@ async function additionalValidations( const validationToken = key || parent || token; const validationDefinition = validationToken.definition; - const allowedContext = getAllowedContext(validationToken, parent); - // If this is an expression, validate it if (isBasicExpression(token)) { await validateExpression( diagnostics, token, - allowedContext, + validationToken.definitionInfo?.allowedContext || [], config?.contextProviderConfig, getProviderContext(documentUri, template, root, token) );