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

Partial type name resolution #621

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/rbs/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,16 @@ def validate_type_params
end
end

def resolve_type_names
def resolve_type_names(only: nil)
resolver = TypeNameResolver.from_env(self)
env = Environment.new()

declarations.each do |decl|
env << resolve_declaration(resolver, decl, outer: [], prefix: Namespace.root)
if only && !only.member?(decl)
env << decl
else
env << resolve_declaration(resolver, decl, outer: [], prefix: Namespace.root)
end
end

env
Expand Down
8 changes: 7 additions & 1 deletion sig/environment.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ module RBS
# Runs generics type params validation over each class definitions.
def validate_type_params: () -> void

def resolve_type_names: () -> Environment
# Resolve all type names in the environment to absolute type names.
# Relative type name will be left if absolute type name cannot be found.
#
# When `only` is given, it skips other _top-level_ declarations not included in the collection.
# This helps running resolution faster in the case of _partial updates_.
#
def resolve_type_names: (?only: Set[AST::Declarations::t]?) -> Environment

def resolve_declaration: (TypeNameResolver resolver, AST::Declarations::t decl, outer: Array[module_decl], prefix: Namespace) -> AST::Declarations::t

Expand Down