starscope 1.3.0.pre.rc1 → 1.3.0.pre.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c09fb48ea12174fc241fc799d5eb948da2a44582
4
- data.tar.gz: c56e8c9fc177ecc94d7dbd77b15af4a130b2c65f
3
+ metadata.gz: 8990a179b74e33abc0f11be5138cafbb0c753268
4
+ data.tar.gz: 24799a335d01f5cbe1402e8f375cf39b5e0ec28b
5
5
  SHA512:
6
- metadata.gz: 715d7b4ff92b00c9a9e8feee0acd4e6a198215c66b142796a5c90f5eac7f66eafdf4890fd1314d323a62c00f1bbc65f3ad3a64d57f5942c6326952e47361b34c
7
- data.tar.gz: ab315bcf74d0b42dc7420c8ee18a30fbc17b66a1a6e8259cfa93d19953d1a462de597fda4895ae3c10cf7bac762d27b546ac95ea2925c565aaf873d466920521
6
+ metadata.gz: 7181a98649ff618e53d35d1f182ecea36ee33dee532ecfa892dc576033b222010b196879270af803376bd8d6eb5b2fd4533b8950878cffbf69de2c52557c552c
7
+ data.tar.gz: 8fb98b2744e28b9cbee19a8d90866ab95d49963a5f5b331bd3f97934da76699a6867d447d64afa16bbba9d42b21952e3a720c9a1a7d4c5edfc8763be5aad9593
data/CHANGELOG.md CHANGED
@@ -13,7 +13,9 @@ New Features:
13
13
  integration with cscope's "find this C symbol" (#60).
14
14
 
15
15
  Bug Fixes:
16
- * Simplify query logic to match user expectations (#91)
16
+ * Simplify query logic to match user expectations (#91).
17
+ * Cscope: fix export of inline function definitions.
18
+ * DB: fix saving of upconverted databases in rare circumstances.
17
19
 
18
20
  v1.2.0 (2014-09-02)
19
21
  --------------------
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starscope (1.3.0.pre.rc1)
4
+ starscope (1.3.0.pre.rc2)
5
5
  backports (~> 3.6)
6
6
  oj (~> 2.9)
7
7
  parser (~> 2.1)
data/bin/starscope CHANGED
@@ -193,7 +193,8 @@ db = Starscope::DB.new(output)
193
193
  db_exists = File.exists?(options[:db])
194
194
 
195
195
  if options[:read] && db_exists
196
- new_data = db.load(options[:db])
196
+ # we consider it 'new data' if the db was upconverted from an old format
197
+ new_data = !db.load(options[:db])
197
198
  else
198
199
  # no need to run an update if we didn't read any old data
199
200
  options[:update] = false
data/lib/starscope/db.rb CHANGED
@@ -36,6 +36,7 @@ class Starscope::DB
36
36
  @tables = {}
37
37
  end
38
38
 
39
+ # returns true iff the database was already in the most recent format
39
40
  def load(filename)
40
41
  @output.extra("Reading database from `#{filename}`... ")
41
42
  current_fmt = open_db(filename)
@@ -144,13 +144,7 @@ END
144
144
  # use the column if we have it, otherwise fall back to scanning
145
145
  index = record[:col] || line.index(key)
146
146
 
147
- # keep scanning if our current index doesn't actually match the key, or if
148
- # either the preceeding or succeeding character is a word character
149
- # (meaning we've accidentally matched the middle of some other token)
150
- while index &&
151
- ((line[index, key.length] != key) ||
152
- (index > 0 && line[index-1] =~ /\w/) ||
153
- (index+key.length < line.length && line[index+key.length] =~ /\w/))
147
+ while index && !valid_index?(line, index, key)
154
148
  index = line.index(key, index+1)
155
149
  end
156
150
 
@@ -174,22 +168,27 @@ END
174
168
 
175
169
  def cscope_output(line, prev, offset, record)
176
170
  buf = ""
177
- buf << CSCOPE_GLOBAL_HACK_STOP if record[:type] == :func && record[:tbl] == :defs
178
171
 
179
- tokens = record[:name][0...-1].map {|x| x.to_s.sub(/\W+$/, '')}.select {|x| !x.empty?}.join("|")
180
- if !tokens.empty?
172
+ if record[:type] == :func && record[:tbl] == :defs
173
+ buf << " " if prev > 0 # urgh cscope
174
+ buf << CSCOPE_GLOBAL_HACK_STOP
175
+ end
176
+
177
+ record[:name][0...-1].each do |key|
181
178
  # output previous components of the name (ie the Foo in Foo::bar) as unmarked symbols
182
- rxp = Regexp.new("\\W(#{tokens})\\W")
183
- index = line.index(rxp, prev)
179
+ key = key.to_s.sub(/\W+$/, '')
180
+ next if key.empty?
181
+
182
+ index = line.index(key, prev)
183
+
184
+ while index && index+key.length < offset && !valid_index?(line, index, key)
185
+ index = line.index(key, index+1)
186
+ end
184
187
 
185
- while index
186
- tok = rxp.match(line[index..-1])[1]
187
- index += 1
188
- break if index+tok.length > offset
188
+ if index && index+key.length < offset
189
189
  buf << cscope_plaintext(line, prev, index) << "\n"
190
- buf << "#{tok}\n"
191
- prev = index + tok.length
192
- index = line.index(rxp, prev)
190
+ buf << "#{key}\n"
191
+ prev = index + key.length
193
192
  end
194
193
  end
195
194
 
@@ -203,6 +202,13 @@ END
203
202
  line
204
203
  end
205
204
 
205
+ def valid_index?(line, index, key)
206
+ # index is valid if the key exists at it, and the prev/next chars are not word characters
207
+ ((line[index, key.length] == key) &&
208
+ (index == 0 || line[index-1] !~ /\w/) &&
209
+ (index+key.length == line.length || line[index+key.length] !~ /\w/))
210
+ end
211
+
206
212
  def cscope_plaintext(line, start, stop)
207
213
  ret = line.slice(start, stop-start)
208
214
  ret.lstrip! if start == 0
@@ -2,7 +2,7 @@ require "parser/current"
2
2
 
3
3
  module Starscope::Lang
4
4
  module Ruby
5
- VERSION = 1
5
+ VERSION = 2
6
6
 
7
7
  def self.match_file(name)
8
8
  return true if name.end_with?(".rb")
@@ -78,10 +78,16 @@ module Starscope::Lang
78
78
  yield :reads, name, :line_no => loc.line, :col => loc.name.column
79
79
 
80
80
  when :lvar, :ivar, :cvar, :gvar
81
- yield :reads, scope + [node.children[0]], :line_no => loc.line, :col => loc.expression.column
81
+ yield :reads, scope + [node.children[0]], :line_no => loc.line, :col => loc.name.column
82
82
 
83
83
  when :sym
84
- yield :sym, [node.children[0]], :line_no => loc.line, :col => loc.expression.column
84
+ # handle `:foo` vs `foo: 1`
85
+ col = if loc.begin
86
+ loc.begin.column+1
87
+ else
88
+ loc.expression.column
89
+ end
90
+ yield :sym, [node.children[0]], :line_no => loc.line, :col => col
85
91
  end
86
92
  end
87
93
 
@@ -4,7 +4,7 @@ module Starscope::Queryable
4
4
 
5
5
  def query(tables, value, filters={})
6
6
  tables = [tables] if tables.is_a?(Symbol)
7
- tables.each { |t| raise NoTableError, "Table '#{t}' not found" unless @tables[t] }
7
+ tables.each { |t| raise Starscope::DB::NoTableError, "Table '#{t}' not found" unless @tables[t] }
8
8
  input = Enumerator.new do |y|
9
9
  tables.each do |t|
10
10
  @tables[t].each do |elem|
@@ -1,3 +1,3 @@
1
1
  module Starscope
2
- VERSION = "1.3.0-rc1"
2
+ VERSION = "1.3.0-rc2"
3
3
  end
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: 1.3.0.pre.rc1
4
+ version: 1.3.0.pre.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Huus