diff --git a/sway-core/src/semantic_analysis/namespace/module.rs b/sway-core/src/semantic_analysis/namespace/module.rs index 7436b03fc00..890c2cc6480 100644 --- a/sway-core/src/semantic_analysis/namespace/module.rs +++ b/sway-core/src/semantic_analysis/namespace/module.rs @@ -1,7 +1,7 @@ use crate::{ engine_threading::Engines, language::{ - ty::{self, TyDecl}, + ty::{self}, Visibility, }, Ident, TypeId, @@ -416,14 +416,6 @@ impl Module { }) .collect::>() } - - pub fn get_impl_spans_for_decl(&self, engines: &Engines, ty_decl: &TyDecl) -> Vec { - let handler = Handler::default(); - ty_decl - .return_type(&handler, engines) - .map(|type_id| TraitMap::get_impl_spans_for_type(self, engines, &type_id)) - .unwrap_or_default() - } } impl From for Module { diff --git a/sway-core/src/semantic_analysis/namespace/trait_map.rs b/sway-core/src/semantic_analysis/namespace/trait_map.rs index 5f77a7dcce7..186840edaa3 100644 --- a/sway-core/src/semantic_analysis/namespace/trait_map.rs +++ b/sway-core/src/semantic_analysis/namespace/trait_map.rs @@ -19,7 +19,7 @@ use crate::{ engine_threading::*, language::{ parsed::{EnumDeclaration, ImplItem, StructDeclaration}, - ty::{self, TyImplItem, TyTraitItem}, + ty::{self, TyDecl, TyImplItem, TyTraitItem}, CallPath, }, type_system::{SubstTypes, TypeId}, @@ -1113,6 +1113,19 @@ impl TraitMap { spans } + /// Find the spans of all impls for the given decl. + pub fn get_impl_spans_for_decl( + module: &Module, + engines: &Engines, + ty_decl: &TyDecl, + ) -> Vec { + let handler = Handler::default(); + ty_decl + .return_type(&handler, engines) + .map(|type_id| TraitMap::get_impl_spans_for_type(module, engines, &type_id)) + .unwrap_or_default() + } + /// Find the entries in `self` with trait name `trait_name` and return the /// spans of the impls. pub fn get_impl_spans_for_trait_name(module: &Module, trait_name: &CallPath) -> Vec { diff --git a/sway-lsp/src/capabilities/hover/hover_link_contents.rs b/sway-lsp/src/capabilities/hover/hover_link_contents.rs index a84439b2412..695c1497806 100644 --- a/sway-lsp/src/capabilities/hover/hover_link_contents.rs +++ b/sway-lsp/src/capabilities/hover/hover_link_contents.rs @@ -103,9 +103,11 @@ impl<'a> HoverLinkContents<'a> { /// Adds implementations of the given type to the list of implementations using the [`TyDecl`]. pub fn add_implementations_for_decl(&mut self, ty_decl: &TyDecl) { if let Some(namespace) = self.session.namespace() { - let impl_spans = namespace - .module(self.engines) - .get_impl_spans_for_decl(self.engines, ty_decl); + let impl_spans = TraitMap::get_impl_spans_for_decl( + namespace.module(self.engines), + self.engines, + ty_decl, + ); self.add_implementations(&ty_decl.span(self.engines), impl_spans); } }