From 3eabb5ad81b5de454b4b91ea29f2a2ccf74db7c9 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Tue, 22 Nov 2022 16:53:01 -0800 Subject: [PATCH] Add some docs for findToken --- actions-languageservice/src/utils/find-token.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/actions-languageservice/src/utils/find-token.ts b/actions-languageservice/src/utils/find-token.ts index 8d2cbfd..4e840f2 100644 --- a/actions-languageservice/src/utils/find-token.ts +++ b/actions-languageservice/src/utils/find-token.ts @@ -16,6 +16,18 @@ export type TokenResult = { parent: TemplateToken | null; }; +/** + * Find a token at the given position in the document. + * + * If the position is within + * - the key of a mapping, parent will be the mapping, keyToken will be null, and token will be the key. + * - the value of a mapping, parent will be the mapping, keyToken will be the key for the value, and token will be the value + * - a sequence item, parent will be the sequence, keyToken will be null, and token will be the item + * + * @param pos Position within the document for which to find a token + * @param root Root node + * @returns Token result + */ export function findToken(pos: Position, root?: TemplateToken): TokenResult { if (!root) { return {