starscope 0.1.9 → 0.1.10
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.
- data/.travis.yml +2 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +4 -13
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/starscope/db.rb +4 -4
- data/lib/starscope/langs/go.rb +24 -24
- data/lib/starscope/langs/ruby.rb +17 -17
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +1 -1
- data/test/files/sample_ruby.rb +4 -4
- data/test/lib/test_db.rb +1 -1
- data/test/lib/test_golang.rb +2 -2
- data/test/lib/test_ruby.rb +2 -2
- data/test/lib/test_version.rb +1 -1
- metadata +4 -4
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
v0.1.
|
|
4
|
+
v0.1.10 (trunk)
|
|
5
|
+
-------------------
|
|
6
|
+
|
|
7
|
+
Improvements:
|
|
8
|
+
* Import new ruby parser version and make necessary changes so that StarScope
|
|
9
|
+
now runs on older Ruby versions (1.9.2 and 1.8.7)
|
|
10
|
+
|
|
11
|
+
v0.1.9 (2014-02-22)
|
|
5
12
|
-------------------
|
|
6
13
|
|
|
7
14
|
Bug Fixes:
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
starscope (0.1.
|
|
4
|
+
starscope (0.1.10)
|
|
5
5
|
oj (~> 2.5)
|
|
6
6
|
parser (~> 2.1)
|
|
7
7
|
ruby-progressbar (~> 1.4)
|
|
@@ -11,25 +11,16 @@ GEM
|
|
|
11
11
|
specs:
|
|
12
12
|
ast (1.1.0)
|
|
13
13
|
coderay (1.1.0)
|
|
14
|
-
columnize (0.3.6)
|
|
15
|
-
debugger (1.6.5)
|
|
16
|
-
columnize (>= 0.3.1)
|
|
17
|
-
debugger-linecache (~> 1.2.0)
|
|
18
|
-
debugger-ruby_core_source (~> 1.3.1)
|
|
19
|
-
debugger-linecache (1.2.0)
|
|
20
|
-
debugger-ruby_core_source (1.3.1)
|
|
21
14
|
method_source (0.8.2)
|
|
15
|
+
minitest (5.2.3)
|
|
22
16
|
oj (2.5.5)
|
|
23
|
-
parser (2.1.
|
|
17
|
+
parser (2.1.5)
|
|
24
18
|
ast (~> 1.1)
|
|
25
19
|
slop (~> 3.4, >= 3.4.5)
|
|
26
20
|
pry (0.9.12.6)
|
|
27
21
|
coderay (~> 1.0)
|
|
28
22
|
method_source (~> 0.8)
|
|
29
23
|
slop (~> 3.4)
|
|
30
|
-
pry-debugger (0.2.2)
|
|
31
|
-
debugger (~> 1.3)
|
|
32
|
-
pry (~> 0.9.10)
|
|
33
24
|
rake (10.1.1)
|
|
34
25
|
ruby-progressbar (1.4.1)
|
|
35
26
|
slop (3.4.7)
|
|
@@ -39,7 +30,7 @@ PLATFORMS
|
|
|
39
30
|
|
|
40
31
|
DEPENDENCIES
|
|
41
32
|
bundler (~> 1.5)
|
|
33
|
+
minitest
|
|
42
34
|
pry
|
|
43
|
-
pry-debugger
|
|
44
35
|
rake
|
|
45
36
|
starscope!
|
data/README.md
CHANGED
|
@@ -13,7 +13,7 @@ StarScope is a similar tool for [Ruby](https://www.ruby-lang.org/) and
|
|
|
13
13
|
support for other languages at some point within the same framework (thus the
|
|
14
14
|
name StarScope, ie \*scope).
|
|
15
15
|
|
|
16
|
-
Install it as a gem
|
|
16
|
+
Install it as a gem:
|
|
17
17
|
```
|
|
18
18
|
$ gem install starscope
|
|
19
19
|
```
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
2
|
require 'rake/testtask'
|
|
3
3
|
|
|
4
4
|
Rake::TestTask.new do |t|
|
|
@@ -6,5 +6,5 @@ Rake::TestTask.new do |t|
|
|
|
6
6
|
t.test_files = FileList['test/lib/test_*.rb']
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
desc
|
|
9
|
+
desc 'Run tests'
|
|
10
10
|
task :default => :test
|
data/lib/starscope/db.rb
CHANGED
|
@@ -33,7 +33,7 @@ class StarScope::DB
|
|
|
33
33
|
if format == DB_FORMAT
|
|
34
34
|
@paths = Oj.load(file.gets)
|
|
35
35
|
@files = Oj.load(file.gets)
|
|
36
|
-
@tables = Oj.load(file.gets, symbol_keys
|
|
36
|
+
@tables = Oj.load(file.gets, :symbol_keys => true)
|
|
37
37
|
elsif format <= 2
|
|
38
38
|
# Old format (pre-json), so read the directories segment then rebuild
|
|
39
39
|
len = file.gets.to_i
|
|
@@ -66,7 +66,7 @@ class StarScope::DB
|
|
|
66
66
|
files = paths.map {|p| self.class.files_from_path(p)}.flatten
|
|
67
67
|
return if files.empty?
|
|
68
68
|
if @progress
|
|
69
|
-
pbar = ProgressBar.create(title
|
|
69
|
+
pbar = ProgressBar.create(:title => "Building", :total => files.length, :format => PBAR_FORMAT, :length => 80)
|
|
70
70
|
end
|
|
71
71
|
files.each do |f|
|
|
72
72
|
add_file(f)
|
|
@@ -77,7 +77,7 @@ class StarScope::DB
|
|
|
77
77
|
def update
|
|
78
78
|
new_files = (@paths.map {|p| self.class.files_from_path(p)}.flatten) - @files.keys
|
|
79
79
|
if @progress
|
|
80
|
-
pbar = ProgressBar.create(title
|
|
80
|
+
pbar = ProgressBar.create(:title => "Updating", :total => new_files.length + @files.length, :format => PBAR_FORMAT, :length => 80)
|
|
81
81
|
end
|
|
82
82
|
changed = @files.keys.map do |f|
|
|
83
83
|
changed = update_file(f)
|
|
@@ -236,7 +236,7 @@ END
|
|
|
236
236
|
if entry[:line_no]
|
|
237
237
|
tmpdb[entry[:file]] ||= {}
|
|
238
238
|
tmpdb[entry[:file]][entry[:line_no]] ||= []
|
|
239
|
-
tmpdb[entry[:file]][entry[:line_no]] << {tbl
|
|
239
|
+
tmpdb[entry[:file]][entry[:line_no]] << {:tbl => tbl, :key => key, :entry => entry}
|
|
240
240
|
end
|
|
241
241
|
end
|
|
242
242
|
end
|
data/lib/starscope/langs/go.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module StarScope::Lang
|
|
2
2
|
module Go
|
|
3
3
|
FUNC_CALL = /([\w\.]*?\w)\(/
|
|
4
|
-
END_OF_BLOCK = /^\s
|
|
4
|
+
END_OF_BLOCK = /^\s*\}\s*$/
|
|
5
5
|
END_OF_GROUP = /^\s*\)\s*$/
|
|
6
6
|
BUILTIN_FUNCS = ['new', 'make', 'len', 'close', 'copy', 'delete',
|
|
7
7
|
'int', 'int8', 'int16', 'int32', 'int64',
|
|
@@ -51,7 +51,7 @@ module StarScope::Lang
|
|
|
51
51
|
when :struct
|
|
52
52
|
case line
|
|
53
53
|
when END_OF_BLOCK
|
|
54
|
-
yield :end, "}", line_no
|
|
54
|
+
yield :end, "}", :line_no => line_no, :scope => scope, :type => :class
|
|
55
55
|
stack.pop
|
|
56
56
|
scope.pop
|
|
57
57
|
when /(.+)\s+\w+/
|
|
@@ -60,11 +60,11 @@ module StarScope::Lang
|
|
|
60
60
|
when :interface
|
|
61
61
|
case line
|
|
62
62
|
when END_OF_BLOCK
|
|
63
|
-
yield :end, "}", line_no
|
|
63
|
+
yield :end, "}", :line_no => line_no, :scope => scope, :type => :class
|
|
64
64
|
stack.pop
|
|
65
65
|
scope.pop
|
|
66
66
|
when /(\w+)\(.*\)\s+/
|
|
67
|
-
yield :defs, $1, line_no
|
|
67
|
+
yield :defs, $1, :line_no => line_no, :scope => scope
|
|
68
68
|
end
|
|
69
69
|
when :def
|
|
70
70
|
case line
|
|
@@ -81,55 +81,55 @@ module StarScope::Lang
|
|
|
81
81
|
stack.pop
|
|
82
82
|
when /"(.+)"/
|
|
83
83
|
name = $1.split('/')
|
|
84
|
-
yield :imports, name[-1], line_no
|
|
84
|
+
yield :imports, name[-1], :line_no => line_no, :scope => name[0...-1]
|
|
85
85
|
end
|
|
86
86
|
else
|
|
87
|
-
if stack[-1] == :func and
|
|
88
|
-
yield :end, "}", line_no
|
|
87
|
+
if stack[-1] == :func and /^\}/ =~ line
|
|
88
|
+
yield :end, "}", :line_no => line_no, :type => :func
|
|
89
89
|
stack.pop
|
|
90
90
|
end
|
|
91
91
|
case line
|
|
92
92
|
when /^func\s+(\w+)\(/
|
|
93
|
-
yield :defs, $1, line_no
|
|
93
|
+
yield :defs, $1, :line_no => line_no, :scope => scope, :type => :func
|
|
94
94
|
stack.push(:func)
|
|
95
95
|
when /^func\s+\(\w+\s+\*?(\w+)\)\s*(\w+)\(/
|
|
96
|
-
yield :defs, $2, line_no
|
|
96
|
+
yield :defs, $2, :line_no => line_no, :scope => scope + [$1], :type => :func
|
|
97
97
|
stack.push(:func)
|
|
98
98
|
when /^package\s+(\w+)/
|
|
99
|
-
yield :defs, $1, line_no
|
|
99
|
+
yield :defs, $1, :line_no => line_no, :scope => scope, :type => :package
|
|
100
100
|
scope.push($1)
|
|
101
|
-
when /^type\s+(\w+)\s+struct\s
|
|
102
|
-
yield :defs, $1, line_no
|
|
101
|
+
when /^type\s+(\w+)\s+struct\s*\{/
|
|
102
|
+
yield :defs, $1, :line_no => line_no, :scope => scope, :type => :class
|
|
103
103
|
scope.push($1)
|
|
104
104
|
stack.push(:struct)
|
|
105
|
-
when /^type\s+(\w+)\s+interface\s
|
|
106
|
-
yield :defs, $1, line_no
|
|
105
|
+
when /^type\s+(\w+)\s+interface\s*\{/
|
|
106
|
+
yield :defs, $1, :line_no => line_no, :scope => scope, :type => :class
|
|
107
107
|
scope.push($1)
|
|
108
108
|
stack.push(:interface)
|
|
109
109
|
when /^type\s+(\w+)/
|
|
110
|
-
yield :defs, $1, line_no
|
|
110
|
+
yield :defs, $1, :line_no => line_no, :scope => scope, :type => :type
|
|
111
111
|
when /^import\s+"(.+)"/
|
|
112
112
|
name = $1.split('/')
|
|
113
|
-
yield :imports, name[-1], line_no
|
|
113
|
+
yield :imports, name[-1], :line_no => line_no, :scope => name[0...-1]
|
|
114
114
|
when /^import\s+\(/
|
|
115
115
|
stack.push(:import)
|
|
116
116
|
when /^var\s+\(/
|
|
117
117
|
stack.push(:def)
|
|
118
118
|
when /^var\s+(\w+)\s+\w+/
|
|
119
|
-
yield :defs, $1, line_no
|
|
119
|
+
yield :defs, $1, :line_no => line_no, :scope => scope
|
|
120
120
|
when /^const\s+\(/
|
|
121
121
|
stack.push(:def)
|
|
122
122
|
when /^const\s+(\w+)\s+\w+/
|
|
123
|
-
yield :defs, $1, line_no
|
|
123
|
+
yield :defs, $1, :line_no => line_no, :scope => scope
|
|
124
124
|
when /^\s+(.*?) :?=[^=]/
|
|
125
125
|
$1.split(' ').each do |var|
|
|
126
126
|
next if CONTROL_KEYS.include?(var)
|
|
127
127
|
name = var.delete(',').split('.')
|
|
128
128
|
next if name[0] == "_" # assigning to _ is a discard in golang
|
|
129
129
|
if name.length == 1
|
|
130
|
-
yield :assigns, name[0], line_no
|
|
130
|
+
yield :assigns, name[0], :line_no => line_no, :scope => scope
|
|
131
131
|
else
|
|
132
|
-
yield :assigns, name[1], line_no
|
|
132
|
+
yield :assigns, name[1], :line_no => line_no, :scope => name[0..-1]
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
parse_call(line, line_no, scope, &block)
|
|
@@ -151,19 +151,19 @@ module StarScope::Lang
|
|
|
151
151
|
if name.length == 1
|
|
152
152
|
next if name[0] == 'func'
|
|
153
153
|
if BUILTIN_FUNCS.include?(name[0])
|
|
154
|
-
yield :calls, name[0], line_no
|
|
154
|
+
yield :calls, name[0], :line_no => line_no
|
|
155
155
|
else
|
|
156
|
-
yield :calls, name[0], line_no
|
|
156
|
+
yield :calls, name[0], :line_no => line_no, :scope => scope
|
|
157
157
|
end
|
|
158
158
|
else
|
|
159
|
-
yield :calls, name[-1], line_no
|
|
159
|
+
yield :calls, name[-1], :line_no => line_no, :scope => name[0...-1]
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
def self.parse_def(line, line_no, scope)
|
|
165
165
|
line.split.each do |var|
|
|
166
|
-
yield :defs, var.delete(','), line_no
|
|
166
|
+
yield :defs, var.delete(','), :line_no => line_no, :scope => scope
|
|
167
167
|
break if not var.end_with?(',')
|
|
168
168
|
end
|
|
169
169
|
end
|
data/lib/starscope/langs/ruby.rb
CHANGED
|
@@ -53,38 +53,38 @@ module StarScope::Lang
|
|
|
53
53
|
when :send
|
|
54
54
|
fqn = scoped_name(node)
|
|
55
55
|
yield :calls, fqn.last,
|
|
56
|
-
line_no
|
|
57
|
-
scope
|
|
56
|
+
:line_no => node.location.expression.line,
|
|
57
|
+
:scope => fqn[0...-1]
|
|
58
58
|
if node.children[0].nil? and node.children[1] == :require and node.children[2].type == :str
|
|
59
59
|
fqn = node.children[2].children[0].split("/")
|
|
60
60
|
yield :requires, fqn.last,
|
|
61
|
-
line_no
|
|
62
|
-
scope
|
|
61
|
+
:line_no => node.location.expression.line,
|
|
62
|
+
:scope => fqn[0...-1]
|
|
63
63
|
end
|
|
64
64
|
when :def
|
|
65
65
|
yield :defs, node.children[0],
|
|
66
|
-
line_no
|
|
67
|
-
scope
|
|
68
|
-
yield :end, :end, line_no
|
|
66
|
+
:line_no => node.location.expression.line,
|
|
67
|
+
:scope => @scope, :type => :func
|
|
68
|
+
yield :end, :end, :line_no => node.location.end.line, :type => :func
|
|
69
69
|
when :defs
|
|
70
70
|
yield :defs, node.children[1],
|
|
71
|
-
line_no
|
|
72
|
-
scope
|
|
73
|
-
yield :end, :end, line_no
|
|
71
|
+
:line_no => node.location.expression.line,
|
|
72
|
+
:scope => @scope, :type => :func
|
|
73
|
+
yield :end, :end, :line_no => node.location.end.line, :type => :func
|
|
74
74
|
when :module, :class
|
|
75
75
|
fqn = @scope + scoped_name(node.children[0])
|
|
76
|
-
yield :defs, fqn.last, line_no
|
|
77
|
-
scope
|
|
78
|
-
yield :end, :end, line_no
|
|
76
|
+
yield :defs, fqn.last, :line_no => node.location.expression.line,
|
|
77
|
+
:scope => fqn[0...-1], :type => node.type
|
|
78
|
+
yield :end, :end, :line_no => node.location.end.line, :type => node.type
|
|
79
79
|
when :casgn
|
|
80
80
|
fqn = scoped_name(node)
|
|
81
81
|
yield :assigns, fqn.last,
|
|
82
|
-
line_no
|
|
83
|
-
scope
|
|
82
|
+
:line_no => node.location.expression.line,
|
|
83
|
+
:scope => fqn[0...-1]
|
|
84
84
|
when :lvasgn, :ivasgn, :cvasgn, :gvasgn
|
|
85
85
|
yield :assigns, node.children[0],
|
|
86
|
-
line_no
|
|
87
|
-
scope
|
|
86
|
+
:line_no => node.location.expression.line,
|
|
87
|
+
:scope => @scope
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
data/lib/starscope/version.rb
CHANGED
data/starscope.gemspec
CHANGED
|
@@ -21,5 +21,5 @@ Gem::Specification.new do |gem|
|
|
|
21
21
|
gem.add_development_dependency 'bundler', '~> 1.5'
|
|
22
22
|
gem.add_development_dependency 'rake'
|
|
23
23
|
gem.add_development_dependency 'pry'
|
|
24
|
-
gem.add_development_dependency '
|
|
24
|
+
gem.add_development_dependency 'minitest'
|
|
25
25
|
end
|
data/test/files/sample_ruby.rb
CHANGED
|
@@ -26,7 +26,7 @@ class StarScope::DB
|
|
|
26
26
|
if format == DB_FORMAT
|
|
27
27
|
@paths = Oj.load(file.gets)
|
|
28
28
|
@files = Oj.load(file.gets)
|
|
29
|
-
@tables = Oj.load(file.gets, symbol_keys
|
|
29
|
+
@tables = Oj.load(file.gets, :symbol_keys => true)
|
|
30
30
|
elsif format <= 2
|
|
31
31
|
# Old format (pre-json), so read the directories segment then rebuild
|
|
32
32
|
len = file.gets.to_i
|
|
@@ -59,7 +59,7 @@ class StarScope::DB
|
|
|
59
59
|
files = paths.map {|p| self.class.files_from_path(p)}.flatten
|
|
60
60
|
return if files.empty?
|
|
61
61
|
if @progress
|
|
62
|
-
pbar = ProgressBar.create(title
|
|
62
|
+
pbar = ProgressBar.create(:title => "Building", :total => files.length, :format => PBAR_FORMAT, :length => 80)
|
|
63
63
|
end
|
|
64
64
|
files.each do |f|
|
|
65
65
|
add_file(f)
|
|
@@ -70,7 +70,7 @@ class StarScope::DB
|
|
|
70
70
|
def update
|
|
71
71
|
new_files = (@paths.map {|p| self.class.files_from_path(p)}.flatten) - @files.keys
|
|
72
72
|
if @progress
|
|
73
|
-
pbar = ProgressBar.create(title
|
|
73
|
+
pbar = ProgressBar.create(:title => "Updating", :total => new_files.length + @files.length, :format => PBAR_FORMAT, :length => 80)
|
|
74
74
|
end
|
|
75
75
|
changed = @files.keys.map do |f|
|
|
76
76
|
changed = update_file(f)
|
|
@@ -114,7 +114,7 @@ class StarScope::DB
|
|
|
114
114
|
if entry[:line_no]
|
|
115
115
|
tmpdb[entry[:file]] ||= {}
|
|
116
116
|
tmpdb[entry[:file]][entry[:line_no]] ||= []
|
|
117
|
-
tmpdb[entry[:file]][entry[:line_no]] << {tbl
|
|
117
|
+
tmpdb[entry[:file]][entry[:line_no]] << {:tbl => tbl, :key => key, :entry => entry}
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
end
|
data/test/lib/test_db.rb
CHANGED
data/test/lib/test_golang.rb
CHANGED
data/test/lib/test_ruby.rb
CHANGED
data/test/lib/test_version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: starscope
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.10
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-02-
|
|
12
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: oj
|
|
@@ -108,7 +108,7 @@ dependencies:
|
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
109
|
version: '0'
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
|
-
name:
|
|
111
|
+
name: minitest
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
|
113
113
|
none: false
|
|
114
114
|
requirements:
|
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
176
176
|
version: '0'
|
|
177
177
|
segments:
|
|
178
178
|
- 0
|
|
179
|
-
hash:
|
|
179
|
+
hash: 818285020742325812
|
|
180
180
|
requirements: []
|
|
181
181
|
rubyforge_project:
|
|
182
182
|
rubygems_version: 1.8.23
|