Skip to content

Preserve source positions in parsed CQL trees - #32

Merged
adamdickmeiss merged 1 commit into
masterfrom
preserve-source-positions-in-parsed-cql-trees
Nov 20, 2026
Merged

adamdickmeiss merged 1 commit into
masterfrom
preserve-source-positions-in-parsed-cql-trees

Conversation

@adamdickmeiss

Copy link
Copy Markdown
Contributor

Track exact token boundaries in the lexer and compose source ranges in the parser, preserving original whitespace, quotes and escapes.

Expose getStart() and exclusive getEnd() offsets on nodes, modifiers and sort keys. Include subtrees and enclosing parentheses in node ranges; use -1 for objects without a source location.

Preserve existing public signatures and the CQLTokenizer interface. Add position regression tests, document range semantics and credit the proposal in PR #19.

All 22 tests pass. Verify binary compatibility against existing API descriptors and a client compiled against the previous implementation.

Track exact token boundaries in the lexer and compose source ranges in
the parser, preserving original whitespace, quotes and escapes.

Expose getStart() and exclusive getEnd() offsets on nodes, modifiers and
sort keys. Include subtrees and enclosing parentheses in node ranges;
use -1 for objects without a source location.

Preserve existing public signatures and the CQLTokenizer interface.
Add position regression tests, document range semantics and credit
the proposal in PR #19.

All 22 tests pass. Verify binary compatibility against existing API
descriptors and a client compiled against the previous implementation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review identifies no active issues requiring changes to the source-position metadata implementation.

No open issues 🎉

What changed in this PR

Adds source-position metadata to parsed CQL trees so callers can locate original query fragments without losing whitespace, quotes or escapes, building on the proposal in PR #19.

Changes:

  • Tracks lexer token boundaries and composes parser ranges across subtrees, parentheses, prefixes and sorting.
  • Exposes inclusive getStart() and exclusive getEnd() UTF-16 offsets while preserving existing public signatures and the CQLTokenizer interface.
  • Adds position regression tests and documents range semantics, including -1 for unavailable locations.
File Description
src/​test/​java/​org/​z3950/​zing/​cql/​CQLSourcePositionsTest.java Tests source preservation, nested ranges, modifiers, sort keys and legacy lexer positions.
src/​main/​java/​org/​z3950/​zing/​cql/​ModifierSet.java Adds source ranges for bases and their modifiers, including sort keys.
src/​main/​java/​org/​z3950/​zing/​cql/​Modifier.java Adds modifier ranges that include the leading slash.
src/​main/​java/​org/​z3950/​zing/​cql/​CQLParser.java Composes source ranges from consumed token boundaries.
src/​main/​java/​org/​z3950/​zing/​cql/​CQLNode.java Adds shared node range accessors and documents their semantics.
src/​main/​java/​org/​z3950/​zing/​cql/​CQLLexer.java Exposes exact token boundaries without changing pos().
README.md Documents source-position usage and limitations, and credits PR #19.

Review effort: Balanced

@adamdickmeiss
adamdickmeiss merged commit 91d9f53 into master Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants