Replace atom-editor-support with language-support XAR#68
Open
joewiz wants to merge 6 commits intowolfgangmm:masterfrom
Open
Replace atom-editor-support with language-support XAR#68joewiz wants to merge 6 commits intowolfgangmm:masterfrom
joewiz wants to merge 6 commits intowolfgangmm:masterfrom
Conversation
Switch from atom-editor-support (GET-based, single error, client-side
import resolution) to language-support (POST JSON, multi-error diagnostics,
server-side import resolution via lsp:* functions).
Key changes:
- linting.ts: POST /api/diagnostics with structured JSON response
- analyzed-document.ts: POST /api/{completions,hover,definition} with
full query text; removed resolveImports/parseImports/getParameters
- server.ts: pass document text to getCompletions and getHover
- utils.ts: detect language-support XAR instead of atom-editor
Requires eXist-db 7.0+ with lsp:* module (eXist-db/exist#6130).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- linting.ts: remove getWarnings() call, keep only getAST() for local symbol lookup. Eliminates false positives like wolfgangmm#67 (unused variable with arrow operator). Server-side lsp:diagnostics handles error checking. - analyzed-document.ts: handle "uri" field from lsp:definition response for cross-module go-to-definition. Maps database paths to workspace file URIs using settings.path prefix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three new LSP capabilities for parity with eXide: - Semantic tokens: highlights function and variable declarations using server-side lsp:symbols, with local fallback - Document formatting: Prettier-based XQuery formatting via prettier-plugin-xquery (XQuery files only — VS Code handles other languages natively) - Enhanced document symbols: uses server-side lsp:symbols for richer outline with return types and parameter types, local fallback Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Calls /api/references to find all usages of the symbol at cursor. Enables VS Code's "Find All References" (Shift+F12) and "Rename Symbol" (F2) for XQuery functions and variables. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
Replace the legacy POST /apps/atom-editor/execute calls with cursor-based execution through the language-support XAR API (lsp:eval/fetch/close). Server: evalQuery() calls /api/eval to get a cursor handle then fetches the first page via /api/fetch. fetchResults() and closeCursor() support paging and cleanup. Legacy executeQuery() preserved as fallback when lsp:eval is unavailable — detected at startup via a probe request. Client: execute command now handles both cursor-based (array items) and legacy (string) results. New "Load More Results" command fetches subsequent pages. Previous cursors are closed before new queries. Tests: 16 new Mocha tests covering eval/fetch/close lifecycle, capability detection (success, 404, unreachable, bad response, close-failure), command routing, and legacy fallback. Run with `npm test`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New settings: existdb.query.serializationMethod (adaptive/xml/json/text) and existdb.query.indent (boolean). These control how lsp:fetch serializes query results. New command: "eXist-db: Set Output Format" — quick pick to change the serialization method, with a clickable status bar item showing the current format. Serialization options (method, indent) are threaded from the client through the server to the lsp:fetch REST call. For Lucene queries containing ft:query or ft:search, highlight-matches is automatically enabled. 10 new tests covering option pass-through and Lucene detection. Co-Authored-By: Claude Opus 4.6 (1M context) <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
atom-editor-supportXAR with a newlanguage-supportXAR that wraps eXist-db'slsp:*Java functionsutil:compile-query)lsp:eval/lsp:fetch/lsp:close— replaces legacyPOST /apps/atom-editor/executeCloses #15 —
request:and other eXist-db built-in namespace prefixes no longer trigger falseXPST0081errors, sincelsp:diagnosticsresolves them correctly (unlike the oldutil:compile-querypath).What changed
New companion XAR:
existdb-language-support/api/diagnostics,/api/symbols,/api/completions,/api/hover,/api/definition{query, base}(plusline,columnfor positional queries) and delegates tolsp:*functionsresources/language-support-1.0.0.xar(replacesatom-editor-1.1.0.xar)Cursor-based query execution
Replaces the legacy
POST /apps/atom-editor/executewith a three-step cursor-based approach:lsp:eval($query, $base?)— executes the query, returns{ cursor, items, elapsed }lsp:fetch($cursor, $start, $count)— fetches a page of results on demandlsp:close($cursor)— releases server-side resourcesServer (
server/src/analyzed-document.ts):evalQuery()calls/api/eval, then auto-fetches the first page via/api/fetchfetchResults()andcloseCursor()support on-demand paging and cleanupexecuteQuery()preserved as fallback whenlsp:evalis unavailableServer (
server/src/server.ts):lsp:evalis available (sendsquery: '1', checks for cursor in response)executecommand routes to cursor-based or legacy path based on capabilityfetchandcloseCursorcommandsClient (
client/src/extension.ts):existdb.loadMoreResultscommand fetches the next page from an open cursorClient (
client/src/query-results-provider.ts):CursorStateinterface tracks active cursor, total hits, fetched count, output modeappendResults()appends pages;clearCursor()resets stateOutput format settings
Settings (
package.json):existdb.query.serializationMethod— defaultadaptive, enum:adaptive,xml,json,textexistdb.query.indent— defaulttrue, controls indentation of resultsClient (
client/src/extension.ts):existdb.setOutputFormatcommand — quick pick: Adaptive, XML, JSON, Text (with checkmark on current)Adaptive)getSerializationOptions()builds options object from settings, auto-enableshighlight-matches: bothwhen query containsft:queryorft:searchexecuteandfetchcommands to serverServer:
evalQuery()andfetchResults()accept optionalserializationOptionsparameterbody.optionsin the/api/fetchREST callserver/src/linting.tsserverLint(): POST to/apps/language-support/api/diagnostics(was PUT tocompile.xql)mapSeverity()(was regex-parsing a single error message)server/src/analyzed-document.tsgetCompletions(): POST full query text to/api/completions(was GET with resolved imports as query params)getHoverRemote(): POST query + position to/api/hover(was GET with function signature)gotoDefinitionRemote(): POST query + position to/api/definition(was GET with signature + client-side file reading)resolveImports(),parseImports(),getParameters(),getOptions(),importsmap,Importinterfaceserver/src/server.tsgetCompletions()andtextDocumenttogetHover()lsp:symbols, local fallbackprettier-plugin-xquerylsp:symbolsfor richer outline (return types, parameter types), local fallbackserver/src/utils.tscheckServer(): detecthttp://exist-db.org/apps/language-support(wasatom-editor)Tests
27 tests total (26 new). Run with:
npm testtest/cursor-execution.spec.ts(11 tests):evalQuery: eval→fetch two-step, output mode detection, custom page size, error propagationfetchResults: correct params, empty resultscloseCursor: success/failure returnsexecuteQuerylegacy: atom-editor endpoint, form-encoded bodytest/capability-check.spec.ts(7 tests):test/serialization-options.spec.ts(10 tests):ft:query/ft:searchregex detection (positive and negative cases)Known limitation: xqlint client-side pass
This PR retains the xqlint client-side pass, which serves two purposes:
getAST()— builds an AST used for local symbol lookup (finding which function call the cursor is on, for hover/go-to-definition without a server roundtrip)— removed in this PR. Server-sidegetWarnings()lsp:diagnosticshandles error checking without the false positives xqlint produces (e.g., false positive problem reports "unused variable" #67).A future improvement would be to swap xqlint entirely for eXide's REx-generated parser, which produces a correct AST from the W3C XQuery 3.1 grammar.
Requirements
lsp:*module (eXist-db/exist#6130)Test plan
language-supportXAR on eXist-db withlsp:*module.existdb.jsonin VS Code Extension Development HostXPST0081error onrequest:get-parameter(VSCode objects to "request:" namespace prefix #15)[W03] Unused variablewarnings (false positive problem reports "unused variable" #67 — xqlint warnings removed)lsp:evalis unavailableexistdb.query.serializationMethodft:queryin query auto-enables highlight-matchesnpm testpasses (27 tests)🤖 Generated with Claude Code