summaryrefslogtreecommitdiff
path: root/src/tracing_emitter.rs
AgeCommit message (Collapse)Author
2023-09-28break!: make AttributeMap::get return Option<&str>Martin Fischer
Most of the time you'll only be interested in the attribute value, so the `get` method should directly return it instead of a wrapper type. This also makes the API more predictable since e.g. the DOM getAttribute method also returns a string. Lastly previously it was quite confusing that map[key] wasn't equivalent to map.get(key).unwrap().
2023-09-28feat: add span to Trace::CharMartin Fischer
2023-09-28feat: add offset to Trace::EndOfFileMartin Fischer
2023-09-28break!: move offsets out of TokenMartin Fischer
Previously the Token enum contained the offsets using the O generic type parameter, which could be a usize if you're tracking offsets or a zero-sized type if you didn't care about offsets. This commit moves all the byte offset and syntax information to a new Trace enum, which has several advantages: * Traces can now easily be stored separately, while the tokens are fed to the tree builder. (The tree builder only has to keep track of which tree nodes originate from which tokens.) * No needless generics for functions that take a token but don't care about offsets (a tree construction implementation is bound to have many of such functions). * The FromIterator<(String, String)> impl for AttributeMap no longer has to specify arbitrary values for the spans and the value_syntax). * The PartialEq implementation of Token is now much more useful (since it no longer includes all the offsets). * The Debug formatting of Token is now more readable (since it no longer includes all the offsets). * Function pointers to functions accepting tokens are possible. (Since function pointer types may not have generic parameters.)
2023-09-28refactor: make TracingEmitter only work with usizesMartin Fischer
2023-09-28break!: rename DefaultEmitter to TracingEmitterMartin Fischer