Remove unused code and address feedback

This commit is contained in:
Jacob Wallraff
2023-03-06 11:33:28 -08:00
parent bde26c84ea
commit 6aaeefb9c2
7 changed files with 6 additions and 9 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ export async function complete(
return [];
}
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, textDocument.uri, config, {
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, textDocument.uri, config, {
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0,
errorPolicy: ErrorPolicy.TryConversion
});
+1 -1
View File
@@ -18,7 +18,7 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
return [];
}
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, document.uri, undefined, {
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, document.uri, undefined, {
errorPolicy: ErrorPolicy.TryConversion
});
+1 -1
View File
@@ -48,7 +48,7 @@ export async function hover(document: TextDocument, position: Position, config?:
return null;
}
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, document.uri, config, {
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, document.uri, config, {
errorPolicy: ErrorPolicy.TryConversion,
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0
});
+1 -2
View File
@@ -27,7 +27,7 @@ export function clearWorkflowTemplateCache() {
export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResult | undefined {
let result = parsedWorkflowCache.get(uri);
if (!result || !result.value) {
if (!result?.value) {
result = parseWorkflow(file, nullTrace);
if (!result.value) {
return undefined;
@@ -38,7 +38,6 @@ export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResu
}
export async function fetchOrConvertWorkflowTemplate(
file: File,
parsedWorkflow: ParseWorkflowResult,
uri: string,
config?: CompletionConfig,
+1 -1
View File
@@ -53,7 +53,7 @@ export async function validate(textDocument: TextDocument, config?: ValidationCo
if (parsedWorkflow.value) {
// Errors will be updated in the context. Attempt to do the conversion anyway in order to give the user more information
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, textDocument.uri, config, {
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, textDocument.uri, config, {
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0,
errorPolicy: ErrorPolicy.TryConversion
});
+1 -1
View File
@@ -38,7 +38,7 @@ jobs:
`convertWorkflowTemplate` then takes that intermediate representation and converts it to a [`WorkflowTemplate`](./src/workflow-template.ts) object, which is a more convenient representation for working with workflows.
```typescript
const workflowTemplate = await convertWorkflowTemplate("test.yaml", result.context, result.value);
const workflowTemplate = await convertWorkflowTemplate(result.context, result.value);
// workflowTemplate.jobs[0].id === "build"
// workflowTemplate.jobs[0].steps[0].run === "echo 'hello'"
-2
View File
@@ -11,8 +11,6 @@ import {convertReferencedWorkflow} from "./converter/referencedWorkflow";
import {isReusableWorkflowJob} from "./type-guards";
import {WorkflowTemplate} from "./workflow-template";
const workflowTemplateCache = new Map<string, WorkflowTemplate>();
export enum ErrorPolicy {
ReturnErrorsOnly,
TryConversion