Add output description to hover
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {isMapping, isString, ParseWorkflowResult} from "@github/actions-workflow-parser";
|
||||
import {isMapping, isString} from "@github/actions-workflow-parser";
|
||||
import {DESCRIPTION} from "@github/actions-workflow-parser/templates/template-constants";
|
||||
import {WorkflowContext} from "../context/workflow-context";
|
||||
import {TokenResult} from "../utils/find-token";
|
||||
|
||||
@@ -34,4 +34,28 @@ jobs:
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual("**Context:** github, inputs, vars, needs, strategy, matrix");
|
||||
});
|
||||
|
||||
it("hover on job output with description", async () => {
|
||||
const input = `
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: ./reusable-workflow-with-outputs.yaml
|
||||
echo_outputs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- run: echo \${{ needs.build.outputs.bu|ild_id }}
|
||||
`;
|
||||
|
||||
const result = await hover(
|
||||
...getPositionFromCursor(input),
|
||||
testHoverConfig("", "string-steps-context")
|
||||
);
|
||||
expect(result).not.toBeUndefined();
|
||||
expect(result?.contents).toEqual(
|
||||
"The resulting build ID\n\n**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,10 +15,7 @@ import {Hover} from "vscode-languageserver-types";
|
||||
import {ContextProviderConfig} from "./context-providers/config";
|
||||
import {getContext, Mode} from "./context-providers/default";
|
||||
import {getWorkflowContext, WorkflowContext} from "./context/workflow-context";
|
||||
import {
|
||||
isReusableWorkflowJobInput,
|
||||
getReusableWorkflowInputDescription
|
||||
} from "./description-providers/reusable-job-inputs";
|
||||
import {isReusableWorkflowJobInput, getReusableWorkflowInputDescription} from "./description-providers/reusable-job-inputs";
|
||||
import {ExpressionPos, mapToExpressionPos} from "./expression-hover/expression-pos";
|
||||
import {HoverVisitor} from "./expression-hover/visitor";
|
||||
import {validatorFunctions} from "./expression-validation/functions";
|
||||
@@ -67,7 +64,11 @@ export async function hover(document: TextDocument, position: Position, config?:
|
||||
|
||||
const exprPos = mapToExpressionPos(token, position);
|
||||
if (exprPos) {
|
||||
return expressionHover(exprPos, context, namedContexts, functions);
|
||||
let hover = expressionHover(exprPos, context, namedContexts, functions);
|
||||
if (hover) {
|
||||
hover.contents = appendContext(token, hover.contents as string);
|
||||
}
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user