Skip to content

Conversation

@simoncozens
Copy link
Contributor

As discussed with @cmyr yesterday - .edit() is a useful thing, but currently the ranges produced in the new tree are inaccurate and need to be recompute.

@simoncozens simoncozens requested a review from cmyr November 5, 2025 12:28
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, two little notes inline but otherwise happy to see this merged :)

//!
//! This is currently unused.
#![allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also remove this #![allow] please?

///
/// range start/end just fall on token boundaries.
pub(crate) fn edit(&self, edits: Vec<(Range<usize>, Node)>, skip_parent: bool) -> Node {
/// Assumes that the range start/end just fall on token boundaries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that 'just' was a typo for 'must', but if this is public API now I would be a bit more formal:

Suggested change
/// Assumes that the range start/end just fall on token boundaries.
/// # Panics
///
/// Panics if the provided range is not the range of an existing node or token.

Some things I noticed just now, reading through the old code:

  • there's no concept of an insertion that does not replace something. (Of course you could fake this by prepending a copy of the node-to-be-replaced at the front of the replacement) This would be easy enough to add, it just wasn't needed originally.
  • the edit cannot occur unless at a 'node boundary'. For instance for the statement sub a by b; we could replace the whole statement, or we could replace any individual token, but we could not replace sub a or by b.

@simoncozens
Copy link
Contributor Author

I don't need this any more as I'm rewriting the whole feature file using fea-rs-ast rather than trying to do piecemeal edits. I can clear the PR up if you still would like to see it in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants