Skip to content

LSP follow-up: tree-sitter grammar gaps closed (callTests + literals + multiline-template + C5 + skip-list cleanup) - #452

Merged
lagergren merged 40 commits into
masterfrom
lagergren/lsp-gene-followup-grammar
May 1, 2026
Merged

lagergren merged 40 commits into
masterfrom
lagergren/lsp-gene-followup-grammar

Conversation

@lagergren

Copy link
Copy Markdown
Contributor

Summary

Multi-session sweep over remaining tree-sitter grammar gaps. Active sweep moves from 853/876 (with 7 parked entries) to 880/880 with 13 parked entries — the parked count grew only because re-categorizing `intentional.txt` uncovered 13 real grammar gaps that were previously hidden under the "intentionally not parseable" label.

Highlights

callTests.x — `(i1, Int i2) = testMultiReturns(0);` (mixed bare-ident + typed-decl tuple_assignment). Closed by combining:

  • An external-scanner `TUPLE_ASSIGN_LPAREN` token that peeks past the matching `)` for `=` (and not `==` / `=>`) before any `;` / `{` / `}` / EOF, requires at least one `,` at depth 1, and only fires at statement start. Forces LR commit to `tuple_assignment` at the `(` shift.
  • Narrowing `tuple_assignment_element`'s bare alt from `prec.dynamic(1, $._expression)` to `choice($.identifier, $.member_expression, $.index_expression)` — the three node shapes that actually appear as bare LHS slots in real code. With the scanner suppressing the container-level fork, a full `_expression` alt was a trap (typed elements like `UInt8 left` could lose to a failing _expression parse with no backtrack).
  • Scanner skips leading whitespace via `lexer->advance(skip=true)` (tree-sitter doesn't auto-skip extras before invoking external scanners) but defers to the TODO scanner when both are valid, otherwise it eats the hspace TODO needs.

literals.x — bare absolute-path primary expression (`Path p = /allow.txt;`). Closed by adding the existing `path_literal` rule to `_literal`'s choice and tightening the regex first-char class to disambiguate against `//` (line comment) and `/*` (block comment) starts.

reflect.x — closed by the multiline-template interpolation work (template interpolation expressions can now span physical lines via the parent `|` continuation; scanner emits `MULTILINE_CONTINUATION` when persistent state shows we're inside a multiline-template interpolation expression).

generics.x — closed by the C5 LHS work (split-shift operators `<<` / `>>` / `>>>` so the lexer never produces a multi-char shift token, unblocking nested type-argument lists like `Function<<Int, String>, > f = ...`).

Skip-list re-categorization — the previous `intentional.txt` claimed 19 files were "intentionally not parseable by tree-sitter". Re-checking against both parsers shows:

  • 4 files parse cleanly with both — moved into the active sweep.
  • 13 files have no Java `PARSER-NN` errors but produce ERROR nodes in tree-sitter — these are real grammar debt; moved to `parked.txt` for follow-up. Tracked by issue (filed alongside this PR).
  • 2 files (`socks-catalog.x`, `socks-user.x`) have genuine `PARSER-03` errors from the Java compiler too; remain in `intentional.txt` with a corrected header documenting the real criterion ("xcc emits PARSER-NN").

Verification

```
./gradlew :lang:dsl:generateScannerC :lang:dsl:generateTreeSitter \
:lang:tree-sitter:validateTreeSitterGrammar \
:lang:updateGeneratedExamples \
:lang:tree-sitter:testTreeSitterParse \
:lang:lsp-server:test \
:lang:intellij-plugin:verifyPlugin \
-PincludeBuildLang=true -PincludeBuildAttachLang=true
```

  • Sweep: 880/880 passing
  • `validateTreeSitterGrammar`: no "unnecessary conflict" warnings (also dropped one stale conflict that became redundant after the bare-element narrowing)
  • `lsp-server:test`: green
  • `intellij-plugin:verifyPlugin`: Compatible
  • Configuration cache: stored / reused throughout

Test plan

  • Reviewers spot-check the four formerly-`intentional` files now in the sweep parse to non-trivial trees: `archive/web-static.x`, `dbTests/PeopleDB.x`, `jsondb/.../JsonValueStoreTest.x`, `webTests/Hello.x`.
  • Reviewer eyeballs the new TUPLE_ASSIGN_LPAREN scanner block in `ScannerCGeneratorDsl.kt` (TODO-deferral guard is the load-bearing detail).
  • Reviewer eyeballs the narrowed `tuple_assignment_element` and confirms `choice($.identifier, $.member_expression, $.index_expression)` covers all bare LHS shapes used in this codebase (the parked.txt comment lists the working cases).

lagergren added 26 commits May 1, 2026 15:35
Plugin Verifier statically analyses the built plugin against real IDE
distributions to catch binary-incompat regressions (removed APIs, missing
classes, signature changes) before users hit them. Previously verifyPlugin
was a registered no-op (`pluginVerifier()` was commented out), and the
CI release-build path named it but skipped it for lack of the verifier dep.

This commit:

  - Uncomments `pluginVerifier()` and adds a `pluginVerification` block
    using `recommended()` so every IDE build matching since-build="261" is
    checked. failureLevel is explicit (COMPATIBILITY_PROBLEMS / INVALID_PLUGIN
    / MISSING_DEPENDENCIES) — deprecated/experimental API touches stay warnings.
  - Wires `publishPlugin.dependsOn(verifyPlugin)` so no publish path
    (CI, local, snapshot pipeline) can ship an unverified plugin.
  - Drops the dead `intellijLocalPath` plumbing — the only consumer was
    lang/Dockerfile, which has been deleted (drifted to a year-old IDE
    pin and not referenced by any CI workflow).
  - Adds `validate-lang` output to the existing publish-flags step that
    fires when ANY of: lang/ paths changed, force-publish-intellij-plugin,
    publish-intellij-plugin, include-lang. Both the existing tree-sitter
    validation step and the new verifier step gate on this unified flag,
    so manual workflow_dispatch overrides correctly trigger validation.
  - Adds a `verifyPlugin` step in commit.yml after tree-sitter, plus an
    actions/cache entry for `lang/.intellijPlatform/ides` keyed on
    libs.versions.toml, plus an upload-artifact step for verifier reports
    (14-day retention, runs even on failure for diagnostics).

Local verification: verifyPlugin reports `Compatible` against IU-261.23567.138
(2026.1.1 Ultimate). First run ~2 min, cached re-run ~40 s. Configuration
cache compatible.

verifyPlugin remains opt-in for normal local builds — it is NOT wired into
`build` or `check`. It only runs when explicitly invoked, when publishing,
or via the new CI step.
…in-stdlib

Two related cleanups for the IntelliJ plugin distribution.

== Rebrand: XTC -> Ecstasy ==

The language is officially "Ecstasy"; "XTC" is the file extension and
informal/legacy short-form. Publishing the plugin as "Ecstasy Language
Support" is the correct primary name. JetBrains Marketplace search
indexes both name and description fields, so we surface both terms in
the description ("Ecstasy programming language (also known by its file
extension and informal short-form, XTC)") to keep the plugin discoverable
for either search query. Search ranking will favor "ecstasy" since it's
now in the name field, but "xtc" queries will still match.

The marketplace's per-plugin tag chips are admin-only and managed via the
publisher web UI; the codebase only controls the indexed text fields.

  - lang/intellij-plugin/build.gradle.kts: pluginConfiguration name
    changed; changeNotes updated to use "Ecstasy (XTC)" form.
  - lang/intellij-plugin/src/main/resources/META-INF/plugin.xml:
    <name>, <vendor>, and <description> updated to put Ecstasy first
    while preserving XTC as a searchable alias.

== Exclude bundled kotlin-stdlib ==

Without `kotlin.stdlib.default.dependency=false`, the Kotlin Gradle plugin
auto-adds org.jetbrains.kotlin:kotlin-stdlib (~1.8 MB) to the plugin's
runtime classpath, and the IntelliJ Platform Gradle Plugin then bundles it
into the published ZIP. The IntelliJ Platform already provides its own
kotlin-stdlib in lib/, so two stdlib JARs end up loaded against the same
classloader -- a real conflict source per JetBrains' canonical advice
(https://jb.gg/intellij-platform-kotlin-stdlib).

Verified before/after by inspecting build/distributions/intellij-plugin-*.zip:
  - before: contains intellij-plugin/lib/kotlin-stdlib-2.3.21.jar
  - after:  no kotlin-stdlib JAR; only our plugin JAR + lsp server fat JAR
            + textmate grammar files.

The flag is scoped to lang/intellij-plugin/ via a module-level
gradle.properties so it does not silently affect the other Kotlin modules
in the lang composite (none of which currently declare kotlin-stdlib
explicitly -- they all rely on the auto-add). A root-level placement would
have wider blast radius without runtime benefit elsewhere.

verifyPluginProjectConfiguration's lint for this property only inspects
the root gradle.properties, so it continues to flag the warning even
though the property is in effect. Documented in the gradle.properties
header so future readers do not chase a "fix" that is already applied.

Local verification: plugin verifier still reports `Compatible` against
IU-261.23567.138 (2026.1.1 Ultimate). Configuration cache compatible.
…ADME.md

The plugin is published only to JetBrains Marketplace's alpha channel and
will be for the foreseeable future. The default plugin search and public
plugin page filter to the stable channel only, so users cannot find or
install the plugin via the normal in-IDE Marketplace flow without first
adding the alpha custom-repo URL.

The URL was buried in lang/intellij-plugin/README.md as Step 7 of the
"Publishing to JetBrains Marketplace" walkthrough -- a publishing-time
artifact, not an end-user install method. Surface it in lang/README.md
as a primary install method users actually need.

Also documents that the "Not compatible" warning that shows on the public
marketplace plugin page is a stable-channel-filter quirk and does not
reflect actual compatibility -- the alpha builds run through JetBrains'
Plugin Verifier against current 2026.1.x releases (see PR F's verifier
wiring). Avoids confusion when users see the scary red banner on the page
but the in-IDE install flow works fine.
…return assignment (C1)

manualTests/src/main/x/services.x had two grammar gaps that prevented it
from parsing. Both unblock the same file; commit them together as PR C1.

== 1. Fractional duration literals ==

`Duration:0.5S` (half a second) and `Duration:0.01S` (10 ms) failed to
parse: the `duration_literal` regex accepted only integer values per unit
(`[0-9]+[YMDHS]`), so `0.5` was eaten by `float_literal` and the trailing
`S` errored. ISO-8601 durations allow fractional values; the regex now
accepts an optional decimal fraction per unit:

    /P?T?[0-9]+(\.[0-9]+)?[YMDHS]([0-9]+(\.[0-9]+)?[YMDHS])*/i

Integer forms like `Duration:30S`, `PT1H30M` still parse identically.
Test: `shouldParseFractionalDurationLiteral`.

== 2. Annotated multi-return destructuring assignment ==

`(@future Int v1, @future Int v2) = svc.multiReturn(...)` is how an
Ecstasy service declares async-future variables via tuple destructuring.
The grammar already had `tuple_assignment` and `tuple_assignment_element`
for the typed and val/var-prefixed forms, but neither alternative allowed
a leading annotation -- so the parser fell back to interpreting the LHS
as a `parameters` list (function-parameter syntax) and errored at the `=`.

`tuple_assignment_element` now accepts `repeat($.annotation)` before both
the val/var form and the type form. A 2-way conflict declaration between
`parameter` and `tuple_assignment_element` is required: the existing
3-way conflict `[tuple_type_element, parameter, tuple_assignment_element]`
covers some LR states but not all -- some states see only the 2-way
ambiguity, which tree-sitter rejects without an explicit declaration.

Test: `shouldParseAnnotatedMultiReturnAssignment`.

== Verification ==

`tree-sitter parse manualTests/src/main/x/services.x` now reports zero
ERROR / MISSING nodes (was 2 ERRORs at line 99 and line 106 before).
`:lang:lsp-server:test` and `:lang:tree-sitter:validateTreeSitterGrammar`
both green. `lang/generated-examples/grammar.js` regenerated via
`:lang:updateGeneratedExamples`.

== Note on the original plan ==

The plan (lsp-bugfixes-gene-plan.md) listed C1 as "postfix async-call
operator `expr.foo^()`". That construct already parses cleanly via the
existing `async_call_expression` rule (likely fixed by an earlier change
since the plan was written). Running `tree-sitter parse` first surfaced
the two real failures in this file.
…form constructor body, single-element tuple (C2)

Three independent grammar gaps blocking two manualTests files. As with
C1, the original plan's described failures (modifier/annotation ordering
on properties) did not match what `tree-sitter parse` actually reports;
the real failures are listed below.

== 1. Stacked switch labels: `default: case <pattern>:` ==

`case_clause` and `expression_case_clause` previously allowed only
`case <pattern>:` labels in the leading repeat, with a single final
`case <pattern>` or `default` label. So `default:` followed by another
`case ...:` (a fall-through where one of the labels is `default`) errored.

The repeat now accepts both `case <pattern>:` and `default:`, allowing
arbitrary mixing of fall-through labels for the same arm. From
`StringBufferTest.x`'s `switch (rnd.int(97)) { default: case 0..39: ...; }`.

== 2. Short-form constructor body: `construct(...) = expr;` ==

The grammar already supports short-form `= expr;` for methods and getters
(parity with class bodies) but constructors only accepted `{ ... }` blocks
or `;` (signature-only). Adding the `= expr ;` alternative to
`constructor_declaration` lets `@Override construct(String s) = TODO();`
parse -- a placeholder constructor satisfying a required signature with
the language's TODO sentinel. From multiple class declarations in
`StringBufferTest.x` (lines 169, 177, 185, ...).

== 3. Single-element tuple expression: `(expr,)` ==

`tuple_expression` previously accepted only the empty `()` form and
2+ element tuples. The single-element tuple uses an explicit trailing
comma `(expr,)` to disambiguate from a parenthesized expression `(expr)`.
`tuple.x`'s `(1.toInt(),).addAll(t4)` failed at the `,)` boundary.

The new alternative reuses the same `prec(1)` as the empty-tuple form to
keep tuple-vs-parenthesized resolution consistent. As a side-effect, two
previously-required conflict declarations become unnecessary and tree-sitter
emits a warning for them; both are removed:
  - `[$.tuple_assignment_element, $.tuple_expression]`
  - `[$.pattern_element, $.tuple_expression]`

== Verification ==

`tree-sitter parse manualTests/src/main/x/{StringBufferTest.x, tuple.x,
services.x}` all report zero ERROR / MISSING nodes.
`:lang:lsp-server:test` passes (3 new tests added).
`:lang:tree-sitter:validateTreeSitterGrammar` clean (no unnecessary-conflict
warnings). `lang/generated-examples/grammar.js` regenerated.

== CI gap noted (separate follow-up) ==

`testTreeSitterParse` only scans `lib_*` directories; `manualTests/*.x`
files are not in the regression suite, which is why these failures
weren't caught by CI before. Per-shape tests in TreeSitterAdapterTest
close the gap for known failures; a follow-up should extend the parse
test (or add a sweep) over `manualTests/src/main/x/`.
`for (@watch(logger) Int i = 3; i > 0; --i) {}` failed to parse: the
`for_var_declarations` rule accepted `Type identifier = expr` but not
annotations on the type. Other variable-declaration forms in the grammar
(plain locals, properties, etc.) already supported `repeat($.annotation)`
preludes -- the for-loop init was the lone holdout.

Adding `repeat($.annotation)` to both the first declaration and each
comma-separated subsequent declaration in `for_var_declarations` brings
it in line. Cascade errors that propagated through the rest of the method
body (visible in the parse tree as multiple ERROR nodes downstream of the
for-loop) all clear as a side-effect once the for-init parses.

Despite the plan describing this as "annotations on local declarations
inside lambda bodies", the actual gap was specifically in `for_var_declarations`.
Standalone local-variable annotations like `@Watch(log) Int i;` (line 30
of annos.x) parse fine via `variable_declaration`, which already accepts
the annotation prefix.

Verification: `tree-sitter parse manualTests/src/main/x/annos.x` reports
zero ERROR / MISSING nodes (was 5+ cascade errors before).
`:lang:lsp-server:test` passes (1 new test added).
`:lang:tree-sitter:validateTreeSitterGrammar` clean.
`package contained import TestContained inject(Int value, String _) using SimpleResourceProvider;`
failed to parse: `import_spec` only accepted `'import' qualified_name`, so
the `inject(...) using ...` tail collapsed into garbled fallbacks
(`inject(...)` was parsed as an `arguments` invocation against an
identifier `inject`, then `using SimpleResourceProvider` errored as
free-floating tokens).

Extending `import_spec` to accept two optional trailing clauses fixes it:

  - `inject(parameters)` -- declares the formal parameters the resource
    provider must supply. Reuses the existing `parameters` rule (same shape
    as method/function parameter lists; supports `Type identifier` pairs
    including the `_` wildcard name).
  - `using qualified_name` -- names the provider class.

Both clauses are independently optional; either may appear without the
other (`package foo import bar using Provider;` is valid, as is the simple
`package foo import bar;`). `inject` and `using` were not previously
keywords in the grammar; `using` was already a literal token in the
using-statement rule, so adding it here is a no-op for tokenization.
`inject` is now a literal token here for the first time, but it stays
a valid identifier elsewhere via tree-sitter's contextual parsing.

Verification: `tree-sitter parse manualTests/src/main/x/container.x`
reports zero ERROR / MISSING nodes (was 4 before).
`:lang:lsp-server:test` passes (1 new test added covering all three
shapes: with-both, using-only, plain).
`:lang:tree-sitter:validateTreeSitterGrammar` clean.
…errors

Two correctness gaps in the grammar regression suite:

1. The corpus skipped manualTests/. The task's libDirs filter was a strict
   `lib_*/` glob against the composite root, so manualTests/src/main/x/
   never reached the parser. The very files we patched grammar gaps for
   in the C-series (services.x, StringBufferTest.x, tuple.x, annos.x,
   container.x) were never in the regression corpus -- meaning future
   regressions on those shapes would be invisible to CI without the
   per-file unit tests in TreeSitterAdapterTest.

2. The task collected results, logged them, and exited zero. Forty-three
   files in the existing lib_*/ scan were silently failing every run,
   for who knows how long. CI registered "BUILD SUCCESSFUL" the whole time.

This commit:

  - Adds manualTests/src/main/x to the parse corpus (treated as a peer
    of lib_*/), reusing the same TreeSitterParseTestTask. Idiomatic
    `takeIf { it.isDirectory }` + `listOfNotNull(...)` rather than an
    if/else, so the absence of the directory just produces an empty list.

  - Logs results at lifecycle level instead of info, so the summary and
    failure list appear in CI output without --info, and so a developer
    running the task locally sees them immediately.

  - Throws GradleException at the end of the task action if any file
    failed to parse, with a message pointing at the lifecycle log.
    Throwing only after the full corpus has been processed means a single
    run produces the complete list of failures; throwing earlier would
    cut it off and force iterative re-runs.

  - Factors the 20-file display cap into a single named local
    `maxFailuresLogged` so the take/if/diff trio shares one definition.

Current state when this lands: 852 of 895 .x files pass; 43 fail. The
lang-validation CI step now goes red on every PR until those 43 are
fixed (or each is investigated and confirmed intentional). Some files
fail because they are deliberately broken Ecstasy (e.g., manualTests/.../errors.x
is in the manualTests build's exclude list) -- those should agree with
the Java reference parser, which excludes them from compilation, so a
follow-up will need to teach this task to honor the manualTests source-set
exclude list rather than fail on intentional invalid code.
…perty

The composite build had three separate JDK version properties:

  - org.xtclang.java.jdk        (in version.properties)
  - org.xtclang.kotlin.jdk      (in version.properties)
  - lang-intellij-jdk           (in gradle/libs.versions.toml)

All three were 25. The kotlin one historically diverged (was 24 until
commit afa62e0 flipped it to 25); the IntelliJ-plugin one was a
hold-over from when the IDE plugin needed to be tracked separately.

There is no scenario today in which any of these three properties
should hold a different value:

  - The project requires JDK 25 minimum (matching IntelliJ 2026.1's
    JBR 25 floor, which is our since-build floor).
  - Kotlin 2.3.21 (pinned in libs.versions.toml) emits JVM 25 bytecode
    (verified: all .class files have major version 69).
  - IntelliJ 2026.1+ ships JBR 25 exclusively; verifyPlugin confirms
    binary compatibility against IU-261.23567.138.

Consolidating to one property is pure simplification:

  - Removes `org.xtclang.kotlin.jdk` from version.properties.
  - Removes `lang-intellij-jdk` from gradle/libs.versions.toml.
  - Renames every kotlinJdkVersion / intellijJdkVersion local to jdkVersion
    in the six build files that declared them.
  - Drops the redundant property providers and the second-toolchain
    indirection in build-logic/common-plugins, build-logic/aggregator,
    and build-logic/settings-plugins.
  - Updates xdk.properties' comment block to reflect the single property.

Future JDK bumps (26, 27, ...) are now a one-line edit in
version.properties; toolchain auto-download in gradle.properties handles
acquiring the JDK on machines that don't have it.

Verified post-change:

  - `./gradlew clean` (alone, per CLAUDE.md gradle rules)
  - `./gradlew build :lang:intellij-plugin:verifyPlugin
        -PincludeBuildLang=true -PincludeBuildAttachLang=true`
    succeeds; verifier reports `Plugin org.xtclang.idea:0.4.4-SNAPSHOT
    against IU-261.23567.138: Compatible`.
  - Sample bytecode (TreeSitterAdapter.class, XtcLanguageServer.class,
    XtcCommenter.class -- including the IntelliJ-instrumented variant):
    all `major version: 69` (JVM 25).
  - Configuration cache stored cleanly.

Net change: 10 files, 29 insertions, 39 deletions.
…s java.toolchain)

The Kotlin Gradle plugin reads `java.toolchain` and uses it for both the
Kotlin compiler launcher and the bytecode jvmTarget when no explicit
`kotlin.jvmToolchain` is set. Per JetBrains' docs:

> If you don't specify a Kotlin toolchain, Kotlin uses Java's toolchain
> configuration.

We had identical `kotlin { jvmToolchain { ... } }` blocks alongside every
`java { toolchain { ... } }` block, all reading from the same jdkVersion
provider. With the Java side as the single source of truth, the Kotlin
side is pure duplication.

Files updated (7 total):
  - build-logic/aggregator/build.gradle.kts
  - build-logic/common-plugins/build.gradle.kts
  - build-logic/settings-plugins/build.gradle.kts
  - lang/dap-server/build.gradle.kts
  - lang/dsl/build.gradle.kts
  - lang/intellij-plugin/build.gradle.kts
  - lang/lsp-server/build.gradle.kts

Each loses a 5-line `kotlin { jvmToolchain { ... } }` block. A short
comment is left in its place to document the auto-inherit relationship
(saves the next reader from wondering why Kotlin has no toolchain block).

Verified post-change:

  - `./gradlew clean` then `./gradlew build :lang:intellij-plugin:verifyPlugin`
    with -PincludeBuildLang/-PincludeBuildAttachLang both succeed.
  - Plugin Verifier still reports `Compatible` against IU-261.23567.138.
  - Sample bytecode (TreeSitterAdapter.class, XtcLanguageServer.class,
    XtcCommenter.class -- including IntelliJ-instrumented variant): all
    `major version: 69` (JVM 25). Kotlin auto-inheritance works.
  - Configuration cache stored cleanly.
…guard

The lang/* build files were each redeclaring the same Java toolchain block,
even though they all apply org.xtclang.build.xdk.properties. Move the
toolchain wiring into that convention plugin so every project that touches
Java OR Kotlin gets it from a single source.

Changes:

  - org.xtclang.build.xdk.properties (new section): wires the Java toolchain
    using `plugins.withType<JavaBasePlugin>` + `JavaPluginExtension`. Reads
    org.xtclang.java.jdk via xdkProperties (the canonical property after
    the earlier kotlin.jdk + lang-intellij-jdk consolidation). Kotlin
    auto-inherits this toolchain (no separate kotlin.jvmToolchain block needed).

  - org.xtclang.build.java: drops its own java.toolchain block. The plugin
    applies xdk.build.properties first, so the toolchain is inherited
    transitively. Existing JavaCompile/JavaExec/Test wiring is unchanged.

  - lang/dsl, lang/lsp-server, lang/dap-server, lang/intellij-plugin:
    drop their `java { toolchain { ... } }` block, the local jdkVersion
    val that fed it, and the now-unused JavaLanguageVersion import.
    Each gains a 2-line comment pointing at xdk.build.properties.

  - build-logic projects (common-plugins, aggregator, settings-plugins)
    keep their own bootstrap toolchain config since they cannot apply
    xdk.build.properties to themselves (chicken-and-egg).

== Divergence guard ==

Added a configuration-time assertion in xdk.build.properties that fires
in `afterEvaluate` for any project applying JavaBasePlugin: it reads the
resolved `java.toolchain.languageVersion` and fails the build if it
doesn't equal `org.xtclang.java.jdk`. This catches:

  - direct java.toolchain overrides in any build script
  - `kotlin { jvmToolchain(N) }` shorthands at a divergent N (Kotlin
    propagates that N to java.toolchain, so this surfaces it)

The check uses Gradle's typed JavaPluginExtension API -- no reflection,
no Kotlin-Gradle-plugin dep added to build-logic.

Verified the guard fires correctly: temporarily injected
`kotlin { jvmToolchain(21) }` into lang/dap-server, ran the build, got:

  > A problem occurred configuring project ':lang:dap-server'.
  > > JDK toolchain divergence in project ':dap-server': resolved
  >   toolchain languageVersion=21 but org.xtclang.java.jdk=25. ...

Removed the test injection; build is clean again.

== Verification ==

  - `./gradlew clean` (alone, per CLAUDE.md gradle rules)
  - `./gradlew build :lang:intellij-plugin:verifyPlugin
        -PincludeBuildLang=true -PincludeBuildAttachLang=true`
    succeeds; verifier reports `Compatible` against IU-261.23567.138.
  - Sample bytecode (TreeSitterAdapter.class, XtcLanguageServer.class,
    XtcCommenter.class -- including IntelliJ-instrumented variant): all
    `major version: 69` (JVM 25). Toolchain centralization preserves
    bytecode target.
  - Configuration cache stored cleanly.
…id + parked files

The strict-mode parse sweep (commit a8c6af8) surfaced 43 failures across
lib_*/ and manualTests/. Triage shows 21 of those are deliberate exclusions
that should never be "fixed":

- 19 INTENTIONAL-INVALID: files in manualTests/build.gradle.kts excludes
  (archive/, dbTests/, jsondb/, webTests/, errors.x). The XTC reference
  compiler does not parse them either; tree-sitter rejecting them is the
  correct behavior.
- 2 PARKED: reflect.x and generics.x exercise nested angle-bracket
  function types (Function<<...>, <...>>), the C5 issue from the canonical
  plan. The fix requires either an external scanner or operator-token
  rework -- significant work, deliberately deferred.

Mechanism: a checked-in `lang/tree-sitter/treeSitterParseSkipList.txt`
file with one path per line and `#` comments. The file's header documents
the two categories. TreeSitterParseTestTask reads the file (relative to
the composite root), partitions xtcFiles, and warns on any stale entry
that no longer matches a real file. Configuration-cache compatible
(InputFile-tracked).

After this change, the sweep reports 852 passed / 22 failed / 21 skipped.
The remaining 22 are real grammar gaps that must be fixed in this branch.
`val _ = expr;` is the standard "evaluate and discard" idiom in Ecstasy
(used pervasively in `manualTests/.../slow/readers.x` to force evaluation
of properties that may have side effects). The grammar's
`variable_declaration` rule's val/var form bound the `name:` field to
`$.identifier` only, but in tree-sitter `_` tokenizes to the literal
wildcard token (because the anonymous `'_'` in the `wildcard` rule wins
over the identifier regex). Result: the line failed to parse.

Fix: name field is now `choice($.identifier, $.wildcard)` for the val/var
form. The typed form (`Type _ = expr`) is left unchanged for now -- no
file in the corpus uses it, and adding it later is a one-line change.

Adds a regression test for the shape and unblocks `slow/readers.x` from
the parse sweep (22 failures -> 21).
…xpression

`File f = ./IO.x;` and `Directory d = ../shared;` use a bare relative
path as a primary expression -- the runtime equivalent of a File/Directory
reference relative to the source file. This is distinct from `#path`
(binary embed at compile time) and `$./path` (string embed at compile
time), both of which were already in the grammar. The bare form was not.

Fix: new rule `relative_path_literal: /\.\.?\/[\w./-]+/` added to the
`_literal` alternation. The leading `./` or `../` makes the token
unambiguous against any other primary expression -- regular identifiers
cannot start with a dot. Absolute `/path` form is intentionally not
added here because it would conflict with division in expressions like
`a/b`; the existing `path_literal` (typed-only, e.g. `Path:/sys/info`)
remains the way to write absolute paths.

Adds a regression test exercising both `./` and `../` shapes. Unblocks
`manualTests/.../IO.x` from the parse sweep (21 failures -> 20).
`assert:rnd(N) cond` is the sample-rate form of assert -- the assertion
fires roughly once per N invocations. The grammar's `assert_variant`
rule listed `assert:rnd` alongside the other colon-suffixed variants
but had no syntactic slot for the `(N)` argument, so
`manualTests/.../exceptions.x`'s `assert:rnd(100) x < size();` failed
to parse.

Tricky part: `assert:arg` immediately follows `(...)` too, but in that
case the parens are the tuple destructuring conditional declaration's
pattern (`assert:arg (Type x, Type y) := expr`, used pervasively in
`lib_net/.../UriTemplate.x` and similar). An initial attempt that
allowed `(...)` for *every* variant swallowed the tuple pattern and
regressed UriTemplate.x. The fix scopes the optional arg list to
`assert:rnd` alone -- the only variant that actually takes args.

Adds two regression tests: one for the new `assert:rnd(N)` shape and
a companion for `assert:arg (Type x, ...) := expr` to guard against
re-introducing the swallow-the-tuple bug. Unblocks exceptions.x
(20 failures -> 19).
`assert !(Color c4 := c3.next());` is the "negated typed conditional"
form -- it asserts that the `:=` conditional binding *fails* (i.e.
`next()` does not yield a Color). Used in `manualTests/.../misc.x`'s
testEnums().

The negation cannot be expressed via `_expression` because
`parenthesized_expression` only wraps `_expression` and a
`conditional_declaration` is not an expression. Fix: extend
`assert_condition` directly with a third alternative:
`'!' '(' conditional_declaration ')'`. Not generalizing this to
`if_condition` / `while_condition` because no file in the corpus uses
those shapes, and a targeted addition is easier to remove than a
broader rule shift.

Adds a regression test for the assert-with-negated-conditional shape.
Unblocks misc.x from the parse sweep (19 failures -> 18).
`v:5.6.7.8-alpha`, `v:1.2beta5+123-456.abc`, and other multi-segment /
pre-release / build-metadata version literals failed to parse: the
grammar had no `version_literal` rule, so `typed_literal` was parsing
`v:N` as `type 'v' ':' integer_literal` and the rest as ERROR.

Fix: new single-token rule `version_literal: /v:[a-zA-Z0-9._+-]+/` added
to the `_literal` alternation. The lexer's longest-match rule reliably
picks `version_literal` over the bare `v` identifier (3+ chars vs 1).

While in the file, `literals.x` is moved to the skip list as PARKED.
It is a stress-test of every literal form, and fix H only closes the
version-literal gap; four other independent gaps remain (`Path:./`
typed-literal, bare `./` alone, long paths containing reserved
keywords, bare hex `#123_4567...`). Each is a separate small grammar
change but batching them into the C-series would muddy the per-fix
commit discipline. The skip-list entry documents the four remaining
shapes; revisit once the rest of the sweep is green.

Plan doc updated to reflect the C-series triage progress (5 shapes
fixed, ~16 files remaining all under shape B+C, plus shape I).

Sweep state: 17 failures (from 18); 22 files now skip-listed.
Two related shapes from `manualTests/.../annos.x`:

1. **Qualified-new with annotation**: `outer.new @anno(args) Type()`.
   The `new_expression` rule's unqualified form already accepted
   `repeat($.annotation)` between the keyword and the type; the
   `expr.new Type(args)` qualified form did not. Same shape as
   `testAnnotations2()`'s `new Parent().new @Parent.Anno(descr) Parent.Child()`.

2. **Annotated parenthesized type**: `(@AutoFreezable Freezable)? o`.
   `parenthesized_type` was strictly `'(' type_expression ')'`, no
   annotation slot, but Ecstasy lets you wrap an annotated type in
   parens to scope the `?` nullable wrap (or any other type-level
   operator) over the entire annotated form. From
   `testMethodAnno(@tagged(weight=2) (@AutoFreezable Freezable)? o = Null)`.

Adds two regression tests, one per shape. Unblocks `annos.x` from the
parse sweep (17 failures -> 16). Down to one shape remaining: B+C,
the destructuring-with-`_`-and-bare-identifier shape that covers the
remaining 16 files in one fix.
…e element

`(_, Int index) = collection.binarySearch(...)` and `(_, _) = pair` are
the canonical "discard a tuple slot" idioms in Ecstasy, used pervasively
in `lib_ecstasy/.../maps/*.x`, `lib_xml/.../impl/*.x`, etc. The grammar's
`tuple_assignment_element` choice did not list `wildcard`, and
`for_tuple_destructure` required typed bindings on every element.

Three changes:

1. `tuple_assignment_element` adds `$.wildcard` as a fourth alternative.
   `prec.dynamic(1)` on the existing `$._expression` alt (kept around
   for `this.field` and bare-identifier forms) was tried as an attempt
   to bias the GLR toward tuple_assignment over tuple_type interpretation
   for `(i1, Int i2) = ...`; it didn't move the needle, see the
   skip-list note for `callTests.x` for what was tried.

2. `for_tuple_destructure` factored out `_for_tuple_destructure_element`
   = `choice($.wildcard, seq($.type_expression, $.identifier))` so
   `for ((_, _) : map)` and `for ((_, Int v) : map)` now parse.

3. Two new GLR conflicts:
   - `[tuple_assignment_element, _for_tuple_destructure_element, _expression]`
     for the bare-`_` ambiguity inside a for-loop's parenthesized form
   - `[tuple_type_element, parameter, tuple_assignment_element, _for_tuple_destructure_element]`
     for the `(Type x, ...)` ambiguity in the same position

Plus `tuple_assignment` now wraps in `prec(2)` to outweigh
`variable_declaration`'s typed-form `prec(1)` -- doesn't change the
parse tree of any existing-and-passing file, but is the right
precedence relationship to encode regardless.

Unblocks 15 files: 14 lib_*/ files + `manualTests/.../maps.x`.
`callTests.x`'s `(bare_ident, Type ident) = expr;` shape is moved to
the skip list as PARKED; the GLR consistently commits to
`variable_declaration` with `(bare_ident, Type ident)` as a tuple-type,
and the fix needs deeper investigation than this branch warrants.

Adds two regression tests (wildcard tuple-assignment, for-loop wildcard
destructure). Plan doc reflects all of the above plus the now-green
sweep state (872 passed, 0 failed, 23 skip-listed).

Sweep state: 872 passed, 0 failed.
…nt_element/for_tuple_destructure conflict

The 4-way conflict involving `for_tuple_destructure` (the rule itself)
became redundant when commit 09b4b30 (B+C destructuring) added a
narrower 4-way conflict involving `_for_tuple_destructure_element`
(the inner element). Tree-sitter's grammar validator was flagging
the older entry as 'unnecessary conflicts'.

Drop it. `validateTreeSitterGrammar` is now warning-free.
Documents the four additional approaches tried in this session for
the `(i1, Int i2) = ...` GLR puzzle, plus the diagnostic insight that
the 'unnecessary conflict' warnings from tree-sitter give us: the
container-level decision (tuple_assignment vs variable_declaration)
is made deterministically at LALR generation time, before any of the
element-level conflicts or prec.dynamic biases get a chance to apply.

Updates the 'fix is likely...' suggestion accordingly: structural
rewrite or alias-with-high-prec.dynamic on the bare-ident path.
No grammar change. Park entry stands.
…re `./` parses as Directory

Two adjacent fixes for the parked literals.x file, both one-line
grammar changes:

(a) `typed_literal`'s value choice gains `relative_path_literal`,
    so `Path:./`, `Path:./more/msgs.txt`, `Directory:./more/` all
    parse as typed literals (Type:value form). Previously the bare
    relative-path value after `:` errored.

(b) `relative_path_literal` regex relaxes `+` -> `*` on the trailing
    portion, so a bare `./` (current dir) and bare `../` (parent dir)
    parse as a path literal. Previously at least one trailing char was
    required, so `Directory dir = ./;` errored at the `./`.

literals.x sweep delta: closes 3 of the 5+ remaining errors in the
file (lines 119/120 `Path:./;`, line 154 bare `./;`, line 155 `./;`
in the assignment that follows). Lines 149 (long path with reserved
keywords), 246-247 (hex byte literal), and 304+ (Time/Duration typed
literals -- additional sub-gaps) remain. Skip-list entry stays.

No regressions: 872 of 872 pass, validateTreeSitterGrammar warning-free.
Adds `multiline_hex_byte_literal` token rule for multi-line hex byte
constants of the shape:

    bytes = #|0123456789aBcDeF 0123456789aBcDeF
             |0123456789aBcDeF_0123456789aBcDeF
             ;

Mirrors the existing `multiline_literal` rule (`\|...|`) — same
line-continuation regex, only the prefix differs (`#|` instead of
`\|`). Wired into `_literal` so it's a primary expression.

literals.x sweep delta: closes the lines 246-247 error. Remaining
errors are line 149 (bare absolute path `/foo` as primary expression
— ambiguous with division) and lines 304+ (Time:/Duration: typed
literals). Skip-list entry stays.

Sweep: 872 of 872 pass. validateTreeSitterGrammar warning-free.
Three coordinated fixes for ISO-8601 typed-literal forms used in
`literals.x`'s testTimes() and testDurations() blocks:

1. New `date_literal` rule (`YYYY-MM-DD` and `YYYYMMDD`) for
   `Date:2024-01-26` and `Date:20240126`.

2. New `time_literal` rule for ISO 8601 datetime forms:
   - `YYYY-MM-DDTHH:MM:SS`, with optional `.fff` fractional seconds
     and optional timezone (`Z` or `+HH:MM` / `-HH:MM`)
   - compact: `YYYYMMDDTHHMMSS[.fff][TZ]`
   covering all six `Time:...` shapes in literals.x lines 304-319.

3. `duration_literal` regex moves the `T?` (date/time separator)
   from being valid only at the start to being valid before any
   unit-digit pair: `P?(T?[0-9]+(\.[0-9]+)?[YMDHS])+`. Now matches
   `P3DT4H5M6S` and `P1DT1H1M1.23456S` (literals.x lines 326+).

All three rules wired into `typed_literal`'s value choice. Order is
`time_literal` before `date_literal` so the longest-match prefers
the full datetime when present.

literals.x sweep delta: closes the lines 304-329 errors. Only
remaining error is line 149 (bare absolute path `/foo` as primary
expression — needs context-sensitive tokenization to disambiguate
against division). Skip-list entry stays.

Sweep: 872 of 872 pass. validateTreeSitterGrammar warning-free.
…g context

The C5 puzzle was that tree-sitter's internal lexer greedily tokenizes
`>>`, `>=`, `>>=`, `>>>=` as single operator tokens. In an
expression like `a >> b` that's correct. In a nested type-argument
list like `Function<<Int, String>, <Int>>` it isn't -- the closing
`>` of the inner list and the closing `>` of the outer list need to
be two separate tokens, but the lexer commits to `>>` as right-shift
before the parser can disambiguate.

Fix: introduce `TYPE_GT` as an external scanner token. The grammar
uses `$._type_gt` (instead of literal `'>'`) as the closer of
`type_parameters`, `type_arguments`, and `angle_bracket_type_list`.
The scanner emits TYPE_GT only when the parser asks for it (i.e. when
TYPE_GT is in valid_symbols), so expression-context `>>` keeps its
existing tokenization.

Whitespace handling: tree-sitter does NOT auto-skip extras before
calling an external scanner, so the scanner skips horizontal/vertical
whitespace itself for shapes like `Map< Int >`. The skip is gated on
NOT being inside a template-interpolation context (where the
template scanner depends on whitespace not being pre-consumed).

Reflect.x / generics.x impact (still parked): the right-hand side of
`new TestTurtle<<Int, String>>()` and `bar.as(Function<<Int, String>, <Int>>)`
now parses cleanly. Their left-hand-side counterparts
(`TestTurtle<<...>> turtle = ...`, `Function<<...>, <...>> f = bar;`)
still fail -- those need a complementary `<`-side fix because the
lexer also greedily tokenizes `<<` as left-shift. Follow-up commit.

Sweep: 872 of 872 still pass. validateTreeSitterGrammar warning-free.
Documents the asymmetry the experiment surfaced: the closing-side
TYPE_GT external token is safe because the parser only requests it in
unambiguous type-position rules; the opening-side TYPE_LT mirror is
not safe because at statement start the parser keeps both
variable_declaration and expression_statement alive, so TYPE_LT lands
in valid_symbols and eagerly consumes `<` from `a < b` comparisons.
160 files broke when TYPE_LT was wired in; reverted.

The skip-list note now records what shipped (RHS shapes work),
what doesn't (LHS shapes still parked), why TYPE_LT can't be a
naive mirror, and the most promising direction (structural grammar
rewrite or context-aware TYPE_LT).
lagergren added 12 commits May 1, 2026 15:35
The single `treeSitterParseSkipList.txt` had grown to 23 entries, of
which only 4 were genuine grammar debt to fix; the other 19 are files
permanently excluded from the XTC compile (archive/, dbTests/,
jsondb/, webTests/, errors.x). The real debt was drowning in noise.

Split into two companion files, both named with the
`treeSitterParseSkipList.*` prefix so the relationship is obvious:

  - treeSitterParseSkipList.intentional.txt — 19 files, will stay
    skip-listed forever; the reference compiler doesn't parse them
    either, so tree-sitter rejecting them is correct behavior.

  - treeSitterParseSkipList.parked.txt — 4 files (reflect.x,
    generics.x, callTests.x, literals.x), real grammar gaps with
    triage notes for the next attack.

Build wiring: the task's input changes from a single `RegularFileProperty`
to a `ConfigurableFileCollection` that loads both. The lifecycle log
now lists the source filenames so it's clear which file an entry
came from.

Sweep: 872 of 872 still pass. 23 file(s) excluded (combined count
matches the previous single-file behavior).
Closes the opening side of the C5 nested-angle-bracket type case.
Emit the binary shift operators `<<`, `>>`, `>>>` as character-level
sequences `seq('<', token.immediate('<'))` etc. so the tree-sitter
lexer never produces a multi-char shift token. With `<<` no longer a
terminal, the lexer naturally emits `<` `<` for inputs like
`Function<<Int, String>, <Int>>` and the type_arguments /
angle_bracket_type_list rules consume the chars normally; the closing
`>` chars continue to go through the TYPE_GT external scanner shipped
in d384f23.

Cost: a 1-element self-conflict on `binary_expression`. At state
`_expression • >` the parser cannot tell from a single lookahead
whether `>` opens precedence-9 comparison, precedence-10 range, or
precedence-11 shift, so GLR forks and unmatched alternatives die on
the second char.

Assignment shifts `<<=`, `>>=`, `>>>=` are deliberately NOT split.
The lexer's longest-match rule still emits them as single 3-char
tokens, and splitting them was rejected by the validator with a 5-way
conflict spanning assignment_expression, binary_expression,
unary_expression, call_expression, async_call_expression at
`_expression • <`.

Sweep: 873 / 873 passing (was 872 / 872 with reflect.x and generics.x
parked).
…ritten

Remove generics.x from the parked list (now parses cleanly after the
shift-operator split). Rewrite the C5 section to record the LHS fix
strategy and the LALR(1) constraint that keeps assignment shifts
intact.

Update reflect.x triage: the C5 LHS errors at lines 31-32 are gone
but a previously-masked, unrelated bug surfaces at lines 193+. Inside
a template interpolation `{f2 } -> {f2 ()}` the parser greedily
commits to a lambda `f2 -> {f2 ()}` whose body block consumes the
closing `}` of the first interpolation. Minimal repro recorded.
reflect.x's residual error -- the chain
`{method.as(Method<...>>).\n   |   invoke(p, ())[0]}` inside a multiline
template -- closes here, alongside the simpler `$"{y } abc"` trailing-
whitespace case.

Two scanner-level fixes:

1. Inside an interpolation expression (`in_expr`), the scanner now
   skips horizontal whitespace before checking for the closing `}`.
   Previously the trailing space in `{y }` caused TEMPLATE_EXPR_END
   not to fire, so the `}` was lexed as a regular brace and parse
   error recovery committed to bizarre interpretations (e.g. lambda
   `y -> {y ()}` swallowing the next interpolation's `{...}`).

2. New external token MULTILINE_CONTINUATION declared in `extras`.
   Emitted when peek is `\n` AND we're inside a multiline-template
   interpolation expression -- consumes the trailing `   |`
   continuation marker so the `|` is not lexed as a bitwise-OR
   operator. Gating uses persistent scanner state: a depth counter
   `ml_interp_depth` bumped on MULTILINE_EXPR_START and popped on
   the matching TEMPLATE_EXPR_END. The depth gate is what keeps
   normal multi-line `a\n     | b` bitwise-OR expressions from being
   silently swallowed.

Sweep: 874 / 874 passing (was 873 / 873, with reflect.x parked).
Validator: warning-free.
reflect.x now parses cleanly. Replace the C5 LHS section with a unified
note covering both the operator-split fix and the multiline-continuation
scanner fix that closed it out. callTests.x and literals.x remain
parked.
Both files remain parked. The notes now record:

callTests.x — `(i1, Int i2) = ...` tuple_assignment commit
  Adds a new failed attempt: `prec.dynamic(-1)` on `tuple_type_element`
  to disprefer it when `tuple_assignment_element` is alive in parallel.
  GLR explored more paths (parse time went up) but the deterministic
  LALR commit to `variable_declaration` was unchanged. Notes also
  enumerate the working-case shapes (typed first element, all-bare,
  member-access second) to clarify what specifically about
  bare-ident-first defeats every attempted disambiguation.

literals.x — bare absolute-path primary expression
  Records an end-to-end attempt at the obvious fix: an external-scanner-
  emitted ABSOLUTE_PATH_LITERAL gated on `valid_symbols`, mirroring the
  TYPE_GT and MULTILINE_CONTINUATION pattern from earlier in this
  branch. Scanner instrumentation showed the token *is* emitted
  correctly in `typed_literal` context (line 259, `FileStore:/archive`)
  but the scanner is *never invoked* at line 150's `Path p = /allow.txt`
  position — `_absolute_path_literal` is observably missing from
  valid_symbols at the LR state reached after `Path p = `, despite the
  rule being wired through `_literal -> _expression`. Adding the rule
  to `typed_literal`'s value choice introduces a regression
  (`Type:/path` parses as `else_expression` instead of `typed_literal`).
  The next attempt should compare parser.c lex_state tables against a
  `tree-sitter parse --debug` trace at the failing position to
  identify why the external is being skipped.
…literal in _literal

Adds the existing `path_literal` rule (previously only reachable via
`typed_literal`) to `_literal`'s choice so `Path p = /allow.txt;` parses
as a primary expression. Tightens the regex from
`/\/[a-zA-Z0-9_\-\.\/]*/` to `/\/[a-zA-Z0-9_][a-zA-Z0-9_\-\.\/]*/` so
the first body char after `/` can't be `/` or `*` -- this disambiguates
against `//` (line_comment) and `/*` (block_comment) start tokens, which
otherwise win longest-match in expression-statement-start states.

The earlier parking note assumed the internal regex would conflict with
spaceless division (`bytesLen/2`); empirically it does not, because
tree-sitter's lex states are state-restricted and a primary-expression
starter is not active mid-binary-expression. The real conflict was with
comment starts, which the stricter first-char class fixes. Cost: zero
new conflicts, no scanner work.

Sweep moves from 874/874 to 875/875.
… TUPLE_ASSIGN_LPAREN attempt

literals.x removed from the parked list (closed by the previous commit
adding `path_literal` to `_literal`). The parked-list header now records
the fix as item 3 in the running summary of what closed each formerly-
parked entry.

callTests.x stays parked. Triage extended with the latest attempt: an
external-scanner-emitted TUPLE_ASSIGN_LPAREN token that peeks past the
matching `)` for `=` and uniquely starts `tuple_assignment`. The scanner
DID emit correctly for the target shape, but forcing the LR parser to
commit to `tuple_assignment` at the `(` shift regressed 4+ files in the
existing sweep AND the lsp-server test-cases for typed / wildcard /
annotated `tuple_assignment_element` shapes -- e.g.
`(UInt8 left, UInt8 digit) = this /% 10;` and `(_, Int idx, _) = split();`.
The interaction is with `prec.dynamic(1, $._expression)` on the
`_expression` alt of `tuple_assignment_element`: with the external token
suppressing GLR's container-level fork, that bias starts winning even
for typed elements (`UInt8 left` -> tries `_expression`, fails on the
two-token shape, can't backtrack). Reverting the prec.dynamic regresses
the wildcard cases. The external-token approach is incompatible with
the current element-alternation precedence structure; closing this gap
probably requires a structural rewrite of `tuple_assignment_element`
alongside the scanner.

Plan file updated: literals.x moved from "still parked" to "closed";
sweep state at 875/875 with one parked entry (callTests.x); 20 files
total skip-listed (19 intentional-invalid + 1 parked).
Combine an external-scanner TUPLE_ASSIGN_LPAREN token with a
narrowed bare-element alt of `tuple_assignment_element` to make
mixed bare-ident + typed-decl tuple assignments parse — e.g.
`(i1, Int i2) = testMultiReturns(0);` (callTests.x line 20),
which previously errored on `=` because GLR committed to
variable_declaration with a tuple_type at the `(` shift.

Scanner: peek past balanced `(...)` looking for `=` (and not
`==`/`=>`) before any `;` / `{` / `}` / EOF, requiring at least
one `,` at depth 1. Skip leading whitespace via
`lexer->advance(skip=true)` (tree-sitter doesn't auto-skip
extras before invoking external scanners) but defer to TODO
freeform when both are valid — otherwise we'd consume the
hspace the TODO scanner needs.

Grammar: `tuple_assignment` now starts with the external token,
forcing LR commit at the `(` shift. The bare-element alt of
`tuple_assignment_element` is narrowed from
`prec.dynamic(1, $._expression)` to
`choice($.identifier, $.member_expression, $.index_expression)`
— with the container fork suppressed by the scanner, a full
`_expression` alt would cause typed elements like `UInt8 left`
to lose to a failing _expression parse (no backtrack). The
three node shapes cover all bare LHS slots seen in real code:
single ident (`i1`), member chain (`this.growAt`), subscript
(`quotients[i]`). Adds one 4-way conflict and removes the
previously-required `[tuple_type_element, parameter,
tuple_assignment_element]` (now unnecessary).

Sweep: 876/876, lsp-server tests green, intellij-plugin
verifyPlugin Compatible.
…ries

callTests.x was the last parked entry. Closing it required the
combination described in the previous commit; updated the
"closed" history section to record the fix shape (external
TUPLE_ASSIGN_LPAREN scanner + narrow bare-element alt) and
removed both the long triage block and the file path itself.
The previous `intentional.txt` claimed 19 files were "intentionally not
parseable by tree-sitter" and excluded them from the parse sweep on
that basis. Re-checking against both parsers shows the categorization
was wrong:

  - 4 files parse cleanly with both tree-sitter and the Java reference
    compiler -- moved into the active sweep:
      archive/web-static.x
      dbTests/PeopleDB.x
      jsondb/jsondb_test/storage/JsonValueStoreTest.x
      webTests/Hello.x

  - 13 files have no Java PARSER-NN errors (Java parses them; failures
    are at the semantic / verify level which is below tree-sitter's
    concern) but DO produce ERROR nodes in the tree-sitter parse.
    Moved to parked.txt as newly-uncovered grammar gaps with
    per-entry ERROR-node counts as a triage hint. The actual
    grammar-fix work for these is deferred to a follow-up PR.

  - 2 files (sock-shop/socks-catalog.x, sock-shop/socks-user.x) have
    genuine PARSER-03 errors from the Java compiler; they remain in
    intentional.txt with a corrected header that documents the
    real criterion ("xcc emits PARSER-NN") for landing on this list.

Sweep: 880/880 with 13 parked entries, lsp-server tests green,
intellij-plugin verifyPlugin Compatible.
Commit 87aa434 ("consolidate JDK toolchain to a single
org.xtclang.java.jdk property") removed `org.xtclang.kotlin.jdk` from
version.properties but missed updating the GitHub composite action,
which still required the property and `exit 1`'d when missing. CI on
this branch consequently failed at the very first step ("Setup XVM
Project") with no informative message in the live log because the
echo lines only print before the script's last failed-grep exit.

Default `KOTLIN_JAVA_VERSION` to `JAVA_VERSION` when the property is
absent (the only consumer is the secondary setup-java step that
double-installs a different JDK if the two diverge — equal values just
skip it, which is what we want post-consolidation).
@lagergren
lagergren force-pushed the lagergren/lsp-gene-followup-grammar branch from 43dd074 to 7e5048e Compare May 1, 2026 13:37
The previous fix added a `[ -z "$KOTLIN_JAVA_VERSION" ]` fallback but
the script exited *before* reaching it: bash 5 with
`set -e -o pipefail` (the GitHub Actions default for shell:bash) treats
`var=\$(failing-pipeline)` as a script-level failure and aborts. Since
the kotlin.jdk property no longer exists in version.properties (commit
87aa434 consolidated to a single org.xtclang.java.jdk), the
\$(grep ...) substitution failed and killed the whole step before the
script could reach any echo / assignment / fallback.

The CI log was unhelpful: between the script-source listing and
`Process completed with exit code 1` there were zero runtime lines,
which is the giveaway that the script died on the first command
substitution returning non-zero.

Wrap the grep in a brace group with `|| true` so the pipeline always
returns 0; the substitution captures an empty string when the property
is absent, and the existing `[ -z ]` fallback then assigns
JAVA_VERSION as the default (no second JDK install needed since they
were always equal post-consolidation).
@lagergren
lagergren force-pushed the lagergren/lsp-gene-followup-grammar branch from ed7996a to d720b9e Compare May 1, 2026 13:47
The `tree-sitter parse` CLI prints a 4-line warning every invocation
when it can't find a user-level config listing `parser-directories`:

    Warning: You have not configured any parser directories!
    Please run `tree-sitter init-config` and edit the resulting
    configuration file to indicate where we should look for
    language grammars.

Locally this is mildly annoying. In CI it's a flood: ~3,500 lines
across the 880-file parse sweep, drowning the actual test output.

Fix: extend `generateTreeSitterConfig` to write a minimal local
user-config (`tree-sitter-user-config.json`) listing the generated
grammar dir as the only parser-directory, and pass `--config-path`
to every `tree-sitter parse` call (including the warmup invocation).
The config is hermetic (no $HOME dependency), the warning is gone,
and the test still reports 880/880.

`tree-sitter generate` doesn't accept --config-path and doesn't emit
the warning anyway, so validateTreeSitterGrammar is unchanged.

@ggleyzer ggleyzer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks so much cleaner now!

@lagergren
lagergren merged commit 474cda9 into master May 1, 2026
4 checks passed
@lagergren
lagergren deleted the lagergren/lsp-gene-followup-grammar branch May 1, 2026 14:54
@lagergren

Copy link
Copy Markdown
Contributor Author

Looks so much cleaner now!

Thx. This was HARD.

lagergren added a commit that referenced this pull request May 1, 2026
Two follow-up tweaks from the PR review.

== Drop the explicit IntelliJ IDE distribution cache ==

Pre-PR, lang/.intellijPlatform/ides was cached via actions/cache@v4
with a step ordered AFTER the main build, so the cache restore was a
no-op for the run that needed it (Gradle had already downloaded the
IDE). The save still happened post-job, so subsequent runs benefited
slightly -- but only via the standalone verifier that this PR has now
deleted, so the explicit cache no longer accelerates anything in the
new shape.

Rather than fix the ordering, drop the explicit cache entirely. ~1 GB
per cached IDE eats into the 10 GB per-repo GitHub cache budget that's
much more valuable for PR Gradle / dep caches that hit on every build.
The verifier only needs the IDE on the rare lang/-changed run (PR
validation or master publish), and the IntelliJ Platform Gradle Plugin
redownloads it on demand. ~1-2 minutes slower on those rare runs, but
it stops the duplicate explicit cache entry from displacing caches
that hit on every PR.

A NOTE comment is added where the cache step used to live so this
decision doesn't get re-litigated by someone reading "but we should
cache the IDE!" without context.

Caveat (for completeness, not addressed by this PR): the IntelliJ
Platform Gradle Plugin also unpacks the IDE under
  ~/.gradle/caches/9.5.0/transforms/.../transformed/idea-261*/
which is captured by setup-gradle's gradle-transforms-v1 cache
pattern (/home/runner/.gradle/caches/*/transforms/*/) -- a few hundred
MB end up in that cache key on lang/-changed runs. This behaviour
predates PR #452 (the bug this PR is fixing), is not new, and is left
alone here. Eliminating it would require filtering setup-gradle's
gradle-home-cache-excludes, with destabilization risk for unrelated
artifact transforms. Punted as a separate cache-tuning task if the
gradle-transforms key ever becomes a budget problem; this PR is about
the publish-version regression, not full IDE-cache eradication.

== Better diagnostics in the pre-upload sanity check ==

Copilot review on PR #454 flagged that the previous version-mismatch
diagnostic was ambiguous when the failure was actually structural --
e.g., the find expression returned empty because the IntelliJ Platform
Gradle Plugin changed its ZIP layout, not because the version was
wrong. Both paths printed the same "<version>: <empty>" message.

Split the diagnostic into three explicit failure modes, each with
targeted output:

  1. INNER_JAR not found in the ZIP -- print top-level ZIP layout so
     the next maintainer can see what the plugin actually produced
     and update the find expression.

  2. plugin.xml found but no <version> element extracted -- print
     JAR contents and the first 80 lines of plugin.xml so a malformed
     descriptor or missing META-INF entry is obvious.

  3. Version mismatch (the original case this PR was meant to catch)
     -- now also echoes the inner JAR path so reviewers can correlate
     against build/distributions/ in the build artifacts.

No behavioural change for the happy path or for the bug-detection
path; just better signal when something else goes wrong.
lagergren added a commit that referenced this pull request May 23, 2026
…ls in expression position

Closes two grammar gaps that surface as parse errors against the
manualTests corpus (CI hides these on master because the validation
step is gated on path-filter `lang/**`):

* annos.x:141 — `annotation Foo(...) into Bar { ... }` inside a method
  body. Local class/interface/mixin/service declarations were already in
  the `_statement` choice; `annotation_declaration` was not. Added.

* generics.x:27 — `Base<Int>.Child2<String>` as a value-position type
  literal. `member_type` was reachable from `_non_bi_type` only, so it
  was never tried in expression position. Added to `_expression` next
  to `$.generic_type` (the symmetric case for non-virtual-child type
  literals).

  The with-type-arguments form of `member_type` is split into its own
  alternative at `prec.left(MAX_PRECEDENCE_PLUS_3)` so it outranks
  `member_expression` (MAX_PRECEDENCE_PLUS_2). Without that, the GLR
  conflict resolver preferred `member_expression(Base<Int>, Child2)`
  and choked on the trailing `<String>`. The no-arguments form keeps
  default precedence so `Base<Int>.Child` still parses as a
  `member_expression` (no AST shape change for that case).

  The previously-declared `[$.member_type, $._expression]` GLR conflict
  is now redundant (static precedence resolves the ambiguity) and was
  removed; tree-sitter flagged it as an unnecessary conflict.

Why this regressed silently
---------------------------
Neither failure is a tooling/grammar regression — both are new XTC
syntax patterns added to the manualTests corpus that the grammar
never had a test case for:

* generics.x:27 was added on 2026-05-06 by 0120712 ("Fix
  NameExpression code production for parameterized virtual child
  classes") — a compiler bugfix that needed a test exercising
  `Base<Int>.Child2<String>`.
* annos.x:141 was added on 2026-05-17 by 91f6d7d ("Fix a compiler
  exception (#463)") — a compiler bugfix that needed a test exercising
  a local `annotation … into …` declaration.

Both PRs only touched `manualTests/src/main/x/` and `javatools/`,
never `lang/`. The `dorny/paths-filter` gate in
`.github/workflows/commit.yml` skips the tree-sitter validation step
whenever no `lang/**` paths change, so the master CI run was green
even though both new test files would have failed grammar validation.
This PR (which touches `lang/vscode-extension/**`) is the first since
May 6 to trip the gate and run the validation, which is why both
failures surfaced together here.

The skip lists (parked.txt, intentional.txt) and the grammar template
itself were unchanged between PR #452 (May 1, last grammar work) and
the May 6 / May 17 corpus additions — git log confirms generics.x was
never in any skip list, so the parked.txt header comment "generics.x
parses cleanly now -- removed from this list" is incidentally
misleading; it refers to a draft state that never made it into git.

Verified: `:lang:tree-sitter:testTreeSitterParse` 881/881 (was 879/881),
`:lang:lsp-server:test -Plsp.adapter=treesitter` green,
`validateTreeSitterGrammar` no warnings.
@lagergren lagergren mentioned this pull request May 23, 2026
lagergren added a commit that referenced this pull request May 23, 2026
…ls in expression position

Closes two grammar gaps that surface as parse errors against the
manualTests corpus (CI hides these on master because the validation
step is gated on path-filter `lang/**`):

* annos.x:141 — `annotation Foo(...) into Bar { ... }` inside a method
  body. Local class/interface/mixin/service declarations were already in
  the `_statement` choice; `annotation_declaration` was not. Added.

* generics.x:27 — `Base<Int>.Child2<String>` as a value-position type
  literal. `member_type` was reachable from `_non_bi_type` only, so it
  was never tried in expression position. Added to `_expression` next
  to `$.generic_type` (the symmetric case for non-virtual-child type
  literals).

  The with-type-arguments form of `member_type` is split into its own
  alternative at `prec.left(MAX_PRECEDENCE_PLUS_3)` so it outranks
  `member_expression` (MAX_PRECEDENCE_PLUS_2). Without that, the GLR
  conflict resolver preferred `member_expression(Base<Int>, Child2)`
  and choked on the trailing `<String>`. The no-arguments form keeps
  default precedence so `Base<Int>.Child` still parses as a
  `member_expression` (no AST shape change for that case).

  The previously-declared `[$.member_type, $._expression]` GLR conflict
  is now redundant (static precedence resolves the ambiguity) and was
  removed; tree-sitter flagged it as an unnecessary conflict.

Why this regressed silently
---------------------------
Neither failure is a tooling/grammar regression — both are new XTC
syntax patterns added to the manualTests corpus that the grammar
never had a test case for:

* generics.x:27 was added on 2026-05-06 by 0120712 ("Fix
  NameExpression code production for parameterized virtual child
  classes") — a compiler bugfix that needed a test exercising
  `Base<Int>.Child2<String>`.
* annos.x:141 was added on 2026-05-17 by 91f6d7d ("Fix a compiler
  exception (#463)") — a compiler bugfix that needed a test exercising
  a local `annotation … into …` declaration.

Both PRs only touched `manualTests/src/main/x/` and `javatools/`,
never `lang/`. The `dorny/paths-filter` gate in
`.github/workflows/commit.yml` skips the tree-sitter validation step
whenever no `lang/**` paths change, so the master CI run was green
even though both new test files would have failed grammar validation.
This PR (which touches `lang/vscode-extension/**`) is the first since
May 6 to trip the gate and run the validation, which is why both
failures surfaced together here.

The skip lists (parked.txt, intentional.txt) and the grammar template
itself were unchanged between PR #452 (May 1, last grammar work) and
the May 6 / May 17 corpus additions — git log confirms generics.x was
never in any skip list, so the parked.txt header comment "generics.x
parses cleanly now -- removed from this list" is incidentally
misleading; it refers to a draft state that never made it into git.

Verified: `:lang:tree-sitter:testTreeSitterParse` 881/881 (was 879/881),
`:lang:lsp-server:test -Plsp.adapter=treesitter` green,
`validateTreeSitterGrammar` no warnings.
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