PSI Comment in php files

Answered

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

 

4 comments
Comment actions Permalink

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

 

0
Comment actions Permalink

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) {
elements.add(root);
PsiElement[] arr = root.getChildren();
for(PsiElement element : arr){
elements = getAllNodes(elements, element);
}

return elements;
}
0
Comment actions Permalink

Maybe try with PsiTreeUtil.processElements() instead?

0
Comment actions Permalink

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

0

Please sign in to leave a comment.