Skip to content

Commit

Permalink
fix: catch internal errors caused by wrong synthetic nodes created by…
Browse files Browse the repository at this point in the history
… completion provider (#1001)

### Summary of Changes

Triggering completion could lead to errors like `Error: SdsMap:result is
not a valid reference id.`. These are now caught, since the completion
provider inevitably sometimes creates the wrong synthetic nodes before
invoking the scope provider.
  • Loading branch information
lars-reimann authored Apr 6, 2024
1 parent 854122c commit 8a6ab99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export class SafeDsScopeProvider extends DefaultScopeProvider {
} else if (isSdsYield(node) && context.property === 'result') {
return this.getScopeForYieldResult(node);
} else {
return super.getScope(context);
try {
// May throw errors when triggered from the completion provider due to wrong synthetic nodes
return super.getScope(context);
} catch {
return EMPTY_SCOPE;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ describe('SafeDsCompletionProvider', async () => {
shouldContain: ['Annotation', 'MyAnnotation', 'OtherAnnotation'],
},
},
{
testName: 'no error when completing block lambda result',
code: `
pipeline myPipeline {
(param1) {
yield <|>
}
`,
expectedLabels: {
shouldEqual: [],
},
},
];

it.each(testCases)('$testName', async ({ code, uri, expectedLabels }) => {
Expand Down

0 comments on commit 8a6ab99

Please sign in to comment.