Files
languageservices/languageserver/src/description-provider.ts
T

22 lines
727 B
TypeScript
Raw Normal View History

2023-01-23 16:02:13 -05:00
import {DescriptionProvider} from "@github/actions-languageservice/hover";
import {Octokit} from "@octokit/rest";
import {getActionInputDescription} from "./description-providers/action-input";
2023-01-30 17:05:32 -08:00
import {TTLCache} from "./utils/cache";
2023-01-23 16:02:13 -05:00
2023-01-30 17:05:32 -08:00
export function descriptionProvider(client: Octokit | undefined, cache: TTLCache): DescriptionProvider {
2023-01-23 16:02:13 -05:00
const getDescription: DescriptionProvider["getDescription"] = async (context, token, path) => {
2023-01-30 17:05:32 -08:00
if (!client) {
2023-01-23 16:02:13 -05:00
return undefined;
}
2023-01-30 17:05:32 -08:00
2023-01-23 16:02:13 -05:00
const parent = path[path.length - 1];
if (context.step && parent.definition?.key === "step-with") {
2023-01-30 17:05:32 -08:00
return await getActionInputDescription(client, cache, context.step, token);
2023-01-23 16:02:13 -05:00
}
};
return {
getDescription
};
}