module SyntaxTree::Translation

This module is responsible for translating the Syntax Tree syntax tree into other representations.

Public Class Methods

to_parser(node, buffer) click to toggle source

This method translates the given node into the representation defined by the whitequark/parser gem. We don’t explicitly list it as a dependency because it’s not required for the core functionality of Syntax Tree.

# File lib/syntax_tree/translation.rb, line 10
def self.to_parser(node, buffer)
  require "parser"
  require_relative "translation/parser"

  node.accept(Parser.new(buffer))
end
to_rubocop_ast(node, buffer) click to toggle source

This method translates the given node into the representation defined by the rubocop/rubocop-ast gem. We don’t explicitly list it as a dependency because it’s not required for the core functionality of Syntax Tree.

# File lib/syntax_tree/translation.rb, line 20
def self.to_rubocop_ast(node, buffer)
  require "rubocop/ast"
  require_relative "translation/parser"
  require_relative "translation/rubocop_ast"

  node.accept(RuboCopAST.new(buffer))
end