forked from dfinity/vscode-motoko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38684d3
commit 1c7fb9e
Showing
1 changed file
with
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { readFileSync } from 'node:fs'; | ||
import { DocumentSymbol, Hover } from 'vscode-languageserver/node'; | ||
import { URI } from 'vscode-uri'; | ||
import { createBenchmark, Setup, wait } from './helpers'; | ||
import { join } from 'node:path'; | ||
|
||
createBenchmark('didChange', async (setup: Setup) => { | ||
const file = join( | ||
setup.rootUri.fsPath, | ||
'src', | ||
'game_launcher_backend', | ||
'launchpad', | ||
'swap.mo', | ||
); | ||
const fileUri = URI.file(file); | ||
const document = { | ||
uri: `${fileUri}`, | ||
version: 1, | ||
text: readFileSync(file, 'utf-8'), | ||
}; | ||
|
||
await setup.sendNotification('textDocument/didOpen', { | ||
textDocument: { | ||
...document, | ||
languageId: 'motoko', | ||
}, | ||
}); | ||
|
||
await setup.sendNotification('workspace/didChangeConfiguration', { | ||
settings: { | ||
motoko: { | ||
dfx: 'dfx', | ||
legacyLanguageServer: true, | ||
maxNumberOfProblems: 100, | ||
hideWarningRegex: '', | ||
trace: { | ||
server: 'verbose', | ||
}, | ||
debugHover: false, | ||
canister: '', | ||
formatter: 'prettier', | ||
}, | ||
}, | ||
}); | ||
|
||
await setup.benchmark<DocumentSymbol>('textDocument/documentSymbol', { | ||
textDocument: { uri: document.uri }, | ||
}); | ||
|
||
await setup.benchmark<Hover>('textDocument/hover', { | ||
textDocument: { uri: document.uri }, | ||
position: { line: 14, character: 15 }, | ||
}); | ||
|
||
await wait(3); | ||
|
||
await setup.benchmark<Hover>('textDocument/hover', { | ||
textDocument: { uri: document.uri }, | ||
position: { line: 14, character: 15 }, | ||
}); | ||
|
||
document.version++; | ||
await setup.sendNotification( | ||
'textDocument/didChange', | ||
{ | ||
textDocument: { | ||
uri: document.uri, | ||
version: document.version, | ||
}, | ||
contentChanges: [ | ||
{ | ||
text: document.text, | ||
}, | ||
], | ||
}, | ||
100, | ||
); | ||
|
||
await wait(0.5); | ||
|
||
await setup.benchmark<Hover>('textDocument/hover', { | ||
textDocument: { uri: document.uri }, | ||
position: { line: 64, character: 14 }, | ||
}); | ||
}); |