-
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.
tech(LS): moving hover functionality to engines (#1766)
* Moves hover impl to engines, for further details: prisma/prisma-engines#4923
- Loading branch information
Showing
14 changed files
with
207 additions
and
135 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/language-server/src/__test__/__fixtures__/multi-file/user-posts/Post.prisma
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
6 changes: 5 additions & 1 deletion
6
packages/language-server/src/__test__/__fixtures__/multi-file/user-posts/User.prisma
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
/// This is the user of the platform | ||
model User { | ||
id String @id @default(uuid()) | ||
id String @id @default(uuid()) @map("_id") | ||
name String | ||
email String | ||
posts Post[] | ||
address Address | ||
favouriteAnimal FavouriteAnimal | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/language-server/src/__test__/__fixtures__/multi-file/user-posts/address.prisma
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,6 @@ | ||
/// Petrichor V | ||
type Address { | ||
/// ISO 3166-2 standard | ||
country String | ||
POBox Int | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/language-server/src/__test__/__fixtures__/multi-file/user-posts/animal.prisma
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,6 @@ | ||
/// My favourite is the red panda, could you tell? | ||
enum FavouriteAnimal { | ||
RedPanda | ||
Cat | ||
Dog | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/language-server/src/__test__/__fixtures__/multi-file/user-posts/config.prisma
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
datasource db { | ||
provider = "postgresql" | ||
provider = "mongodb" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
|
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,135 @@ | ||
import { test, expect, describe } from 'vitest' | ||
import { handleHoverRequest } from '../lib/MessageHandler' | ||
import { getMultifileHelper } from './MultifileHelper' | ||
|
||
describe('hover', () => { | ||
test('model doc from field', async () => { | ||
const helper = await getMultifileHelper('user-posts') | ||
const user = helper.file('User.prisma') | ||
|
||
const response = handleHoverRequest(helper.schema, user.textDocument, { | ||
textDocument: { | ||
uri: user.uri, | ||
}, | ||
position: user.lineContaining('posts Post[]').characterAfter('Po'), | ||
}) | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
{ | ||
"contents": { | ||
"kind": "markdown", | ||
"value": "\`\`\`prisma | ||
model Post { | ||
... | ||
author User @relation(name: "PostToUser", fields: [authorId], references: [id]) | ||
} | ||
\`\`\` | ||
___ | ||
one-to-many | ||
___ | ||
This is a blog post", | ||
}, | ||
} | ||
`) | ||
}) | ||
|
||
test('enum doc from field', async () => { | ||
const helper = await getMultifileHelper('user-posts') | ||
const user = helper.file('User.prisma') | ||
|
||
const response = handleHoverRequest(helper.schema, user.textDocument, { | ||
textDocument: { | ||
uri: user.uri, | ||
}, | ||
position: user.lineContaining('favouriteAnimal FavouriteAnimal').characterAfter('Favo'), | ||
}) | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
{ | ||
"contents": { | ||
"kind": "markdown", | ||
"value": "\`\`\`prisma | ||
enum FavouriteAnimal {} | ||
\`\`\` | ||
___ | ||
My favourite is the red panda, could you tell?", | ||
}, | ||
} | ||
`) | ||
}) | ||
|
||
test('composite doc from field', async () => { | ||
const helper = await getMultifileHelper('user-posts') | ||
const user = helper.file('User.prisma') | ||
|
||
const response = handleHoverRequest(helper.schema, user.textDocument, { | ||
textDocument: { | ||
uri: user.uri, | ||
}, | ||
position: user.lineContaining('address Address').characterAfter('Addr'), | ||
}) | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
{ | ||
"contents": { | ||
"kind": "markdown", | ||
"value": "\`\`\`prisma | ||
type Address {} | ||
\`\`\` | ||
___ | ||
Petrichor V", | ||
}, | ||
} | ||
`) | ||
}) | ||
|
||
test('doc from block name', async () => { | ||
const helper = await getMultifileHelper('user-posts') | ||
const user = helper.file('animal.prisma') | ||
|
||
const response = handleHoverRequest(helper.schema, user.textDocument, { | ||
textDocument: { | ||
uri: user.uri, | ||
}, | ||
position: user.lineContaining('enum FavouriteAnimal {').characterAfter('Fav'), | ||
}) | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
{ | ||
"contents": { | ||
"kind": "markdown", | ||
"value": "\`\`\`prisma | ||
enum FavouriteAnimal {} | ||
\`\`\` | ||
___ | ||
My favourite is the red panda, could you tell?", | ||
}, | ||
} | ||
`) | ||
}) | ||
|
||
test('doc from field name', async () => { | ||
const helper = await getMultifileHelper('user-posts') | ||
const user = helper.file('address.prisma') | ||
|
||
const response = handleHoverRequest(helper.schema, user.textDocument, { | ||
textDocument: { | ||
uri: user.uri, | ||
}, | ||
position: user.lineContaining('country String').characterAfter('cou'), | ||
}) | ||
|
||
expect(response).toMatchInlineSnapshot(` | ||
{ | ||
"contents": { | ||
"kind": "markdown", | ||
"value": "\`\`\`prisma | ||
country | ||
\`\`\` | ||
___ | ||
ISO 3166-2 standard", | ||
}, | ||
} | ||
`) | ||
}) | ||
}) |
21 changes: 0 additions & 21 deletions
21
packages/language-server/src/__test__/hover/multi-file.test.ts
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
packages/language-server/src/__test__/hover/single-file.test.ts
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.