Skip to content

Commit fab282f

Browse files
committed
Refactor getPatternMatchCompletions using map
1 parent 7b044d4 commit fab282f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

server/src/server.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,6 @@ function getWhereClauseCompletions(): CompletionItem[] {
766766
}
767767

768768
function getPatternMatchCompletions(): CompletionItem[] {
769-
const completions: CompletionItem[] = [];
770-
771769
const patterns = [
772770
{ label: "basic pattern", insertText: "| ${1:pattern} -> ${2:expression}" },
773771
{ label: "catch-all", insertText: "| _ -> ${1:default}" },
@@ -796,19 +794,17 @@ function getPatternMatchCompletions(): CompletionItem[] {
796794
{ label: "text pattern", insertText: '| "${1:text}" -> ${2:expression}' },
797795
];
798796

799-
patterns.forEach((pattern, index) => {
800-
completions.push({
797+
return patterns.map((pattern, index) => {
798+
return {
801799
label: pattern.label,
802800
kind: CompletionItemKind.Snippet,
803801
detail: "Pattern match case",
804802
documentation: `Pattern matching case: ${pattern.label}`,
805803
insertText: pattern.insertText,
806804
insertTextFormat: InsertTextFormat.Snippet,
807805
sortText: `0${index.toString().padStart(2, "0")}`,
808-
});
806+
}
809807
});
810-
811-
return completions;
812808
}
813809

814810
function getRecordFieldCompletions(recordType?: string): CompletionItem[] {

0 commit comments

Comments
 (0)