isDeclarationAhead used to skip *any* directive, so '#scope_file' was absorbed as
a modifier of the declaration after it. That misreports scope, since a scope
directive governs everything that follows it. Only #as, #overlay, #add_context
and #no_reset actually prefix a declaration in the corpus; the rest are
statements now, which the regenerated Directives.txt shows.
Golden fixtures cover the reference doc's gotcha list: declaration forms,
procedures (named/multiple/variadic/polymorphic/foreign returns), structs, enums,
unions, array and pointer types, the 'if x == { case }' switch form, for
modifiers, ifx, and directives including a here-string.
DebugParseTest is now inert by default and documented as the scratch loop.
generateParser wipes its output through a Delete task rather than a doFirst,
because a lambda added from a Kotlin build script captures the script object and
breaks the configuration cache ('./jaigradle check' failed to store it).
check and verifyPlugin (IU-253/261/262) both green.
68 lines
2.5 KiB
Kotlin
68 lines
2.5 KiB
Kotlin
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
|
|
|
|
plugins {
|
|
id("org.jetbrains.kotlin.jvm")
|
|
id("org.jetbrains.changelog")
|
|
id("org.jetbrains.intellij.platform")
|
|
id("org.jetbrains.intellij.platform.grammarkit")
|
|
}
|
|
|
|
// Grammar-Kit output. Committed so diffs are reviewable, never hand-edited.
|
|
val generatedSourceDir = file("src/main/gen")
|
|
|
|
sourceSets {
|
|
main {
|
|
java.srcDirs(generatedSourceDir)
|
|
}
|
|
}
|
|
|
|
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html
|
|
dependencies {
|
|
testImplementation(libs.junit)
|
|
|
|
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
|
|
intellijPlatform {
|
|
intellijIdea("2025.3.5")
|
|
testFramework(TestFrameworkType.Platform)
|
|
|
|
// Add plugin dependencies for compilation here, for example:
|
|
// bundledPlugin("com.intellij.java")
|
|
}
|
|
}
|
|
|
|
// purgeOldFiles is not enough: Grammar-Kit rewrites only the files whose rule
|
|
// changed, so a PSI interface can keep an accessor its regenerated Impl no longer has
|
|
// (`JaiDeclaration.getArgumentList()` with no override) and the build then fails
|
|
// inside generated code. Wiping first makes every generation self-consistent.
|
|
//
|
|
// This is a separate Delete task rather than a doFirst, because any lambda added to a
|
|
// task from a Kotlin build script captures the script object, which the configuration
|
|
// cache cannot serialize.
|
|
val cleanGeneratedSources by tasks.registering(Delete::class) {
|
|
delete(generatedSourceDir)
|
|
}
|
|
|
|
tasks.generateParser {
|
|
dependsOn(cleanGeneratedSources)
|
|
sourceFile.set(file("src/main/grammar/Jai.bnf"))
|
|
targetRootOutputDir.set(generatedSourceDir)
|
|
pathToParser.set("dev/hgh/jai/parser/JaiParser.java")
|
|
pathToPsiRoot.set("dev/hgh/jai/psi")
|
|
purgeOldFiles.set(true)
|
|
}
|
|
|
|
// Without this the compile tasks read src/main/gen with no ordering guarantee, so an
|
|
// edit to Jai.bnf could be compiled against the *previous* generated parser and the
|
|
// tests would quietly assert the old grammar. Editing Jai.bnf must be enough.
|
|
tasks.compileJava { dependsOn(tasks.generateParser) }
|
|
|
|
tasks.compileKotlin { dependsOn(tasks.generateParser) }
|
|
|
|
// Forward -Djai.debug.* to the test JVM for the scratch parser harness.
|
|
tasks.test {
|
|
System.getProperties().forEach { key, value ->
|
|
val name = key.toString()
|
|
if (name.startsWith("jai.debug.")) systemProperty(name, value.toString())
|
|
}
|
|
}
|