rubocop-ast 1.26.0 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc10e7c795dab5de6b3af9e4256ac4312e5c3593dac55ac4bf290386813d8375
4
- data.tar.gz: 4f5712401b5ce837a33b44a9e1e5061ca134fe794a04a9bdb46d7941564be73d
3
+ metadata.gz: 52016862b66d8a632662c2a59a76713e02644e8f650bc8d845be3f0e00789ce6
4
+ data.tar.gz: '0837fef80b414ceb2282a2b61edeb45e4902063717b88367b9f37a2394b01570'
5
5
  SHA512:
6
- metadata.gz: db2491014949e08395d008635c29a22d56b6495d020adc3ecc83071bf9f8614be7ff00088a69e82cc4add3ea118a71a28f3903ed3905012312191988cb61ec92
7
- data.tar.gz: 7ba42b76e1fa3721ac7d41e83d9ad4a87ec214c02938af1b6f2162e80ec55a4706698bee254591cdf50c3467648a95d972ad615fc559f0e8669a8de64552aa83
6
+ metadata.gz: eb2e878290bcbf536f69139eb3c678a74718e9f2b74f99afc90917d80b2f9787ed3a99b25c383623d2aa604fa5f4e75a61100b4728e604670019bdc4929459b3
7
+ data.tar.gz: 83fd6a5aead7d3e84b1d455eb2c6fb36704d60ec1f1ba4a0130e1b8d97591433ef56b2364ee0a161c32d227d69722d5775c42616cbeaba02cf14b18366021b83
@@ -19,76 +19,77 @@ module RuboCop
19
19
 
20
20
  # @api private
21
21
  NODE_MAP = {
22
- and: AndNode,
23
- and_asgn: AndAsgnNode,
24
- alias: AliasNode,
25
- arg: ArgNode,
26
- blockarg: ArgNode,
27
- forward_arg: ArgNode,
28
- kwarg: ArgNode,
29
- kwoptarg: ArgNode,
30
- kwrestarg: ArgNode,
31
- optarg: ArgNode,
32
- restarg: ArgNode,
33
- shadowarg: ArgNode,
34
- args: ArgsNode,
35
- array: ArrayNode,
36
- lvasgn: AsgnNode,
37
- ivasgn: AsgnNode,
38
- cvasgn: AsgnNode,
39
- gvasgn: AsgnNode,
40
- block: BlockNode,
41
- numblock: BlockNode,
42
- break: BreakNode,
43
- case_match: CaseMatchNode,
44
- casgn: CasgnNode,
45
- case: CaseNode,
46
- class: ClassNode,
47
- const: ConstNode,
48
- def: DefNode,
49
- defined?: DefinedNode,
50
- defs: DefNode,
51
- dstr: DstrNode,
52
- ensure: EnsureNode,
53
- for: ForNode,
54
- forward_args: ForwardArgsNode,
55
- float: FloatNode,
56
- hash: HashNode,
57
- if: IfNode,
58
- in_pattern: InPatternNode,
59
- int: IntNode,
60
- index: IndexNode,
61
- indexasgn: IndexasgnNode,
62
- irange: RangeNode,
63
- erange: RangeNode,
64
- kwargs: HashNode,
65
- kwsplat: KeywordSplatNode,
66
- lambda: LambdaNode,
67
- module: ModuleNode,
68
- next: NextNode,
69
- op_asgn: OpAsgnNode,
70
- or_asgn: OrAsgnNode,
71
- or: OrNode,
72
- pair: PairNode,
73
- procarg0: Procarg0Node,
74
- regexp: RegexpNode,
75
- rescue: RescueNode,
76
- resbody: ResbodyNode,
77
- return: ReturnNode,
78
- csend: CsendNode,
79
- send: SendNode,
80
- str: StrNode,
81
- xstr: StrNode,
82
- sclass: SelfClassNode,
83
- super: SuperNode,
84
- zsuper: SuperNode,
85
- sym: SymbolNode,
86
- until: UntilNode,
87
- until_post: UntilNode,
88
- when: WhenNode,
89
- while: WhileNode,
90
- while_post: WhileNode,
91
- yield: YieldNode
22
+ and: AndNode,
23
+ and_asgn: AndAsgnNode,
24
+ alias: AliasNode,
25
+ arg: ArgNode,
26
+ blockarg: ArgNode,
27
+ forward_arg: ArgNode,
28
+ kwarg: ArgNode,
29
+ kwoptarg: ArgNode,
30
+ kwrestarg: ArgNode,
31
+ optarg: ArgNode,
32
+ restarg: ArgNode,
33
+ shadowarg: ArgNode,
34
+ args: ArgsNode,
35
+ array: ArrayNode,
36
+ lvasgn: AsgnNode,
37
+ ivasgn: AsgnNode,
38
+ cvasgn: AsgnNode,
39
+ gvasgn: AsgnNode,
40
+ block: BlockNode,
41
+ numblock: BlockNode,
42
+ break: BreakNode,
43
+ case_match: CaseMatchNode,
44
+ casgn: CasgnNode,
45
+ case: CaseNode,
46
+ class: ClassNode,
47
+ const: ConstNode,
48
+ def: DefNode,
49
+ defined?: DefinedNode,
50
+ defs: DefNode,
51
+ dstr: DstrNode,
52
+ ensure: EnsureNode,
53
+ for: ForNode,
54
+ forward_args: ForwardArgsNode,
55
+ forwarded_kwrestarg: KeywordSplatNode,
56
+ float: FloatNode,
57
+ hash: HashNode,
58
+ if: IfNode,
59
+ in_pattern: InPatternNode,
60
+ int: IntNode,
61
+ index: IndexNode,
62
+ indexasgn: IndexasgnNode,
63
+ irange: RangeNode,
64
+ erange: RangeNode,
65
+ kwargs: HashNode,
66
+ kwsplat: KeywordSplatNode,
67
+ lambda: LambdaNode,
68
+ module: ModuleNode,
69
+ next: NextNode,
70
+ op_asgn: OpAsgnNode,
71
+ or_asgn: OrAsgnNode,
72
+ or: OrNode,
73
+ pair: PairNode,
74
+ procarg0: Procarg0Node,
75
+ regexp: RegexpNode,
76
+ rescue: RescueNode,
77
+ resbody: ResbodyNode,
78
+ return: ReturnNode,
79
+ csend: CsendNode,
80
+ send: SendNode,
81
+ str: StrNode,
82
+ xstr: StrNode,
83
+ sclass: SelfClassNode,
84
+ super: SuperNode,
85
+ zsuper: SuperNode,
86
+ sym: SymbolNode,
87
+ until: UntilNode,
88
+ until_post: UntilNode,
89
+ when: WhenNode,
90
+ while: WhileNode,
91
+ while_post: WhileNode,
92
+ yield: YieldNode
92
93
  }.freeze
93
94
 
94
95
  # Generates {Node} from the given information.
@@ -15,8 +15,8 @@ module RuboCop
15
15
  # :bar
16
16
  # ]
17
17
  #
18
- # node.loc.begin.line_span # => 1..1
19
- # node.loc.expression.line_span(exclude_end: true) # => 1...4
18
+ # node.loc.begin.line_span # => 1..1
19
+ # node.source_range.line_span(exclude_end: true) # => 1...4
20
20
  def line_span(exclude_end: false)
21
21
  ::Range.new(first_line, last_line, exclude_end)
22
22
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  module RuboCop
4
4
  module AST
5
- # A node extension for `kwsplat` nodes. This will be used in place of a
6
- # plain node when the builder constructs the AST, making its methods
7
- # available to all `kwsplat` nodes within RuboCop.
5
+ # A node extension for `kwsplat` and `forwarded_kwrestarg` nodes. This will be used in
6
+ # place of a plain node when the builder constructs the AST, making its methods available to
7
+ # all `kwsplat` and `forwarded_kwrestarg` nodes within RuboCop.
8
8
  class KeywordSplatNode < Node
9
9
  include HashElementNode
10
10
 
@@ -41,6 +41,13 @@ module RuboCop
41
41
  def node_parts
42
42
  [self, self]
43
43
  end
44
+
45
+ # This provides `forwarded_kwrestarg` node to return true to be compatible with `kwsplat` node.
46
+ #
47
+ # @return [true]
48
+ def kwsplat_type?
49
+ true
50
+ end
44
51
  end
45
52
  end
46
53
  end
@@ -47,7 +47,7 @@ module RuboCop
47
47
  # @return [String] a Rainbow colorized version of ruby
48
48
  def colorize(color_scheme = COLOR_SCHEME)
49
49
  map = color_map(color_scheme)
50
- ast.loc.expression.source_buffer.source.chars.map.with_index do |char, i|
50
+ ast.source_range.source_buffer.source.chars.map.with_index do |char, i|
51
51
  Rainbow(char).color(map[i])
52
52
  end.join
53
53
  end
@@ -75,6 +75,10 @@ module RuboCop
75
75
  self.class.new(type, children, { location: location })
76
76
  end
77
77
 
78
+ def source_range
79
+ loc.expression
80
+ end
81
+
78
82
  INT_TO_RANGE = Hash.new { |h, k| h[k] = k..k }
79
83
  private_constant :INT_TO_RANGE
80
84
 
@@ -48,12 +48,12 @@ module RuboCop
48
48
 
49
49
  def emit_unary_op(type, operator_t = nil, *children)
50
50
  children[-1] = children[-1].first if children[-1].is_a?(Array) # token?
51
- map = source_map(children.first.loc.expression, operator_t: operator_t)
51
+ map = source_map(children.first.source_range, operator_t: operator_t)
52
52
  n(type, children, map)
53
53
  end
54
54
 
55
55
  def emit_list(type, begin_t, children, end_t)
56
- expr = children.first.loc.expression.join(children.last.loc.expression)
56
+ expr = children.first.source_range.join(children.last.source_range)
57
57
  map = source_map(expr, begin_t: begin_t, end_t: end_t)
58
58
  n(type, children, map)
59
59
  end
@@ -79,8 +79,7 @@ module RuboCop
79
79
  end
80
80
 
81
81
  def join_exprs(left_expr, right_expr)
82
- left_expr.loc.expression
83
- .join(right_expr.loc.expression)
82
+ left_expr.source_range.join(right_expr.source_range)
84
83
  end
85
84
 
86
85
  def source_map(token_or_range, begin_t: nil, end_t: nil, operator_t: nil, selector_t: nil)
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module AST
5
5
  module Version
6
- STRING = '1.26.0'
6
+ STRING = '1.28.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-ast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.26.0
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-02-11 00:00:00.000000000 Z
13
+ date: 2023-03-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser