Skip to content

Scala edges: move import/package extraction onto tree-sitter-scala #243

Description

@nikolay-e

The Scala import/package reader in edges/semantic/jvm.rs is regex, and it is
now on its fifth patch: the import-regex fix (#179), the import a}.{B panic
(1.14.0), and three more in 1.15.0 — Scala 3 as renames, multi-line brace
imports, nested package blocks (#215). The multi-line fix counts braces with a
hard bound (joined < 32) so an unbalanced file cannot swallow the rest of
itself: an honest bound, but a bound is not a parse.

tree-sitter-scala is already a dependency (the fragmenter uses it) and answers
all three structurally through import_declaration and package_clause.

What makes this bigger than a swap, and why it was not done in the same pass as
the #209 / #213 / #207 cleanup: the edge layer reads fragment CONTENT with regex
for every one of the 30+ languages — no parse tree reaches it. Parsing inside an
edge builder would be the first of its kind, with a per-fragment parse cost and
its own corpus calibration. It is Q-class: edge sets move, so the baseline moves.

Shape when picked up:

  • parse Scala fragments once, reuse the tree for imports, package and extends;
  • keep the regex path as the fallback for content the parser rejects;
  • gate on the full YAML corpus, and record the baseline delta either way.

Standing rule this issue exists to enforce: the SECOND patch on a hand-written
parser for a language that already has a grammar is the signal to move to the
grammar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions