PsiElement.firstChild vs PsiElement.children.first()

Viewed 27

I expected PsiElement.firstChild and PsiElement.children.first() to always return the same PsiElement, however, it turns out that (considering KtElements):

  • for KtBlockExpression they are not the same: firstChild returns a left curly brace and children.first() returns the first expression of the body.
  • for KtTypeReference they are the same thing.

So the questions is:

  • Why are they not equivalent in general?
  • When are the equivalent and when are they different (I am interested mainly in classes derived from KtElement)?
0 Answers
Related