Dynamic check of psi tree

Hi I wanted to know how intellij tracks the changes made by the user dynamically.
For example when I am changing a method name it automatically detects that is a renaming action and gives the refactoring icon near the method.
And also how it tracks the changes in the psi class? Like if I comment a statement, it is changed from a psi expression (or something else) to a psi-comment.
Where can I find the implementations of these functionalities? I tried for sometime but no luck.
Thanks in advance
Preetam

5 comments
Comment actions Permalink

Hello Preetam,

When you invoke renaming action, this action calls specific method which collects elements to rename. There are a few renaming actions and methods which init and perform rename.

When you edit a file, it gets relexed right away.  Lexer updates how elements are displayed (comment, keyword, identifier etc).  Parser runs less often. It builds complex elements.

This is brief description. Rename, lexer and parser are very complex areas.

0
Comment actions Permalink

Hello Imants,

Thanks for the reply.

So when does Intellij knows that a psi-statement is changed to a PsiComment?

It runs the parser again or is there any other way?

Can you point me to this call of parser/lexer on document change in the source code?

Thanks

Preetam

0
Comment actions Permalink

I do not know from where lexer / parser is called. Can try to find this but it would take time.

Are you looking to trigger relexing / reparsing or call your method when this happens?

Is this Java code?

 

0
Comment actions Permalink

I am writing a plugin where I highlight some specific key words for the user. When the user changes the code like commenting or deleting the element, I need to update my element list to maintain the highlightion. So I wanted to know how Intellij is doing this.

The user has a android code, so java and xml

Thanks

Preetam

0
Comment actions Permalink

this should be easy enough.

take a look at this:

http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/syntax_highlighter_and_color_settings_page.html 

 

where it uses SimpleTypes, you could use JavaElementType I guess. I am not sure about  XML.

0

Please sign in to leave a comment.