Add a FileProvider to parseWorkflow

This commit is contained in:
Josh Gross
2023-02-06 11:15:15 -05:00
parent c55066fbec
commit f4dde16b61
19 changed files with 96 additions and 161 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export async function complete(
name: textDocument.uri,
content: newDoc.getText()
};
const result = parseWorkflow(file.name, [file], nullTrace);
const result = parseWorkflow(file, nullTrace);
if (!result.value) {
return [];
}
@@ -8,13 +8,10 @@ import {getWorkflowContext, WorkflowContext} from "./workflow-context";
function testGetWorkflowContext(input: string): WorkflowContext {
const [textDocument, pos] = getPositionFromCursor(input);
const result = parseWorkflow(
"wf.yaml",
[
{
content: textDocument.getText(),
name: "wf.yaml"
}
],
{
content: textDocument.getText(),
name: "wf.yaml"
},
nullTrace
);
@@ -14,7 +14,7 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
content: document.getText()
};
const result = parseWorkflow(file.name, [file], nullTrace);
const result = parseWorkflow(file, nullTrace);
if (!result.value) {
return [];
}
@@ -78,7 +78,7 @@ function testMapToExpressionPos(input: string) {
name: td.uri,
content: td.getText()
};
const result = parseWorkflow(file.name, [file], nullTrace);
const result = parseWorkflow(file, nullTrace);
if (!result.value) {
throw new Error("Invalid workflow");
}
@@ -105,7 +105,7 @@ async function hoverExpression(input: string) {
name: td.uri,
content: td.getText()
};
const result = parseWorkflow(file.name, [file], nullTrace);
const result = parseWorkflow(file, nullTrace);
if (!result.value) {
return undefined;
}
+1 -1
View File
@@ -37,7 +37,7 @@ export async function hover(document: TextDocument, position: Position, config?:
name: document.uri,
content: document.getText()
};
const result = parseWorkflow(file.name, [file], nullTrace);
const result = parseWorkflow(file, nullTrace);
if (!result.value) {
return null;
}
@@ -27,13 +27,10 @@ function testFindToken(input: string): {
} {
const [textDocument, pos] = getPositionFromCursor(input);
const result = parseWorkflow(
"wf.yaml",
[
{
content: textDocument.getText(),
name: "wf.yaml"
}
],
{
content: textDocument.getText(),
name: "wf.yaml"
},
nullTrace
);
+1 -1
View File
@@ -56,7 +56,7 @@ export async function validate(
const diagnostics: Diagnostic[] = [];
try {
const result: ParseWorkflowResult = parseWorkflow(file.name, [file], nullTrace);
const result: ParseWorkflowResult = parseWorkflow(file, nullTrace);
if (result.value) {
// Errors will be updated in the context. Attempt to do the conversion anyway in order to give the user more information
const template = convertWorkflowTemplate(result.context, result.value, ErrorPolicy.TryConversion);
@@ -1,5 +0,0 @@
import {File} from "@github/actions-workflow-parser/workflows/file";
export type WorkflowProvider = {
getWorkflow: (name: string) => Promise<File | undefined>;
};