| 17 | } |
| 18 | |
| 19 | fn split_idents_on_dot(line: &str) -> Option<(usize, Vec<String>)> { |
| 20 | let mut words = vec![String::new()]; |
| 21 | let mut startpos = 0; |
| 22 | for (i, c) in line.chars().rev().enumerate() { |
| 23 | match c { |
| 24 | '.' => { |
| 25 | // check for a double dot |
| 26 | if i != 0 && words.last().is_some_and(|s| s.is_empty()) { |
| 27 | return None; |
| 28 | } |
| 29 | reverse_string(words.last_mut().unwrap()); |
| 30 | if words.len() == 1 { |
| 31 | startpos = line.len() - i; |
| 32 | } |
| 33 | words.push(String::new()); |
| 34 | } |
| 35 | c if c.is_alphanumeric() || c == '_' => words.last_mut().unwrap().push(c), |
| 36 | _ => { |
| 37 | if words.len() == 1 { |
| 38 | if words.last().unwrap().is_empty() { |
| 39 | return None; |
| 40 | } |
| 41 | startpos = line.len() - i; |
| 42 | } |
| 43 | break; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | if words == [String::new()] { |
| 48 | return None; |
| 49 | } |
| 50 | reverse_string(words.last_mut().unwrap()); |
| 51 | words.reverse(); |
| 52 | |
| 53 | Some((startpos, words)) |
| 54 | } |
| 55 | |
| 56 | impl<'vm> ShellHelper<'vm> { |
| 57 | pub const fn new(vm: &'vm VirtualMachine, globals: PyDictRef) -> Self { |