mike-lischke / vscode-antlr4

ANTLR4 language support for Visual Studio Code
http://www.soft-gems.net
MIT License
429 stars 60 forks source link

Problems list not updated after remedying concern #206

Open chris-miner opened 1 year ago

chris-miner commented 1 year ago

I did the following:

  1. created a lexer grammar of common lexer rules
  2. imported that in my grammar
  3. added rules using the results of the lexer rules
  4. noticed there were no problems reported
  5. changed the name of the file imported
  6. noticed that all the tokens defined in the imported file were now listed as undefined in the problems tab
  7. changed the name of the file imported back to one that actually exists

found: The list of issues reported in the problem tab did not update (ie disappear)

expected: The list of issues reported would reflect the current status of the file.

extra info: There's a line that was commented out in runSemanticAnalysisIfNeeded about 3 years ago.

       //this.diagnostics.length = 0; Don't, we would lose our syntax errors from last parse run.

except that we want to lose those errors that are no longer relevant. I uncommented that line, but that didn't remedy the problem. I ended up looking at checkSymbolExistence. Even after fixing the grammar, the symbol table doesn't include symbols defined in the imported lexer grammar.

Strangely, relaunching the extension results in the same errors even though the project contains correct files.

mike-lischke commented 1 year ago

My assumption is that the syntactic and semantic analysis is not triggered again. Need to investigate.

mike-lischke commented 11 months ago

@chris-miner I finally found time to come back to this issue, and I cannot reproduce it. When you rename your lexer grammar, new files are generated with the new name. But the old files persist, so the old lexer can still be imported into your parser. It's not the grammar that is actually imported, but the .tokens file. You can even remove the lexer grammar, the parser still would be built properly. So, it's unclear to me how you suddenly can see errors for the imported symbols (unless you have renamed all related files, including those that have been generated).

For a test I removed the .tokens file and changed something in the parser, which resulted in the reported errors. Then I renamed the lexer grammar which regenerated all the files. Another small change in the parser brought it back to a valid state. So, I'm a bit clueless now.

Do you still see this issue with the latest release of the extension?