solargraph 0.12.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12ba7fd6f2f9b2393c21aba8249cd43e7c69062f
4
- data.tar.gz: c102835081a9b19b74180c1f75b7ebaea695e5f1
3
+ metadata.gz: 1ff8b6c3f8f03cacb73e9a6b398d3f984dc2e240
4
+ data.tar.gz: 58449ce1fd531e8426bcbad2733487a66a23ff3a
5
5
  SHA512:
6
- metadata.gz: 0bd7974b55a00ec8a914e77dffe352af321bbe9e27d1a1c19c74417015bc6d7886077017313e3526489e6a12e2b0933dc586cae2252e31afb0332da75f5a9f76
7
- data.tar.gz: cdc14d195c758dc1acd151e22155c41390026bb89e9a74756b9b28e24cd68f53fde8c1e8ce20f4c8a3bb1244f0bfa12f034fda91e0438a9c534483e8a61aed01
6
+ metadata.gz: dc8c5611342e2be6c3fbcd354663e611523b2aaf756f738a08f20bcd1a4ca8a9e6a278a64cb31541d09e8243be8170e2c7588de827ae6d36cf95253594eed3cc
7
+ data.tar.gz: a1d6666d9098e565b2d663a5d1ece4a617fb3ea1d0a97ca4703f4d114656afb831552b60345b9970abb6081028bc623ad65e117dfb98f20029f120e2a665f437
@@ -872,7 +872,7 @@ module Solargraph
872
872
  }
873
873
  end
874
874
 
875
- def map_namespaces node, tree = [], visibility = :public, scope = :instance, fqn = nil, local_scope = :class
875
+ def map_namespaces node, tree = [], visibility = :public, scope = :instance, fqn = nil
876
876
  if node.kind_of?(AST::Node)
877
877
  return if node.type == :str or node.type == :dstr
878
878
  if node.type == :class or node.type == :module
@@ -896,8 +896,10 @@ module Solargraph
896
896
  node.children.each do |c|
897
897
  if c.kind_of?(AST::Node)
898
898
  if c.type == :ivasgn
899
- @ivar_pins[fqn] ||= []
900
- @ivar_pins[fqn].push IvarPin.new(self, c, fqn, local_scope, get_comment_for(c))
899
+ @ivar_pins[fqn || ''] ||= []
900
+ par = find_parent(c, :class, :module, :def, :defs)
901
+ local_scope = ( (par.kind_of?(AST::Node) and par.type == :def) ? :instance : :class )
902
+ @ivar_pins[fqn || ''].push IvarPin.new(self, c, fqn || '', local_scope, get_comment_for(c))
901
903
  elsif c.type == :cvasgn
902
904
  @cvar_pins[fqn] ||= []
903
905
  @cvar_pins[fqn].push CvarPin.new(self, c, fqn, get_comment_for(c))
@@ -907,7 +909,7 @@ module Solargraph
907
909
  if c.type == :def and c.children[0].to_s[0].match(/[a-z]/i)
908
910
  @method_pins[fqn] ||= []
909
911
  @method_pins[fqn].push MethodPin.new(c, fqn, scope, visibility, get_comment_for(c))
910
- map_namespaces c, tree, visibility, scope, fqn, :instance
912
+ map_namespaces c, tree, visibility, scope, fqn
911
913
  next
912
914
  elsif c.type == :defs
913
915
  @method_pins[fqn] ||= []
@@ -478,6 +478,13 @@ module Solargraph
478
478
  inferred = nil
479
479
  parts = signature.split('.')
480
480
  ns_here = namespace_from(node)
481
+ if parts[0] and parts[0].include?('::')
482
+ sub = get_namespace_or_constant(parts[0], ns_here)
483
+ unless sub.nil?
484
+ return sub if signature.match(/^#{parts[0]}\.$/)
485
+ parts[0] = sub
486
+ end
487
+ end
481
488
  unless signature.include?('.')
482
489
  fqns = api_map.find_fully_qualified_namespace(signature, ns_here)
483
490
  return "Class<#{fqns}>" unless fqns.nil?
@@ -791,6 +798,30 @@ module Solargraph
791
798
  nil
792
799
  end
793
800
 
801
+ def get_namespace_or_constant con, namespace
802
+ parts = con.split('::')
803
+ conc = parts.shift
804
+ result = nil
805
+ is_constant = false
806
+ while parts.length > 0
807
+ result = api_map.find_fully_qualified_namespace("#{conc}::#{parts[0]}", namespace)
808
+ if result.nil? or result.empty?
809
+ sugg = api_map.namespaces_in(conc, namespace).select{ |s| s.label == parts[0] }.first
810
+ return nil if sugg.nil?
811
+ result = sugg.return_type
812
+ break if result.nil?
813
+ is_constant = true
814
+ conc = result
815
+ parts.shift
816
+ else
817
+ is_constant = false
818
+ conc += "::#{parts.shift}"
819
+ end
820
+ end
821
+ return result if is_constant
822
+ nil
823
+ end
824
+
794
825
  def beginning_of_line_from str, i
795
826
  while i > 0 and str[i] != "\n"
796
827
  i -= 1
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.12.1'
2
+ VERSION = '0.12.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser