ASTNode (Node n) { if (n instanceof Token) { Token token = (Token)n; return token.getBuilder().createLeaf(token.getTokenType(), token.getStartOffsetInBuilder(), token.getEndOffsetInBuilder()); } else if (n instanceof ErrorItem) { return Factory.createErrorElement(((ErrorItem)n).myMessage); } else { StartMarker startMarker = (StartMarker)n; CompositeElement composite = n == myRoot ? (CompositeElement)myRoot.myBuilder.createRootAST(myRoot) : createComposite(startMarker, startMarker.myBuilder.getASTFactory()); startMarker.myBuilder.bind(startMarker, composite); return composite; } }