Skip to content

Replace DBA XQuery editor with REx-based implementation - #2782

Open
GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:rex-based-editor
Open

GuntherRademacher wants to merge 1 commit into
BaseXdb:mainfrom
GuntherRademacher:rex-based-editor

Conversation

@GuntherRademacher

Copy link
Copy Markdown
Member

This replaces the DBA editor’s existing Lezer-based XQuery support with the REx-based implementation from the local basex-lsp project. It preserves the existing DBA editor interface, but includes richer language support:

Static analysis

The new bundle reports, with XQuery error codes:

  • undeclared variables (XPST0008)
  • unknown functions or wrong numbers of arguments (XPST0017)
  • unknown types (XPST0051)
  • undeclared namespace prefixes (XPST0081)
  • duplicate function declarations (XQST0034)
  • record fields without a default after one that has it (XQST0148)

It also gives hints for unused variables, functions, types and namespace prefixes, and warnings for potentially undefined context-value references in function bodies.

Smarter completion

  • It proposes variables that are in scope, functions declared in the document, and BaseX functions by prefix. Calls are inserted with placeholders for the required parameters.
  • It completes the names of elements and attributes that the document uses, after /, @, < and inside a start tag.
  • It offers only what the parser accepts at the cursor.

Features the old bundle did not have

  • Signature help: the parameter list while arguments are typed, with the current parameter marked; it works in incomplete code.
  • Hover on functions declared in the document, with a link that jumps to the declaration.
  • Navigation: F12 and Ctrl-click go to the definition; the uses of the name under the cursor are highlighted, and the matching tag of an element is marked.
  • Records: constructor functions of record declarations are known (arity, hover, completion, errors).

Better XML + Markdown handling (xml-markdown mode)

  • A literal < in the code, such as count(.) < 10, no longer disrupts highlighting of subsequent fenced blocks.

Other remarks

  • Size: the new script is about 1.45 MB, the old cm6.js about 0.89 MB. Out of this, about 600KB are REx parser tables (lists of integers), which the script contains in uncompressed form. By turning on transfer-level gzip compression, this can be greatly reduced.
  • the new implementation's project has more than 200 automated tests, and the bundle was tested manually in DBA and basex-help.

@ChristianGruen

Copy link
Copy Markdown
Member

…promising! Could the same style be used for prefixes and local names?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants