Difference between PsiElementVisitor and PsiRecursiveElementVisitor?

In what way is it recursive?

0
5 comments
Avatar
Permanently deleted user

Barry Kaplan wrote:

In what way is it recursive?

Passes all children provided that super methods (of
RecursiveElementVisitor) are called

--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Avatar
Permanently deleted user

So PsiElementVisitor will only visit the top level elements? For a java
file just the one node 'PsiJavaFile' and nothing else?

Maxim Mossienko wrote:

Barry Kaplan wrote:

>> In what way is it recursive?


Passes all children provided that super methods (of
RecursiveElementVisitor) are called


--
Barry Kaplan
bkaplan@integratedtrading.com

0
Avatar
Permanently deleted user

Hi,

Simple (nonrecursive) visitor will receive notification about visiting
of the node it is applied to. E.g.

PsiElementVisitor visitor = ...;
PsiElement element = ...;

element.accept(visitor);

During accept call visitor will have called only 'visitXXX' for element.

Barry Kaplan wrote:

So PsiElementVisitor will only visit the top level elements? For a java
file just the one node 'PsiJavaFile' and nothing else?

Maxim Mossienko wrote:

>> Barry Kaplan wrote:
>>
>>> In what way is it recursive?
>>
>>
>> Passes all children provided that super methods (of
>> RecursiveElementVisitor) are called
>>



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Avatar
Permanently deleted user

Another way to put it is that PsiRecursiveElementVisitor.visitElement
calls

child.accept(this)

for each child of the element.

Since all default implementations in PsiElementVisitor end up calling
visitElement(), it effectively traverses the whole tree from top to leaves.

Friendly,
Dmitry

Maxim Mossienko wrote:

Hi,

Simple (nonrecursive) visitor will receive notification about visiting
of the node it is applied to. E.g.

PsiElementVisitor visitor = ...;
PsiElement element = ...;

element.accept(visitor);

During accept call visitor will have called only 'visitXXX' for element.

Barry Kaplan wrote:

>> So PsiElementVisitor will only visit the top level elements? For a java
>> file just the one node 'PsiJavaFile' and nothing else?
>>
>> Maxim Mossienko wrote:
>>
>>> Barry Kaplan wrote:
>>>
>>>> In what way is it recursive?
>>>
>>>
>>> Passes all children provided that super methods (of
>>> RecursiveElementVisitor) are called
>>>
>>



--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Avatar
Permanently deleted user

Got it. Thanks!

Dmitry Lomov (JetBrains) wrote:

Another way to put it is that PsiRecursiveElementVisitor.visitElement
calls

child.accept(this)

for each child of the element.

Since all default implementations in PsiElementVisitor end up calling
visitElement(), it effectively traverses the whole tree from top to leaves.

Friendly,
Dmitry

Maxim Mossienko wrote:

>>Hi,
>>
>>Simple (nonrecursive) visitor will receive notification about visiting
>>of the node it is applied to. E.g.
>>
>>PsiElementVisitor visitor = ...;
>>PsiElement element = ...;
>>
>>element.accept(visitor);
>>
>>During accept call visitor will have called only 'visitXXX' for element.
>>
>>Barry Kaplan wrote:
>>
>>>So PsiElementVisitor will only visit the top level elements? For a java
>>>file just the one node 'PsiJavaFile' and nothing else?
>>>
>>>Maxim Mossienko wrote:
>>>
>>>
>>>>Barry Kaplan wrote:
>>>>
>>>>
>>>>>In what way is it recursive?
>>>>
>>>>
>>>>Passes all children provided that super methods (of
>>>>RecursiveElementVisitor) are called
>>>>
>>>
>>


--
Barry Kaplan
bkaplan@integratedtrading.com

0

Please sign in to leave a comment.