MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / add

Method add

codegraph-kernel/src/ccpp/brace_scopes.rs:27–42  ·  view source on GitHub ↗

Adds the interval `(open, close)`. One that opens before the last one added, or crosses one that holds it, is refused (false).

(&mut self, open: usize, close: usize, value: T)

Source from the content-addressed store, hash-verified

25 /// Adds the interval `(open, close)`. One that opens before the last one
26 /// added, or crosses one that holds it, is refused (false).
27 pub fn add(&mut self, open: usize, close: usize, value: T) -> bool {
28 if close <= open || self.opens.last().is_some_and(|&last| open <= last) {
29 return false;
30 }
31 let parent = self.innermost(open);
32 if let Some(p) = parent {
33 if close >= self.closes[p] {
34 return false;
35 }
36 }
37 self.opens.push(open);
38 self.closes.push(close);
39 self.parents.push(parent);
40 self.values.push(value);
41 true
42 }
43
44 /// The values of the intervals holding `offset` (open < offset < close), outermost first.
45 pub fn at(&self, offset: usize) -> Vec<T> {

Callers 2

open_class_scopeMethod · 0.45
scanFunction · 0.45

Calls 2

pushMethod · 0.80
innermostMethod · 0.45

Tested by

no test coverage detected