Merge branch 'main' into thyeggman/cronstrue-hover

This commit is contained in:
Jacob Wallraff
2023-01-24 11:17:08 -08:00
12 changed files with 426 additions and 91 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@github/actions-languageservice",
"version": "0.1.92",
"version": "0.1.94",
"description": "Language service for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -38,8 +38,8 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@github/actions-expressions": "^0.1.92",
"@github/actions-workflow-parser": "^0.1.92",
"@github/actions-expressions": "^0.1.94",
"@github/actions-workflow-parser": "^0.1.94",
"vscode-languageserver-textdocument": "^1.0.7",
"vscode-languageserver-types": "^3.17.2",
"yaml": "^2.1.1"
+24 -1
View File
@@ -129,6 +129,26 @@ jobs:
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("");
});
it("shows context inherited from parent nodes", async () => {
const input = `
on: push
jobs:
build:
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v2
with:
ref|: main
`;
const result = await hover(...getPositionFromCursor(input));
expect(result).not.toBeUndefined();
// The `ref` is a `string` definition and inherits the context from `step-with`
const expected = "**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
expect(result?.contents).toEqual(expected);
});
});
describe("hover with description provider", () => {
@@ -146,7 +166,10 @@ jobs:
const result = await hover(...getPositionFromCursor(input), testHoverConfig("ref", "string", "The branch, tag or SHA to checkout."));
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("The branch, tag or SHA to checkout.");
const expected = "The branch, tag or SHA to checkout.\n\n" +
"**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
expect(result?.contents).toEqual(expected);
});
it("falls back to the token description", async () => {
+3 -4
View File
@@ -51,11 +51,10 @@ export async function hover(document: TextDocument, position: Position, config?:
let description = await getDescription(document, config, result, token, tokenResult.path);
if (token.definition.evaluatorContext.length > 0) {
const allowedContext = token.definitionInfo?.allowedContext;
if (allowedContext && allowedContext?.length > 0) {
// Only add padding if there is a description
description += `${description.length > 0 ? `\n\n` : ""}**Context:** ${token.definition.evaluatorContext.join(
", "
)}`;
description += `${description.length > 0 ? `\n\n` : ""}**Context:** ${allowedContext.join(", ")}`;
}
return {