-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
companion pr to prisma/prisma-engines#4934
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/language-server/src/lib/prisma-schema-wasm/references.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Location, ReferenceParams } from 'vscode-languageserver' | ||
import { PrismaSchema } from '../Schema' | ||
import { handleFormatPanic, handleWasmError } from './internals' | ||
import { prismaSchemaWasm } from '.' | ||
|
||
export default function references( | ||
schema: PrismaSchema, | ||
params: ReferenceParams, | ||
onError?: (errorMessage: string) => void, | ||
): Location[] | undefined { | ||
try { | ||
if (process.env.FORCE_PANIC_PRISMA_SCHEMA) { | ||
handleFormatPanic(() => { | ||
console.debug('Triggering a Rust panic...') | ||
prismaSchemaWasm.debug_panic() | ||
}) | ||
} | ||
|
||
const response = prismaSchemaWasm.references(JSON.stringify(schema), JSON.stringify(params)) | ||
|
||
return JSON.parse(response) as Location[] | ||
} catch (e) { | ||
const err = e as Error | ||
|
||
handleWasmError(err, 'references', onError) | ||
|
||
return undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters