Phase 4: add structure, folding, and references

This commit is contained in:
hgranthorner
2026-08-04 14:49:03 -04:00
parent bb54639ce5
commit c4e1d92c9a
16 changed files with 826 additions and 14 deletions

View File

@@ -61,7 +61,8 @@ Last verified state (all green, `./jaigradle check` and `verifyPlugin` too):
```text
dev.hgh.HarnessSmokeTest tests=2
dev.hgh.jai.JaiFileTypeTest tests=4
dev.hgh.jai.editor.JaiEditorSupportTest tests=5
dev.hgh.jai.editor.JaiEditorSupportTest tests=7
dev.hgh.jai.editor.JaiFoldingBuilderTest tests=3
dev.hgh.jai.highlighting.* tests=8
dev.hgh.jai.lexer.JaiCorpusLexerTest tests=2 <- the Tier 0 gate
dev.hgh.jai.lexer.JaiLexerTest tests=13
@@ -69,13 +70,15 @@ dev.hgh.jai.parser.JaiCorpusParserTest tests=1 <- the Tier 3 gate
dev.hgh.jai.parser.JaiParserGoldenTest tests=5 <- Tier 2 golden trees
dev.hgh.jai.parser.JaiParserLongTailTest tests=1 <- focused parser regressions
dev.hgh.jai.parser.DebugParseTest tests=2 <- scratch harness, inert
-> total 43, failures+errors 0
dev.hgh.jai.reference.JaiReferenceTest tests=4
dev.hgh.jai.structure.JaiStructureViewTest tests=3
-> total 55, failures+errors 0
```
The corpus gates report what they actually did; check both lines are still there:
```text
Tier 0: lexed 714 files, 17154195 chars, 3009381 tokens cleanly.
Tier 0: lexed 714 files, 17154195 chars, 3008777 tokens cleanly.
Tier 3: parsed 714 files, 714 clean (100.0%), 0 with errors, 0 PsiErrorElements total.
```
@@ -108,6 +111,10 @@ Tier 3: parsed 714 files, 714 clean (100.0%), 0 with errors, 0 PsiErrorElements
`src/main/gen`, `JaiParserDefinition`, `JaiParserUtil`. Tier 2 golden trees and
the Tier 3 corpus gate are green at **100.0% (714/714 files parse with zero
`PsiErrorElement`)**.
- **Phase 4** — structure view, folding for blocks/comments/here-strings, and
`#import`/`#load` path references with standard go-to-definition resolution.
Headless tests cover source-ordered declarations, nested structure members,
folding ranges, local `#load`, and Jai module directories.
### Lexer design facts worth knowing before touching it
@@ -162,16 +169,18 @@ Tier 3: parsed 714 files, 714 clean (100.0%), 0 with errors, 0 PsiErrorElements
- **Directive flags require adjacency.** `#library,system` is a flag;
`(cb: (*GUID) #c_call, ctx: *void)` is a parameter separator. Without the
adjacency check the flag swallowed `, ctx`.
- **Contributed references need a PSI host.** Generated AST wrappers do not
implement `ContributedReferenceHost`, so `literalExpr` uses the
`JaiReferenceHostMixin` from the BNF. Do not remove the mixin and expect a
`PsiReferenceContributor` to be queried through the standard reference service.
### Not done — pick up here
1. **Phase 4**structure view, folding, `#import`/`#load` reference resolution
and go-to-definition. The PSI is in place, and the Tier 3 corpus gate is now
fully green. `JaiFileTypeTest` used to document being blocked on the
`ParserDefinition`; that no longer applies.
`#asm` bodies are intentionally consumed opaquely, so nothing inside them has
PSI yet.
2. **Phases 5+** — see the plan.
1. **Phase 5**completion (keywords, directives, module names), rename, and
find-usages; see `docs/BUILD_PLAN.md`.
2. **Phases 6+** — formatter, inspections, compiler integration, and other
optional work remain. `#asm` bodies are intentionally consumed opaquely, so
nothing inside them has PSI yet.
### Open questions for the user (unanswered)