Skip to content

Commit 59aa791

Browse files
committed
fix: rewrite code_action generate_delegate_trait
1 parent 19387d3 commit 59aa791

File tree

8 files changed

+984
-159
lines changed

8 files changed

+984
-159
lines changed

crates/hir/src/semantics.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ use crate::{
4040
source_analyzer::{resolve_hir_path, SourceAnalyzer},
4141
Access, Adjust, Adjustment, AutoBorrow, BindingMode, BuiltinAttr, Callable, ConstParam, Crate,
4242
DeriveHelper, Field, Function, HasSource, HirFileId, Impl, InFile, Label, LifetimeParam, Local,
43-
Macro, Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, ToolModule, Trait, Type,
44-
TypeAlias, TypeParam, VariantDef,
43+
Macro, Module, ModuleDef, Name, OverloadedDeref, Path, ScopeDef, Struct, ToolModule, Trait,
44+
Type, TypeAlias, TypeParam, VariantDef,
4545
};
4646

4747
pub enum DescendPreference {
@@ -229,6 +229,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
229229
pub fn to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module> {
230230
self.imp.to_module_def(file)
231231
}
232+
233+
pub fn to_struct_def(&self, s: &ast::Struct) -> Option<Struct> {
234+
self.imp.to_def(s).map(Struct::from)
235+
}
236+
237+
pub fn to_impl_def(&self, i: &ast::Impl) -> Option<Impl> {
238+
self.imp.to_def(i).map(Impl::from)
239+
}
232240
}
233241

234242
impl<'db> SemanticsImpl<'db> {

0 commit comments

Comments
 (0)