antlr / intellij-plugin-v4

An IntelliJ plugin for ANTLR v4
https://plugins.jetbrains.com/plugin/7358-antlr-v4
BSD 3-Clause "New" or "Revised" License
468 stars 104 forks source link

switching from lexer to parser in a split grammar regenerates `.tokens` no matter what #540

Closed parrt closed 2 years ago

parrt commented 2 years ago

This could slow down switching between tabs so we should check see if the .tokens file is older than the lexer .g4 file in `RunANTLROnGrammarFile.run() on line 85.

    // is lexer file? gen .tokens file no matter what as tokens might have changed;
    // a parser that feeds off of that file will need to see the changes.
    if ( previewState.g==null && previewState.lg!=null) {
        Grammar g = previewState.lg;
        String language = g.getOptionString(ANTLRv4GrammarProperties.PROP_LANGUAGE);
        Tool tool = ParsingUtils.createANTLRToolForLoadingGrammars(getGrammarProperties(project, grammarFile));
        CodeGenerator gen = CodeGenerator.create(tool, g, language);
        gen.writeVocabFile();
    }
kjarrio commented 2 years ago

I have a fix for this one, but still figuring out how to properly test it in a headless environment

kjarrio commented 2 years ago

Should be fixed in #577

parrt commented 2 years ago

Fixed by https://github.com/antlr/intellij-plugin-v4/pull/577