Sha256: 14f69b47338c3cbd11891564f2324e65cd6cfdb212fa9e6550834fd99556e472
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
module Yoda module Typing class ConstantResolver # @abstract class Query class << self # @param node [AST::ConstantNode] # @param tracer [Inferencer::Tracer] def from_node(node, tracer: nil) case node.type when :cbase CbaseQuery.new when :empty RelativeBaseQuery.new when :const MemberQuery.new(parent: from_node(node.base, tracer: tracer), name: node.name.name.to_s, tracer: tracer && NodeTracer.new(node: node, tracer: tracer)) else CodeQuery.new(node: node) end end def from_string(string, parent: RelativeBaseQuery.new) base, child = string.split("::", 2) case base when nil parent when "" base_query = CbaseQuery.new if child.nil? base_query else from_string(child, parent: base_query) end else base_query = MemberQuery.new(parent: parent, name: base) if child.nil? base_query else from_string(child, parent: base_query) end end end end # @abstract # @return [Query, nil] def parent fail NotImplementedError end # @return [NodeTracer, nil] def tracer nil end # @return [Query] def base if parent parent.base else self end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yoda-language-server-0.10.1 | lib/yoda/typing/constant_resolver/query.rb |
yoda-language-server-0.10.0 | lib/yoda/typing/constant_resolver/query.rb |