starscope 1.5.6 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby-ci.yml +26 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -4
- data/CHANGELOG.md +35 -0
- data/README.md +1 -3
- data/Rakefile +5 -2
- data/bin/starscope +54 -51
- data/doc/LANGUAGE_SUPPORT.md +8 -0
- data/doc/USER_GUIDE.md +14 -4
- data/lib/starscope/db.rb +26 -28
- data/lib/starscope/exportable.rb +35 -33
- data/lib/starscope/fragment_extractor.rb +3 -4
- data/lib/starscope/langs/erb.rb +3 -3
- data/lib/starscope/langs/golang.rb +24 -25
- data/lib/starscope/langs/javascript.rb +4 -2
- data/lib/starscope/langs/ruby.rb +26 -7
- data/lib/starscope/langs/vue.rb +32 -0
- data/lib/starscope/matcher.rb +2 -2
- data/lib/starscope/output.rb +6 -3
- data/lib/starscope/queryable.rb +1 -0
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +16 -13
- data/test/fixtures/sample_golang.go +1 -1
- data/test/fixtures/sample_ruby.rb +5 -0
- data/test/fixtures/sample_vue.vue +48 -0
- data/test/functional/starscope_test.rb +16 -15
- data/test/test_helper.rb +2 -1
- data/test/unit/db_test.rb +50 -50
- data/test/unit/exportable_test.rb +12 -10
- data/test/unit/fragment_extractor_test.rb +10 -10
- data/test/unit/langs/erb_test.rb +17 -17
- data/test/unit/langs/golang_test.rb +55 -55
- data/test/unit/langs/javascript_test.rb +44 -44
- data/test/unit/langs/ruby_test.rb +46 -27
- data/test/unit/langs/vue_test.rb +28 -0
- data/test/unit/output_test.rb +3 -3
- data/test/unit/queryable_test.rb +29 -29
- metadata +68 -35
- data/.travis.yml +0 -9
data/lib/starscope/exportable.rb
CHANGED
@@ -4,6 +4,7 @@ module Starscope
|
|
4
4
|
module Exportable
|
5
5
|
CTAGS_DEFAULT_PATH = 'tags'.freeze
|
6
6
|
CSCOPE_DEFAULT_PATH = 'cscope.out'.freeze
|
7
|
+
ASCII = Encoding.find('ASCII')
|
7
8
|
|
8
9
|
class UnknownExportFormatError < StandardError; end
|
9
10
|
|
@@ -19,7 +20,7 @@ module Starscope
|
|
19
20
|
|
20
21
|
@output.normal("Exporting to '#{path}' in format '#{format}'...")
|
21
22
|
path_prefix = Pathname.getwd.relative_path_from(Pathname.new(path).dirname.expand_path)
|
22
|
-
File.open(path, '
|
23
|
+
File.open(path, 'wb') do |file|
|
23
24
|
export_to(format, file, path_prefix)
|
24
25
|
end
|
25
26
|
@output.normal('Export complete.')
|
@@ -39,14 +40,14 @@ module Starscope
|
|
39
40
|
private
|
40
41
|
|
41
42
|
def export_ctags(file, path_prefix)
|
42
|
-
file.puts
|
43
|
-
!_TAG_FILE_FORMAT 2 /extended format/
|
44
|
-
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
45
|
-
!_TAG_PROGRAM_AUTHOR Evan Huus /eapache@gmail.com/
|
46
|
-
!_TAG_PROGRAM_NAME Starscope //
|
47
|
-
!_TAG_PROGRAM_URL https://github.com/eapache/starscope //
|
48
|
-
!_TAG_PROGRAM_VERSION #{Starscope::VERSION} //
|
49
|
-
|
43
|
+
file.puts <<~HEADER
|
44
|
+
!_TAG_FILE_FORMAT 2 /extended format/
|
45
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
46
|
+
!_TAG_PROGRAM_AUTHOR Evan Huus /eapache@gmail.com/
|
47
|
+
!_TAG_PROGRAM_NAME Starscope //
|
48
|
+
!_TAG_PROGRAM_URL https://github.com/eapache/starscope //
|
49
|
+
!_TAG_PROGRAM_VERSION #{Starscope::VERSION} //
|
50
|
+
HEADER
|
50
51
|
defs = (@tables[:defs] || {}).sort_by { |x| x[:name][-1].to_s }
|
51
52
|
defs.each do |record|
|
52
53
|
file.puts ctag_line(record, @meta[:files][record[:file]], path_prefix)
|
@@ -150,7 +151,7 @@ END
|
|
150
151
|
file.print("0\n")
|
151
152
|
file.print("#{files.length}\n")
|
152
153
|
buf = ''
|
153
|
-
files.each { |f| buf << f
|
154
|
+
files.each { |f| buf << "#{f}\n" }
|
154
155
|
file.print("#{buf.length}\n#{buf}")
|
155
156
|
end
|
156
157
|
|
@@ -159,6 +160,7 @@ END
|
|
159
160
|
@tables.each do |tbl, records|
|
160
161
|
records.each do |record|
|
161
162
|
next unless record[:line_no]
|
163
|
+
|
162
164
|
record[:tbl] = tbl
|
163
165
|
db[record[:file]] ||= {}
|
164
166
|
db[record[:file]][record[:line_no]] ||= []
|
@@ -177,16 +179,14 @@ END
|
|
177
179
|
# use the column if we have it, otherwise fall back to scanning
|
178
180
|
index = record[:col] || line.index(key)
|
179
181
|
|
180
|
-
while index && !valid_index?(line, index, key)
|
181
|
-
index = line.index(key, index + 1)
|
182
|
-
end
|
182
|
+
index = line.index(key, index + 1) while index && !valid_index?(line, index, key)
|
183
183
|
|
184
184
|
next if index.nil?
|
185
185
|
|
186
186
|
# Strip trailing non-word characters, otherwise cscope barfs on
|
187
187
|
# function names like `include?`
|
188
188
|
if key =~ /^\W*$/
|
189
|
-
next unless [
|
189
|
+
next unless %i[defs end].include?(record[:tbl])
|
190
190
|
else
|
191
191
|
key.sub!(/\W+$/, '')
|
192
192
|
end
|
@@ -209,25 +209,23 @@ END
|
|
209
209
|
|
210
210
|
index = line.index(key, prev)
|
211
211
|
|
212
|
-
while index && index + key.length < offset && !valid_index?(line, index, key)
|
213
|
-
index = line.index(key, index + 1)
|
214
|
-
end
|
212
|
+
index = line.index(key, index + 1) while index && index + key.length < offset && !valid_index?(line, index, key)
|
215
213
|
|
216
214
|
next unless index && index + key.length < offset
|
217
215
|
|
218
216
|
buf << cscope_plaintext(line, prev, index) << "\n"
|
219
|
-
buf << "#{key}\n"
|
217
|
+
buf << "#{strip_unicode(key)}\n"
|
220
218
|
prev = index + key.length
|
221
219
|
end
|
222
220
|
|
223
221
|
buf << cscope_plaintext(line, prev, offset) << "\n"
|
224
|
-
buf << cscope_mark(record) << record[:key] << "\n"
|
222
|
+
buf << cscope_mark(record) << strip_unicode(record[:key]) << "\n"
|
225
223
|
|
226
224
|
buf << CSCOPE_GLOBAL_HACK_START if record[:type] == :func && record[:tbl] == :end
|
227
225
|
buf
|
228
226
|
rescue ArgumentError
|
229
227
|
# invalid utf-8 byte sequence in the line, oh well
|
230
|
-
line
|
228
|
+
strip_unicode(line)
|
231
229
|
end
|
232
230
|
|
233
231
|
def valid_index?(line, index, key)
|
@@ -242,10 +240,10 @@ END
|
|
242
240
|
ret.lstrip! if start == 0
|
243
241
|
ret.rstrip! if stop == line.length
|
244
242
|
ret.gsub!(/\s+/, ' ')
|
245
|
-
ret.empty? ? ' ' : ret
|
243
|
+
ret.empty? ? ' ' : strip_unicode(ret)
|
246
244
|
rescue ArgumentError
|
247
245
|
# invalid utf-8 byte sequence in the line, oh well
|
248
|
-
line
|
246
|
+
strip_unicode(line)
|
249
247
|
end
|
250
248
|
|
251
249
|
def cscope_mark(rec)
|
@@ -260,16 +258,16 @@ END
|
|
260
258
|
when :file
|
261
259
|
ret = '@'
|
262
260
|
when :defs
|
263
|
-
case rec[:type]
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
261
|
+
ret = case rec[:type]
|
262
|
+
when :func
|
263
|
+
'$'
|
264
|
+
when :class, :module
|
265
|
+
'c'
|
266
|
+
when :type
|
267
|
+
't'
|
268
|
+
else
|
269
|
+
'g'
|
270
|
+
end
|
273
271
|
when :calls
|
274
272
|
ret = '`'
|
275
273
|
when :requires
|
@@ -282,7 +280,11 @@ END
|
|
282
280
|
return ''
|
283
281
|
end
|
284
282
|
|
285
|
-
"\t"
|
283
|
+
"\t#{ret}"
|
284
|
+
end
|
285
|
+
|
286
|
+
def strip_unicode(str)
|
287
|
+
str.encode(ASCII, invalid: :replace, undef: :replace, replace: '')
|
286
288
|
end
|
287
289
|
end
|
288
290
|
end
|
@@ -5,16 +5,15 @@ module Starscope
|
|
5
5
|
@frags = frags
|
6
6
|
end
|
7
7
|
|
8
|
-
def extract(path,
|
9
|
-
|
8
|
+
def extract(path, _text)
|
9
|
+
compiled_text = @frags.map { |f| f.delete(:frag).strip }.join("\n")
|
10
10
|
|
11
|
-
|
11
|
+
@child.extract(path, compiled_text) do |tbl, name, args|
|
12
12
|
args.merge!(@frags[args[:line_no] - 1]) if args[:line_no]
|
13
13
|
yield tbl, name, args
|
14
14
|
end
|
15
15
|
|
16
16
|
# TODO: translate metadata?
|
17
|
-
extractor_metadata
|
18
17
|
end
|
19
18
|
|
20
19
|
def name
|
data/lib/starscope/langs/erb.rb
CHANGED
@@ -3,8 +3,8 @@ module Starscope
|
|
3
3
|
module ERB
|
4
4
|
VERSION = 1
|
5
5
|
|
6
|
-
ERB_START = /<%(?:-|={1,4})
|
7
|
-
ERB_END = /[-=]
|
6
|
+
ERB_START = /<%(?:-|={1,4})?/.freeze
|
7
|
+
ERB_END = /[-=]?%>/.freeze
|
8
8
|
|
9
9
|
def self.match_file(name)
|
10
10
|
name.end_with?('.erb')
|
@@ -20,7 +20,7 @@ module Starscope
|
|
20
20
|
term = line.index(ERB_END)
|
21
21
|
if term
|
22
22
|
yield Starscope::DB::FRAGMENT, :Ruby, frag: line[0...term], line_no: line_no
|
23
|
-
line = line[term + 1
|
23
|
+
line = line[term + 1..]
|
24
24
|
multiline = false
|
25
25
|
else
|
26
26
|
yield Starscope::DB::FRAGMENT, :Ruby, frag: line, line_no: line_no
|
@@ -3,13 +3,13 @@ module Starscope
|
|
3
3
|
module Golang
|
4
4
|
VERSION = 1
|
5
5
|
|
6
|
-
FUNC_CALL = /([
|
7
|
-
END_OF_BLOCK = /^\s*\}\s
|
8
|
-
END_OF_GROUP = /^\s*\)\s
|
9
|
-
STRING_LITERAL = /".+?"
|
10
|
-
BUILTIN_FUNCS = %w
|
11
|
-
uint uint8 uint16 uint32 uint64 string byte
|
12
|
-
CONTROL_KEYS = %w
|
6
|
+
FUNC_CALL = /([[[:word:]].]*?[[:word:]])\(/.freeze
|
7
|
+
END_OF_BLOCK = /^\s*\}\s*$/.freeze
|
8
|
+
END_OF_GROUP = /^\s*\)\s*$/.freeze
|
9
|
+
STRING_LITERAL = /".+?"/.freeze
|
10
|
+
BUILTIN_FUNCS = %w[new make len close copy delete int int8 int16 int32 int64
|
11
|
+
uint uint8 uint16 uint32 uint64 string byte].freeze
|
12
|
+
CONTROL_KEYS = %w[if for switch case].freeze
|
13
13
|
|
14
14
|
def self.match_file(name)
|
15
15
|
name.end_with?('.go')
|
@@ -36,6 +36,7 @@ module Starscope
|
|
36
36
|
if stack[-1] == :comment
|
37
37
|
match = %r{\*/(.*)}.match(line)
|
38
38
|
next unless match
|
39
|
+
|
39
40
|
line = match[1]
|
40
41
|
stack.pop
|
41
42
|
end
|
@@ -45,7 +46,7 @@ module Starscope
|
|
45
46
|
pos = 0
|
46
47
|
while (match = STRING_LITERAL.match(line, pos))
|
47
48
|
eos = find_end_of_string(line, match.begin(0))
|
48
|
-
line = line[0..match.begin(0)] + line[eos
|
49
|
+
line = line[0..match.begin(0)] + line[eos..]
|
49
50
|
pos = match.begin(0) + 2
|
50
51
|
end
|
51
52
|
end
|
@@ -56,14 +57,14 @@ module Starscope
|
|
56
57
|
case line
|
57
58
|
when END_OF_BLOCK
|
58
59
|
end_block(line_no, scope, stack, &block)
|
59
|
-
when /(.+)\s
|
60
|
+
when /(.+)\s+[[:word:]]+/
|
60
61
|
parse_def(Regexp.last_match(1), line_no, scope, &block)
|
61
62
|
end
|
62
63
|
when :interface
|
63
64
|
case line
|
64
65
|
when END_OF_BLOCK
|
65
66
|
end_block(line_no, scope, stack, &block)
|
66
|
-
when /(
|
67
|
+
when /([[:word:]]+)\(.*\)\s+/
|
67
68
|
yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
|
68
69
|
end
|
69
70
|
when :def
|
@@ -105,45 +106,42 @@ module Starscope
|
|
105
106
|
# handles new lines (when not in the middle of an existing definition)
|
106
107
|
def self.parse_new_line(line, line_no, scope, stack, &block)
|
107
108
|
case line
|
108
|
-
when /^func\s+(
|
109
|
+
when /^func\s+([[:word:]]+)\(/
|
109
110
|
yield :defs, scope + [Regexp.last_match(1)], line_no: line_no, type: :func
|
110
111
|
stack.push(:func)
|
111
|
-
when /^func\s+\(
|
112
|
+
when /^func\s+\([[:word:]]+\s+\*?([[:word:]]+)\)\s*([[:word:]]+)\(/
|
112
113
|
yield :defs, scope + [Regexp.last_match(1), Regexp.last_match(2)], line_no: line_no, type: :func
|
113
114
|
stack.push(:func)
|
114
|
-
when /^package\s+(
|
115
|
+
when /^package\s+([[:word:]]+)/
|
115
116
|
scope.push(Regexp.last_match(1))
|
116
117
|
yield :defs, scope, line_no: line_no, type: :package
|
117
|
-
when /^type\s+(
|
118
|
+
when /^type\s+([[:word:]]+)\s+struct\s*\{/
|
118
119
|
scope.push(Regexp.last_match(1))
|
119
120
|
stack.push(:struct)
|
120
121
|
yield :defs, scope, line_no: line_no, type: :class
|
121
|
-
when /^type\s+(
|
122
|
+
when /^type\s+([[:word:]]+)\s+interface\s*\{/
|
122
123
|
scope.push(Regexp.last_match(1))
|
123
124
|
stack.push(:interface)
|
124
125
|
yield :defs, scope, line_no: line_no, type: :class
|
125
|
-
when /^type\s+(
|
126
|
+
when /^type\s+([[:word:]]+)/
|
126
127
|
yield :defs, scope + [Regexp.last_match(1)], line_no: line_no, type: :type
|
127
128
|
when /^import\s+"(.+)"/
|
128
129
|
name = Regexp.last_match(1).split('/')
|
129
130
|
yield :imports, name, line_no: line_no
|
130
131
|
when /^import\s+\(/
|
131
132
|
stack.push(:import)
|
132
|
-
when /^var\s+\(/
|
133
|
-
stack.push(:def)
|
134
|
-
when /^var\s+(\w+)\s/
|
135
|
-
yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
|
136
|
-
parse_call(line, line_no, scope, &block)
|
137
|
-
when /^const\s+\(/
|
133
|
+
when /^var\s+\(/, /^const\s+\(/
|
138
134
|
stack.push(:def)
|
139
|
-
when /^
|
135
|
+
when /^var\s+([[:word:]]+)\s/, /^const\s+([[:word:]]+)\s/
|
140
136
|
yield :defs, scope + [Regexp.last_match(1)], line_no: line_no
|
141
137
|
parse_call(line, line_no, scope, &block)
|
142
138
|
when /^\s+(.*?) :?=[^=]/
|
143
|
-
Regexp.last_match(1).split
|
139
|
+
Regexp.last_match(1).split.each do |var|
|
144
140
|
next if CONTROL_KEYS.include?(var)
|
141
|
+
|
145
142
|
name = var.delete(',').split('.')
|
146
143
|
next if name[0] == '_' # assigning to _ is a discard in golang
|
144
|
+
|
147
145
|
if name.length == 1
|
148
146
|
yield :assigns, scope + [name[0]], line_no: line_no
|
149
147
|
else
|
@@ -158,9 +156,10 @@ module Starscope
|
|
158
156
|
|
159
157
|
def self.parse_call(line, line_no, scope)
|
160
158
|
line.scan(FUNC_CALL) do |match|
|
161
|
-
name = match[0].split('.').
|
159
|
+
name = match[0].split('.').reject(&:empty?)
|
162
160
|
if name.length == 1
|
163
161
|
next if name[0] == 'func'
|
162
|
+
|
164
163
|
if BUILTIN_FUNCS.include?(name[0])
|
165
164
|
yield :calls, name[0], line_no: line_no
|
166
165
|
else
|
@@ -96,7 +96,8 @@ module Starscope
|
|
96
96
|
next
|
97
97
|
end
|
98
98
|
|
99
|
-
next if found[node.name]
|
99
|
+
next if found[node.name]&.include?(line)
|
100
|
+
|
100
101
|
yield :defs, node.name, line_no: line
|
101
102
|
found[node.name] ||= Set.new
|
102
103
|
found[node.name].add(line)
|
@@ -113,7 +114,8 @@ module Starscope
|
|
113
114
|
line = find_line(node.range.from, map, lines, name)
|
114
115
|
next unless line
|
115
116
|
|
116
|
-
next if found[name]
|
117
|
+
next if found[name]&.include?(line)
|
118
|
+
|
117
119
|
yield :reads, name, line_no: line
|
118
120
|
end
|
119
121
|
end
|
data/lib/starscope/langs/ruby.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'parser/
|
1
|
+
require 'parser/ruby31'
|
2
2
|
|
3
3
|
module Starscope
|
4
4
|
module Lang
|
@@ -16,9 +16,11 @@ module Starscope
|
|
16
16
|
|
17
17
|
def self.match_file(name)
|
18
18
|
return true if name.end_with?('.rb', '.rake')
|
19
|
+
|
19
20
|
File.open(name) do |f|
|
20
21
|
head = f.read(2)
|
21
22
|
return false if head.nil? || !head.start_with?('#!')
|
23
|
+
|
22
24
|
return f.readline.include?('ruby')
|
23
25
|
end
|
24
26
|
end
|
@@ -27,7 +29,7 @@ module Starscope
|
|
27
29
|
buffer = Parser::Source::Buffer.new(path, 1)
|
28
30
|
buffer.source = contents.force_encoding(Encoding::UTF_8)
|
29
31
|
|
30
|
-
parser = Parser::
|
32
|
+
parser = Parser::Ruby31.new(Builder.new)
|
31
33
|
parser.diagnostics.ignore_warnings = true
|
32
34
|
parser.diagnostics.all_errors_are_fatal = false
|
33
35
|
|
@@ -39,12 +41,15 @@ module Starscope
|
|
39
41
|
extract_node(tree, scope, &block)
|
40
42
|
|
41
43
|
new_scope = []
|
42
|
-
|
44
|
+
child_nodes = tree.children
|
45
|
+
|
46
|
+
if %i[class module].include? tree.type
|
43
47
|
new_scope = scoped_name(tree.children[0], scope)
|
44
48
|
scope += new_scope
|
49
|
+
child_nodes = child_nodes[1..] # module and class constant definitions are not "read"s
|
45
50
|
end
|
46
51
|
|
47
|
-
|
52
|
+
child_nodes.each { |node| extract_tree(node, scope, &block) if node.is_a? AST::Node }
|
48
53
|
|
49
54
|
scope.pop(new_scope.count)
|
50
55
|
end
|
@@ -68,7 +73,12 @@ module Starscope
|
|
68
73
|
when :def
|
69
74
|
yield :defs, scope + [node.children[0]],
|
70
75
|
line_no: loc.line, type: :func, col: loc.name.column
|
71
|
-
|
76
|
+
if loc.end
|
77
|
+
yield :end, :end, line_no: loc.end.line, type: :func, col: loc.end.column
|
78
|
+
else
|
79
|
+
# ruby 3.x syntax for "def foo = ..."
|
80
|
+
yield :end, :end, line_no: loc.line, type: :func, col: loc.expression.end.column
|
81
|
+
end
|
72
82
|
|
73
83
|
when :defs
|
74
84
|
yield :defs, scope + [node.children[1]],
|
@@ -90,7 +100,16 @@ module Starscope
|
|
90
100
|
|
91
101
|
when :const
|
92
102
|
name = scoped_name(node, scope)
|
93
|
-
|
103
|
+
# handle `__ENCODING__` and other weird quasi-constants
|
104
|
+
column = case loc
|
105
|
+
when Parser::Source::Map::Constant
|
106
|
+
loc.name.column
|
107
|
+
when Parser::Source::Map
|
108
|
+
loc.column
|
109
|
+
when nil
|
110
|
+
return
|
111
|
+
end
|
112
|
+
yield :reads, name, line_no: loc.line, col: column
|
94
113
|
|
95
114
|
when :lvar, :ivar, :cvar, :gvar
|
96
115
|
yield :reads, scope + [node.children[0]], line_no: loc.line, col: loc.name.column
|
@@ -109,7 +128,7 @@ module Starscope
|
|
109
128
|
def self.scoped_name(node, scope)
|
110
129
|
if node.type == :block
|
111
130
|
scoped_name(node.children[0], scope)
|
112
|
-
elsif [
|
131
|
+
elsif %i[lvar ivar cvar gvar const send casgn].include? node.type
|
113
132
|
if node.children[0].is_a? Symbol
|
114
133
|
[node.children[0]]
|
115
134
|
elsif node.children[0].is_a? AST::Node
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Starscope
|
2
|
+
module Lang
|
3
|
+
module Vue
|
4
|
+
VERSION = 1
|
5
|
+
|
6
|
+
SCRIPT_START = '<script>'.freeze
|
7
|
+
SCRIPT_END = '</script>'.freeze
|
8
|
+
|
9
|
+
def self.match_file(name)
|
10
|
+
name.end_with?('.vue')
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.extract(_path, contents)
|
14
|
+
in_script = false
|
15
|
+
|
16
|
+
contents.lines.each_with_index do |line, line_no|
|
17
|
+
line_no += 1 # zero-index to one-index
|
18
|
+
|
19
|
+
if in_script
|
20
|
+
if line.strip == SCRIPT_END
|
21
|
+
in_script = false
|
22
|
+
else
|
23
|
+
yield Starscope::DB::FRAGMENT, :Javascript, frag: line, line_no: line_no
|
24
|
+
end
|
25
|
+
elsif line.strip == SCRIPT_START
|
26
|
+
in_script = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/starscope/matcher.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Starscope
|
2
2
|
class Matcher
|
3
|
-
MATCH_TYPES = [
|
3
|
+
MATCH_TYPES = %i[literal_match regexp_match].freeze
|
4
4
|
|
5
5
|
def initialize(query)
|
6
6
|
@query = query
|
@@ -15,7 +15,7 @@ module Starscope
|
|
15
15
|
def match(input)
|
16
16
|
if input.end_with?(@query)
|
17
17
|
:literal_match
|
18
|
-
elsif @regexp
|
18
|
+
elsif @regexp&.match(input)
|
19
19
|
:regexp_match
|
20
20
|
end
|
21
21
|
end
|
data/lib/starscope/output.rb
CHANGED
@@ -4,7 +4,7 @@ module Starscope
|
|
4
4
|
class Output
|
5
5
|
PBAR_FORMAT = '%t: %c/%C %E ||%b>%i||'.freeze
|
6
6
|
|
7
|
-
def initialize(level, out =
|
7
|
+
def initialize(level, out = $stdout)
|
8
8
|
@out = out
|
9
9
|
@level = level
|
10
10
|
@pbar = nil
|
@@ -12,27 +12,30 @@ module Starscope
|
|
12
12
|
|
13
13
|
def new_pbar(title, num_items)
|
14
14
|
return if @level == :quiet
|
15
|
+
|
15
16
|
@pbar = ProgressBar.create(title: title, total: num_items,
|
16
17
|
format: PBAR_FORMAT, length: 80,
|
17
18
|
out: @out)
|
18
19
|
end
|
19
20
|
|
20
21
|
def inc_pbar
|
21
|
-
@pbar
|
22
|
+
@pbar&.increment
|
22
23
|
end
|
23
24
|
|
24
25
|
def finish_pbar
|
25
|
-
@pbar
|
26
|
+
@pbar&.finish
|
26
27
|
@pbar = nil
|
27
28
|
end
|
28
29
|
|
29
30
|
def extra(msg)
|
30
31
|
return unless @level == :verbose
|
32
|
+
|
31
33
|
output(msg)
|
32
34
|
end
|
33
35
|
|
34
36
|
def normal(msg)
|
35
37
|
return if @level == :quiet
|
38
|
+
|
36
39
|
output(msg)
|
37
40
|
end
|
38
41
|
|
data/lib/starscope/queryable.rb
CHANGED
data/lib/starscope/version.rb
CHANGED
data/starscope.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('lib/starscope/version.rb', __dir__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'starscope'
|
5
5
|
gem.version = Starscope::VERSION
|
6
6
|
gem.summary = 'Smart code search and indexing'
|
7
|
-
gem.description = <<-
|
7
|
+
gem.description = <<-DESC
|
8
8
|
Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
|
9
9
|
Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
|
10
10
|
answer a lot of questions about a lot of code.
|
11
|
-
|
11
|
+
DESC
|
12
12
|
gem.authors = ['Evan Huus']
|
13
13
|
gem.homepage = 'https://github.com/eapache/starscope'
|
14
14
|
gem.email = 'eapache@gmail.com'
|
@@ -17,19 +17,22 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
18
|
gem.test_files = `git ls-files -- test/*`.split("\n")
|
19
19
|
gem.require_paths = ['lib']
|
20
|
-
gem.required_ruby_version = '>= 2.
|
20
|
+
gem.required_ruby_version = '>= 2.6'
|
21
21
|
|
22
|
-
gem.add_dependency 'oj', '~> 3.3'
|
23
|
-
gem.add_dependency 'parser', '~> 2.4'
|
24
|
-
gem.add_dependency 'ruby-progressbar', '~> 1.9'
|
25
|
-
gem.add_dependency 'rkelly-remix', '~> 0.0.7'
|
26
22
|
gem.add_dependency 'babel-transpiler', '~> 0.7'
|
23
|
+
gem.add_dependency 'oj', '~> 3.7'
|
24
|
+
gem.add_dependency 'parser', '~> 3.1'
|
25
|
+
gem.add_dependency 'rkelly-remix', '~> 0.0.7'
|
26
|
+
gem.add_dependency 'ruby-progressbar', '~> 1.9'
|
27
27
|
gem.add_dependency 'sourcemap', '~> 0.1'
|
28
28
|
|
29
|
-
gem.add_development_dependency 'bundler', '
|
30
|
-
gem.add_development_dependency '
|
31
|
-
gem.add_development_dependency '
|
32
|
-
gem.add_development_dependency 'minitest', '~> 5.10'
|
29
|
+
gem.add_development_dependency 'bundler', '>= 1.7'
|
30
|
+
gem.add_development_dependency 'byebug', '~> 11.1'
|
31
|
+
gem.add_development_dependency 'minitest', '~> 5.12'
|
33
32
|
gem.add_development_dependency 'mocha', '~> 1.3'
|
34
|
-
gem.add_development_dependency '
|
33
|
+
gem.add_development_dependency 'rake', '~> 13.0'
|
34
|
+
gem.add_development_dependency 'rubocop', '~> 1.25.0'
|
35
|
+
gem.add_development_dependency 'rubocop-minitest', '~> 0.17.1'
|
36
|
+
gem.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
37
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
35
38
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="container">
|
3
|
+
<span>
|
4
|
+
<a
|
5
|
+
href="https://www.markdownguide.org/cheat-sheet/"
|
6
|
+
target="_blank"
|
7
|
+
style="padding-left: 6px; padding-bottom: 0px;"
|
8
|
+
>Markdown </a>
|
9
|
+
{{ descriptionLinkingVerb }} supported.
|
10
|
+
</span>
|
11
|
+
</div>
|
12
|
+
</template>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
import marked from 'marked';
|
16
|
+
|
17
|
+
export default {
|
18
|
+
props: {
|
19
|
+
placeholderText: {
|
20
|
+
type: String,
|
21
|
+
default: 'This field supports Markdown. Try it out!'
|
22
|
+
}
|
23
|
+
},
|
24
|
+
computed: {
|
25
|
+
markdown() {
|
26
|
+
return marked(this.value || '');
|
27
|
+
}
|
28
|
+
},
|
29
|
+
methods: {
|
30
|
+
handleChange(e) {
|
31
|
+
this.$emit('change', e.target.value);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
</script>
|
36
|
+
|
37
|
+
<style scoped>
|
38
|
+
@import "../shared/style.css";
|
39
|
+
</style>
|
40
|
+
|
41
|
+
<style>
|
42
|
+
.container {
|
43
|
+
overflow: auto;
|
44
|
+
padding: 5px;
|
45
|
+
border-radius: 5px;
|
46
|
+
}
|
47
|
+
|
48
|
+
</style>
|