PSI Comment in php files


Hello everyone, 

i have a function iterating over a psifile and getting all child nodes of said file. 

If the psi file is a php.file the function excludes all comments in the file. Does anybody know why in the php file the comments arent included in the psi tree? 

Additional Note: Comments are included in PSI as long as no other php element is. As soon as one php element is added to the file all comments vanquish from the psi tree



Daniel, have you checked your file with PsiViewer? All the comments are supposed to be present within the PSI tree.



in the psi viewer they are   i also now use PsiTreeUtil.findChildrenof   an this works fine       however my original code still has the same issue 

private List<PsiElement> getAllNodes (List<PsiElement> elements, PsiElement root) {
PsiElement[] arr = root.getChildren();
for(PsiElement element : arr){
elements = getAllNodes(elements, element);

return elements;

Maybe try with PsiTreeUtil.processElements() instead?


ok i found out why   in php comments are counted as leaf elements which get not returned by .getChildren();


Please sign in to leave a comment.