starscope 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +11 -1
- data/Rakefile +5 -2
- data/bin/starscope +1 -2
- data/doc/LANGUAGE_SUPPORT.md +1 -1
- data/lib/starscope/langs/javascript.rb +27 -4
- data/lib/starscope/version.rb +1 -1
- data/starscope.gemspec +1 -0
- data/test/fixtures/sample_javascript.js +3 -0
- data/test/functional/starscope_test.rb +3 -1
- data/test/unit/langs/javascript_test.rb +17 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a53857d630c84472be96e4290b3ea5e0db5a91f
|
4
|
+
data.tar.gz: fce33444e0824932570e254b79299eb02abdd3e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f99e826dd012862204a89d4578920835952f28a08929e22612f04dda3861c15d75919bac97f2fc2c89dc5e632db61ec1f49ae2619474814fec4e1fb492ea2cbf
|
7
|
+
data.tar.gz: eefdd45150054b3039ef7bd540a008fa44231def86f019803f0625a3b3945a145754fe927ac16b32a857e53a8828d32910b933a6ec97914b8eb33b2a2c6c96ab
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
v1.5.
|
4
|
+
v1.5.1 (trunk)
|
5
|
+
--------------------
|
6
|
+
|
7
|
+
Improvements:
|
8
|
+
* Support CommonJS require syntax and ES6 import syntax in JavaScript (#146).
|
9
|
+
|
10
|
+
Bug Fixes:
|
11
|
+
* Fix handling of Ctrl-C in line-mode to exit cleanly instead of crashing.
|
12
|
+
* Fix handling of braceless fat-arrow methods in JavaScript (#147).
|
13
|
+
|
14
|
+
v1.5.0 (2015-09-24)
|
5
15
|
--------------------
|
6
16
|
|
7
17
|
New Features:
|
data/Rakefile
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
|
4
5
|
Rake::TestTask.new do |t|
|
5
6
|
t.test_files = FileList['test/**/*_test.rb']
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
RuboCop::RakeTask.new
|
10
|
+
|
11
|
+
desc 'Run tests and style checks'
|
12
|
+
task default: [:test, :rubocop]
|
data/bin/starscope
CHANGED
data/doc/LANGUAGE_SUPPORT.md
CHANGED
@@ -62,7 +62,7 @@ belongs (basically its type). Current tables already include:
|
|
62
62
|
* `defs` for definitions of classes, functions, modules, etc.
|
63
63
|
* `end` for the matching *end* of each definition
|
64
64
|
* `assigns` for variable assignment
|
65
|
-
* `requires` for required files in Ruby
|
65
|
+
* `requires` for required files in Ruby and JavaScript
|
66
66
|
* `imports` for imported packages in Golang
|
67
67
|
* `reads` for reading of variables, constants etc. (e.g. use in an expression)
|
68
68
|
* `sym` for Ruby symbols
|
@@ -4,7 +4,7 @@ require 'sourcemap'
|
|
4
4
|
|
5
5
|
module Starscope::Lang
|
6
6
|
module Javascript
|
7
|
-
VERSION =
|
7
|
+
VERSION = 1
|
8
8
|
|
9
9
|
def self.match_file(name)
|
10
10
|
name.end_with?('.js')
|
@@ -49,17 +49,28 @@ module Starscope::Lang
|
|
49
49
|
next if type == :class
|
50
50
|
|
51
51
|
mapping = map.bsearch(SourceMap::Offset.new(node.range.to.line, node.range.to.char))
|
52
|
-
|
52
|
+
if lines[mapping.original.line - 1].include? '}'
|
53
|
+
yield :end, '}', line_no: mapping.original.line, type: type
|
54
|
+
else
|
55
|
+
yield :end, '', line_no: mapping.original.line, type: type, col: mapping.original.column
|
56
|
+
end
|
53
57
|
when RKelly::Nodes::FunctionCallNode
|
54
58
|
name = node_name(node.value)
|
55
59
|
next unless name
|
56
60
|
|
61
|
+
node = node.arguments.value[0] if name == 'require'
|
62
|
+
|
57
63
|
line = find_line(node.range.from, map, lines, name)
|
58
64
|
next unless line
|
59
65
|
|
60
|
-
yield :calls, name, line_no: line
|
61
66
|
found[name] ||= Set.new
|
62
67
|
found[name].add(line)
|
68
|
+
|
69
|
+
if name == 'require'
|
70
|
+
yield :requires, node.value[1...-1], line_no: line
|
71
|
+
else
|
72
|
+
yield :calls, name, line_no: line
|
73
|
+
end
|
63
74
|
end
|
64
75
|
end
|
65
76
|
|
@@ -73,6 +84,15 @@ module Starscope::Lang
|
|
73
84
|
line = find_line(node.range.from, map, lines, node.name)
|
74
85
|
next unless line
|
75
86
|
|
87
|
+
if node.value.is_a?(RKelly::Nodes::AssignExprNode) &&
|
88
|
+
node.value.value.is_a?(RKelly::Nodes::FunctionCallNode) &&
|
89
|
+
node.value.value.value.is_a?(RKelly::Nodes::ResolveNode) &&
|
90
|
+
node.value.value.value.value == 'require'
|
91
|
+
found[node.name] ||= Set.new
|
92
|
+
found[node.name].add(line)
|
93
|
+
next
|
94
|
+
end
|
95
|
+
|
76
96
|
next if found[node.name] && found[node.name].include?(line)
|
77
97
|
yield :defs, node.name, line_no: line
|
78
98
|
found[node.name] ||= Set.new
|
@@ -107,7 +127,10 @@ module Starscope::Lang
|
|
107
127
|
def self.find_line(from, map, lines, name)
|
108
128
|
mapping = map.bsearch(SourceMap::Offset.new(from.line, from.char))
|
109
129
|
return unless mapping
|
110
|
-
|
130
|
+
|
131
|
+
line = lines[mapping.original.line - 1]
|
132
|
+
return unless line.include?(name) || (name == 'require' && line.include?('import'))
|
133
|
+
|
111
134
|
mapping.original.line
|
112
135
|
end
|
113
136
|
end
|
data/lib/starscope/version.rb
CHANGED
data/starscope.gemspec
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
import React from 'react-native';
|
4
4
|
|
5
|
+
let madness = require('foo-bar');
|
6
|
+
|
5
7
|
var {
|
6
8
|
Component,
|
7
9
|
StyleSheet,
|
@@ -15,6 +17,7 @@ var styles = StyleSheet.create({
|
|
15
17
|
justifyContent: 'center',
|
16
18
|
alignItems: 'center',
|
17
19
|
},
|
20
|
+
bracelessMethod: () => 42,
|
18
21
|
});
|
19
22
|
|
20
23
|
var func1 = () => {
|
@@ -22,7 +22,9 @@ describe 'starscope executable script' do
|
|
22
22
|
it 'must produce a valid database dump' do
|
23
23
|
lines = `#{EXTRACT} -d requires`.lines.to_a
|
24
24
|
lines[1].split.first.must_equal 'date'
|
25
|
-
lines[2].split.first.must_equal '
|
25
|
+
lines[2].split.first.must_equal 'foo-bar'
|
26
|
+
lines[3].split.first.must_equal 'react-native'
|
27
|
+
lines[4].split.first.must_equal 'zlib'
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'must correctly query the database' do
|
@@ -35,11 +35,14 @@ describe Starscope::Lang::Javascript do
|
|
35
35
|
defs.must_include :foo
|
36
36
|
defs.must_include :MyStat
|
37
37
|
defs.must_include :myStatFunc
|
38
|
+
defs.must_include :bracelessMethod
|
38
39
|
|
39
40
|
defs.wont_include :setStyle
|
40
41
|
defs.wont_include :setState
|
41
42
|
defs.wont_include :fontFamily
|
42
43
|
defs.wont_include :navigator
|
44
|
+
defs.wont_include :madness
|
45
|
+
defs.wont_include :React
|
43
46
|
end
|
44
47
|
|
45
48
|
it 'must only tag static classes once' do
|
@@ -48,7 +51,12 @@ describe Starscope::Lang::Javascript do
|
|
48
51
|
|
49
52
|
it 'must identify endings' do
|
50
53
|
@db.keys.must_include :end
|
51
|
-
@db[:end].count.must_equal
|
54
|
+
@db[:end].count.must_equal 12
|
55
|
+
|
56
|
+
# bracelessMethod doesn't have a taggable end token so
|
57
|
+
# we have to do a little dancing with an empty name and a precise column
|
58
|
+
@db[:end][0][:name].must_equal [:'']
|
59
|
+
@db[:end][0][:col].must_equal 27
|
52
60
|
end
|
53
61
|
|
54
62
|
it 'must identify function calls' do
|
@@ -65,4 +73,12 @@ describe Starscope::Lang::Javascript do
|
|
65
73
|
calls[:pop].count.must_equal 1
|
66
74
|
calls[:_tabItem].count.must_equal 3
|
67
75
|
end
|
76
|
+
|
77
|
+
it 'must identify module requires' do
|
78
|
+
@db.keys.must_include :requires
|
79
|
+
requires = @db[:requires].group_by { |x| x[:name][-1] }
|
80
|
+
|
81
|
+
requires.keys.must_include :'foo-bar'
|
82
|
+
requires.keys.must_include :'react-native'
|
83
|
+
end
|
68
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Huus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '1.1'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.34.2
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.34.2
|
167
181
|
description: |2
|
168
182
|
Starscope is a code indexer, search and navigation tool for Ruby, Golang, and JavaScript.
|
169
183
|
Inspired by the extremely popular Ctags and Cscope utilities, Starscope can
|
@@ -243,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
257
|
version: '0'
|
244
258
|
requirements: []
|
245
259
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.
|
260
|
+
rubygems_version: 2.4.8
|
247
261
|
signing_key:
|
248
262
|
specification_version: 4
|
249
263
|
summary: Smart code search and indexing
|