Skip to content

Commit ee2848b

Browse files
authored
feat: add compilerBuild argument support (#1964)
Adds support for the new `compilerBuild` setting
1 parent 1281065 commit ee2848b

File tree

3 files changed

+106
-2
lines changed

3 files changed

+106
-2
lines changed

packages/language-server/src/__test__/completions/single-file.test.ts

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ describe('Completions', function () {
431431
label: 'importFileExtension',
432432
kind: CompletionItemKind.Field,
433433
}
434+
const fieldCompilerBuild = {
435+
label: 'compilerBuild',
436+
kind: CompletionItemKind.Field,
437+
}
434438
//#endregion
435439

436440
test('Diagnoses generator field suggestions in empty block', () => {
@@ -493,6 +497,7 @@ describe('Completions', function () {
493497
fieldModuleFormat,
494498
fieldGeneratedFileExtension,
495499
fieldImportFileExtension,
500+
fieldCompilerBuild,
496501
],
497502
},
498503
})
@@ -713,6 +718,29 @@ describe('Completions', function () {
713718
},
714719
})
715720
})
721+
722+
test('compilerBuild = "|"', () => {
723+
assertCompletion({
724+
schema: /* Prisma */ `
725+
generator gen {
726+
provider = "prisma-client"
727+
compilerBuild = "|"
728+
}`,
729+
expected: {
730+
isIncomplete: true,
731+
items: [
732+
{
733+
label: 'fast',
734+
kind: CompletionItemKind.Constant,
735+
},
736+
{
737+
label: 'small',
738+
kind: CompletionItemKind.Constant,
739+
},
740+
],
741+
},
742+
})
743+
})
716744
})
717745

718746
describe('prisma-client-js', () => {
@@ -725,7 +753,30 @@ describe('Completions', function () {
725753
}`,
726754
expected: {
727755
isIncomplete: false,
728-
items: [fieldPreviewFeatures, fieldOutput],
756+
items: [fieldPreviewFeatures, fieldOutput, fieldCompilerBuild],
757+
},
758+
})
759+
})
760+
761+
test('compilerBuild = "|"', () => {
762+
assertCompletion({
763+
schema: /* Prisma */ `
764+
generator gen {
765+
provider = "prisma-client-js"
766+
compilerBuild = "|"
767+
}`,
768+
expected: {
769+
isIncomplete: true,
770+
items: [
771+
{
772+
label: 'fast',
773+
kind: CompletionItemKind.Constant,
774+
},
775+
{
776+
label: 'small',
777+
kind: CompletionItemKind.Constant,
778+
},
779+
],
729780
},
730781
})
731782
})
@@ -3112,7 +3163,7 @@ describe('Completions', function () {
31123163
id Int @id
31133164
lists ${scalarType}[] @default([|])
31143165
}
3115-
3166+
31163167
enum color {
31173168
RED
31183169
GREEN

packages/language-server/src/lib/completions/completions.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119
"insertText": "importFileExtension = \"$0\"",
120120
"documentation": "File extension used in import statements. Can be ts, mts, cts, js, mjs, cjs, or empty (for bare imports).",
121121
"fullSignature": "importFileExtension = \"ts\" | \"mts\" | \"cts\" | \"js\" | \"mjs\" | \"cjs\" | \"\""
122+
},
123+
{
124+
"label": "compilerBuild",
125+
"insertText": "compilerBuild = \"$0\"",
126+
"documentation": "The build of the query compiler to use. Can be 'fast' or 'small'.",
127+
"fullSignature": "compilerBuild = \"fast\" | \"small\""
122128
}
123129
],
124130
"generatorPrismaClientJSFields": [
@@ -133,6 +139,12 @@
133139
"insertText": "output = \"$0\"",
134140
"documentation": "Determines the location for the generated client. Default: `node_modules/.prisma/client`. [Learn more](https://pris.ly/d/generator-fields).",
135141
"fullSignature": "output = \"String\""
142+
},
143+
{
144+
"label": "compilerBuild",
145+
"insertText": "compilerBuild = \"$0\"",
146+
"documentation": "The build of the query compiler to use. Can be 'fast' or 'small'.",
147+
"fullSignature": "compilerBuild = \"fast\" | \"small\""
136148
}
137149
],
138150
"blockAttributes": [
@@ -519,6 +531,16 @@
519531
"documentation": "For bare imports."
520532
}
521533
],
534+
"compilerBuild": [
535+
{
536+
"label": "fast",
537+
"documentation": "Faster query execution. Larger bundle size."
538+
},
539+
{
540+
"label": "small",
541+
"documentation": "Smaller bundle size. Slower query execution."
542+
}
543+
],
522544
"runtimeArguments": [
523545
{
524546
"label": "\"\"",
@@ -547,6 +569,13 @@
547569
"documentation": "File extension used in import statements."
548570
}
549571
],
572+
"compilerBuildArguments": [
573+
{
574+
"label": "\"\"",
575+
"insertText": "\"$0\"",
576+
"documentation": "The build of the query compiler to use."
577+
}
578+
],
550579
"datasourceProviders": [
551580
{
552581
"label": "mysql",

packages/language-server/src/lib/completions/generator.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ const importFileExtensions: CompletionItem[] = convertToCompletionItems(
150150
CompletionItemKind.Constant,
151151
)
152152

153+
const compilerBuildArguments: CompletionItem[] = convertToCompletionItems(
154+
completions.compilerBuildArguments,
155+
CompletionItemKind.Property,
156+
)
157+
158+
const compilerBuilds: CompletionItem[] = convertToCompletionItems(
159+
completions.compilerBuild,
160+
CompletionItemKind.Constant,
161+
)
162+
153163
// Fields for prisma-client generator
154164
const prismaClientFields: CompletionItem[] = convertToCompletionItems(
155165
completions.generatorPrismaClientFields,
@@ -383,4 +393,18 @@ export const generatorSuggestions = (
383393
isIncomplete: true,
384394
}
385395
}
396+
397+
// compilerBuild
398+
if (line.startsWith('compilerBuild')) {
399+
if (isInsideQuotation) {
400+
return {
401+
items: compilerBuilds,
402+
isIncomplete: true,
403+
}
404+
}
405+
return {
406+
items: compilerBuildArguments,
407+
isIncomplete: true,
408+
}
409+
}
386410
}

0 commit comments

Comments
 (0)