From 0d1b951c141a0c68855fc0dfc444b7c0f9b699f9 Mon Sep 17 00:00:00 2001 From: Beth Brennan Date: Tue, 22 Nov 2022 16:03:01 -0500 Subject: [PATCH] Use isMapping --- actions-languageservice/src/hover.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/actions-languageservice/src/hover.ts b/actions-languageservice/src/hover.ts index 8af5131..388236e 100644 --- a/actions-languageservice/src/hover.ts +++ b/actions-languageservice/src/hover.ts @@ -1,12 +1,10 @@ -import {parseWorkflow} from "@github/actions-workflow-parser"; +import {isMapping, parseWorkflow} from "@github/actions-workflow-parser"; import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token"; -import {MappingToken} from "@github/actions-workflow-parser/templates/tokens/mapping-token"; import {File} from "@github/actions-workflow-parser/workflows/file"; import {Position, TextDocument} from "vscode-languageserver-textdocument"; import {Hover} from "vscode-languageserver-types"; import {nullTrace} from "./nulltrace"; -import {findInnerToken, findToken} from "./utils/find-token"; -import {TokenType} from "@github/actions-workflow-parser/templates/tokens/types"; +import {findToken} from "./utils/find-token"; // Render value description and Context when hovering over a key in a MappingToken export async function hover(document: TextDocument, position: Position): Promise { @@ -20,9 +18,8 @@ export async function hover(document: TextDocument, position: Position): Promise if (result.value && token) { // If the parent is a MappingToken and no keyToken was returned, our token is the key - if (parent?.templateTokenType === TokenType.Mapping && !keyToken) { - const mappingToken = parent as MappingToken; - const value = mappingToken.find(token.toString()); + if (parent && isMapping(parent) && !keyToken) { + const value = parent.find(token.toString()); if (value) { return getHover(token, value); }