Skip to content

Commit 3387e94

Browse files
committed
added fall back case for umpl top parent functions
1 parent aaa0bf6 commit 3387e94

File tree

1 file changed

+28
-5
lines changed
  • git-function-history-lib/src/languages

1 file changed

+28
-5
lines changed

git-function-history-lib/src/languages/umpl.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,34 @@ fn find_function_recurse(
123123
continue;
124124
};
125125
// FIXME: this should find the last line of the `top` by looking at its first element of is ast instead of finding the the first `⧼` (which could be commented out)
126-
let Some(top_end) = file_contents.lines().enumerate().skip(lines.0 -1).find_map(|line| {
127-
line.1.contains('⧼').then_some(line.0)
128-
}) else {
129-
results.append(&mut find_function_recurse(name, file_contents, fns.body, &new_current));
130-
continue;
126+
let top_end = if let Some(top_end) = file_contents
127+
.lines()
128+
.enumerate()
129+
.skip(lines.0 - 1)
130+
.find_map(|line| line.1.contains('⧼').then_some(line.0))
131+
{
132+
top_end
133+
} else {
134+
(if let Some(body) = fns.body.first() {
135+
match body {
136+
Thing::Identifier(ident) => ident.line,
137+
Thing::Expression(expr) => expr.line,
138+
Thing::Function(fns) => fns.line,
139+
Thing::IfStatement(ifs) => ifs.line,
140+
Thing::LoopStatement(loops) => loops.line,
141+
Thing::Break(line)
142+
| Thing::Continue(line)
143+
| Thing::Return(_, line) => *line,
144+
}
145+
} else {
146+
results.append(&mut find_function_recurse(
147+
name,
148+
file_contents,
149+
fns.body,
150+
&new_current,
151+
));
152+
continue;
153+
}) as usize
131154
};
132155
let top = file_contents
133156
.lines()

0 commit comments

Comments
 (0)