Skip to content

Commit

Permalink
refactor(sol-hir): remove useless declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
aripiprazole committed Mar 4, 2024
1 parent e034b7e commit 6f9a582
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 425 deletions.
55 changes: 3 additions & 52 deletions sol-hir/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,40 +316,6 @@ mod impls {
}
}

impl HirFormatter for top_level::ClassDecl {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
format_decl(self, "class", db, scope, f, |db, f, scope| {
// Write the classes' methods wi
code_block(db, scope, f, |db, f, scope| {
scope.unlined(db, f, self.methods(db), ";")
})
})
}
}

impl HirFormatter for top_level::InstanceDecl {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
// TODO: Print implementation's type
format_decl(self, "instance", db, scope, f, |db, f, scope| {
// Write the classes' methods wi
code_block(db, scope, f, |db, f, scope| {
scope.unlined(db, f, self.methods(db), ";")
})
})
}
}

impl HirFormatter for top_level::TraitDecl {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
format_decl(self, "trait", db, scope, f, |db, f, scope| {
// Write the classes' methods wi
code_block(db, scope, f, |db, f, scope| {
scope.unlined(db, f, self.methods(db), ";")
})
})
}
}

impl HirFormatter for top_level::Constructor {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
scope.write_indent(f)?;
Expand All @@ -361,26 +327,15 @@ mod impls {

impl HirFormatter for top_level::Inductive {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
format_decl(self, "data", db, scope, f, |db, f, scope| {
format_decl(self, "inductive", db, scope, f, |db, f, scope| {
// Write the classes' methods wi
code_block(db, scope, f, |db, f, scope| {
scope.unlined(db, f, self.variants(db), ";")?;
scope.unlined(db, f, self.methods(db), ";")
scope.unlined(db, f, self.variants(db), ";")
})
})
}
}

impl HirFormatter for top_level::TypeDecl {
fn hir_fmt(&self, db: &dyn HirDb, f: &mut Formatter, scope: &Scope) -> std::fmt::Result {
format_decl(self, "type", db, scope, f, |_, _, _| {
// Nothing to do as [`format_decl`] does everything
// for us
Ok(())
})
}
}

/// A formatter for [`top_level::TopLevel`]. It does
/// takes an attribute and format it as it would be written
/// in a source file.
Expand All @@ -393,11 +348,7 @@ mod impls {
Using(using_top_level) => using_top_level.hir_fmt(db, f, scope),
Command(command_top_level) => command_top_level.hir_fmt(db, f, scope),
BindingGroup(binding_group) => binding_group.hir_fmt(db, f, scope),
ClassDecl(class_decl) => class_decl.hir_fmt(db, f, scope),
InstanceDecl(instance_decl) => instance_decl.hir_fmt(db, f, scope),
TraitDecl(trait_decl) => trait_decl.hir_fmt(db, f, scope),
Inductive(decl_decl) => decl_decl.hir_fmt(db, f, scope),
TypeDecl(type_decl) => type_decl.hir_fmt(db, f, scope),
Inductive(inductive) => inductive.hir_fmt(db, f, scope),
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions sol-hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ pub struct Jar(
source::top_level::Clause,
source::top_level::Signature,
source::top_level::UsingTopLevel,
source::top_level::ClassDecl,
source::top_level::InstanceDecl,
source::top_level::TraitDecl,
source::top_level::Inductive,
source::top_level::TypeDecl,
source::top_level::Constructor,
source::top_level::BindingGroup,
source::top_level::CommandTopLevel,
Expand Down
22 changes: 2 additions & 20 deletions sol-hir/src/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,12 @@ impl<'db, U: Checkable> HirListener for ReferenceWalker<'db, U> {
}
}

fn enter_data_top_level(&mut self, decl: top_level::Inductive) {
fn enter_inductive_top_level(&mut self, decl: top_level::Inductive) {
self.enter_scope(self.db, decl.location(self.db), decl.scope(self.db));
self.stack.push(decl.scope(self.db));
}

fn exit_data_top_level(&mut self, _: top_level::Inductive) {
self.stack.pop();
}

fn enter_class_top_level(&mut self, decl: top_level::ClassDecl) {
self.enter_scope(self.db, decl.location(self.db), decl.scope(self.db));
self.stack.push(decl.scope(self.db));
}

fn exit_class_top_level(&mut self, _: top_level::ClassDecl) {
self.stack.pop();
}

fn enter_trait_top_level(&mut self, decl: top_level::TraitDecl) {
self.enter_scope(self.db, decl.location(self.db), decl.scope(self.db));
self.stack.push(decl.scope(self.db));
}

fn exit_trait_top_level(&mut self, _: top_level::TraitDecl) {
fn exit_inductive_top_level(&mut self, _: top_level::Inductive) {
self.stack.pop();
}

Expand Down
Loading

0 comments on commit 6f9a582

Please sign in to comment.