ASTNode (@NotNull PsiFile psiFile) { // need to keep tree reachable to avoid being garbage-collected (via WeakReference in PsiFileImpl) // and then being reparsed from wrong (escaped) document content ASTNode node = psiFile.getNode(); // expand chameleons ASTNode child = node.getFirstChildNode(); assert !TreeUtil.isCollapsedChameleon(node) : "Chameleon "+node+" is collapsed; file: "+psiFile+"; language: "+psiFile.getLanguage(); psiFile.putUserData(TREE_HARD_REF, node); // just to use child variable Reference.reachabilityFence(child); return node; }