feat(editor): inline query diagnostics and PostgreSQL enum value completion - #2106
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Closes #2095. Follow-up to #2102 and #2105, covering the last two items.
Inline diagnostics
The editor underlines a structural mistake in red as you type, through
EmphasisManager, which owns its own drawing layer and needs no change to the vendored packages.The design constraint here is restraint, not coverage. Every high-vote DataGrip inspection ticket is a false positive on SQL that runs fine, and Postico's auto-suggest request sat open since 2017 because its maintainer would not ship suggestions before they were context-sensitive enough not to annoy. So this reports only what more typing cannot fix:
Brackets inside a string literal or comment are ignored. Checking runs 500ms after you stop typing and is skipped on large documents.
On MongoDB the parser runs too, once the structure is balanced, and reports its own reason.
MongoShellParseErrorcarries no range, so rather than underline the whole statement the producer locates the offending token where it can: an unsupported method is underlined on the method name itself, everything else falls back to the first statement line.Why this is custom. The editor is not an
NSTextView.CodeEditTextView.TextViewis anNSViewwith a hand-rolledNSTextInputClientand its ownTextLayoutManager, soNSLayoutManager.setTemporaryAttributesandNSTextLayoutManager.addRenderingAttributeare both structurally unreachable, not merely unused.EmphasisManager.underline(color:)is the seam. Also worth recording: TextKit 2 rendering attributes silently ignoreunderlineStyle(verified by pixel-diff, documented nowhere), so the usual "modernize the squiggle" move would have shipped an invisible diagnostic.Not included: a gutter marker.
GutterViewhas no per-line marker primitive, so that needs a vendored change and is better as its own PR.PostgreSQL enum values
WHERE status =now offers the labels the enum type declares. The fetch layer already existed:PostgreSQLPluginDriver+Columnsreadspg_enumintoPluginColumnInfo.allowedValuesand it flows toColumnInfo. Nothing surfaced it. This adds the missing half.The analyzer gained a
comparisonColumnsignal: scanning back over whitespace, a comparison operator (=,<>,!=,<,>,<=,>=,IN,LIKE,ILIKE), then an identifier, with word operators requiring a real word boundary and SQL keywords excluded soWHEREalone never counts as a column.Value lookup is cache-only and never triggers a fetch. Completion runs on every keystroke, so the first draft, which called
getColumns, would have fired a schema fetch per table per keystroke in aWHEREclause. The eager column preload is what fills the cache.SQLContext.replacingTableReferencesforwards the new field explicitly, the same trap that would have silently droppedoperatorsfromwithCaseSensitivityStylein #2102.DataGrip completes enum values in the data-editor grid only, not the SQL editor. DBeaver reaches them by scanning user data, off by default and unimplemented in its default engine. Reading
pg_enumdirectly in a comparison is unclaimed.Testing
19 new diagnostics tests, weighted toward the restraint cases (a half-typed statement, an unterminated string, brackets inside strings and comments) since that is the property most likely to regress. Suites green: QueryDiagnostics, SQLContextAnalyzer, CompletionEngine, SQLSchemaProvider, MongoContextAnalyzer.
swiftlint lint --strictclean across 1340 files.One pre-existing failure to be aware of, not introduced here.
SQLCompletionProviderTestshas three tests (testProviderAcceptsDatabaseType,testMySQLProviderTypes,testCommaFromScopesColumnsToAllTables) that fail when the suite runs as a whole but pass individually. I verified this on cleanmainat1665429d2before and after my changes: identical failures both ways. The suite is already in.github/macos-test-quarantine.txt, so CI skips it. Flagging it because the isolation-vs-suite split suggests parallel test interference rather than the documented driver-dependency reason.Behaviour note
MQL has no comment syntax: the parser treats a
//line as part of the statement, which the MongoDB docs already state. The diagnostics scanner matches the parser, sodb.users.find({}) // )reports the unmatched bracket rather than hiding it.MongoContextAnalyzerstill suppresses completion inside//, which is an advisory affordance rather than a correctness claim. Teaching the parser to strip comments the way mongosh does would remove the split, and is worth its own change.