feat(soql-completions): implement SOQL completion context, keywords, and suggestions - #1907
Open
paustint wants to merge 1 commit into
Open
feat(soql-completions): implement SOQL completion context, keywords, and suggestions#1907paustint wants to merge 1 commit into
paustint wants to merge 1 commit into
Conversation
…and suggestions - Added `soql-completion-context.ts` to handle cursor-context detection for SOQL editors, allowing for dynamic completion suggestions based on the current query context. - Introduced `soql-completion-keywords.ts` to define static SOQL vocabulary, including keywords, date literals, aggregate functions, and more, for use in completion suggestions. - Created `soql-completions.ts` to register and manage SOQL completion items, integrating with the Monaco editor and providing context-aware suggestions based on the user's input. - Implemented `useSoqlCompletions.ts` hook to facilitate the registration of SOQL completions in a React component, ensuring that completions are scoped to the specific editor instance.
| function parseAtCursor(queryWithCursor: string) { | ||
| const cursorOffset = queryWithCursor.indexOf('|'); | ||
| expect(cursorOffset, 'test case must include a | cursor marker').toBeGreaterThan(-1); | ||
| return parseSoqlContext(queryWithCursor.replace('|', ''), cursorOffset); |
Contributor
There was a problem hiding this comment.
🟡 Not ready to approve
Picklist value suggestions currently insert unescaped SOQL string content, which can generate invalid queries when values contain characters like apostrophes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds context-aware SOQL autocomplete to Jetstream’s Monaco-based editors, using org metadata (global + per-sObject describes) plus a curated SOQL vocabulary to provide relevant suggestions as the user types.
Changes:
- Introduced a tolerant cursor-context parser to determine the active SOQL clause, scope object, relationship path, and comparison-value position.
- Added a Monaco completion provider that merges keyword suggestions with org-aware sObject/field/relationship/value suggestions.
- Wired the completions into the Query editors via a
useSoqlCompletionshook and Monaco editor option tweaks to favor metadata-driven suggestions.
File summaries
| File | Description |
|---|---|
| libs/shared/ui-core/src/query/soql-completions/useSoqlCompletions.ts | Hook to register/dispose a completion provider scoped to a single editor model. |
| libs/shared/ui-core/src/query/soql-completions/soql-completions.ts | Monaco completion provider implementation: context parsing + metadata lookups + suggestion building. |
| libs/shared/ui-core/src/query/soql-completions/soql-completion-keywords.ts | Static SOQL keyword/function/date literal suggestion data (snippet-capable). |
| libs/shared/ui-core/src/query/soql-completions/soql-completion-context.ts | Cursor-context detection that tolerates incomplete queries while typing. |
| libs/shared/ui-core/src/query/soql-completions/tests/soql-completion-context.spec.ts | Vitest coverage for context masking/parsing behaviors. |
| libs/shared/ui-core/src/index.ts | Exposes the new SOQL completion utilities from @jetstream/ui-core. |
| libs/features/query/src/QueryResults/QueryResultsSoqlPanel.tsx | Registers SOQL completions on the results-panel editor; adjusts Monaco suggestion behavior. |
| libs/features/query/src/QueryOptions/ManualSoql.tsx | Registers SOQL completions on the manual editor; pulls current org from app state; adjusts Monaco suggestion behavior. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| return []; | ||
| } | ||
|
|
||
| const quote = (value: string) => (isInsideStringLiteral ? value : `'${value}'`); |
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.
soql-completion-context.tsto handle cursor-context detection for SOQL editors, allowing for dynamic completion suggestions based on the current query context.soql-completion-keywords.tsto define static SOQL vocabulary, including keywords, date literals, aggregate functions, and more, for use in completion suggestions.soql-completions.tsto register and manage SOQL completion items, integrating with the Monaco editor and providing context-aware suggestions based on the user's input.useSoqlCompletions.tshook to facilitate the registration of SOQL completions in a React component, ensuring that completions are scoped to the specific editor instance.