Add a needs context provider for auto-completion

This commit is contained in:
Josh Gross
2022-11-30 11:21:32 -05:00
parent 6704debc09
commit 643917ae9d
6 changed files with 132 additions and 8 deletions
+2 -2
View File
@@ -65,6 +65,7 @@ export async function complete(
const {token, keyToken, parent, path} = findToken(newPos, result.value);
const template = convertWorkflowTemplate(result.context, result.value, ErrorPolicy.TryConversion);
const workflowContext = getWorkflowContext(textDocument.uri, template, path);
// If we are inside an expression, take a different code-path. The workflow parser does not correctly create
// expression nodes for invalid expressions and during editing expressions are invalid most of the time.
@@ -82,13 +83,12 @@ export async function complete(
const expressionInput = (getExpressionInput(currentInput, relCharPos) || "").trim();
const allowedContext = getAllowedContext(token, parent!);
const context = await getContext(allowedContext, contextProviderConfig);
const context = await getContext(allowedContext, contextProviderConfig, workflowContext);
return completeExpression(expressionInput, context, []);
}
}
const workflowContext = getWorkflowContext(textDocument.uri, template, path);
const values = await getValues(token, parent, valueProviderConfig, workflowContext);
return values.map(value => CompletionItem.create(value.label));
}