Remove unused code and address feedback
This commit is contained in:
@@ -70,7 +70,7 @@ export async function complete(
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, textDocument.uri, config, {
|
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, textDocument.uri, config, {
|
||||||
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0,
|
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0,
|
||||||
errorPolicy: ErrorPolicy.TryConversion
|
errorPolicy: ErrorPolicy.TryConversion
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, document.uri, undefined, {
|
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, document.uri, undefined, {
|
||||||
errorPolicy: ErrorPolicy.TryConversion
|
errorPolicy: ErrorPolicy.TryConversion
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export async function hover(document: TextDocument, position: Position, config?:
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const template = await fetchOrConvertWorkflowTemplate(file, parsedWorkflow, document.uri, config, {
|
const template = await fetchOrConvertWorkflowTemplate(parsedWorkflow, document.uri, config, {
|
||||||
errorPolicy: ErrorPolicy.TryConversion,
|
errorPolicy: ErrorPolicy.TryConversion,
|
||||||
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0
|
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export function clearWorkflowTemplateCache() {
|
|||||||
|
|
||||||
export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResult | undefined {
|
export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResult | undefined {
|
||||||
let result = parsedWorkflowCache.get(uri);
|
let result = parsedWorkflowCache.get(uri);
|
||||||
if (!result || !result.value) {
|
if (!result?.value) {
|
||||||
result = parseWorkflow(file, nullTrace);
|
result = parseWorkflow(file, nullTrace);
|
||||||
if (!result.value) {
|
if (!result.value) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -38,7 +38,6 @@ export function fetchOrParseWorkflow(file: File, uri: string): ParseWorkflowResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchOrConvertWorkflowTemplate(
|
export async function fetchOrConvertWorkflowTemplate(
|
||||||
file: File,
|
|
||||||
parsedWorkflow: ParseWorkflowResult,
|
parsedWorkflow: ParseWorkflowResult,
|
||||||
uri: string,
|
uri: string,
|
||||||
config?: CompletionConfig,
|
config?: CompletionConfig,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export async function validate(textDocument: TextDocument, config?: ValidationCo
|
|||||||
|
|
||||||
if (parsedWorkflow.value) {
|
if (parsedWorkflow.value) {
|
||||||
// Errors will be updated in the context. Attempt to do the conversion anyway in order to give the user more information
|
// 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,
|
fetchReusableWorkflowDepth: config?.fileProvider ? 1 : 0,
|
||||||
errorPolicy: ErrorPolicy.TryConversion
|
errorPolicy: ErrorPolicy.TryConversion
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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.
|
`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
|
```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].id === "build"
|
||||||
// workflowTemplate.jobs[0].steps[0].run === "echo 'hello'"
|
// workflowTemplate.jobs[0].steps[0].run === "echo 'hello'"
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import {convertReferencedWorkflow} from "./converter/referencedWorkflow";
|
|||||||
import {isReusableWorkflowJob} from "./type-guards";
|
import {isReusableWorkflowJob} from "./type-guards";
|
||||||
import {WorkflowTemplate} from "./workflow-template";
|
import {WorkflowTemplate} from "./workflow-template";
|
||||||
|
|
||||||
const workflowTemplateCache = new Map<string, WorkflowTemplate>();
|
|
||||||
|
|
||||||
export enum ErrorPolicy {
|
export enum ErrorPolicy {
|
||||||
ReturnErrorsOnly,
|
ReturnErrorsOnly,
|
||||||
TryConversion
|
TryConversion
|
||||||
|
|||||||
Reference in New Issue
Block a user