vscode icon indicating copy to clipboard operation
vscode copied to clipboard

feat: extend typescript help signatures with mongodb items VSCODE-403

Open alenakhineika opened this issue 1 year ago • 0 comments

Description

This PR is not necessarily going to be merged in the existing format. Treat it as an investigation/collaboration resource.

The JS contextual signature help for find thinks that any find keyword is the Array.find() method. This is confusing for users of the extension, because MongoDB has its own usage and syntax the find method.

VSCode does not allow extensions to change the results of other extensions, therefor to overcome this obstacle we use the TypeScript Language Service API to extend default JavaScript Method Signatures in playgrounds.

If the cursor is positioned in the query node we show the query method help:

Collection.find(query, projection, options) : Cursor
---
Selects documents in a collection or view.

And similarly for the aggregate method, we show the aggregate method help:

Collection.aggregate(pipeline, options) : Cursor
---
Calculates aggregate values for the data in a collection or a view.

If the current node is neither find nor aggregation, we return the TypeScript language server help signatures.

Checklist

  • [x] New tests and/or benchmarks are included
  • [ ] Documentation is changed or added
  • [ ] I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • [ ] Bugfix
  • [x] New feature
  • [ ] Dependency update
  • [ ] Misc

Types of changes

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

alenakhineika avatar Apr 05 '23 18:04 alenakhineika