Skip to content

Commit df53427

Browse files
committed
Refactor getPatternMatchCompletions using map
1 parent a88e5d3 commit df53427

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
@@ -772,8 +772,6 @@ function getWhereClauseCompletions(): CompletionItem[] {
772772
}
773773

774774
function getPatternMatchCompletions(): CompletionItem[] {
775-
const completions: CompletionItem[] = [];
776-
777775
const patterns = [
778776
{ label: "basic pattern", insertText: "| ${1:pattern} -> ${2:expression}" },
779777
{ label: "catch-all", insertText: "| _ -> ${1:default}" },
@@ -802,19 +800,17 @@ function getPatternMatchCompletions(): CompletionItem[] {
802800
{ label: "text pattern", insertText: '| "${1:text}" -> ${2:expression}' },
803801
];
804802

805-
patterns.forEach((pattern, index) => {
806-
completions.push({
803+
return patterns.map((pattern, index) => {
804+
return {
807805
label: pattern.label,
808806
kind: CompletionItemKind.Snippet,
809807
detail: "Pattern match case",
810808
documentation: `Pattern matching case: ${pattern.label}`,
811809
insertText: pattern.insertText,
812810
insertTextFormat: InsertTextFormat.Snippet,
813811
sortText: `0${index.toString().padStart(2, "0")}`,
814-
});
812+
}
815813
});
816-
817-
return completions;
818814
}
819815

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

0 commit comments

Comments
 (0)