feat(mongodb): extend parser to support all mongosh commands#53
Merged
feat(mongodb): extend parser to support all mongosh commands#53
Conversation
Extend the MongoDB Shell parser grammar to recognize all mongosh commands with comprehensive test coverage. Grammar additions: - Collection methods: write operations, index/schema management - Database methods: createCollection, dropDatabase, stats, serverStatus, etc. - Cursor methods: batchSize, collation, hint, maxTimeMS, toArray, etc. - Bulk operations: initializeOrderedBulkOp, Bulk.find, Bulk.insert, etc. - Connection methods: Mongo(), connect(), getDB, setReadPref, etc. - Replication methods: rs.status, rs.initiate, rs.add, rs.reconfig, etc. - Sharding methods: sh.status, sh.enableSharding, sh.shardCollection, etc. - Encryption methods: KeyVault, ClientEncryption via db.getMongo() - Native shell functions: cat, load, quit, pwd, sleep, etc. - Query plan cache: db.collection.getPlanCache().list/clear/etc. - Atlas-specific: Search Index methods, Stream Processing (sp.*) - Object constructors: BinData, Binary, BSONRegExp, HexData Test files: 300+ test files covering all command categories Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR extends the MongoDB Shell parser grammar to recognize all mongosh commands, transforming it from a basic parser to a comprehensive one supporting 300+ commands across 14 categories. The grammar is intentionally permissive to allow for future translator implementations.
Changes:
- Extended grammar to support 300+ mongosh commands across collection operations, cursor methods, database administration, bulk operations, connections, replication, sharding, encryption, and Atlas-specific features
- Added comprehensive test coverage with 306 test files organized by command category
- Regenerated parser files from updated ANTLR grammar
Reviewed changes
Copilot reviewed 299 out of 301 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mongodb/mongoshellparser_listener.go | Added 138 new Enter/Exit method pairs for grammar productions supporting all command categories |
| mongodb/mongoshellparser_base_visitor.go | Added 152 visitor methods for new grammar productions |
| mongodb/mongoshellparser_base_listener.go | Added 152 listener methods for new grammar productions |
| mongodb/mongoshell_lexer.go | Extended lexer with 97 new tokens for MongoDB commands and keywords |
| mongodb/examples/sp-stop.js | Test file for stream processor stop command |
| mongodb/examples/sp-start.js | Test file for stream processor start command |
| mongodb/examples/sp-sample.js | Test file for stream processor sample command |
| mongodb/examples/sp-processor.js | Test file for stream processor access patterns |
| mongodb/examples/sp-process.js | Test file for inline stream processing pipeline |
| mongodb/examples/sp-listStreamProcessors.js | Test file for listing stream processors |
| mongodb/examples/sh-transitionToDedicatedConfigServer.js | Test file for sharding config server transition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rebelice
approved these changes
Jan 20, 2026
h3n4l
added a commit
that referenced
this pull request
Jan 21, 2026
Extend the MongoDB Shell parser grammar to recognize all mongosh commands with comprehensive test coverage. Grammar additions: - Collection methods: write operations, index/schema management - Database methods: createCollection, dropDatabase, stats, serverStatus, etc. - Cursor methods: batchSize, collation, hint, maxTimeMS, toArray, etc. - Bulk operations: initializeOrderedBulkOp, Bulk.find, Bulk.insert, etc. - Connection methods: Mongo(), connect(), getDB, setReadPref, etc. - Replication methods: rs.status, rs.initiate, rs.add, rs.reconfig, etc. - Sharding methods: sh.status, sh.enableSharding, sh.shardCollection, etc. - Encryption methods: KeyVault, ClientEncryption via db.getMongo() - Native shell functions: cat, load, quit, pwd, sleep, etc. - Query plan cache: db.collection.getPlanCache().list/clear/etc. - Atlas-specific: Search Index methods, Stream Processing (sp.*) - Object constructors: BinData, Binary, BSONRegExp, HexData Test files: 300+ test files covering all command categories Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grammar Additions
Test plan
make buildmake testpasses🤖 Generated with Claude Code