Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.39 #311

Merged
merged 292 commits into from
Apr 25, 2020
Merged

V0.39 #311

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
292 commits
Select commit Hold shift + click to select a range
e93d6a2
RubyVM visibility processing.
castwide Nov 30, 2019
b490243
RubyVM syntax error handling.
castwide Nov 30, 2019
7660190
RubyVM rescue processing.
castwide Nov 30, 2019
af4386d
RubyVM alias_method processing.
castwide Nov 30, 2019
03795b8
Node type fix.
castwide Nov 30, 2019
8689a37
RubyVM constant rebasing.
castwide Nov 30, 2019
1d85e6c
RubyVM include and extend processing.
castwide Nov 30, 2019
78652fe
RubyVM processes private constants.
castwide Nov 30, 2019
ef106de
RubyVM module_function processing.
castwide Nov 30, 2019
6b9bce2
Check call type of visibility methods.
castwide Nov 30, 2019
5e8ca42
Dirty assignment tests.
castwide Nov 30, 2019
af2bfd8
RubyVM NodeChainer.
castwide Nov 30, 2019
e24f546
BaseVariable#probe gets range from node.
castwide Nov 30, 2019
dc79a57
RubyVM string detection.
castwide Dec 1, 2019
e1625c3
RubyVM chains.
castwide Dec 1, 2019
761678d
RubyVM recipient node detection.
castwide Dec 1, 2019
9b326d1
RubyVM cursor, chain, and return node fixes.
castwide Dec 1, 2019
0e99a08
RubyVM block_pass links.
castwide Dec 1, 2019
2e94418
RubyVM node chainer processes opcalls.
castwide Dec 1, 2019
2d795ec
RubyVM detects strings in unsynchronized sources.
castwide Dec 1, 2019
1cef807
RubyVM chains and probes.
castwide Dec 1, 2019
3fe9da1
Parser-independent test.
castwide Dec 1, 2019
f6d51c1
Vary specs based on the parser.
castwide Dec 1, 2019
ebf9e2a
Environment template checks parser type.
castwide Dec 1, 2019
da6251d
Resbody node checks for exception variable.
castwide Dec 1, 2019
64767ac
Finding references includes local variables.
castwide Dec 1, 2019
67388a5
Nil node handling in variable probes.
castwide Dec 1, 2019
2c6f63d
Register lambda node processor.
castwide Jan 16, 2020
92f23d4
Merge branch 'master' into rubyvm
castwide Jan 16, 2020
4817e54
Temporarily disable exception variables.
castwide Jan 16, 2020
3927ab4
CommentRipper caches buffer lines array.
castwide Jan 16, 2020
5222117
Merge branch 'master' into rubyvm
castwide Jan 16, 2020
1b14104
RubyVM detects literal booleans.
castwide Jan 16, 2020
5a5db78
RubyVM detects rescued exception variables.
castwide Jan 16, 2020
d1c055d
TypeChecker handles RubyVM VCALL nodes.
castwide Jan 16, 2020
8669758
Skip legacy specs when using RubyVM.
castwide Jan 16, 2020
482ccce
Off by one error.
castwide Jan 16, 2020
4bfb116
Off by one error.
castwide Jan 16, 2020
20126f1
Fix module reference in legacy NodeMethods spec.
castwide Jan 16, 2020
7ac97f8
Register DASGN_CURR node processor.
castwide Jan 17, 2020
0983889
Merge branch 'master' into rubyvm
castwide Jan 17, 2020
c6fec06
Chain ATTRASGN nodes.
castwide Jan 17, 2020
ea43b4a
Refactoring TypeChecker to use chains instead of nodes (WIP)
castwide Jan 17, 2020
49dc12b
Handle blank lines when stringifying comments.
castwide Jan 17, 2020
206c486
Minor refactoring.
castwide Jan 17, 2020
9886b8a
TypeChecker reports not enough arguments.
castwide Jan 17, 2020
fc82924
Merge branch 'master' into rubyvm
castwide Jan 18, 2020
5f71f92
Kernel method handling.
castwide Jan 18, 2020
718e958
Remove Chain::Call#head?
castwide Jan 18, 2020
d328d6b
SendNode handles mapped methods without arguments.
castwide Jan 18, 2020
a465c43
Stale code.
castwide Jan 18, 2020
59d0162
DRY node methods.
castwide Jan 18, 2020
0fdfd06
Merge branch 'master' into rubyvm
castwide Jan 18, 2020
0c1a198
CommentRipper ignores frozen_string_literal.
castwide Jan 18, 2020
103f97f
CommentRipper handles invalid byte sequences.
castwide Jan 18, 2020
a9de2ef
Formatting.
castwide Jan 18, 2020
84911ea
Remove BLOCK from foldable node types.
castwide Jan 18, 2020
8e221c3
Predicate method specs.
castwide Jan 18, 2020
fb9639c
Merge branch 'master' into rubyvm
castwide Jan 18, 2020
763e7a5
Add STR to foldable node types.
castwide Jan 18, 2020
e5283e8
Merge branch 'master' into rubyvm-inference
castwide Jan 19, 2020
d161245
Method pin checks for nil type return nodes.
castwide Jan 19, 2020
9dbdea9
RubyVM AST changes in Ruby 2.7.0
castwide Jan 19, 2020
05dc135
Local merge branch 'rubyvm'
castwide Jan 19, 2020
33bf023
TypeChecker rules and checks (WIP).
castwide Jan 20, 2020
dcac7c4
Typechecker#internal?
castwide Jan 20, 2020
14e97cb
TypeChecker requires type tags at strong level.
castwide Jan 20, 2020
241e061
Tag type checks.
castwide Jan 20, 2020
2934ee8
TypeChecker normal level specs.
castwide Jan 20, 2020
ca4eae7
Typed and strict TypeChecker specs.
castwide Jan 20, 2020
948a51e
Merge branch 'typecheck-rules' into rubyvm
castwide Jan 20, 2020
50200f4
Strict call validation specs.
castwide Jan 20, 2020
9f01be9
Ignore type inference for method macros.
castwide Jan 20, 2020
d52379c
Argument type checks.
castwide Jan 21, 2020
0f3b7dd
Merge branch 'master' into rubyvm
castwide Jan 21, 2020
9599cb7
Merge branch 'master' into typecheck-rules
castwide Jan 21, 2020
3fecdb5
Stale comments.
castwide Jan 21, 2020
52feca2
Remove duplicate test.
castwide Jan 21, 2020
d801891
Normal type check ignores undefined argument types.
castwide Jan 21, 2020
dacace5
Source method pins with empty bodies infer nil.
castwide Jan 21, 2020
5dc9b26
Nil method inferences from clips.
castwide Jan 21, 2020
df1d75e
Refactored typecheck reporter.
castwide Jan 21, 2020
899a227
Multi-level parameter checks.
castwide Jan 21, 2020
a735517
Unresolved call handling.
castwide Jan 21, 2020
e2cceb7
Merge branch 'master' into typecheck-rules
castwide Jan 21, 2020
f085454
Typecheck kwargs in calls.
castwide Jan 21, 2020
f72278c
Type checker validates duck type parameters.
castwide Jan 21, 2020
b2234f2
Merge branch 'master' into rubyvm
castwide Jan 21, 2020
a9e234e
TypeChecker validates kwrestargs.
castwide Jan 21, 2020
48212c2
TypeChecker treats optional hashes as kwrestargs.
castwide Jan 21, 2020
6e268bd
Remove stale TypeChecker code.
castwide Jan 21, 2020
1a45941
Merge branch 'master' into typecheck-rules
castwide Jan 21, 2020
e21c9b9
TypeChecker qualifies param types in declaration context.
castwide Jan 21, 2020
3592982
Do not check inference on attributes.
castwide Jan 22, 2020
e936cea
CLI executable uses new type checker.
castwide Jan 22, 2020
28145e2
TypeChecker attribute spec.
castwide Jan 22, 2020
c2c6bf0
New method node stub.
castwide Jan 22, 2020
6ff7015
Documentation.
castwide Jan 22, 2020
4b64ac6
TypeChecker optional parameter spec.
castwide Jan 22, 2020
7d5408c
Self handling in type checks.
castwide Jan 22, 2020
3dfb684
TypeChecker resolves self on declared and inferred types.
castwide Jan 22, 2020
21935dc
Merge branch 'master' into typecheck-rules
castwide Jan 22, 2020
4cab1d1
Reduce normal type checking rules.
castwide Jan 22, 2020
5b514bd
Strong type checking rules.
castwide Jan 22, 2020
5761405
TypeChecker validates calls at strict or higher.
castwide Jan 22, 2020
43b0b13
Reduce strictness of typed level.
castwide Jan 22, 2020
8af798f
Merge branch 'master' into typecheck-rules
castwide Jan 22, 2020
2598fd2
Merge branch 'master' into rubyvm
castwide Jan 22, 2020
ddd144f
Merge branch 'master' into rubyvm
castwide Jan 24, 2020
f3bb829
Cached core pins.
castwide Jan 26, 2020
e48429e
Serialize stdlib pins (WIP)
castwide Jan 26, 2020
21138a9
Serialize gem pins.
castwide Jan 26, 2020
c589d6a
Stale code.
castwide Jan 26, 2020
22de3a4
Moved chainer calls.
castwide Jan 26, 2020
d404318
Merge branch 'serialize-core' into rubyvm-serial
castwide Jan 26, 2020
c608fc7
Merge branch 'master' into typecheck-rules
castwide Jan 26, 2020
e72456e
Log YardMap loads.
castwide Jan 26, 2020
6012686
Merge branch 'typecheck-rules' into rubyvm
castwide Jan 26, 2020
f6272a6
RubyVM detects method body nodes.
castwide Jan 26, 2020
6fa4da8
RubyVM call node detection (WIP).
castwide Jan 26, 2020
3c6f507
Method parameter types.
castwide Jan 26, 2020
478a424
Unused node methods.
castwide Jan 26, 2020
3cf216e
Refactoring node methods (WIP).
castwide Jan 26, 2020
cf97ee4
Move location of methods defined in macros.
castwide Jan 27, 2020
0304a23
Documentation.
castwide Jan 27, 2020
f5708cf
CoreDocs creates gems directory.
castwide Jan 27, 2020
c51cb9f
CoreDocs.require_minimum always creates cache directories.
castwide Jan 27, 2020
224b5bb
RubyVM handles args in for constructs.
castwide Jan 27, 2020
37f0183
Chains infer String from interpolated strings.
castwide Jan 27, 2020
a8fffe0
Stale code.
castwide Jan 27, 2020
c37c317
Return tags.
castwide Jan 27, 2020
86d9053
Virtual new method spec.
castwide Jan 27, 2020
5c3daae
Infer undefined from methods with nil nodes.
castwide Jan 28, 2020
f6924fd
Rearranging type checker specs by level (WIP).
castwide Jan 28, 2020
ee71e28
Stale typecheck diagnostics test.
castwide Jan 28, 2020
48ab471
Validate attribute writer arguments.
castwide Jan 28, 2020
f22cb67
Strong type checks inherit param tags.
castwide Jan 28, 2020
8a60c6d
Simple matches in any_types_match?
castwide Jan 28, 2020
195a296
Fix argument chains.
castwide Jan 28, 2020
bd28376
Return nodes include AND.
castwide Jan 28, 2020
8fcdb2a
Return AND nodes inside RETURN nodes.
castwide Jan 28, 2020
b615414
Type tags.
castwide Jan 28, 2020
38a07b9
Object#dup core fill deletes overloads.
castwide Jan 28, 2020
6225381
String#each_line core fill.
castwide Jan 28, 2020
16b0af6
Implicit rest and block parameter types.
castwide Jan 28, 2020
724aa2c
Typed level uses loose return tag matches.
castwide Jan 28, 2020
4a00f7b
Return tag validation specs.
castwide Jan 28, 2020
8d624e9
Documentation.
castwide Jan 28, 2020
c4b3fee
Type tag.
castwide Jan 28, 2020
e599337
Check variable assignments for external calls.
castwide Jan 28, 2020
754950e
Validate kwoptargs without arguments.
castwide Jan 28, 2020
6daacf8
Parameter traversal and display.
castwide Jan 29, 2020
50d9bce
Validate optional hash args as kwrestargs.
castwide Jan 29, 2020
e597400
Rearranging node methods.
castwide Jan 29, 2020
bbc0a67
Legacy node chainer attaches nodes.
castwide Jan 29, 2020
0c92a18
Legacy node methods and specs.
castwide Jan 29, 2020
fc2b667
Add OPCALL to call nodes.
castwide Jan 29, 2020
b754445
Merge branch 'v0.39' (legacy) into v0.39
castwide Jan 29, 2020
45c8dff
KW_ARG node changed in Ruby 2.7.
castwide Jan 29, 2020
36bca0f
Merge branch 'v0.39' (Windows) into v0.39
castwide Jan 29, 2020
1f4c6ab
Stale code.
castwide Jan 29, 2020
aff8b16
Add asgn_code to kwoptargs.
castwide Jan 29, 2020
52411f3
Prefer @return to @type in constant tags.
castwide Jan 29, 2020
7a2dd08
All BaseMethod pins have node attributes.
castwide Jan 29, 2020
021735d
Constant links resolve nested constants.
castwide Jan 30, 2020
22af9ef
Constant link iterates over all pins for resolution.
castwide Jan 30, 2020
7b8d05d
TypeChecker handles `@abstract` tags.
castwide Jan 31, 2020
e0fbf03
Cursor recipient detection (WIP).
castwide Jan 31, 2020
495393c
Clip#signify edge cases (WIP).
castwide Feb 2, 2020
0f11678
Cursor#recipient_node edge cases (WIP).
castwide Feb 2, 2020
92c1410
Cursor#recipient_node handles unsynchronized sources with parentheses.
castwide Feb 2, 2020
7be216e
Cursor#recipient_node handles synchronized sources with trailing commas.
castwide Feb 2, 2020
20edb8f
Redundant code and related specs.
castwide Feb 2, 2020
33b88d9
ApiMap#cursor_at raises FileNotFoundError.
castwide Feb 2, 2020
67b0944
Cursor#recipient_node with unsynchronized nested symbols.
castwide Feb 2, 2020
60b8f9d
Cursor#recipient_node nesting and fencepost issues.
castwide Feb 2, 2020
e42c36a
Host#diagnose rescues FileNotFoundError.
castwide Feb 2, 2020
112d956
Refactored find_recipient_node.
castwide Feb 2, 2020
8e9181a
Legacy find_recipient_node (WIP).
castwide Feb 2, 2020
9209b81
Legacy find_recipient_node conforms to specs.
castwide Feb 2, 2020
8bc0259
Numeric core fills.
castwide Feb 3, 2020
3566a2b
public_suffix dependency for Ruby < 2.3.
castwide Feb 3, 2020
246628a
Fuzzier inheritance checks.
castwide Feb 9, 2020
c3657d8
Merge branch 'v0.39-signify' into v0.39
castwide Feb 9, 2020
371d524
Merge branch 'v0.39-reverse-inheritance-check' into v0.39
castwide Feb 9, 2020
d124b0e
Unused method.
castwide Feb 9, 2020
7c53c11
RubyVM NodeChainer recognizes SUPER.
castwide Feb 16, 2020
b611c5a
Superclass namespace detection.
castwide Feb 16, 2020
dcd8b86
Documentation and minor refactoring.
castwide Feb 16, 2020
9af28aa
Fix super/zsuper bug in legacy parser.
castwide Feb 26, 2020
9110387
Merge branch 'v0.39-super' into v0.39
castwide Feb 26, 2020
ad8df9b
Refactored uri queue synchronization. (#289)
castwide Mar 6, 2020
7b0b007
Merge branch 'master' into v0.39
castwide Mar 21, 2020
1ac20e8
Merge branch 'v0.39' of github.com:castwide/solargraph into v0.39
castwide Mar 21, 2020
44314d2
Merge branch 'master' into v0.39
castwide Mar 23, 2020
5b455e2
Constant resolution finds nearest names (#287)
castwide Mar 23, 2020
ce974f5
Unused method Cursor#first_char_offset.
castwide Mar 23, 2020
9a8a4af
Minor typecheck fixes.
castwide Mar 23, 2020
54dffd8
Arity checks.
castwide Mar 25, 2020
478db29
Merge branch 'master' into v0.39
castwide Mar 27, 2020
992640b
Integer#+ override.
castwide Apr 4, 2020
cff21ab
Merge branch 'v0.39-numeric' into v0.39
castwide Apr 4, 2020
7ed13fc
Numeric#+ mapping and checking.
castwide Apr 4, 2020
6a3bc1a
Verify child node in convert_hash
castwide Apr 6, 2020
202e357
Broaden rest argument check.
castwide Apr 6, 2020
d319fe6
Validate optional argument arity.
castwide Apr 6, 2020
2c1aefb
Exception for restargs in core methods.
castwide Apr 7, 2020
bca7aca
BundlerMethods documentation.
castwide Apr 7, 2020
f8e9490
BaseMethod#explicit? attribute.
castwide Apr 8, 2020
30a79e3
TypeChecker does not check arity of non-explicit methods.
castwide Apr 8, 2020
4de58f0
Merge branch 'v0.39-core-restargs' into v0.39
castwide Apr 8, 2020
ee0a577
Core == method hack.
castwide Apr 9, 2020
2744f08
Arity checks accept valid block passes.
castwide Apr 9, 2020
ada0c7a
Arity checks verify extra block passes.
castwide Apr 9, 2020
f78b3e4
Detect return nodes in case statements (#283)
castwide Apr 9, 2020
59ea9cd
Update argument array nodes for Ruby 2.7.
castwide Apr 9, 2020
cb1dd22
Chains can be splats.
castwide Apr 10, 2020
dca399a
Verify arity of calls with splats.
castwide Apr 10, 2020
0d92f65
Spec for return nodes from case statements.
castwide Apr 10, 2020
778fcfd
Handle ARGSCAT in chains and typechecker.
castwide Apr 10, 2020
ead1069
Handle BLOCK_PASS with other arguments.
castwide Apr 10, 2020
c7edcc3
Merge branch 'v0.39-splat' into v0.39
castwide Apr 10, 2020
1ff9c93
Merge branch 'v0.39'
castwide Apr 10, 2020
582340e
Add Errno classes to core pins.
castwide Apr 11, 2020
4d3d697
Add @return text to documentaiton.
castwide Apr 11, 2020
0e1f91e
Merge branch 'master' into v0.39
castwide Apr 11, 2020
f557ab1
Unused convention method.
castwide Apr 11, 2020
9c2b642
Infer literal DOT3 ranges.
castwide Apr 13, 2020
77a7f54
TypeChecker allows undeclared block args.
castwide Apr 15, 2020
1e96ee5
Kernel#puts returns nil.
castwide Apr 15, 2020
afbc280
Shell cache handling.
castwide Apr 15, 2020
728745c
Legacy case node handling.
castwide Apr 16, 2020
299de8b
Legacy splat handling.
castwide Apr 16, 2020
c050f27
Merge branch 'v0.39' of s:\repos\solargraph into v0.39
castwide Apr 16, 2020
eea8249
Plugins configuration.
castwide Apr 16, 2020
3c2bfc5
Rescue specific errors in gemspec evaluation.
castwide Apr 16, 2020
a783c38
Full parameters in signature help.
castwide Apr 18, 2020
d410238
feat: treat prepend module as include module (#302)
SolaWing Apr 19, 2020
6515268
Merge branch 'master' of github.com:castwide/solargraph
castwide Apr 19, 2020
dde49ef
Merge branch 'master' into v0.39
castwide Apr 19, 2020
7a7f174
Merge branch 'v0.39' of github.com:castwide/solargraph into v0.39
castwide Apr 19, 2020
1e05872
Set prepended module ancestry.
castwide Apr 19, 2020
00a90f4
Legacy SendNode typo.
castwide Apr 19, 2020
34cc3be
and -> &&
castwide Apr 19, 2020
157a305
Array#uniq CoreFill.
castwide Apr 19, 2020
0122112
Validate constants.
castwide Apr 19, 2020
316db2e
Legacy const_nodes_from method.
castwide Apr 19, 2020
e69ffc6
Merge branch 'v0.39-abstract' into v0.39
castwide Apr 23, 2020
23f93af
Update YARD dependency.
castwide Apr 23, 2020
17af472
Rescue ENOENT errors when loading sources (#308)
castwide Apr 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/solargraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BundleNotFoundError < StandardError; end
autoload :Environ, 'solargraph/environ'
autoload :Convention, 'solargraph/convention'
autoload :Documentor, 'solargraph/documentor'
autoload :Parser, 'solargraph/parser'

dir = File.dirname(__FILE__)
YARDOC_PATH = File.realpath(File.join(dir, '..', 'yardoc'))
Expand Down
17 changes: 14 additions & 3 deletions lib/solargraph/api_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def local_path_hash
# @return [Source::Cursor]
def cursor_at filename, position
position = Position.normalize(position)
raise "File not found: #{filename}" unless source_map_hash.has_key?(filename)
raise FileNotFoundError, "File not found: #{filename}" unless source_map_hash.has_key?(filename)
source_map_hash[filename].cursor_at(position)
end

Expand Down Expand Up @@ -308,6 +308,7 @@ def get_methods fqns, scope: :instance, visibility: [:public], deep: true
result.concat inner_get_methods('Kernel', :instance, visibility, deep, skip)
else
result.concat inner_get_methods(fqns, scope, visibility, deep, skip)
result.concat inner_get_methods('Kernel', :instance, [:public], deep, skip) if visibility.include?(:private)
end
resolved = resolve_method_aliases(result, visibility)
cache.set_methods(fqns, scope, visibility, deep, resolved)
Expand Down Expand Up @@ -560,6 +561,12 @@ def inner_get_methods fqns, scope, visibility, deep, skip, no_core = false
return [] if skip.include?(reqstr)
skip.add reqstr
result = []
if deep && scope == :instance
store.get_prepends(fqns).reverse.each do |im|
fqim = qualify(im, fqns)
result.concat inner_get_methods(fqim, scope, visibility, deep, skip, true) unless fqim.nil?
end
end
result.concat store.get_methods(fqns, scope: scope, visibility: visibility).sort{ |a, b| a.name <=> b.name }
if deep
if scope == :instance
Expand Down Expand Up @@ -601,7 +608,11 @@ def inner_get_methods fqns, scope, visibility, deep, skip, no_core = false
def inner_get_constants fqns, visibility, skip
return [] if fqns.nil? || skip.include?(fqns)
skip.add fqns
result = store.get_constants(fqns, visibility)
result = []
store.get_prepends(fqns).each do |is|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
end
result.concat store.get_constants(fqns, visibility)
.sort { |a, b| a.name <=> b.name }
store.get_includes(fqns).each do |is|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
Expand Down Expand Up @@ -727,7 +738,7 @@ def resolve_method_alias pin
comments: origin.comments,
scope: origin.scope,
visibility: origin.visibility,
args: origin.parameters
parameters: origin.parameters
)
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/solargraph/api_map/bundler_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class ApiMap
module BundlerMethods
module_function

# @param directory [String]
# @return [Hash]
def require_from_bundle directory
@require_from_bundle ||= begin
Solargraph.logger.info "Loading gems for bundler/require"
Expand All @@ -16,6 +18,7 @@ def require_from_bundle directory
end
end

# @return [void]
def reset_require_from_bundle
@require_from_bundle = nil
end
Expand Down
7 changes: 1 addition & 6 deletions lib/solargraph/api_map/source_to_yard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ def rake_yard store
code_object_map[pin.path].docstring = pin.docstring
code_object_map[pin.path].visibility = pin.visibility || :public
code_object_map[pin.path].parameters = pin.parameters.map do |p|
n = p.match(/^[a-z0-9_]*:?/i)[0]
v = nil
if p.length > n.length
v = p[n.length..-1].gsub(/^ = /, '')
end
[n, v]
[p.name, p.asgn_code]
end
end
end
Expand Down
22 changes: 19 additions & 3 deletions lib/solargraph/api_map/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize pins = []
# @return [Array<Solargraph::Pin::Base>]
def get_constants fqns, visibility = [:public]
namespace_children(fqns).select { |pin|
!pin.name.empty? and (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility)
!pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility)
}
end

Expand All @@ -34,7 +34,7 @@ def get_methods fqns, scope: :instance, visibility: [:public]
end

# @param fqns [String]
# @return [String]
# @return [String, nil]
def get_superclass fqns
return superclass_references[fqns].first if superclass_references.key?(fqns)
return 'Object' if fqns != 'BasicObject' && namespace_exists?(fqns)
Expand All @@ -48,6 +48,12 @@ def get_includes fqns
include_references[fqns] || []
end

# @param fqns [String]
# @return [Array<String>]
def get_prepends fqns
prepend_references[fqns] || []
end

# @param fqns [String]
# @return [Array<String>]
def get_extends fqns
Expand Down Expand Up @@ -172,6 +178,10 @@ def include_references
@include_references ||= {}
end

def prepend_references
@prepend_references ||= {}
end

def extend_references
@extend_references ||= {}
end
Expand Down Expand Up @@ -210,13 +220,16 @@ def index
pins.each do |pin|
namespace_map[pin.namespace] ||= []
namespace_map[pin.namespace].push pin
namespaces.add pin.path if pin.is_a?(Pin::Namespace) and !pin.path.empty?
namespaces.add pin.path if pin.is_a?(Pin::Namespace) && !pin.path.empty?
namespace_pins.push pin if pin.is_a?(Pin::Namespace)
method_pins.push pin if pin.is_a?(Pin::BaseMethod)
symbols.push pin if pin.is_a?(Pin::Symbol)
if pin.is_a?(Pin::Reference::Include)
include_references[pin.namespace] ||= []
include_references[pin.namespace].push pin.name
elsif pin.is_a?(Pin::Reference::Prepend)
prepend_references[pin.namespace] ||= []
prepend_references[pin.namespace].push pin.name
elsif pin.is_a?(Pin::Reference::Extend)
extend_references[pin.namespace] ||= []
extend_references[pin.namespace].push pin.name
Expand Down Expand Up @@ -245,6 +258,9 @@ def index
pin.docstring.add_tag(tag)
end
end
# @todo This is probably not the best place for these overrides
superclass_references['Integer'] = ['Numeric']
superclass_references['Float'] = ['Numeric']
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/solargraph/complex_type/type_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ def qualify api_map, context = ''
t.qualify api_map, context
end
if list_parameters?
Solargraph::ComplexType.parse("#{fqns}<#{rtypes.map(&:tag).join(', ')}>").first
Solargraph::ComplexType.parse("#{fqns}<#{rtypes.map(&:tag).join(', ')}>")
elsif fixed_parameters?
Solargraph::ComplexType.parse("#{fqns}(#{rtypes.map(&:tag).join(', ')})").first
Solargraph::ComplexType.parse("#{fqns}(#{rtypes.map(&:tag).join(', ')})")
elsif hash_parameters?
Solargraph::ComplexType.parse("#{fqns}{#{ltypes.map(&:tag).join(', ')} => #{rtypes.map(&:tag).join(', ')}}").first
Solargraph::ComplexType.parse("#{fqns}{#{ltypes.map(&:tag).join(', ')} => #{rtypes.map(&:tag).join(', ')}}")
else
Solargraph::ComplexType.parse(fqns).first
Solargraph::ComplexType.parse(fqns)
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions lib/solargraph/convention/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ def match? source
false
end

# @return [Environ]
def process
match? ? EMPTY_ENVIRON : environ
end

# The Environ for this convention.
# Subclasses should override this method.
#
Expand Down
30 changes: 28 additions & 2 deletions lib/solargraph/core_fills.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ module CoreFills
@return [self]
@return_single_parameter
)),
Override.method_return('Array#uniq', 'self'),

Override.from_comment('BasicObject#==', %(
@param other [BasicObject]
@return [Boolean]
)),
Override.method_return('BasicObject#initialize', 'void'),

Override.method_return('Class#new', 'self'),
Override.method_return('Class.new', 'Class<Object>'),
Expand All @@ -84,6 +86,11 @@ module CoreFills
Override.method_return('File.extname', 'String'),
Override.method_return('File.join', 'String'),

Override.from_comment('Float#+', %(
@param y [Numeric]
@return [Numeric]
)),

Override.from_comment('Hash#[]', %(
@return_value_parameter
)),
Expand All @@ -94,9 +101,25 @@ module CoreFills
@param_tuple
)),

Override.from_comment('Integer#+', %(
@param y [Numeric]
@return [Numeric]
)),

Override.method_return('Kernel#puts', 'nil'),

# Override.method_return('Module#attr_reader', 'void'),
# Override.method_return('Module#attr_writer', 'void'),
# Override.method_return('Module#attr_accessor', 'void'),

Override.from_comment('Numeric#+', %(
@param y [Numeric]
@return [Numeric]
)),

Override.method_return('Object#!', 'Boolean'),
Override.method_return('Object#clone', 'self', delete: [:overload]),
Override.method_return('Object#dup', 'self'),
Override.method_return('Object#dup', 'self', delete: [:overload]),
Override.method_return('Object#freeze', 'self', delete: [:overload]),
Override.method_return('Object#inspect', 'String'),
Override.method_return('Object#taint', 'self'),
Expand All @@ -121,7 +144,10 @@ module CoreFills

Override.method_return('String#freeze', 'self'),
Override.method_return('String#split', 'Array<String>'),
Override.method_return('String#lines', 'Array<String>')
Override.method_return('String#lines', 'Array<String>'),
Override.from_comment('String#each_line', %(
@yieldparam [String]
))
].concat(
methods_with_yieldparam_subtypes.map do |path|
Override.from_comment(path, %(
Expand Down
1 change: 1 addition & 0 deletions lib/solargraph/diagnostics/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Diagnostics
# The base class for diagnostics reporters.
#
class Base
# @return [Array<String>]
attr_reader :args

def initialize *args
Expand Down
26 changes: 13 additions & 13 deletions lib/solargraph/diagnostics/type_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ module Diagnostics
class TypeCheck < Base
def diagnose source, api_map
return [] unless args.include?('always') || api_map.workspaced?(source.filename)
severity = (args.include?('strict') ? Diagnostics::Severities::ERROR : Diagnostics::Severities::WARNING)
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map)
result = checker.return_type_problems + checker.param_type_problems
result.concat checker.strict_type_problems if args.include?('strict')
result.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line }
result.map do |problem|
{
range: extract_first_line(problem.location, source),
severity: severity,
source: 'Typecheck',
message: problem.message
}
end
severity = Diagnostics::Severities::ERROR
level = (args.reverse.find { |a| ['normal', 'typed', 'strict', 'strong'].include?(a) }) || :normal
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym)
checker.problems
.sort { |a, b| a.location.range.start.line <=> b.location.range.start.line }
.map do |problem|
{
range: extract_first_line(problem.location, source),
severity: severity,
source: 'Typecheck',
message: problem.message
}
end
end

private
Expand Down
13 changes: 11 additions & 2 deletions lib/solargraph/language_server/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ def diagnose uri
type: LanguageServer::MessageTypes::ERROR,
message: "Error in diagnostics: #{e.message}"
}
rescue FileNotFoundError => e
# @todo This appears to happen when an external file is open and
# scheduled for diagnosis, but the file was closed (i.e., the
# editor moved to a different file) before diagnosis started
logger.warn "Unable to diagnose #{uri} : #{e.message}"
send_notification 'textDocument/publishDiagnostics', {
uri: uri,
diagnostics: []
}
end
else
logger.info "Deferring diagnosis of #{uri}"
Expand Down Expand Up @@ -245,7 +254,7 @@ def queue message
#
# @return [String] The most recent data or an empty string.
def flush
tmp = nil
tmp = ''
@buffer_semaphore.synchronize do
tmp = @buffer.clone
@buffer.clear
Expand Down Expand Up @@ -539,7 +548,7 @@ def search query
end

# @param query [String]
# @return [String]
# @return [Array]
def document query
result = []
libraries.each { |lib| result.concat lib.document(query) }
Expand Down
26 changes: 18 additions & 8 deletions lib/solargraph/language_server/host/sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Sources
def initialize
@mutex = Mutex.new
@stopped = true
@has_uri = ConditionVariable.new
end

def stopped?
Expand All @@ -25,17 +26,14 @@ def start
return unless @stopped
@stopped = false
Thread.new do
until stopped?
tick
sleep 0.25 if queue.empty?
end
tick until stopped?
end
end

# @return [void]
def tick
return if queue.empty?
uri = mutex.synchronize { queue.shift }
uri = mutex.synchronize { next_uri }

return if queue.include?(uri)
mutex.synchronize do
nxt = open_source_hash[uri].finish_synchronize
Expand All @@ -45,6 +43,18 @@ def tick
end
end

# @return [void]
def add_uri(uri)
queue.push(uri)
@has_uri.signal
end

# @return [String]
def next_uri
@has_uri.wait(mutex) if queue.empty?
queue.shift
end

# @return [void]
def stop
@stopped = true
Expand Down Expand Up @@ -88,7 +98,7 @@ def async_update uri, updater
src = find(uri)
mutex.synchronize do
open_source_hash[uri] = src.start_synchronize(updater)
queue.push uri
add_uri(uri)
end
changed
notify_observers uri
Expand Down Expand Up @@ -126,7 +136,7 @@ def clear

private

# @return [Array<Source>]
# @return [Hash]
def open_source_hash
@open_source_hash ||= {}
end
Expand Down