ASTNode (ASTNode chameleon) { final PsiElement parentElement = chameleon.getTreeParent().getPsi(); final Project project = parentElement.getProject(); final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, new GroovyLexer(), getLanguage(), chameleon.getText()); PsiBuilder.Marker rootMarker = builder.mark(); if (BUILT_IN_TYPES.contains(chameleon.getText())) { builder.advanceLexer(); } else { new GroovyParser().parseDocReference(builder); while (!builder.eof()) { builder.advanceLexer(); } } rootMarker.done(this); return builder.getTreeBuilt().getFirstChildNode(); }