Module: SyntaxTree::Translation

Defined in:
lib/syntax_tree/translation.rb,
lib/syntax_tree/translation/parser.rb,
lib/syntax_tree/translation/rubocop_ast.rb

Overview

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

Defined Under Namespace

Classes: Parser, RuboCopAST

Class Method Summary collapse

Class Method Details

.to_parser(node, buffer) ⇒ Object

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.



10
11
12
13
14
15
# 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) ⇒ Object

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.



20
21
22
23
24
25
26
# 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