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: add diagnostics feature to the language server VSCODE-375 #493

Merged
merged 11 commits into from
Mar 17, 2023

Conversation

alenakhineika
Copy link
Contributor

@alenakhineika alenakhineika commented Mar 15, 2023

Description

Add the VSCode Language Server Diagnostics feature to highlight the usage of commands that only works inside interactive sessions. We've seen folks try to use Shell syntax that doesn't work in playgrounds like show dbs; or instead of using the correct use('database_name') people type use database_name which only works in the Shell and not playgrounds.

The diagnostic not only highlights the incorrect syntax but also offers quick fixes for the current problem and for all similar problems in the file.

Currently, the following fixes are available (the complete list is here):

[
  { issue: 'use', fix: "use('database')" },
  { issue: 'show databases', fix: 'db.getMongo().getDBs()' },
  { issue: 'show dbs', fix: 'db.getMongo().getDBs()' },
  { issue: 'show collections', fix: 'db.getCollectionNames()' },
  { issue: 'show tables', fix: 'db.getCollectionNames()' },
  { issue: 'show profile', fix: "db.getCollection('system.profile').find()" },
  { issue: 'show users', fix: 'db.getUsers()' },
  { issue: 'show roles', fix: 'db.getRoles({ showBuiltinRoles: true })' },
  { issue: 'show logs', fix: "db.adminCommand({ getLog: '*' })" },
  { issue: 'show log', fix: "db.adminCommand({ getLog: 'global' })" },
]
diag.mov

Additionally, I tried again to fix the telemetry flaky test.

Checklist

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

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)

src/editors/playgroundController.ts Outdated Show resolved Hide resolved
src/editors/playgroundController.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
@alenakhineika alenakhineika marked this pull request as ready for review March 16, 2023 14:14
@alenakhineika alenakhineika requested a review from addaleax March 17, 2023 08:51
src/editors/playgroundDiagnosticsCodeActionProvider.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
src/language/mongoDBService.ts Outdated Show resolved Hide resolved
@alenakhineika alenakhineika merged commit c31a9c5 into main Mar 17, 2023
@alenakhineika alenakhineika deleted the VSCODE-375-diagnostics branch March 17, 2023 18:31
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.

2 participants