MCPcopy Index your code
hub / github.com/RustPython/RustPython / split_idents_on_dot

Function split_idents_on_dot

src/shell/helper.rs:19–54  ·  view source on GitHub ↗
(line: &str)

Source from the content-addressed store, hash-verified

17}
18
19fn 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
56impl<'vm> ShellHelper<'vm> {
57 pub const fn new(vm: &'vm VirtualMachine, globals: PyDictRef) -> Self {

Callers 1

complete_optMethod · 0.85

Calls 11

reverse_stringFunction · 0.85
newFunction · 0.85
charsMethod · 0.80
SomeClass · 0.50
revMethod · 0.45
lastMethod · 0.45
is_emptyMethod · 0.45
unwrapMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
reverseMethod · 0.45

Tested by

no test coverage detected