From b14d285b5e37a8126976019db6aecf3d18ee3edc Mon Sep 17 00:00:00 2001 From: hgranthorner <37941012+hgranthorner@users.noreply.github.com> Date: Tue, 4 Aug 2026 12:51:22 -0400 Subject: [PATCH] Assert the PSI wiring the ParserDefinition unblocked JaiFileTypeTest could previously only check the virtual file's type, because without a ParserDefinition the PSI file fell back to plain text. It now asserts the PSI file is a JaiFile in the Jai language and that JaiParserDefinition is the registered definition - the wiring every PSI-dependent feature needs. Also records the in-memory-fixture flake ('Cannot create child file at /src') as infrastructure, with the note that JaiCorpusParserTest sidesteps it by using PsiFileFactory directly. --- AGENTS.md | 9 ++++++-- .../kotlin/dev/hgh/jai/JaiFileTypeTest.kt | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 8553749..3e55050 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -60,7 +60,7 @@ Last verified state (all green, `./jaigradle check` and `verifyPlugin` too): ```text dev.hgh.HarnessSmokeTest tests=2 -dev.hgh.jai.JaiFileTypeTest tests=3 +dev.hgh.jai.JaiFileTypeTest tests=4 dev.hgh.jai.editor.JaiEditorSupportTest tests=5 dev.hgh.jai.highlighting.* tests=8 dev.hgh.jai.lexer.JaiCorpusLexerTest tests=2 <- the Tier 0 gate @@ -68,7 +68,7 @@ dev.hgh.jai.lexer.JaiLexerTest tests=13 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.DebugParseTest tests=2 <- scratch harness, inert --> total 41, failures+errors 0 +-> total 42, failures+errors 0 ``` The corpus gates report what they actually did; check both lines are still there: @@ -268,6 +268,11 @@ The fast loop for grammar work: ./jaitest ``` +- **`Cannot create child file 'x' at /src` is a flake.** The fixture's in-memory + filesystem occasionally refuses `myFixture.configureByText`. It is not a real + failure — re-run. `JaiCorpusParserTest` avoids it entirely by going through + `PsiFileFactory.createFileFromText` instead of the fixture, which also makes + the 714-file sweep much faster. - **`timeout` does not exist on this macOS box.** Do not use it in scripts. - **Noisy test stderr.** Fixture runs log Vue/JS `PluginException`s from bundled plugins. Tests pass regardless, but real failures can be buried — check the diff --git a/src/test/kotlin/dev/hgh/jai/JaiFileTypeTest.kt b/src/test/kotlin/dev/hgh/jai/JaiFileTypeTest.kt index 2e5b38f..019b56e 100644 --- a/src/test/kotlin/dev/hgh/jai/JaiFileTypeTest.kt +++ b/src/test/kotlin/dev/hgh/jai/JaiFileTypeTest.kt @@ -1,7 +1,10 @@ package dev.hgh.jai +import com.intellij.lang.LanguageParserDefinitions import com.intellij.openapi.fileTypes.FileTypeManager import com.intellij.testFramework.fixtures.BasePlatformTestCase +import dev.hgh.jai.psi.JaiFile +import dev.hgh.jai.psi.JaiParserDefinition /** * Verifies plugin.xml wiring: the `.jai` extension resolves to our file type and @@ -24,12 +27,24 @@ class JaiFileTypeTest : BasePlatformTestCase() { } /** - * The *virtual* file already resolves to our type. The PSI file's language stays - * plain text until a ParserDefinition is registered (phase 3) — asserting that here - * would be asserting the platform's fallback, not our wiring. + * Before phase 3 this could only assert the *virtual* file's type, because + * without a `ParserDefinition` the PSI file fell back to plain text. Now that + * `JaiParserDefinition` is registered, the PSI file itself is a [JaiFile] — which + * is what every PSI-dependent feature (structure view, folding, references) + * relies on. */ - fun testVirtualFileUsesJaiFileType() { + fun testJaiFileProducesJaiPsi() { val file = myFixture.configureByText("sample.jai", "main :: () { }") assertEquals(JaiFileType, file.virtualFile.fileType) + assertEquals(JaiLanguage, file.language) + assertTrue("expected a JaiFile, got ${file.javaClass.name}", file is JaiFile) + } + + fun testParserDefinitionIsRegisteredForJai() { + val definition = LanguageParserDefinitions.INSTANCE.forLanguage(JaiLanguage) + assertTrue( + "plugin.xml must register our parser definition, got $definition", + definition is JaiParserDefinition, + ) } }