From 691fdbffd463cef511b4f49f7984fefe4c86095d Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Wed, 30 Mar 2022 20:29:35 -0400 Subject: [PATCH 1/4] Ignore the vendor/ directory Signed-off-by: Alexandre Terrasa --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4d0d86f3..fd18383d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ /pkg/ /spec/reports/ /tmp/ +/vendor/ test.rb From e826c0628978e84fcf29b8633e7b22f5e8436a04 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Thu, 31 Mar 2022 10:40:22 -0400 Subject: [PATCH 2/4] Clean up markdown --- CHANGELOG.md | 13 +++++++------ README.md | 8 ++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d8ceaa2..847d5af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,9 +122,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - 🎉 Initial release! 🎉 -[unreleased]: https://github.com/kddnewton/syntax_tree/compare/v1.2.0...HEAD -[1.2.0]: https://github.com/kddnewton/syntax_tree/compare/v1.1.1...v1.2.0 -[1.1.1]: https://github.com/kddnewton/syntax_tree/compare/v1.1.0...v1.1.1 -[1.1.0]: https://github.com/kddnewton/syntax_tree/compare/v1.0.0...v1.1.0 -[1.0.0]: https://github.com/kddnewton/syntax_tree/compare/v0.1.0...v1.0.0 -[0.1.0]: https://github.com/kddnewton/syntax_tree/compare/8aa1f5...v0.1.0 +[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v1.1.1...v1.2.0 +[1.1.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v1.1.0...v1.1.1 +[1.1.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v0.1.0...v1.0.0 +[0.1.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/8aa1f5...v0.1.0 diff --git a/README.md b/README.md index 52acbfcf..470826d2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # SyntaxTree -[![Build Status](https://github.com/kddnewton/syntax_tree/workflows/Main/badge.svg)](https://github.com/kddnewton/syntax_tree/actions) +[![Build Status](https://github.com/ruby-syntax-tree/syntax_tree/actions/workflows/main.yml/badge.svg)](https://github.com/ruby-syntax-tree/syntax_tree/actions/workflows/main.yml) [![Gem Version](https://img.shields.io/gem/v/syntax_tree.svg)](https://rubygems.org/gems/syntax_tree) A fast Ruby parser and formatter with only standard library dependencies. @@ -68,12 +68,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/kddnewton/syntax_tree. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kddnewton/syntax_tree/blob/main/CODE_OF_CONDUCT.md). +Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-syntax-tree/syntax_tree. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). - -## Code of Conduct - -Everyone interacting in the syntax_tree project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kddnewton/syntax_tree/blob/main/CODE_OF_CONDUCT.md). From e0a38d3f03c4555948e6ec077569df0245522fff Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Thu, 31 Mar 2022 10:53:22 -0400 Subject: [PATCH 3/4] Move `location` attribute reader to base `Node` class Signed-off-by: Alexandre Terrasa --- lib/syntax_tree/node.rb | 480 +--------------------------------------- 1 file changed, 3 insertions(+), 477 deletions(-) diff --git a/lib/syntax_tree/node.rb b/lib/syntax_tree/node.rb index ee7ecfac..937e1981 100644 --- a/lib/syntax_tree/node.rb +++ b/lib/syntax_tree/node.rb @@ -53,6 +53,9 @@ def self.fixed(line:, char:) # exclusively here to make it easier to operate with the tree in cases where # you're trying to monkey-patch or strictly type. class Node + # [Location] the location of this node + attr_reader :location + def child_nodes raise NotImplementedError end @@ -94,9 +97,6 @@ class BEGINBlock < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -167,9 +167,6 @@ class CHAR < Node # [String] the value of the character literal attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -233,9 +230,6 @@ class ENDBlock < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -309,9 +303,6 @@ class EndContent < Node # [String] the content after the script attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -400,9 +391,6 @@ def format(q) # [DynaSymbol | SymbolLiteral] the old name of the method attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -484,9 +472,6 @@ class ARef < Node # [nil | Args] the value being passed within the brackets attr_reader :index - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -568,9 +553,6 @@ class ARefField < Node # [nil | Args] the value being passed within the brackets attr_reader :index - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -654,9 +636,6 @@ class ArgParen < Node # parentheses attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -721,9 +700,6 @@ class Args < Node # [Array[ untyped ]] the arguments that this node wraps attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -773,9 +749,6 @@ class ArgBlock < Node # [nil | untyped] the expression being turned into a block attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -828,9 +801,6 @@ class ArgStar < Node # [nil | untyped] the expression being splatted attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -894,9 +864,6 @@ class ArgsForward < Node # [String] the value of the operator attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1025,9 +992,6 @@ def format(q) # [nil | Args] the contents of the array attr_reader :contents - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1191,9 +1155,6 @@ def format(q) # optional star if there is one attr_reader :posts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1330,9 +1291,6 @@ class Assign < Node # [untyped] the expression to be assigned attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1415,9 +1373,6 @@ class Assoc < Node # [untyped] the value of this pair attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1499,9 +1454,6 @@ class AssocSplat < Node # [untyped] the expression that is being splatted attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1556,9 +1508,6 @@ class Backref < Node # [String] the name of the global backreference variable attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1607,9 +1556,6 @@ class Backtick < Node # [String] the backtick in the string attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1724,9 +1670,6 @@ class BareAssocHash < Node # [Array[ AssocNew | AssocSplat ]] attr_reader :assocs - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1785,9 +1728,6 @@ class Begin < Node # [BodyStmt] the bodystmt that contains the contents of this begin block attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1852,9 +1792,6 @@ class PinnedBegin < Node # [untyped] the expression being pinned attr_reader :statement - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -1930,9 +1867,6 @@ class Binary < Node # [untyped] the right-hand side of the expression attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2067,9 +2001,6 @@ class BlockVar < Node # [Array[ Ident ]] the list of block-local variable declarations attr_reader :locals - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2137,9 +2068,6 @@ class BlockArg < Node # [nil | Ident] the name of the block argument attr_reader :name - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2200,9 +2128,6 @@ class BodyStmt < Node # [nil | Ensure] the optional ensure clause attr_reader :ensure_clause - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2511,9 +2436,6 @@ class BraceBlock < Node # [Statements] the list of expressions to evaluate within the block attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2636,9 +2558,6 @@ class Break < Node # [Args] the arguments being sent to the keyword attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2720,9 +2639,6 @@ class Call < Node # [nil | ArgParen | Args] the arguments to the method call attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2848,9 +2764,6 @@ class Case < Node # [In | When] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -2941,9 +2854,6 @@ class RAssign < Node # [untyped] the pattern on the right-hand side of the expression attr_reader :pattern - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3057,9 +2967,6 @@ class ClassDeclaration < Node # [BodyStmt] the expressions to execute within the context of the class attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3157,9 +3064,6 @@ class Comma < Node # [String] the comma in the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -3179,9 +3083,6 @@ class Command < Node # [Args] the arguments being sent with the message attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3258,9 +3159,6 @@ class CommandCall < Node # [nil | Args] the arguments going along with the message attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3426,9 +3324,6 @@ def pretty_print(q) attr_reader :inline alias inline? inline - # [Location] the location of this node - attr_reader :location - def initialize(value:, inline:, location:) @value = value @inline = inline @@ -3513,9 +3408,6 @@ class Const < Node # [String] the name of the constant attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3570,9 +3462,6 @@ class ConstPathField < Node # [Const] the constant itself attr_reader :constant - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3640,9 +3529,6 @@ class ConstPathRef < Node # [Const] the constant itself attr_reader :constant - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3709,9 +3595,6 @@ class ConstRef < Node # [Const] the constant itself attr_reader :constant - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3764,9 +3647,6 @@ class CVar < Node # [String] the name of the class variable attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3822,9 +3702,6 @@ class Def < Node # [BodyStmt] the expressions to be executed by the method attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -3921,9 +3798,6 @@ class DefEndless < Node # [untyped] the expression to be executed by the method attr_reader :statement - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4038,9 +3912,6 @@ class Defined < Node # [untyped] the value being sent to the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4108,9 +3979,6 @@ class Defs < Node # [BodyStmt] the expressions to be executed by the method attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4225,9 +4093,6 @@ class DoBlock < Node # [BodyStmt] the expressions to be executed within this block attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4332,9 +4197,6 @@ class Dot2 < Node # [nil | untyped] the right side of the expression attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4407,9 +4269,6 @@ class Dot3 < Node # [nil | untyped] the right side of the expression attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4521,9 +4380,6 @@ class DynaSymbol < Node # [String] the quote used to delimit the dynamic symbol attr_reader :quote - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4633,9 +4489,6 @@ class Else < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4702,9 +4555,6 @@ class Elsif < Node # [nil | Elsif | Else] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -4803,9 +4653,6 @@ class EmbDoc < Node # [String] the contents of the comment attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -4862,9 +4709,6 @@ class EmbExprBeg < Node # [String] the #{ used in the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -4881,9 +4725,6 @@ class EmbExprEnd < Node # [String] the } used in the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -4902,9 +4743,6 @@ class EmbVar < Node # [String] the # used in the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -4925,9 +4763,6 @@ class Ensure < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5000,9 +4835,6 @@ class ExcessedComma < Node # [String] the comma attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5061,9 +4893,6 @@ class FCall < Node # [nil | ArgParen | Args] the arguments to the method call attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5136,9 +4965,6 @@ class Field < Node # [Const | Ident] the name of the field being assigned attr_reader :name - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5211,9 +5037,6 @@ class FloatLiteral < Node # [String] the value of the floating point number literal attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5276,9 +5099,6 @@ class FndPtn < Node # [VarField] the splat on the right-hand side attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5374,9 +5194,6 @@ class For < Node # [Statements] the statements to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5460,9 +5277,6 @@ class GVar < Node # [String] the name of the global variable attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5515,9 +5329,6 @@ class HashLiteral < Node # [Array[ AssocNew | AssocSplat ]] the optional contents of the hash attr_reader :assocs - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5605,9 +5416,6 @@ class Heredoc < Node # heredoc string literal attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5700,9 +5508,6 @@ class HeredocBeg < Node # [String] the opening declaration of the heredoc attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5809,9 +5614,6 @@ def format(q) # [nil | VarField] an optional parameter to gather up all remaining keywords attr_reader :keyword_rest - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -5921,9 +5723,6 @@ class Ident < Node # [String] the value of the identifier attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6061,9 +5860,6 @@ class If < Node # [nil, Elsif, Else] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6146,9 +5942,6 @@ class IfOp < Node # [untyped] the expression to be executed if the predicate is falsy attr_reader :falsy - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6312,9 +6105,6 @@ class IfMod < Node # [untyped] the expression to be checked attr_reader :predicate - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6377,9 +6167,6 @@ class Imaginary < Node # [String] the value of the imaginary number literal attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6438,9 +6225,6 @@ class In < Node # [nil | In | Else] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6528,9 +6312,6 @@ class Int < Node # [String] the value of the integer attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6586,9 +6367,6 @@ class IVar < Node # [String] the name of the instance variable attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6647,9 +6425,6 @@ class Kw < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6698,9 +6473,6 @@ class KwRestParam < Node # [nil | Ident] the name of the parameter attr_reader :name - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6763,9 +6535,6 @@ class Label < Node # [String] the value of the label attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6819,9 +6588,6 @@ class LabelEnd < Node # [String] the end of the label attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -6839,9 +6605,6 @@ class Lambda < Node # [BodyStmt | Statements] the expressions to be executed in this lambda attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6932,9 +6695,6 @@ class LBrace < Node # [String] the left brace attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -6981,9 +6741,6 @@ class LBracket < Node # [String] the left bracket attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7030,9 +6787,6 @@ class LParen < Node # [String] the left parenthesis attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7095,9 +6849,6 @@ class MAssign < Node # [untyped] the value being assigned attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7165,9 +6916,6 @@ class MethodAddBlock < Node # [BraceBlock | DoBlock] the block being sent with the method call attr_reader :block - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7233,9 +6981,6 @@ class MLHS < Node # the syntax tree is being built it can be set by its parent node attr_accessor :comma - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7292,9 +7037,6 @@ class MLHSParen < Node # [MLHS | MLHSParen] the contents inside of the parentheses attr_reader :contents - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7364,9 +7106,6 @@ class ModuleDeclaration < Node # [BodyStmt] the expressions to be executed in the context of the module attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7455,9 +7194,6 @@ class MRHS < Node # Array[untyped] the parts that are being assigned attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7520,9 +7256,6 @@ class Next < Node # [Args] the arguments passed to the next keyword attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7573,9 +7306,6 @@ class Op < Node # [String] the operator attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7631,9 +7361,6 @@ class OpAssign < Node # [untyped] the expression to be assigned attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -7861,9 +7588,6 @@ def format(q) # [nil | BlockArg] the optional block parameter attr_reader :block - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8053,9 +7777,6 @@ class Paren < Node # [nil | untyped] the expression inside the parentheses attr_reader :contents - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8125,9 +7846,6 @@ class Period < Node # [String] the period attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8174,9 +7892,6 @@ class Program < Node # [Statements] the top-level expressions of the program attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8238,9 +7953,6 @@ class QSymbols < Node # [Array[ TStringContent ]] the elements of the array attr_reader :elements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8317,9 +8029,6 @@ class QSymbolsBeg < Node # [String] the beginning of the array literal attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8337,9 +8046,6 @@ class QWords < Node # [Array[ TStringContent ]] the elements of the array attr_reader :elements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8413,9 +8119,6 @@ class QWordsBeg < Node # [String] the beginning of the array literal attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8430,9 +8133,6 @@ class RationalLiteral < Node # [String] the rational number literal attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8479,9 +8179,6 @@ class RBrace < Node # [String] the right brace attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8493,9 +8190,6 @@ class RBracket < Node # [String] the right bracket attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8510,9 +8204,6 @@ class Redo < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8568,9 +8259,6 @@ class RegexpContent < Node # regular expression attr_reader :parts - # [Location] the location of this node - attr_reader :location - def initialize(beginning:, parts:, location:) @beginning = beginning @parts = parts @@ -8591,9 +8279,6 @@ class RegexpBeg < Node # [String] the beginning of the regular expression attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8614,9 +8299,6 @@ class RegexpEnd < Node # [String] the end of the regular expression attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -8638,9 +8320,6 @@ class RegexpLiteral < Node # regular expression literal attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8765,9 +8444,6 @@ class RescueEx < Node # exception attr_reader :variable - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8848,9 +8524,6 @@ class Rescue < Node # [nil | Rescue] the optional next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -8969,9 +8642,6 @@ class RescueMod < Node # [untyped] the value to use if the executed expression raises an error attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9047,9 +8717,6 @@ class RestParam < Node # [nil | Ident] the name of the parameter attr_reader :name - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9100,9 +8767,6 @@ class Retry < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9152,9 +8816,6 @@ class Return < Node # [Args] the arguments being passed to the keyword attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9204,9 +8865,6 @@ class Return0 < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9253,9 +8911,6 @@ class RParen < Node # [String] the parenthesis attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -9276,9 +8931,6 @@ class SClass < Node # [BodyStmt] the expressions to be executed attr_reader :bodystmt - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9354,9 +9006,6 @@ class Statements < Node # [Array[ untyped ]] the list of expressions contained within this node attr_reader :body - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9530,9 +9179,6 @@ class StringContent < Node # string attr_reader :parts - # [Location] the location of this node - attr_reader :location - def initialize(parts:, location:) @parts = parts @location = location @@ -9552,9 +9198,6 @@ class StringConcat < Node # [StringLiteral] the right side of the concatenation attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9621,9 +9264,6 @@ class StringDVar < Node # [Backref | VarRef] the variable being interpolated attr_reader :variable - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9680,9 +9320,6 @@ class StringEmbExpr < Node # [Statements] the expressions to be interpolated attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9756,9 +9393,6 @@ class StringLiteral < Node # [String] which quote was used by the string literal attr_reader :quote - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9840,9 +9474,6 @@ class Super < Node # [ArgParen | Args] the arguments to the keyword attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -9913,9 +9544,6 @@ class SymBeg < Node # [String] the beginning of the symbol attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -9932,9 +9560,6 @@ class SymbolContent < Node # symbol attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -9951,9 +9576,6 @@ class SymbolLiteral < Node # symbol attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10010,9 +9632,6 @@ class Symbols < Node # [Array[ Word ]] the words in the symbol array literal attr_reader :elements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10090,9 +9709,6 @@ class SymbolsBeg < Node # [String] the beginning of the symbol literal array attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -10108,9 +9724,6 @@ class TLambda < Node # [String] the beginning of the lambda literal attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -10127,9 +9740,6 @@ class TLamBeg < Node # [String] the beginning of the body of the lambda literal attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -10146,9 +9756,6 @@ class TopConstField < Node # [Const] the constant being assigned attr_reader :constant - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10203,9 +9810,6 @@ class TopConstRef < Node # [Const] the constant being referenced attr_reader :constant - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10265,9 +9869,6 @@ class TStringBeg < Node # [String] the beginning of the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -10286,9 +9887,6 @@ class TStringContent < Node # [String] the content of the string attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10351,9 +9949,6 @@ class TStringEnd < Node # [String] the end of the string attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -10371,9 +9966,6 @@ class Not < Node # [boolean] whether or not parentheses were used attr_reader :parentheses - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10439,9 +10031,6 @@ class Unary < Node # [untyped] the statement on which to operate attr_reader :statement - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10526,9 +10115,6 @@ def format(q) # [Array[ DynaSymbol | SymbolLiteral ]] the symbols to undefine attr_reader :symbols - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10593,9 +10179,6 @@ class Unless < Node # [nil, Elsif, Else] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10675,9 +10258,6 @@ class UnlessMod < Node # [untyped] the expression to be checked attr_reader :predicate - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10793,9 +10373,6 @@ class Until < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10872,9 +10449,6 @@ class UntilMod < Node # [untyped] the expression to be checked attr_reader :predicate - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -10961,9 +10535,6 @@ class VarAlias < Node # [Backref | GVar] the current name of the variable to be aliased attr_reader :right - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11028,9 +10599,6 @@ class VarField < Node # [nil | Const | CVar | GVar | Ident | IVar] the target of this node attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11084,9 +10652,6 @@ class VarRef < Node # [Const | CVar | GVar | Ident | IVar | Kw] the value of this node attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11141,9 +10706,6 @@ class PinnedVarRef < Node # [VarRef] the value of this node attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11200,9 +10762,6 @@ class VCall < Node # [Ident] the value of this expression attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11301,9 +10860,6 @@ class When < Node # [nil | Else | When] the next clause in the chain attr_reader :consequent - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11418,9 +10974,6 @@ class While < Node # [Statements] the expressions to be executed attr_reader :statements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11497,9 +11050,6 @@ class WhileMod < Node # [untyped] the expression to be checked attr_reader :predicate - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11586,9 +11136,6 @@ class Word < Node # word attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11645,9 +11192,6 @@ class Words < Node # [Array[ Word ]] the elements of this array attr_reader :elements - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11722,9 +11266,6 @@ class WordsBeg < Node # [String] the start of the word literal array attr_reader :value - # [Location] the location of this node - attr_reader :location - def initialize(value:, location:) @value = value @location = location @@ -11740,9 +11281,6 @@ class XString < Node # xstring attr_reader :parts - # [Location] the location of this node - attr_reader :location - def initialize(parts:, location:) @parts = parts @location = location @@ -11758,9 +11296,6 @@ class XStringLiteral < Node # xstring attr_reader :parts - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11815,9 +11350,6 @@ class Yield < Node # [Args | Paren] the arguments passed to the yield attr_reader :arguments - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11881,9 +11413,6 @@ class Yield0 < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments @@ -11933,9 +11462,6 @@ class ZSuper < Node # [String] the value of the keyword attr_reader :value - # [Location] the location of this node - attr_reader :location - # [Array[ Comment | EmbDoc ]] the comments attached to this node attr_reader :comments From 76a53220df0f4953cc687974a7507612978fe790 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Thu, 31 Mar 2022 13:11:53 -0400 Subject: [PATCH 4/4] Bump to v2.0.1 --- CHANGELOG.md | 6 ++++++ Gemfile.lock | 2 +- lib/syntax_tree.rb | 11 +++++++++++ lib/syntax_tree/cli.rb | 11 ----------- lib/syntax_tree/version.rb | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 847d5af4..354776f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [2.0.1] - 2022-03-31 + +### Changed + +- Move the `SyntaxTree.register_handler` method to the correct location. + ## [2.0.0] - 2022-03-31 ### Added diff --git a/Gemfile.lock b/Gemfile.lock index e6eceae8..f3ddbb47 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - syntax_tree (2.0.0) + syntax_tree (2.0.1) GEM remote: https://rubygems.org/ diff --git a/lib/syntax_tree.rb b/lib/syntax_tree.rb index 14db905c..1dcfc348 100644 --- a/lib/syntax_tree.rb +++ b/lib/syntax_tree.rb @@ -25,6 +25,17 @@ end module SyntaxTree + # This holds references to objects that respond to both #parse and #format + # so that we can use them in the CLI. + HANDLERS = {} + HANDLERS.default = SyntaxTree + + # This is a hook provided so that plugins can register themselves as the + # handler for a particular file type. + def self.register_handler(extension, handler) + HANDLERS[extension] = handler + end + # Parses the given source and returns the syntax tree. def self.parse(source) parser = Parser.new(source) diff --git a/lib/syntax_tree/cli.rb b/lib/syntax_tree/cli.rb index 1f6f6468..d6259f3d 100644 --- a/lib/syntax_tree/cli.rb +++ b/lib/syntax_tree/cli.rb @@ -2,17 +2,6 @@ module SyntaxTree module CLI - # This holds references to objects that respond to both #parse and #format - # so that we can use them in the CLI. - HANDLERS = {} - HANDLERS.default = SyntaxTree - - # This is a hook provided so that plugins can register themselves as the - # handler for a particular file type. - def self.register_handler(extension, handler) - HANDLERS[extension] = handler - end - # A utility wrapper around colored strings in the output. class Color attr_reader :value, :code diff --git a/lib/syntax_tree/version.rb b/lib/syntax_tree/version.rb index ddee0eb0..fde7d633 100644 --- a/lib/syntax_tree/version.rb +++ b/lib/syntax_tree/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SyntaxTree - VERSION = "2.0.0" + VERSION = "2.0.1" end