Use isMapping
This commit is contained in:
@@ -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 {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 {File} from "@github/actions-workflow-parser/workflows/file";
|
||||||
import {Position, TextDocument} from "vscode-languageserver-textdocument";
|
import {Position, TextDocument} from "vscode-languageserver-textdocument";
|
||||||
import {Hover} from "vscode-languageserver-types";
|
import {Hover} from "vscode-languageserver-types";
|
||||||
import {nullTrace} from "./nulltrace";
|
import {nullTrace} from "./nulltrace";
|
||||||
import {findInnerToken, findToken} from "./utils/find-token";
|
import {findToken} from "./utils/find-token";
|
||||||
import {TokenType} from "@github/actions-workflow-parser/templates/tokens/types";
|
|
||||||
|
|
||||||
// Render value description and Context when hovering over a key in a MappingToken
|
// Render value description and Context when hovering over a key in a MappingToken
|
||||||
export async function hover(document: TextDocument, position: Position): Promise<Hover | null> {
|
export async function hover(document: TextDocument, position: Position): Promise<Hover | null> {
|
||||||
@@ -20,9 +18,8 @@ export async function hover(document: TextDocument, position: Position): Promise
|
|||||||
|
|
||||||
if (result.value && token) {
|
if (result.value && token) {
|
||||||
// If the parent is a MappingToken and no keyToken was returned, our token is the key
|
// If the parent is a MappingToken and no keyToken was returned, our token is the key
|
||||||
if (parent?.templateTokenType === TokenType.Mapping && !keyToken) {
|
if (parent && isMapping(parent) && !keyToken) {
|
||||||
const mappingToken = parent as MappingToken;
|
const value = parent.find(token.toString());
|
||||||
const value = mappingToken.find(token.toString());
|
|
||||||
if (value) {
|
if (value) {
|
||||||
return getHover(token, value);
|
return getHover(token, value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user