starscope 0.1.5 → 0.1.6
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/CHANGELOG.md +7 -1
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/starscope/langs/go.rb +16 -22
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +1 -0
- data/test/test.go +25 -0
- metadata +4 -3
data/CHANGELOG.md
CHANGED
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.6)
|
5
5
|
oj (~> 2.5)
|
6
6
|
parser (~> 2.1)
|
7
7
|
ruby-progressbar (~> 1.4)
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
debugger-ruby_core_source (1.3.1)
|
21
21
|
method_source (0.8.2)
|
22
22
|
oj (2.5.3)
|
23
|
-
parser (2.1.
|
23
|
+
parser (2.1.3)
|
24
24
|
ast (~> 1.1)
|
25
25
|
slop (~> 3.4, >= 3.4.5)
|
26
26
|
pry (0.9.12.4)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ StarScope is a similar tool for [Ruby](https://www.ruby-lang.org/) and
|
|
12
12
|
support for other languages at some point within the same framework (thus the
|
13
13
|
name StarScope, ie \*scope).
|
14
14
|
|
15
|
-
Install it as a gem:
|
15
|
+
Install it as a gem (requires at least Ruby 1.9.3):
|
16
16
|
```
|
17
17
|
$ gem install starscope
|
18
18
|
```
|
data/lib/starscope/langs/go.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module StarScope::Lang
|
2
2
|
module Go
|
3
|
-
FUNC_CALL = /([\w\.]*?\w)\(
|
3
|
+
FUNC_CALL = /([\w\.]*?\w)\(/
|
4
4
|
BUILTIN_FUNCS = ['new', 'make', 'len', 'close', 'copy', 'delete',
|
5
5
|
'int', 'int8', 'int16', 'int32', 'int64',
|
6
6
|
'uint', 'uint8', 'uint16', 'uint32', 'uint64',
|
@@ -10,7 +10,7 @@ module StarScope::Lang
|
|
10
10
|
name =~ /.*\.go$/
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.extract(file)
|
13
|
+
def self.extract(file, &block)
|
14
14
|
stack = []
|
15
15
|
scope = []
|
16
16
|
str = File.readlines(file).each_with_index do |line, line_no|
|
@@ -116,7 +116,7 @@ module StarScope::Lang
|
|
116
116
|
stack.push(:def)
|
117
117
|
when /^const\s+(\w+)\s+\w+/
|
118
118
|
yield :defs, $1, line_no: line_no, scope: scope
|
119
|
-
when /^\s+(.*?)
|
119
|
+
when /^\s+(.*?) :?=.*/
|
120
120
|
$1.split(',').each do |var|
|
121
121
|
var = var.strip
|
122
122
|
name = var.split('.')
|
@@ -127,16 +127,9 @@ module StarScope::Lang
|
|
127
127
|
yield :assigns, name[1], line_no: line_no, scope: [name[0]]
|
128
128
|
end
|
129
129
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
tmp = parse_call(match[1], line_no, scope)
|
134
|
-
yield tmp if tmp
|
135
|
-
end
|
136
|
-
end
|
137
|
-
when FUNC_CALL
|
138
|
-
tmp = parse_call($1, line_no, scope)
|
139
|
-
yield tmp if tmp
|
130
|
+
parse_call(line, line_no, scope, &block)
|
131
|
+
else
|
132
|
+
parse_call(line, line_no, scope, &block)
|
140
133
|
end
|
141
134
|
end
|
142
135
|
# if the line looks like "foo /* foo" then we enter the comment state
|
@@ -148,17 +141,18 @@ module StarScope::Lang
|
|
148
141
|
end
|
149
142
|
|
150
143
|
def self.parse_call(line, line_no, scope)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
144
|
+
line.scan(FUNC_CALL) do |match|
|
145
|
+
name = match[0].split('.').select {|chunk| not chunk.empty?}
|
146
|
+
if name.length == 1
|
147
|
+
next if name[0] == 'func'
|
148
|
+
if BUILTIN_FUNCS.include?(name[0])
|
149
|
+
yield :calls, name[0], line_no: line_no
|
150
|
+
else
|
151
|
+
yield :calls, name[0], line_no: line_no, scope: scope
|
152
|
+
end
|
157
153
|
else
|
158
|
-
|
154
|
+
yield :calls, name[-1], line_no: line_no, scope: name[0...-1]
|
159
155
|
end
|
160
|
-
else
|
161
|
-
return :calls, name[-1], line_no: line_no, scope: name[0...-1]
|
162
156
|
end
|
163
157
|
end
|
164
158
|
end
|
data/lib/starscope/version.rb
CHANGED
data/starscope.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
13
13
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
+
gem.required_ruby_version = '>= 1.9.3'
|
15
16
|
|
16
17
|
gem.add_dependency 'oj', '~> 2.5'
|
17
18
|
gem.add_dependency 'parser', '~> 2.1'
|
data/test/test.go
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
func a(c int) int {
|
4
|
+
return 3
|
5
|
+
}
|
6
|
+
|
7
|
+
func b() int {
|
8
|
+
return 0
|
9
|
+
}
|
10
|
+
|
11
|
+
func c(a, b int) int {
|
12
|
+
return 1
|
13
|
+
}
|
14
|
+
|
15
|
+
func main() {
|
16
|
+
var (
|
17
|
+
q int
|
18
|
+
t string
|
19
|
+
)
|
20
|
+
x := a(1)
|
21
|
+
y := b()
|
22
|
+
z := c(a(q), b())
|
23
|
+
|
24
|
+
a(c(b(), b()))
|
25
|
+
}
|
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.6
|
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-01-
|
12
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oj
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/starscope/langs/ruby.rb
|
147
147
|
- lib/starscope/version.rb
|
148
148
|
- starscope.gemspec
|
149
|
+
- test/test.go
|
149
150
|
homepage: https://github.com/eapache/starscope
|
150
151
|
licenses:
|
151
152
|
- MIT
|
@@ -158,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
159
|
requirements:
|
159
160
|
- - ! '>='
|
160
161
|
- !ruby/object:Gem::Version
|
161
|
-
version:
|
162
|
+
version: 1.9.3
|
162
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
164
|
none: false
|
164
165
|
requirements:
|