syntax_tree 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,14 @@ module SyntaxTree
34
34
  [:getclassvariable, name]
35
35
  end
36
36
 
37
+ def deconstruct_keys(_keys)
38
+ { name: name }
39
+ end
40
+
41
+ def ==(other)
42
+ other.is_a?(GetClassVariable) && other.name == name
43
+ end
44
+
37
45
  def length
38
46
  2
39
47
  end
@@ -90,6 +98,15 @@ module SyntaxTree
90
98
  [:opt_getinlinecache, label.name, cache]
91
99
  end
92
100
 
101
+ def deconstruct_keys(_keys)
102
+ { label: label, cache: cache }
103
+ end
104
+
105
+ def ==(other)
106
+ other.is_a?(OptGetInlineCache) && other.label == label &&
107
+ other.cache == cache
108
+ end
109
+
93
110
  def length
94
111
  3
95
112
  end
@@ -141,6 +158,14 @@ module SyntaxTree
141
158
  [:opt_setinlinecache, cache]
142
159
  end
143
160
 
161
+ def deconstruct_keys(_keys)
162
+ { cache: cache }
163
+ end
164
+
165
+ def ==(other)
166
+ other.is_a?(OptSetInlineCache) && other.cache == cache
167
+ end
168
+
144
169
  def length
145
170
  2
146
171
  end
@@ -190,6 +215,14 @@ module SyntaxTree
190
215
  [:setclassvariable, name]
191
216
  end
192
217
 
218
+ def deconstruct_keys(_keys)
219
+ { name: name }
220
+ end
221
+
222
+ def ==(other)
223
+ other.is_a?(SetClassVariable) && other.name == name
224
+ end
225
+
193
226
  def length
194
227
  2
195
228
  end
@@ -219,6 +219,10 @@ module SyntaxTree
219
219
  @frame = nil
220
220
  end
221
221
 
222
+ def self.run(iseq)
223
+ new.run_top_frame(iseq)
224
+ end
225
+
222
226
  ##########################################################################
223
227
  # Helper methods for frames
224
228
  ##########################################################################
data/lib/syntax_tree.rb CHANGED
@@ -26,6 +26,7 @@ require_relative "syntax_tree/visitor/with_environment"
26
26
  require_relative "syntax_tree/parser"
27
27
  require_relative "syntax_tree/pattern"
28
28
  require_relative "syntax_tree/search"
29
+ require_relative "syntax_tree/index"
29
30
 
30
31
  require_relative "syntax_tree/yarv"
31
32
  require_relative "syntax_tree/yarv/bf"
@@ -116,4 +117,18 @@ module SyntaxTree
116
117
  def self.search(source, query, &block)
117
118
  Search.new(Pattern.new(query).compile).scan(parse(source), &block)
118
119
  end
120
+
121
+ # Indexes the given source code to return a list of all class, module, and
122
+ # method definitions. Used to quickly provide indexing capability for IDEs or
123
+ # documentation generation.
124
+ def self.index(source)
125
+ Index.index(source)
126
+ end
127
+
128
+ # Indexes the given file to return a list of all class, module, and method
129
+ # definitions. Used to quickly provide indexing capability for IDEs or
130
+ # documentation generation.
131
+ def self.index_file(filepath)
132
+ Index.index_file(filepath)
133
+ end
119
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prettier_print
@@ -130,11 +130,13 @@ files:
130
130
  - lib/syntax_tree/cli.rb
131
131
  - lib/syntax_tree/dsl.rb
132
132
  - lib/syntax_tree/formatter.rb
133
+ - lib/syntax_tree/index.rb
133
134
  - lib/syntax_tree/language_server.rb
134
135
  - lib/syntax_tree/language_server/inlay_hints.rb
135
136
  - lib/syntax_tree/node.rb
136
137
  - lib/syntax_tree/parser.rb
137
138
  - lib/syntax_tree/pattern.rb
139
+ - lib/syntax_tree/plugin/disable_ternary.rb
138
140
  - lib/syntax_tree/plugin/single_quotes.rb
139
141
  - lib/syntax_tree/plugin/trailing_comma.rb
140
142
  - lib/syntax_tree/rake/check_task.rb