mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Extract helper function to get the IdentIds related to a symbol's module
This commit is contained in:
parent
f356f6f7a0
commit
49a3f2d68e
1 changed files with 20 additions and 27 deletions
|
@ -124,18 +124,7 @@ impl Symbol {
|
|||
}
|
||||
|
||||
pub fn is_generated(self, interns: &Interns) -> bool {
|
||||
let ident_ids = interns
|
||||
.all_ident_ids
|
||||
.get(&self.module_id())
|
||||
.unwrap_or_else(|| {
|
||||
internal_error!(
|
||||
"ident_string could not find IdentIds for module {:?} in {:?}",
|
||||
self.module_id(),
|
||||
interns
|
||||
)
|
||||
});
|
||||
|
||||
ident_ids.is_generated_id(self.ident_id())
|
||||
self.ident_ids(interns).is_generated_id(self.ident_id())
|
||||
}
|
||||
|
||||
pub fn module_string<'a>(&self, interns: &'a Interns) -> &'a ModuleName {
|
||||
|
@ -152,24 +141,15 @@ impl Symbol {
|
|||
}
|
||||
|
||||
pub fn as_str(self, interns: &Interns) -> &str {
|
||||
let ident_ids = interns
|
||||
.all_ident_ids
|
||||
.get(&self.module_id())
|
||||
self.ident_ids(interns)
|
||||
.get_name(self.ident_id())
|
||||
.unwrap_or_else(|| {
|
||||
internal_error!(
|
||||
"ident_string could not find IdentIds for module {:?} in {:?}",
|
||||
self.module_id(),
|
||||
interns
|
||||
"ident_string's IdentIds did not contain an entry for {} in module {:?}",
|
||||
self.ident_id().0,
|
||||
self.module_id()
|
||||
)
|
||||
});
|
||||
|
||||
ident_ids.get_name(self.ident_id()).unwrap_or_else(|| {
|
||||
internal_error!(
|
||||
"ident_string's IdentIds did not contain an entry for {} in module {:?}",
|
||||
self.ident_id().0,
|
||||
self.module_id()
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub const fn as_u64(self) -> u64 {
|
||||
|
@ -201,6 +181,19 @@ impl Symbol {
|
|||
pub fn contains(self, needle: &str) -> bool {
|
||||
format!("{self:?}").contains(needle)
|
||||
}
|
||||
|
||||
fn ident_ids(self, interns: &Interns) -> &IdentIds {
|
||||
interns
|
||||
.all_ident_ids
|
||||
.get(&self.module_id())
|
||||
.unwrap_or_else(|| {
|
||||
internal_error!(
|
||||
"ident_string could not find IdentIds for module {:?} in {:?}",
|
||||
self.module_id(),
|
||||
interns
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Rather than displaying as this:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue