Skip to content

Commit 20ad75b

Browse files
feat: show MongoDB completion items before other JS completion VSCODE-382, VSCODE-385 (#490)
* feat: show MongoDB completion items before other JS completion VSCODE-382 * docs: add comment. * test: context in one line * fix: close connections * refactor: use worker only for evaluate * refactor: types clean up * refactor: close connection in finally * refactor: hmm ignore mongosh/browser-runtime-electron * test: wait 1000 * test: fake getTranspiledContent * docs: add completion comments * test: rename suite name * refactor: return default connection details * refactor: address pr comments * fix: send error to formatError * test: try to mock info as well * test: try to not count stages * refactor: remove ignored dep
1 parent eebb3f6 commit 20ad75b

21 files changed

+2860
-2551
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<!-- Ticket number and a general summary of your changes in the Title above -->
22
<!-- e.g. VSCODE-1111: updates ace editor width in agg pipeline view -->
3-
43
<!--- The following fields are not obligatory. Use your best judgement on what you think is applicable to the work you've done -->
5-
64
## Description
75
<!--- Describe your changes in detail -->
86
<!--- If applicable, describe (or illustrate) architecture flow -->
7+
98
### Checklist
109
- [ ] New tests and/or benchmarks are included
1110
- [ ] Documentation is changed or added

package-lock.json

Lines changed: 1699 additions & 1493 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@
10051005
},
10061006
"devDependencies": {
10071007
"@mongodb-js/prettier-config-compass": "^1.0.0",
1008+
"@mongosh/service-provider-core": "^1.8.0",
10081009
"@types/analytics-node": "^3.1.9",
10091010
"@types/babel__core": "^7.1.19",
10101011
"@types/babel__traverse": "^7.18.1",

src/editors/playgroundController.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import playgroundCloneDocumentTemplate from '../templates/playgroundCloneDocumen
2424
import playgroundInsertDocumentTemplate from '../templates/playgroundInsertDocumentTemplate';
2525
import {
2626
PlaygroundResult,
27-
ShellExecuteAllResult,
27+
ShellEvaluateResult,
2828
ExportToLanguageAddons,
2929
ExportToLanguageNamespace,
3030
ExportToLanguageMode,
@@ -378,7 +378,7 @@ export default class PlaygroundController {
378378
return this._createPlaygroundFileWithContent(content);
379379
}
380380

381-
async _evaluate(codeToEvaluate: string): Promise<ShellExecuteAllResult> {
381+
async _evaluate(codeToEvaluate: string): Promise<ShellEvaluateResult> {
382382
const connectionId = this._connectionController.getActiveConnectionId();
383383

384384
if (!connectionId) {
@@ -391,8 +391,8 @@ export default class PlaygroundController {
391391

392392
try {
393393
// Send a request to the language server to execute scripts from a playground.
394-
const result: ShellExecuteAllResult =
395-
await this._languageServerController.executeAll({
394+
const result: ShellEvaluateResult =
395+
await this._languageServerController.evaluate({
396396
codeToEvaluate,
397397
connectionId,
398398
});
@@ -429,7 +429,7 @@ export default class PlaygroundController {
429429
return this._activeTextEditor?.document.getText(selection) || '';
430430
}
431431

432-
async _evaluateWithCancelModal(): Promise<ShellExecuteAllResult> {
432+
async _evaluateWithCancelModal(): Promise<ShellEvaluateResult> {
433433
if (!this._connectionController.isCurrentlyConnected()) {
434434
throw new Error(
435435
'Please connect to a database before running a playground.'
@@ -452,7 +452,7 @@ export default class PlaygroundController {
452452
});
453453

454454
// Run all playground scripts.
455-
const result: ShellExecuteAllResult = await this._evaluate(
455+
const result: ShellEvaluateResult = await this._evaluate(
456456
this._codeToEvaluate
457457
);
458458

@@ -550,7 +550,7 @@ export default class PlaygroundController {
550550

551551
this._outputChannel.clear();
552552

553-
const evaluateResponse: ShellExecuteAllResult =
553+
const evaluateResponse: ShellEvaluateResult =
554554
await this._evaluateWithCancelModal();
555555

556556
if (evaluateResponse?.outputLines?.length) {

src/language/languageServerController.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { workspace, ExtensionContext } from 'vscode';
1212

1313
import { createLogger } from '../logging';
1414
import {
15-
PlaygroundExecuteParameters,
16-
ShellExecuteAllResult,
15+
PlaygroundEvaluateParams,
16+
ShellEvaluateResult,
1717
ExportToLanguageMode,
1818
ExportToLanguageNamespace,
1919
PlaygroundTextAndSelection,
@@ -120,9 +120,9 @@ export default class LanguageServerController {
120120
void this._client.stop();
121121
}
122122

123-
async executeAll(
124-
playgroundExecuteParameters: PlaygroundExecuteParameters
125-
): Promise<ShellExecuteAllResult> {
123+
async evaluate(
124+
playgroundExecuteParameters: PlaygroundEvaluateParams
125+
): Promise<ShellEvaluateResult> {
126126
this._isExecutingInProgress = true;
127127

128128
// Instantiate a new CancellationTokenSource object
@@ -132,8 +132,8 @@ export default class LanguageServerController {
132132
// Send a request with a cancellation token
133133
// to the language server server to execute scripts from a playground
134134
// and return results to the playground controller when ready
135-
const result: ShellExecuteAllResult = await this._client.sendRequest(
136-
ServerCommands.EXECUTE_ALL_FROM_PLAYGROUND,
135+
const result: ShellEvaluateResult = await this._client.sendRequest(
136+
ServerCommands.EXECUTE_CODE_FROM_PLAYGROUND,
137137
playgroundExecuteParameters,
138138
this._source.token
139139
);
@@ -188,4 +188,11 @@ export default class LanguageServerController {
188188
this._isExecutingInProgress = false;
189189
}
190190
}
191+
192+
async updateCurrentSessionFields(params): Promise<void> {
193+
await this._client.sendRequest(
194+
ServerCommands.UPDATE_CURRENT_SESSION_FIELDS,
195+
params
196+
);
197+
}
191198
}

0 commit comments

Comments
 (0)