Grammar (derived from ~/IdeaProjects/S2CfgToJSON/Struct.mts):
file := (comment | struct)*
struct := [key ':'] 'struct.begin' [ '{' refs '}' ] body 'struct.end'
body := (comment | struct | entry)*
entry := key '=' value
key := IDENT | '[' (INT | '*') ']'
refs := ref (';' ref)* ref := ('refurl'|'refkey'|'bskipref'|'bpatch'|'removenode') ['=' text]
value := bool | number('f'?) | 'EEnum::Member' | text | <empty> ; may carry a trailing '{' refs '}'
comment := line starting with '#' or '//'
- Gradle scaffold:
intellij-platform-gradle-plugin2.x, JDK 21, IDEA 2024.3+ target -
S2CfgLanguage,S2CfgFileType(.cfg), icon - Hand-written
LexerBaseproducing tokens: IDENT, INT, FLOAT, BOOL, COLON, EQ, LBRACKET/RBRACKET, LBRACE/RBRACE, SEMI, STRUCT_BEGIN, STRUCT_END, ENUM, TEXT, COMMENT, WS, EOL -
S2CfgParser(PsiBuilder) building STRUCT / STRUCT_HEAD / REFS / ENTRY / KEY / VALUE nodes - PSI classes +
S2CfgFile,ParserDefinition -
SyntaxHighlighter+ColorSettingsPage - Block folding on
struct.begin…struct.end(placeholder = struct name) - Structure view: struct tree with names /
[N]indices - Brace matcher (
[],{}) and#commenter -
./gradlew buildPlugingreen - Parser test asserts zero error elements across all 7709 cfgs in
S2Mods/Mods - Interactive smoke test in
runIde(not run yet — needs a desktop session)
-
FileBasedIndexofSID = Xdeclarations and struct names (S2CfgSidIndex, text-based depth scan) - Declaration vs reference rule: a
SIDis a declaration only at the top level of a file - SID-valued entries (
SID,*SID) resolve to the declaring struct, cross-file -
refurlresolves to the target cfg file;refkeyto the struct inside it (falling back to same file, then project-wide) -
refkey=[0]correctly yields no reference - Find usages + rename for SIDs (rename rewrites struct name, its
SID, and all references) - Go to Symbol (Ctrl+Alt+Shift+N) by SID
- Interactive smoke test in
runIde
Note: references are attached by the PSI elements themselves. A psi.referenceContributor does
nothing here — contributed references are only consulted for ContributedReferenceHost elements,
which custom-language PSI is not.
- Enum member completion, narrowed to the literals the corpus assigns to that key
(
S2CfgEnumIndex), soItemType =offersEItemType::*and not every enum in the game - SID value completion (local structs first, then project-wide)
-
refkeycompletion - Inspection: unresolved
refurlpath (on by default) - Inspection: duplicate key in struct (on by default)
- Inspection: unresolved record reference (off by default — mods reference base-game records whose cfgs are usually outside the project, so it would light up everywhere)
- Navigate | Related Symbol jumps between
Foo_patch_MyMod.cfgandFoo.cfg, in both directions, tie-broken by sharedGameData/...path - Ctrl+Q documentation for a record: fields,
refkey/refurlinheritance, nested structs - [~] Gutter action showing s2cfgtojson JSON — dropped. It would mean shelling out to node from the IDE for output the docs popup already covers in a form the plugin can render itself.
- Interactive smoke test in
runIde
- 22 tests green (
./gradlew test), including a parse of all 7709 cfgs inS2Mods/Mods ./gradlew verifyPlugin-> Compatible with IC-243.21565.193, dynamically loadable- Everything is verified through test fixtures. No interactive
runIdesession has been run, so the live editor feel (folding placeholders, popup rendering, completion ordering) is unconfirmed.