solargraph-arc 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- data/.github/workflows/ruby.yml +41 -0
- data/.gitignore +7 -0
- data/.projections.json +5 -0
- data/.rspec +1 -0
- data/.solargraph.yml +19 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +107 -0
- data/README.md +76 -0
- data/coverage/rails5.json +114 -0
- data/coverage/rails6.json +114 -0
- data/lib/solargraph/arc/annotations.rb +60 -0
- data/lib/solargraph/arc/autoload.rb +48 -0
- data/lib/solargraph/arc/debug.rb +30 -0
- data/lib/solargraph/arc/delegate.rb +34 -0
- data/lib/solargraph/arc/devise.rb +94 -0
- data/lib/solargraph/arc/patches.rb +50 -0
- data/lib/solargraph/arc/rails_api.rb +90 -0
- data/lib/solargraph/arc/relation.rb +60 -0
- data/lib/solargraph/arc/schema.rb +87 -0
- data/lib/solargraph/arc/storage.rb +42 -0
- data/lib/solargraph/arc/types.yml +22 -0
- data/lib/solargraph/arc/util.rb +61 -0
- data/lib/solargraph/arc/version.rb +5 -0
- data/lib/solargraph/arc/walker.rb +89 -0
- data/lib/solargraph-arc.rb +63 -0
- data/script/find_sources.rb +33 -0
- data/script/generate_definitions.rb +133 -0
- data/solargraph-arc.gemspec +43 -0
- data/tmp/.gitkeep +0 -0
- metadata +161 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'solargraph'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
|
4
|
+
require_relative 'solargraph/arc/patches.rb'
|
5
|
+
require_relative 'solargraph/arc/util.rb'
|
6
|
+
require_relative 'solargraph/arc/schema.rb'
|
7
|
+
require_relative 'solargraph/arc/autoload.rb'
|
8
|
+
require_relative 'solargraph/arc/relation.rb'
|
9
|
+
require_relative 'solargraph/arc/devise.rb'
|
10
|
+
require_relative 'solargraph/arc/walker.rb'
|
11
|
+
require_relative 'solargraph/arc/rails_api.rb'
|
12
|
+
require_relative 'solargraph/arc/delegate.rb'
|
13
|
+
require_relative 'solargraph/arc/storage.rb'
|
14
|
+
require_relative 'solargraph/arc/debug.rb'
|
15
|
+
require_relative 'solargraph/arc/version.rb'
|
16
|
+
|
17
|
+
module Solargraph
|
18
|
+
module Arc
|
19
|
+
class NodeParser
|
20
|
+
extend Solargraph::Parser::Legacy::ClassMethods
|
21
|
+
end
|
22
|
+
|
23
|
+
class Convention < Solargraph::Convention::Base
|
24
|
+
def global yard_map
|
25
|
+
Solargraph::Environ.new(
|
26
|
+
pins: Solargraph::Arc::RailsApi.instance.global(yard_map)
|
27
|
+
)
|
28
|
+
rescue => error
|
29
|
+
Solargraph.logger.warn(error.message + "\n" + error.backtrace.join("\n"))
|
30
|
+
EMPTY_ENVIRON
|
31
|
+
end
|
32
|
+
|
33
|
+
def local source_map
|
34
|
+
pins = []
|
35
|
+
ds = source_map.document_symbols.select {|n| n.is_a?(Solargraph::Pin::Namespace) }
|
36
|
+
ns = ds.first
|
37
|
+
|
38
|
+
return EMPTY_ENVIRON unless ns
|
39
|
+
|
40
|
+
pins += run_feature { Schema.instance.process(source_map, ns) }
|
41
|
+
pins += run_feature { Relation.instance.process(source_map, ns) }
|
42
|
+
pins += run_feature { Storage.instance.process(source_map, ns) }
|
43
|
+
pins += run_feature { Autoload.instance.process(source_map, ns, ds) }
|
44
|
+
pins += run_feature { Devise.instance.process(source_map, ns) }
|
45
|
+
pins += run_feature { Delegate.instance.process(source_map, ns) }
|
46
|
+
pins += run_feature { RailsApi.instance.local(source_map, ns) }
|
47
|
+
|
48
|
+
Solargraph::Environ.new(pins: pins)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def run_feature(&block)
|
54
|
+
yield
|
55
|
+
rescue => error
|
56
|
+
Solargraph.logger.warn(error.message + "\n" + error.backtrace.join("\n"))
|
57
|
+
[]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Solargraph::Convention.register(Solargraph::Arc::Convention) unless ENV["RAILS_ENV"] == "test"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(Dir.pwd, ARGV.first, 'config/environment')
|
2
|
+
|
3
|
+
def process(klass, hash)
|
4
|
+
result = {}
|
5
|
+
|
6
|
+
hash.each do |meth, data|
|
7
|
+
method = if meth.start_with?(".")
|
8
|
+
klass.method(meth[1..-1])
|
9
|
+
elsif meth.start_with?("#")
|
10
|
+
klass.instance_method(meth[1..-1])
|
11
|
+
end
|
12
|
+
|
13
|
+
if data["skip"]
|
14
|
+
result[method.source_location.first] ||= []
|
15
|
+
result[method.source_location.first] << meth
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
result
|
20
|
+
end
|
21
|
+
|
22
|
+
# report = process(
|
23
|
+
# ActiveRecord::Base,
|
24
|
+
# YAML.load_file("spec/definitions/activerecord5.yml")
|
25
|
+
# )
|
26
|
+
#
|
27
|
+
# report.sort_by do |owner, methods|
|
28
|
+
# -methods.size
|
29
|
+
# end.each do |owner, methods|
|
30
|
+
# puts "#{owner.to_s} - #{methods.size} methods"
|
31
|
+
# puts methods.join(", ")
|
32
|
+
# end
|
33
|
+
binding.pry
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require File.join(Dir.pwd, ARGV.first, 'config/environment')
|
2
|
+
|
3
|
+
class Model < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
def own_instance_methods(klass, test=klass.new)
|
7
|
+
(instance_methods(klass, test) - Object.methods).select do |m|
|
8
|
+
m.source_location && m.source_location.first.include?("gem")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def own_class_methods(klass)
|
13
|
+
(class_methods(klass) - Object.methods).select do |m|
|
14
|
+
m.source_location && m.source_location.first.include?("gem")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def instance_methods(klass, test=klass.new)
|
19
|
+
klass.instance_methods(true)
|
20
|
+
.sort
|
21
|
+
.reject {|m| m.to_s.start_with?("_") || (test && !test.respond_to?(m)) }
|
22
|
+
.map {|m| klass.instance_method(m) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def class_methods(klass)
|
26
|
+
klass.methods(true)
|
27
|
+
.sort
|
28
|
+
.reject {|m| m.to_s.start_with?("_") || !klass.respond_to?(m) }
|
29
|
+
.map {|m| klass.method(m) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_report(klass, test: klass.new)
|
33
|
+
result = {}
|
34
|
+
distribution = {}
|
35
|
+
|
36
|
+
own_class_methods(klass).each do |meth|
|
37
|
+
distribution[meth.source_location.first] ||= []
|
38
|
+
distribution[meth.source_location.first] << ".#{meth.name}"
|
39
|
+
|
40
|
+
result["#{klass.to_s}.#{meth.name}"] = {
|
41
|
+
types: ["undefined"],
|
42
|
+
skip: false
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
own_instance_methods(klass, test).each do |meth|
|
47
|
+
distribution[meth.source_location.first] ||= []
|
48
|
+
distribution[meth.source_location.first] << "##{meth.name}"
|
49
|
+
|
50
|
+
result["#{klass.to_s}##{meth.name}"] = {
|
51
|
+
types: ["undefined"],
|
52
|
+
skip: false
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
pp distribution
|
57
|
+
result
|
58
|
+
end
|
59
|
+
|
60
|
+
def core_ext_report(klass, test=klass.new)
|
61
|
+
result = {}
|
62
|
+
distribution = {}
|
63
|
+
|
64
|
+
class_methods(klass).select(&:source_location).select do |meth|
|
65
|
+
loc = meth.source_location.first
|
66
|
+
loc.include?("activesupport") && loc.include?("core_ext")
|
67
|
+
end.each do |meth|
|
68
|
+
distribution[meth.source_location.first] ||= []
|
69
|
+
distribution[meth.source_location.first] << ".#{meth.name}"
|
70
|
+
|
71
|
+
result["#{klass.to_s}.#{meth.name}"] = {
|
72
|
+
types: ["undefined"],
|
73
|
+
skip: false
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
instance_methods(klass, test).select(&:source_location).select do |meth|
|
78
|
+
loc = meth.source_location.first
|
79
|
+
loc.include?("activesupport") && loc.include?("core_ext")
|
80
|
+
end.each do |meth|
|
81
|
+
distribution[meth.source_location.first] ||= []
|
82
|
+
distribution[meth.source_location.first] << "##{meth.name}"
|
83
|
+
|
84
|
+
result["#{klass.to_s}##{meth.name}"] = {
|
85
|
+
types: ["undefined"],
|
86
|
+
skip: false
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
result
|
91
|
+
end
|
92
|
+
|
93
|
+
report = build_report(ActiveRecord::Base, test: Model.new)
|
94
|
+
File.write("activerecord.yml", report.deep_stringify_keys.to_yaml)
|
95
|
+
|
96
|
+
report = build_report(ActionController::Base)
|
97
|
+
File.write("actioncontroller.yml", report.deep_stringify_keys.to_yaml)
|
98
|
+
|
99
|
+
report = build_report(ActiveJob::Base)
|
100
|
+
File.write("activejob.yml", report.deep_stringify_keys.to_yaml)
|
101
|
+
|
102
|
+
Rails.application.routes.draw do
|
103
|
+
report = build_report(self.class, test: false)
|
104
|
+
File.write("routes.yml", report.deep_stringify_keys.to_yaml)
|
105
|
+
end
|
106
|
+
|
107
|
+
# [Array, String, Time, Date, Class, DateTime, File, Hash, Integer, Kernel].each do |klass|
|
108
|
+
# test = case klass
|
109
|
+
# when Time
|
110
|
+
# Time.now
|
111
|
+
# when Date
|
112
|
+
# Date.today
|
113
|
+
# when File
|
114
|
+
# false
|
115
|
+
# else
|
116
|
+
# klass.new rescue false
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# report = core_ext_report(klass, test=test)
|
120
|
+
# File.write("#{klass.to_s}.yml", report.deep_stringify_keys.to_yaml)
|
121
|
+
# end
|
122
|
+
|
123
|
+
binding.pry
|
124
|
+
|
125
|
+
|
126
|
+
# File.write("activerecord.yml", result.deep_stringify_keys.to_yaml)
|
127
|
+
|
128
|
+
# report = build_report(
|
129
|
+
# ActionController::Base,
|
130
|
+
# own_class_methods(ActionController::Base),
|
131
|
+
# own_instance_methods(ActionController::Base)
|
132
|
+
# )
|
133
|
+
# File.write("actioncontroller.yml", report.deep_stringify_keys.to_yaml)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "solargraph/arc/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "solargraph-arc"
|
8
|
+
spec.version = Solargraph::Arc::VERSION
|
9
|
+
spec.authors = ["Andrei Lisnic"]
|
10
|
+
spec.email = ["andrei.lisnic@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Awesome Rails Completions for solargraph}
|
13
|
+
spec.description = %q{Awesome Rails Completions for solargraph}
|
14
|
+
spec.homepage = "https://github.com/alisnic/solargraph-arc"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/alisnic/solargraph-arc/blob/master/CHANGELOG.md"
|
23
|
+
else
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
"public gem pushes."
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.9.0"
|
40
|
+
spec.add_development_dependency "pry", "~> 0.14.1"
|
41
|
+
spec.add_dependency "solargraph", "~> 0.44.2"
|
42
|
+
spec.add_dependency "activesupport", "~> 6.1.4.1"
|
43
|
+
end
|
data/tmp/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solargraph-arc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrei Lisnic
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.9.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.9.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.14.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: solargraph
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.44.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.44.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 6.1.4.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 6.1.4.1
|
97
|
+
description: Awesome Rails Completions for solargraph
|
98
|
+
email:
|
99
|
+
- andrei.lisnic@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
105
|
+
- ".github/workflows/ruby.yml"
|
106
|
+
- ".gitignore"
|
107
|
+
- ".projections.json"
|
108
|
+
- ".rspec"
|
109
|
+
- ".solargraph.yml"
|
110
|
+
- CHANGELOG.md
|
111
|
+
- Gemfile
|
112
|
+
- Gemfile.lock
|
113
|
+
- README.md
|
114
|
+
- coverage/rails5.json
|
115
|
+
- coverage/rails6.json
|
116
|
+
- lib/solargraph-arc.rb
|
117
|
+
- lib/solargraph/arc/annotations.rb
|
118
|
+
- lib/solargraph/arc/autoload.rb
|
119
|
+
- lib/solargraph/arc/debug.rb
|
120
|
+
- lib/solargraph/arc/delegate.rb
|
121
|
+
- lib/solargraph/arc/devise.rb
|
122
|
+
- lib/solargraph/arc/patches.rb
|
123
|
+
- lib/solargraph/arc/rails_api.rb
|
124
|
+
- lib/solargraph/arc/relation.rb
|
125
|
+
- lib/solargraph/arc/schema.rb
|
126
|
+
- lib/solargraph/arc/storage.rb
|
127
|
+
- lib/solargraph/arc/types.yml
|
128
|
+
- lib/solargraph/arc/util.rb
|
129
|
+
- lib/solargraph/arc/version.rb
|
130
|
+
- lib/solargraph/arc/walker.rb
|
131
|
+
- script/find_sources.rb
|
132
|
+
- script/generate_definitions.rb
|
133
|
+
- solargraph-arc.gemspec
|
134
|
+
- tmp/.gitkeep
|
135
|
+
homepage: https://github.com/alisnic/solargraph-arc
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata:
|
139
|
+
homepage_uri: https://github.com/alisnic/solargraph-arc
|
140
|
+
source_code_uri: https://github.com/alisnic/solargraph-arc
|
141
|
+
changelog_uri: https://github.com/alisnic/solargraph-arc/blob/master/CHANGELOG.md
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubygems_version: 3.0.9
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Awesome Rails Completions for solargraph
|
161
|
+
test_files: []
|