antlr / antlr4-intellij-adaptor

A library to support the use of ANTLR grammars in jetbrains IDE plugins for building custom languages.
BSD 2-Clause "Simplified" License
212 stars 38 forks source link

How to modify tokens tree programmatically with BaseListener? #25

Open yasamprom opened 2 years ago

yasamprom commented 2 years ago

In my language I have TAB and UNTAB tokens (it is important like in Python). It is impossible to process TAB and UNTAB in grammar.g4 correctly so I need special class (I guess it is BaseListener) for processing TAB/UNTAB when I enter some rules. How to make my BaseListener work in background? This class now is highlighted with grey color, it is not used. Where should I create it?

parrt commented 2 years ago

Do you mean's plugin's parse tree view or arbitrary antlr code altering parse tree? It's typically modified by constructing new parse tree or other from auto-generated tree.

yasamprom commented 2 years ago

Do you mean's plugin's parse tree view or arbitrary antlr code altering parse tree? It's typically modified by constructing new parse tree or other from auto-generated tree.

I guess I need ParseTreeView. My purpose is to add TAB and UNTUB in my PSI programmatically. And I want to do it in background, while user is typing characters. I didn't find examples how to do that

parrt commented 2 years ago

Hmm...ok, yeah, I'm afraid I just can't remember how all this works :( Sorry! Ter