pub struct Index {
pub namespaces: Vec<(String, String)>,
pub elements: Vec<Element>,
/* private fields */
}Fields§
§namespaces: Vec<(String, String)>xmlns bindings of the root element: (prefix, IRI); "" for the
default namespace.
elements: Vec<Element>Implementations§
Source§impl Index
impl Index
Sourcepub fn edited(
self,
old: &str,
old_lines: &LineIndex,
new: &str,
new_lines: &LineIndex,
edits: &[TextEdit],
) -> Result<(Index, Vec<String>), Index>
pub fn edited( self, old: &str, old_lines: &LineIndex, new: &str, new_lines: &LineIndex, edits: &[TextEdit], ) -> Result<(Index, Vec<String>), Index>
The index of new: this index’s text, old, with edits applied (each placed in old as
it was), the lines of each counted. Only what the edits changed is read again, widened to
whole elements and lines; the elements after it keep theirs, moved by the lines it added or
took. Some 0.02 s for an edit of RealGrid’s EQ file, where reading it whole takes 0.5 s.
With the mRIDs of the objects written where the edits are, before and after them: those
they touched.
Err gives this index back for an edit around the objects (the XML declaration, the root
element) or one that leaves an element open: read new whole.
Sourcepub fn of(&self, mrid: &str) -> impl Iterator<Item = &Element>
pub fn of(&self, mrid: &str) -> impl Iterator<Item = &Element>
The elements writing the object mrid, in document order.
Sourcepub fn places_of(&self, mrid: &str) -> &[u32]
pub fn places_of(&self, mrid: &str) -> &[u32]
The places in elements of those writing the object mrid, in document order.
Sourcepub fn namespace(&self, prefix: &str) -> Option<&str>
pub fn namespace(&self, prefix: &str) -> Option<&str>
The namespace IRI prefix is bound to at the root.
Sourcepub fn class_of(&self, qname: &str) -> Option<&'static ClassDef>
pub fn class_of(&self, qname: &str) -> Option<&'static ClassDef>
The class of an element written qname here: by its prefix’s namespace, else by its
local name alone.
Sourcepub fn element_at(&self, pos: Position) -> Option<&Element>
pub fn element_at(&self, pos: Position) -> Option<&Element>
The element whose start-to-end span contains pos.