starscope 1.1.1 → 1.1.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2235e7d803ca938cc48e75eee57d14eb6b5b7a9d
4
+ data.tar.gz: 20c2ff4775299f5b0fa8b96aa38d260a62a48149
5
+ SHA512:
6
+ metadata.gz: 900973601a54f6383c1b58f2302d5c9f6f37e6333540b4ff36167bff8523038d842bf78f6b2337b518208381e2b395634cf93e429750ec879a1b828b4825ef5e
7
+ data.tar.gz: 6570238f423d05dcf5e17f3b133380f2d7e77f542520d7d65e3572062de9f93c87ac8f97350c8b47903a82e881ba0361c19a4358769d9f87ce78311e70a22647
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- v1.1.1 (trunk)
4
+ v1.1.2 (trunk)
5
+ --------------------
6
+
7
+ Bug Fixes:
8
+ * Don't crash exporting to cscope if tokens overlap.
9
+ * In golang, don't parse inside string literals.
10
+
11
+ v1.1.1 (2014-07-21)
5
12
  --------------------
6
13
 
7
14
  New Features:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starscope (1.1.1)
4
+ starscope (1.1.2)
5
5
  oj (~> 2.9)
6
6
  parser (~> 2.1)
7
7
  ruby-progressbar (~> 1.5)
data/README.md CHANGED
@@ -2,7 +2,7 @@ StarScope
2
2
  =========
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/starscope.png)](http://badge.fury.io/rb/starscope)
5
- [![Build Status](https://travis-ci.org/eapache/starscope.png?branch=master)](https://travis-ci.org/eapache/starscope)
5
+ [![Build Status](https://travis-ci.org/eapache/starscope.svg?branch=master)](https://travis-ci.org/eapache/starscope)
6
6
 
7
7
  Anyone who has done much programming in C (or C++) on a Unix-based OS has come
8
8
  across the fantastic [Cscope](http://cscope.sourceforge.net/) tool. Sadly, it
data/lib/starscope/db.rb CHANGED
@@ -218,6 +218,8 @@ END
218
218
  buf << line_no.to_s << " "
219
219
  toks.each do |offset, record|
220
220
 
221
+ next if offset < prev # this probably indicates an extractor bug
222
+
221
223
  # Don't export nested functions, cscope barfs on them since C doesn't
222
224
  # have them at all. Skipping tokens is easy; since prev isn't updated
223
225
  # they get turned into plain text automatically.
@@ -3,6 +3,7 @@ module StarScope::Lang
3
3
  FUNC_CALL = /([\w\.]*?\w)\(/
4
4
  END_OF_BLOCK = /^\s*\}\s*$/
5
5
  END_OF_GROUP = /^\s*\)\s*$/
6
+ STRING_LITERAL = /".+?"/
6
7
  BUILTIN_FUNCS = ['new', 'make', 'len', 'close', 'copy', 'delete',
7
8
  'int', 'int8', 'int16', 'int32', 'int64',
8
9
  'uint', 'uint8', 'uint16', 'uint32', 'uint64',
@@ -16,18 +17,18 @@ module StarScope::Lang
16
17
  def self.extract(file, &block)
17
18
  stack = []
18
19
  scope = []
19
- str = File.readlines(file).each_with_index do |line, line_no|
20
+ File.readlines(file).each_with_index do |line, line_no|
20
21
  line_no += 1 # zero-index to one-index
21
22
 
22
23
  # strip single-line comments like // foo
23
- match = /(.*)\/\//.match(line)
24
- line = match[1] if match
24
+ match = /\/\//.match(line)
25
+ line = match.pre_match if match
25
26
  # strip single-line comments like foo /* foo */ foo
26
- match = /(.*?)\/\*.*\*\/(.*)/.match(line)
27
- line = match[1] + match[2] if match
27
+ match = /\/\*.*\*\//.match(line)
28
+ line = match.pre_match + match.post_match if match
28
29
  # strip end-of-line comment starters like foo /* foo \n
29
- match = /(.*?)\/\*/.match(line)
30
- line = match[1] if match
30
+ match = /\/\*/.match(line)
31
+ line = match.pre_match if match
31
32
  ends_with_comment = !match.nil?
32
33
 
33
34
  # if we're in a block comment, wait for it to end
@@ -38,6 +39,15 @@ module StarScope::Lang
38
39
  stack.pop
39
40
  end
40
41
 
42
+ if stack[-1] != :import && !line.start_with?("import")
43
+ # strip string literals like "foo" unless they're part of an import
44
+ pos = 0
45
+ while match = STRING_LITERAL.match(line[pos..-1])
46
+ line = line[0...pos] + match.pre_match + "\"\"" + match.post_match
47
+ pos += match.begin(0) + 2
48
+ end
49
+ end
50
+
41
51
  # poor-man's parser
42
52
  case stack[-1]
43
53
  when :struct
@@ -1,3 +1,3 @@
1
1
  module StarScope
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -21,7 +21,7 @@ const (
21
21
 
22
22
  var x error = fmt.Errorf("ABC")
23
23
 
24
- const y error = fmt.Errorf("ABC")
24
+ const y string = "ABC"
25
25
 
26
26
  type foo interface {
27
27
  bar() int
@@ -43,6 +43,11 @@ func ttt() (int, int) {
43
43
  return 1, 2
44
44
  }
45
45
 
46
+ type Message struct {
47
+ Topic, Value string
48
+ Key *int
49
+ }
50
+
46
51
  func main() {
47
52
  var (
48
53
  q int
@@ -64,4 +69,8 @@ func main() {
64
69
 
65
70
  fmt.Println(n)
66
71
  fmt.Println(t)
72
+
73
+ msg := &Message{Topic: "single_partition", Key: nil, Value: string(fmt.Sprintf("testing %d", q))}
74
+
75
+ fmt.Print(msg)
67
76
  }
@@ -38,7 +38,7 @@ class TestGolang < Minitest::Test
38
38
 
39
39
  def test_ends
40
40
  assert @db.keys.include? :end
41
- assert @db[:end].count == 6
41
+ assert @db[:end].count == 7
42
42
  end
43
43
 
44
44
  def test_function_calls
@@ -53,7 +53,7 @@ class TestGolang < Minitest::Test
53
53
  assert calls[:b].count == 4
54
54
  assert calls[:c].count == 4
55
55
  assert calls[:ttt].count == 2
56
- assert calls[:Errorf].count == 2
56
+ assert calls[:Errorf].count == 1
57
57
  end
58
58
 
59
59
  def test_variable_assigns
@@ -64,10 +64,17 @@ class TestGolang < Minitest::Test
64
64
  assert assigns.keys.include? :z
65
65
  assert assigns.keys.include? :n
66
66
  assert assigns.keys.include? :m
67
+ assert assigns.keys.include? :msg
67
68
  assert assigns[:x].count == 2
68
69
  assert assigns[:y].count == 1
69
70
  assert assigns[:z].count == 1
70
71
  assert assigns[:n].count == 1
71
72
  assert assigns[:m].count == 2
72
73
  end
74
+
75
+ def test_imports
76
+ assert @db.keys.include? :imports
77
+ imports = @db[:imports].group_by {|x| x[:name][-1]}
78
+ assert imports.keys.include? :fmt
79
+ end
73
80
  end
@@ -19,7 +19,7 @@ describe StarScope::Record do
19
19
  rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 1})
20
20
  rec[:line].must_equal "package main"
21
21
 
22
- rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 66})
22
+ rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 71})
23
23
  rec[:line].must_equal "\tfmt.Println(t)"
24
24
 
25
25
  rec = StarScope::Record.build(RUBY_SAMPLE, :a, {:line_no => 1})
@@ -28,7 +28,7 @@ describe StarScope::Record do
28
28
  rec = StarScope::Record.build(RUBY_SAMPLE, :a, {:line_no => 164})
29
29
  rec[:line].must_equal "end"
30
30
 
31
- rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 67})
31
+ rec = StarScope::Record.build(GOLANG_SAMPLE, :a, {:line_no => 44})
32
32
  rec[:line].must_equal "}"
33
33
  end
34
34
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
5
- prerelease:
4
+ version: 1.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evan Huus
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-21 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: oj
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: parser
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ruby-progressbar
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,49 +69,43 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: pry
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: minitest
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: A tool like the venerable cscope, but for ruby, golang and other languages
@@ -166,30 +151,26 @@ files:
166
151
  homepage: https://github.com/eapache/starscope
167
152
  licenses:
168
153
  - MIT
154
+ metadata: {}
169
155
  post_install_message:
170
156
  rdoc_options: []
171
157
  require_paths:
172
158
  - lib
173
159
  required_ruby_version: !ruby/object:Gem::Requirement
174
- none: false
175
160
  requirements:
176
- - - ! '>='
161
+ - - '>='
177
162
  - !ruby/object:Gem::Version
178
163
  version: 1.8.7
179
164
  required_rubygems_version: !ruby/object:Gem::Requirement
180
- none: false
181
165
  requirements:
182
- - - ! '>='
166
+ - - '>='
183
167
  - !ruby/object:Gem::Version
184
168
  version: '0'
185
- segments:
186
- - 0
187
- hash: 4529526884689841888
188
169
  requirements: []
189
170
  rubyforge_project:
190
- rubygems_version: 1.8.23
171
+ rubygems_version: 2.0.14
191
172
  signing_key:
192
- specification_version: 3
173
+ specification_version: 4
193
174
  summary: A code indexer and analyzer
194
175
  test_files:
195
176
  - test/fixtures/db_old.json.gz