Add trim_end_proc_mark

This commit is contained in:
Shunsuke Shibayama 2022-12-13 22:38:20 +09:00
parent 055b6117ff
commit 855d463011
2 changed files with 19 additions and 2 deletions

View file

@ -2295,6 +2295,13 @@ impl VarName {
pub const fn inspect(&self) -> &Str {
&self.0.content
}
/// Remove `!` from the end of the identifier.
/// Procedures defined in `d.er` automatically register the name without `!` as `py_name`.
/// This method is for undoing it (e.g. pylyzer-mode)
pub fn trim_end_proc_mark(&mut self) {
let _ = self.0.content.trim_end_matches('!');
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -2378,6 +2385,10 @@ impl Identifier {
pub fn is_procedural(&self) -> bool {
self.name.is_procedural()
}
pub fn trim_end_proc_mark(&mut self) {
self.name.trim_end_proc_mark();
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]