| module RBS | |
| class Environment | |
| type module_decl = AST::Declarations::Class | AST::Declarations::Module | |
| # Name of object, it's (single) declaration, and the outer module declarations | |
| # | |
| class SingleEntry[N, D] | |
| attr_reader name: N | |
| attr_reader decl: D | |
| attr_reader context: Resolver::context | |
| def initialize: (name: N, decl: D, context: Resolver::context) -> void | |
| end | |
| class ModuleAliasEntry < SingleEntry[TypeName, AST::Declarations::ModuleAlias] | |
| end | |
| class ClassAliasEntry < SingleEntry[TypeName, AST::Declarations::ClassAlias] | |
| end | |
| class InterfaceEntry < SingleEntry[TypeName, AST::Declarations::Interface] | |
| end | |
| class TypeAliasEntry < SingleEntry[TypeName, AST::Declarations::TypeAlias] | |
| end | |
| class ConstantEntry < SingleEntry[TypeName, AST::Declarations::Constant] | |
| end | |
| class GlobalEntry < SingleEntry[Symbol, AST::Declarations::Global] | |
| end | |
| # Array of source objects loaded in the environment | |
| # | |
| attr_reader sources: Array[Source::RBS | Source::Ruby] | |
| # Class declarations | |
| attr_reader class_decls: Hash[TypeName, ModuleEntry | ClassEntry] | |
| attr_reader class_alias_decls: Hash[TypeName, ModuleAliasEntry | ClassAliasEntry] | |
| # Interface declarations | |
| attr_reader interface_decls: Hash[TypeName, InterfaceEntry] | |
| # Type alias declarations | |
| attr_reader type_alias_decls: Hash[TypeName, TypeAliasEntry] | |
| # Constant declarations | |
| attr_reader constant_decls: Hash[TypeName, ConstantEntry] | |
| # Global declarations | |
| attr_reader global_decls: Hash[Symbol, GlobalEntry] | |
| def initialize: () -> void | |
| def initialize_copy: (Environment) -> void | |
| def each_rbs_source: () { (Source::RBS) -> void } -> void | |
| | () -> Enumerator[Source::RBS] | |
| def each_ruby_source: () { (Source::Ruby) -> void } -> void | |
| | () -> Enumerator[Source::Ruby] | |
| # Construct an environment from EnvironmentLoader | |
| # | |
| def self.from_loader: (EnvironmentLoader) -> Environment | |
| def add_signature: (Source::RBS | Source::Ruby) -> void | |
| # Insert a declaration into the environment | |
| # | |
| private def insert_decl: (AST::Declarations::t, ?context: Resolver::context, ?namespace: Namespace) -> void | |
| private def insert_ruby_decl: (AST::Ruby::Declarations::t, ?context: Resolver::context, ?namespace: Namespace) -> void | |
| # 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 | AST::Ruby::Declarations::t]?) -> Environment | |
| def resolve_signature: (Resolver::TypeNameResolver, UseMap::Table, Array[AST::Directives::t], Array[AST::Declarations::t], ?only: Set[AST::Declarations::t]?) -> [Array[AST::Directives::t], Array[AST::Declarations::t]] | |
| def inspect: () -> String | |
| def buffers: () -> Array[Buffer] | |
| # Remove declarations and directives that are loaded from `buffers` | |
| # | |
| def unload: (Set[Buffer] buffers) -> Environment | |
| # Returns true if an interface with the type name is defined | |
| # | |
| def interface_name?: (TypeName) -> bool | |
| # Returns true if a type alias with the type name is defined | |
| # | |
| def type_alias_name?: (TypeName) -> bool | |
| # Returns true if a module or class with the type name is defined | |
| # | |
| def module_name?: (TypeName) -> bool | |
| # Returns true if the type name is defined | |
| # | |
| def type_name?: (TypeName) -> bool | |
| # Returns if a constant of the name is defined | |
| # | |
| def constant_name?: (TypeName) -> bool | |
| # Returns true if the type name is defined by constant declaration | |
| # | |
| def constant_decl?: (TypeName) -> bool | |
| # Returns true if the type name is defined by class declaration | |
| # | |
| def class_decl?: (TypeName) -> bool | |
| # Returns true if the type name is defined by module declaration | |
| # | |
| def module_decl?: (TypeName) -> bool | |
| # Returns true if the type name is a module alias | |
| # | |
| def module_alias?: (TypeName) -> bool | |
| # Returns true if the type name is a class alias | |
| def class_alias?: (TypeName) -> bool | |
| def class_entry: (TypeName) -> (ClassEntry | ClassAliasEntry | nil) | |
| # Returns ClassEntry if the class definition is found, normalized in case of alias | |
| # | |
| def normalized_class_entry: (TypeName) -> ClassEntry? | |
| def module_entry: (TypeName) -> (ModuleEntry | ModuleAliasEntry | nil) | |
| # Returns ModuleEntry if the module definition is found, normalized in case of alias | |
| # | |
| def normalized_module_entry: (TypeName) -> ModuleEntry? | |
| def constant_entry: (TypeName) -> (ClassEntry | ClassAliasEntry | ModuleEntry | ModuleAliasEntry | ConstantEntry | nil) | |
| def module_class_entry: (TypeName) -> (ClassEntry | ClassAliasEntry | ModuleEntry | ModuleAliasEntry | nil) | |
| def normalized_module_class_entry: (TypeName) -> (ClassEntry | ModuleEntry | nil) | |
| @normalize_module_name_cache: Hash[TypeName, TypeName | false | nil] | |
| # Returns the original module name that is defined with `module` declaration | |
| # | |
| # * Calls `#absolute!` for relative module names | |
| # * Returns `nil` if the rhs name cannot be found | |
| # * Returns `false` if the name is cyclic | |
| # | |
| def normalize_module_name?: (TypeName) -> (TypeName | nil | false) | |
| # Returns the original module name that is defined with `module` declaration | |
| # | |
| # * Raises an error if given type name is not module | |
| # * Calls `#absolute!` for relative module names | |
| # * Returns the name itself if the name cannot be normalized to a class/module | |
| # | |
| def normalize_module_name: (TypeName) -> TypeName | |
| # Returns a normalized module/class name or a type name with a normalized namespace | |
| # | |
| # * Calls `#absolute!` for relative module names | |
| # * Returns `nil` if the typename cannot be found | |
| # * Returns `false` if the name is cyclic | |
| # | |
| def normalize_type_name?: (TypeName) -> (TypeName | nil | false) | |
| # Normalize the type name or raises an error | |
| # | |
| def normalize_type_name!: (TypeName) -> TypeName | |
| # Returns a normalized module/class name or a type name with a normalized namespace | |
| # | |
| # * Calls `#absolute!` for relative module names | |
| # * Returns the typename itself if the name cannot be normalized | |
| # | |
| def normalize_type_name: (TypeName) -> TypeName | |
| # Returns `true` if given type name is normalized | |
| # | |
| def normalized_type_name?: (TypeName) -> bool | |
| # Returns the given type name if it's normalized, or raises | |
| # | |
| def normalized_type_name!: (TypeName) -> TypeName | |
| # Runs generics type params validation over each class definitions | |
| def validate_type_params: () -> void | |
| private | |
| # Returns a context for inside given decls | |
| # | |
| def resolver_context: (*module_decl) -> Resolver::context | |
| def append_context: (Resolver::context, module_decl) -> Resolver::context | |
| def resolve_declaration: (Resolver::TypeNameResolver resolver, UseMap map, AST::Declarations::t decl, context: Resolver::context, prefix: Namespace) -> AST::Declarations::t | |
| def resolve_member: (Resolver::TypeNameResolver, UseMap map, AST::Members::t, context: Resolver::context) -> AST::Members::t | |
| def resolve_method_type: (Resolver::TypeNameResolver, UseMap map, RBS::MethodType, context: Resolver::context) -> RBS::MethodType | |
| def resolve_type_params: (Resolver::TypeNameResolver resolver, UseMap map, Array[AST::TypeParam], context: Resolver::context) -> Array[AST::TypeParam] | |
| def resolve_ruby_declaration: (Resolver::TypeNameResolver resolver, UseMap map, AST::Ruby::Declarations::t decl, context: Resolver::context, prefix: Namespace) -> AST::Ruby::Declarations::t | |
| def resolve_ruby_member: (Resolver::TypeNameResolver, UseMap map, AST::Ruby::Members::t | AST::Ruby::Declarations::SingletonClassDecl, context: Resolver::context) -> (AST::Ruby::Members::t | AST::Ruby::Declarations::SingletonClassDecl) | |
| def absolute_type: (Resolver::TypeNameResolver, UseMap map, Types::t, context: Resolver::context) -> Types::t | |
| def absolute_type_name: (Resolver::TypeNameResolver, UseMap map, TypeName, context: Resolver::context) -> TypeName | |
| end | |
| end |