Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: playgrounds in JS VSCODE-372 #482

Merged
merged 33 commits into from
Mar 1, 2023
Merged

Conversation

alenakhineika
Copy link
Contributor

@alenakhineika alenakhineika commented Feb 20, 2023

Description

Make playgrounds become proper JavaScript environments.

  • Update syntaxes.
    • Replace the MongoDB-TmLanguage grammar with the MongoDB injection grammar.
    • Modify the update-grammar script to update the MongoDB injection grammar with the most recent DevTools constants during the build process.
  • Activate the extension on javascript and plaintext languages.
    • Refactor activation events.
    • For playgrounds opened from the disc set JavaScript language to the document.
  • Identify playgrounds based on the document path.
    • Implement the isPlayground util function that will identify playgrounds among other JavaScrip files.
    • Refactor all places that check for mongodb language id and replace it with isPlayground check.
  • Create playgrounds as JavaScript documents.
    • Create playgrounds by the document UID.
    • Apply required changes to all templates based on playgrounds functionality (clone document, insert document, create collection, create index, search).
  • Declare global variables in playground templates to resolve linting errors.
  • Show the “Run Playground” button only for MongoDB playgrounds and hide it for regular JavaScript files in a workspace.
  • Show Active Connection CodeLens only for MongoDB playgrounds and hide it for regular JavaScript files in a workspace.
  • Show Playground Selected CodeAction only for MongoDB playgrounds and hide it for regular JavaScript files in a workspace.
  • Update the Language Server to work with JavaScript documents.

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@alenakhineika alenakhineika marked this pull request as draft February 20, 2023 12:25
@alenakhineika alenakhineika changed the title Playgrounds in JS feat: playgrounds in JS VSCODE-372 Feb 22, 2023
@alenakhineika alenakhineika marked this pull request as ready for review February 24, 2023 15:29
@mmarcon
Copy link
Member

mmarcon commented Feb 27, 2023

@alenakhineika Notes from a quick test:

  • I don't think we have this today, but can we add use and db to the autocompleteter? Is it easy enough? I think it's extra important to do it now because VS Code in a JS file (at least for me) changes use to URLSearchParams (see gif below)
  • Inside a query or aggregation (at least where we can tell we are inside a query or an aggregation), can we make sure that the MongoDB completions show up before anything else? For example, if I type db.movies.find({ it would be ideal if field names and MongoDB keywords (the $ things) would show up before other "JS things"

Feb-27-2023 08-42-23

@alenakhineika
Copy link
Contributor Author

alenakhineika commented Feb 27, 2023

@mmarcon absolutely agree it would be very useful! Created tickets:

VSCODE-380 - Suggest use and db commands
VSCODE-382 - Show MongoDB completion items before other JS completion

scripts/update-grammar.ts Outdated Show resolved Hide resolved
src/editors/playgroundController.ts Outdated Show resolved Hide resolved
src/editors/playgroundController.ts Show resolved Hide resolved
src/explorer/playgroundsTree.ts Outdated Show resolved Hide resolved
src/test/suite/editors/playgroundController.test.ts Outdated Show resolved Hide resolved
src/test/suite/mdbExtensionController.test.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
…guage

# Conflicts:
#	package-lock.json
#	package.json
#	src/test/suite/editors/activeDBCodeLensProvider.test.ts
#	src/test/suite/telemetry/connectionTelemetry.test.ts
#	src/test/suite/telemetry/telemetryService.test.ts
Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, going to give this a try on local now, left a couple comments.

src/test/suite/mdbExtensionController.test.ts Outdated Show resolved Hide resolved
src/test/suite/mdbExtensionController.test.ts Outdated Show resolved Hide resolved
src/test/suite/telemetry/connectionTelemetry.test.ts Outdated Show resolved Hide resolved
src/utils/playground.ts Show resolved Hide resolved
scripts/update-snippets.ts Show resolved Hide resolved
src/utils/playground.ts Outdated Show resolved Hide resolved
@alenakhineika alenakhineika merged commit a1bf127 into main Mar 1, 2023
@alenakhineika alenakhineika deleted the playgrounds-in-js-language branch March 1, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants