Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bcb63b9
feat: replace mongodb language with javascript in playgrounds
alenakhineika Jan 23, 2023
7441125
feat: use js grammar only
alenakhineika Jan 24, 2023
93fdf8c
feat: save playgrounds as mongodb ext
alenakhineika Feb 2, 2023
4b3c70c
docs: add comment about read-only root
alenakhineika Feb 2, 2023
7864768
refactor: clean up
alenakhineika Feb 2, 2023
be08215
refactor: better handling new files
alenakhineika Feb 3, 2023
5b3cc4f
refactor: drop fragment
alenakhineika Feb 3, 2023
ed9554c
feat: add mongodb grammar injection
alenakhineika Feb 16, 2023
bc1b982
refactor: restore update-grammar script
alenakhineika Feb 20, 2023
f261589
Merge remote-tracking branch 'origin/main' into playgrounds-in-js-lan…
alenakhineika Feb 20, 2023
3a3c520
docs: update contributing page
alenakhineika Feb 20, 2023
4fda3fa
refactor: update-grammar
alenakhineika Feb 20, 2023
2296df8
feat: update mongodb injection grammar
alenakhineika Feb 20, 2023
c924b69
test: update for playgrounds in js
alenakhineika Feb 20, 2023
a86e0ff
refactor: reformat
alenakhineika Feb 20, 2023
084bfd9
refactor: restore snippets
alenakhineika Feb 20, 2023
1a009ed
refactor: clean up
alenakhineika Feb 20, 2023
989675f
build: bump vscode engine
alenakhineika Feb 21, 2023
97c3cb2
build: clean up dependencies
alenakhineika Feb 21, 2023
5fd5077
refactor: reforamt
alenakhineika Feb 21, 2023
ee55d53
build: try with prev npm
alenakhineika Feb 21, 2023
a120824
build: try old deps
alenakhineika Feb 21, 2023
ad04e91
refactor: reformat
alenakhineika Feb 21, 2023
dd64167
test: use activeTextEditor from the playground controller
alenakhineika Feb 21, 2023
414c3a7
refactor: os homedir
alenakhineika Feb 24, 2023
8d77ef3
refactor: clean up
alenakhineika Feb 27, 2023
9f4f808
refactor: address pr comments
alenakhineika Feb 27, 2023
c8d59c9
test: try bigger timeout
alenakhineika Feb 27, 2023
1a09308
Merge remote-tracking branch 'origin/main' into playgrounds-in-js-lan…
alenakhineika Feb 27, 2023
d04bab4
test: less playground documents open
alenakhineika Feb 27, 2023
6c849d9
test: clean up
alenakhineika Feb 28, 2023
23f3e85
test: assert.strictEqual
alenakhineika Feb 28, 2023
f8b7326
test: mock text flaky text document
alenakhineika Feb 28, 2023
12c4bbc
test: fake vscode messages and get rid of some any
alenakhineika Mar 1, 2023
74a9d1e
refactor: command palette clean up
alenakhineika Mar 1, 2023
bdea66b
Merge remote-tracking branch 'origin/main' into tests-and-commands-cl…
alenakhineika Mar 1, 2023
320a863
refactor: stub status view
alenakhineika Mar 1, 2023
3e717e3
test: use sandbox instead of directly using sinon
alenakhineika Mar 1, 2023
ab1600c
fix: add mdb prefix
alenakhineika Mar 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 16 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
},
{
"view": "mongoDBPlaygroundsExplorer",
"contents": "No '.mongodb' playground files found in the workspace.\n[Create New Playground](command:mdb.createNewPlaygroundFromPlaygroundExplorer)"
"contents": "No MongoDB playground files found in the workspace.\n[Create New Playground](command:mdb.createNewPlaygroundFromTreeView)"
}
],
"languages": [
Expand Down Expand Up @@ -175,10 +175,6 @@
"command": "mdb.createPlayground",
"title": "MongoDB: Create MongoDB Playground"
},
{
"command": "mdb.refreshPlaygrounds",
"title": "MongoDB: Refresh Playgrounds List"
},
{
"command": "mdb.refreshPlaygroundsFromTreeView",
"title": "Refresh",
Expand All @@ -187,16 +183,12 @@
"dark": "images/dark/refresh.svg"
}
},
{
"command": "mdb.createNewPlaygroundFromViewAction",
"title": "Create MongoDB Playground"
},
{
"command": "mdb.createNewPlaygroundFromOverviewPage",
"title": "Create MongoDB Playground"
},
{
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
"command": "mdb.createNewPlaygroundFromTreeView",
"title": "Create MongoDB Playground",
"icon": {
"light": "images/light/add.svg",
Expand Down Expand Up @@ -296,7 +288,7 @@
}
},
{
"command": "mdb.openPlaygroundFromTreeItem",
"command": "mdb.openPlaygroundFromTreeView",
"title": "Open Playground"
},
{
Expand Down Expand Up @@ -407,11 +399,7 @@
"menus": {
"view/title": [
{
"command": "mdb.createNewPlaygroundFromViewAction",
"when": "view == mongoDBPlaygroundsExplorer"
},
{
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
"command": "mdb.createNewPlaygroundFromTreeView",
"when": "view == mongoDBPlaygroundsExplorer",
"group": "navigation@1"
},
Expand Down Expand Up @@ -476,7 +464,7 @@
"group": "5@2"
},
{
"command": "mdb.openPlaygroundFromTreeItem",
"command": "mdb.openPlaygroundFromTreeView",
"when": "view == mongoDBPlaygroundsExplorer && viewItem == playgroundsTreeItem",
"group": "1@1"
},
Expand Down Expand Up @@ -630,6 +618,10 @@
}
],
"commandPalette": [
{
"command": "mdb.disconnect",
"when": "mdb.connectedToMongoDB == true"
},
{
"command": "mdb.saveMongoDBDocument",
"when": "editorLangId == json"
Expand All @@ -644,23 +636,23 @@
},
{
"command": "mdb.exportToRuby",
"when": "mdb.isPlayground == true"
"when": "mdb.isPlayground == true && mdb.connectedToMongoDB == true"
},
{
"command": "mdb.exportToPython",
"when": "mdb.isPlayground == true"
"when": "mdb.isPlayground == true && mdb.connectedToMongoDB == true"
},
{
"command": "mdb.exportToJava",
"when": "mdb.isPlayground == true"
"when": "mdb.isPlayground == true && mdb.connectedToMongoDB == true"
},
{
"command": "mdb.exportToCsharp",
"when": "mdb.isPlayground == true"
"when": "mdb.isPlayground == true && mdb.connectedToMongoDB == true"
},
{
"command": "mdb.exportToNode",
"when": "mdb.isPlayground == true"
"when": "mdb.isPlayground == true && mdb.connectedToMongoDB == true"
},
{
"command": "mdb.refreshPlaygroundsFromTreeView",
Expand All @@ -678,16 +670,12 @@
"command": "mdb.addConnectionWithURI",
"when": "false"
},
{
"command": "mdb.createNewPlaygroundFromViewAction",
"when": "false"
},
{
"command": "mdb.createNewPlaygroundFromOverviewPage",
"when": "false"
},
{
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
"command": "mdb.createNewPlaygroundFromTreeView",
"when": "false"
},
{
Expand Down Expand Up @@ -715,7 +703,7 @@
"when": "false"
},
{
"command": "mdb.openPlaygroundFromTreeItem",
"command": "mdb.openPlaygroundFromTreeView",
"when": "false"
},
{
Expand Down
6 changes: 2 additions & 4 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ enum EXTENSION_COMMANDS {
MDB_SAVE_MONGODB_DOCUMENT = 'mdb.saveMongoDBDocument',

MDB_CHANGE_ACTIVE_CONNECTION = 'mdb.changeActiveConnection',
MDB_REFRESH_PLAYGROUNDS = 'mdb.refreshPlaygrounds',

MDB_CODELENS_SHOW_MORE_DOCUMENTS = 'mdb.codeLens.showMoreDocumentsClicked',

// Commands from the tree view.
MDB_ADD_CONNECTION = 'mdb.addConnection',
MDB_ADD_CONNECTION_WITH_URI = 'mdb.addConnectionWithURI',
MDB_REFRESH_PLAYGROUNDS_FROM_TREE_VIEW = 'mdb.refreshPlaygroundsFromTreeView',
MDB_OPEN_PLAYGROUND_FROM_TREE_VIEW = 'mdb.openPlaygroundFromTreeItem',
MDB_OPEN_PLAYGROUND_FROM_TREE_VIEW = 'mdb.openPlaygroundFromTreeView',
MDB_CONNECT_TO_CONNECTION_TREE_VIEW = 'mdb.connectToConnectionTreeItem',
MDB_CREATE_PLAYGROUND_FROM_VIEW_ACTION = 'mdb.createNewPlaygroundFromViewAction',
MDB_CREATE_PLAYGROUND_FROM_PLAYGROUND_EXPLORER = 'mdb.createNewPlaygroundFromPlaygroundExplorer',
MDB_CREATE_PLAYGROUND_FROM_TREE_VIEW = 'mdb.createNewPlaygroundFromTreeView',
MDB_DISCONNECT_FROM_CONNECTION_TREE_VIEW = 'mdb.disconnectFromConnectionTreeItem',
MDB_REFRESH_CONNECTION = 'mdb.refreshConnection',
MDB_COPY_CONNECTION_STRING = 'mdb.copyConnectionString',
Expand Down
12 changes: 12 additions & 0 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ export default class ConnectionController {
// Send metrics to Segment
this.sendTelemetry(dataService, connectionType);

void vscode.commands.executeCommand(
'setContext',
'mdb.connectedToMongoDB',
true
);

return {
successfullyConnected: true,
connectionErrorMessage: '',
Expand Down Expand Up @@ -570,6 +576,12 @@ export default class ConnectionController {
await this._activeDataService.disconnect();
void vscode.window.showInformationMessage('MongoDB disconnected.');
this._activeDataService = null;

void vscode.commands.executeCommand(
'setContext',
'mdb.connectedToMongoDB',
false
);
} catch (error) {
// Show an error, however we still reset the active connection to free up the extension.
void vscode.window.showErrorMessage(
Expand Down
4 changes: 2 additions & 2 deletions src/editors/playgroundController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ export default class PlaygroundController {
!isPlayground(this._activeTextEditor.document.uri)
) {
void vscode.window.showErrorMessage(
"Please open a '.mongodb' playground file before running it."
'Please open a MongoDB playground file before running it.'
);

return Promise.resolve(false);
Expand All @@ -616,7 +616,7 @@ export default class PlaygroundController {
!isPlayground(this._activeTextEditor.document.uri)
) {
void vscode.window.showErrorMessage(
"Please open a '.mongodb' playground file before running it."
'Please open a MongoDB playground file before running it.'
);

return Promise.resolve(false);
Expand Down
2 changes: 2 additions & 0 deletions src/explorer/collectionTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default class CollectionTreeItem

isDropped = false;

iconPath: { light: string; dark: string };

constructor(
collection: CollectionModelType,
databaseName: string,
Expand Down
2 changes: 2 additions & 0 deletions src/explorer/documentListTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export default class DocumentListTreeItem

isExpanded: boolean;

iconPath: { light: string; dark: string };

constructor(
collectionName: string,
databaseName: string,
Expand Down
2 changes: 2 additions & 0 deletions src/explorer/fieldTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export default class FieldTreeItem

isExpanded: boolean;

iconPath: string | { light: string; dark: string };

constructor(
field: SchemaFieldType,
isExpanded: boolean,
Expand Down
2 changes: 2 additions & 0 deletions src/explorer/schemaTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export default class SchemaTreeItem
hasClickedShowMoreFields: boolean;
hasMoreFieldsToShow: boolean;

iconPath: { light: string; dark: string };

constructor(
collectionName: string,
databaseName: string,
Expand Down
5 changes: 1 addition & 4 deletions src/language/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

The language server protocol [(LSP)](https://microsoft.github.io/language-server-protocol/specification) is mainly used as a tool between the editor (the client) and a language smartness provider (the server) to integrate features like autocomplete, go to definition, find all references, list document symbols, signature help and much more. You can find the complete list of supported features in [the official documentation](https://code.visualstudio.com/api/language-extensions/language-server-extension-guide).

We can also extend the mongodb language server and client with custom methods to leverage it as a background worker. Because the language server is a separate JSON RPC enabled process, we can add RPC definitions for:

- Execute playground .mongodb scripts with mongosh repl evaluator thingie
- Schema analysis and caching
We extend the mongodb language server and client with custom methods to leverage it as a background worker.

### Debugging

Expand Down
4 changes: 0 additions & 4 deletions src/language/languageServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ export default class LanguageServerController {
}

deactivate(): void {
if (!this._client) {
return undefined;
}

// Stop the language server
void this._client.stop();
}
Expand Down
9 changes: 1 addition & 8 deletions src/mdbExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ export default class MDBExtensionController implements vscode.Disposable {
EXTENSION_COMMANDS.MDB_RUN_ALL_OR_SELECTED_PLAYGROUND_BLOCKS,
() => this._playgroundController.runAllOrSelectedPlaygroundBlocks()
);
this.registerCommand(EXTENSION_COMMANDS.MDB_REFRESH_PLAYGROUNDS, () =>
this._playgroundsExplorer.refresh()
);

// ------ EXPORT TO LANGUAGE ------ //
this.registerCommand(EXTENSION_COMMANDS.MDB_EXPORT_TO_PYTHON, () =>
Expand Down Expand Up @@ -546,11 +543,7 @@ export default class MDBExtensionController implements vscode.Disposable {
}
);
this.registerCommand(
EXTENSION_COMMANDS.MDB_CREATE_PLAYGROUND_FROM_VIEW_ACTION,
() => this._playgroundController.createPlayground()
);
this.registerCommand(
EXTENSION_COMMANDS.MDB_CREATE_PLAYGROUND_FROM_PLAYGROUND_EXPLORER,
EXTENSION_COMMANDS.MDB_CREATE_PLAYGROUND_FROM_TREE_VIEW,
() => this._playgroundController.createPlayground()
);
this.registerCommand(
Expand Down
Loading