Refactor SemanticModelVisitor to AST