in src/completion/completeSnippets.ts [58:97]
export default function completeSnippets(
node: ASTNode | undefined,
offset: number,
options?: CompleteSnippetsOptions,
): CompletionItem[] {
if (node) {
const errorSnippetOptionsNotDefined = options?.shouldShowErrorSnippets === undefined
// If the value of shouldShowStateSnippets is false prevent the snippets from being displayed
const showStateSnippets =
options?.shouldShowStateSnippets || (options?.shouldShowStateSnippets === undefined && isChildOfStates(node))
if (showStateSnippets) {
return stateSnippets
}
if (errorSnippetOptionsNotDefined) {
if (insideStateNode(node) && doesStateSupportErrorHandling(node)) {
return errorHandlingSnippets
}
return []
}
const errorSnippetsToShow: string[] = []
if (options?.shouldShowErrorSnippets?.catch) {
errorSnippetsToShow.push('Catch')
}
if (options?.shouldShowErrorSnippets?.retry) {
errorSnippetsToShow.push('Retry')
}
if (errorSnippetsToShow.length) {
return errorHandlingSnippets.filter((snippet) => errorSnippetsToShow.includes(snippet.label))
}
}
return []
}