Ensure inherited context is shown on hover
This commit is contained in:
@@ -95,6 +95,27 @@ jobs:
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual("Runs your workflow when you push a commit or tag.");
|
||||
});
|
||||
|
||||
|
||||
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", () => {
|
||||
@@ -112,7 +133,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 () => {
|
||||
|
||||
@@ -35,11 +35,10 @@ export async function hover(document: TextDocument, position: Position, config?:
|
||||
|
||||
let description = await getDescription(document, config, result, token, 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 {
|
||||
|
||||
Reference in New Issue
Block a user