-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Edge::label
from optional to required
#1205
base: main
Are you sure you want to change the base?
Change Edge::label
from optional to required
#1205
Conversation
This involves a couple of changes outside of just changing the field type: 1. `CursorIterator` must be able to produce a label for every node now. This wasn't possible before because the root nodes of a cursor had no parent, and so could not derive a label. I've changed `Cursor` in the following ways to fix this: * `Cursor::parent` is a new type, `Parent<T>`, instead of `Option<Rc<PathAncestor<T>>>`. `Parent<T>` is an enum with three variants - `None`, `Open(Rc<PathAncestor<T>>)`, and `Closed(Rc<PathAncestor<T>>)`. A `Closed` parent is used when a cursor is spawned from an arbitrary non-root node, and means that the parent can be read but not traversed to. `None` is only used for the true root node. 2. `KindTypes::EdgeLabel` is given a `Default` implementation, which for now just returns the first `PredefinedLabel` variant. This is needed in order to be able to set a "concrete" `EdgeLabel` value from the `metaslang_cst` crate. 3. Added a `Root` variant to `PredefinedLabel`. This will be used when a node is the true root node. For now this will be the default value for `KindTypes::EdgeLabel`.
🦋 Changeset detectedLatest commit: 8515650 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
crates/codegen/runtime/cargo/crate/src/runtime/cst/edge_label.rs.jinja2
Outdated
Show resolved
Hide resolved
crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/cst.wit
Outdated
Show resolved
Hide resolved
crates/codegen/runtime/cargo/wasm/src/runtime/interface/generated/cst.wit
Outdated
Show resolved
Hide resolved
crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs
Outdated
Show resolved
Hide resolved
crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/ast/generated/selectors.rs
Outdated
Show resolved
Hide resolved
crates/codegen/runtime/cargo/wasm/src/runtime/wrappers/cst/mod.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
.../testing/snapshots/cst_output/Block/postfix_recovery_regression/generated/0.4.11-failure.yml
Outdated
Show resolved
Hide resolved
@@ -27,7 +27,7 @@ Tree: | |||
- (for_keyword꞉ ForKeyword): "for" # (0..3) | |||
- (open_paren꞉ OpenParen): "(" # (3..4) | |||
- (initialization꞉ ForStatementInitialization) ► (variant꞉ VariableDeclarationStatement) ► (variable_type꞉ VariableDeclarationType) ► (variant꞉ TypeName) ► (variant꞉ ElementaryType) ► (variant꞉ IntKeyword): "int" # (4..7) | |||
- (MISSING): "" # (7..7) | |||
- (root꞉ MISSING): "" # (7..7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we are missing labels for MISSING
nodes. I wonder if we are able to use the original label the parser was trying to parse, to indicate what is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added an Unrecognized label for UNRECOGNIZED nodes. However, getting the correct label for MISSING nodes was not that straightforward, at least for how well I currently understand the parser. For now, I've left those as having the label Root. @OmarTawfik if you have any thoughts about how to get those labels, I'd be happy to go back and make those updates.
I see. Thanks for the update. This looks like it needs a bigger refactoring the parser codegen, and I don't think it should block this PR/fix.
So, for the time being, WDYT of adding a similar EdgeLabel::MISSING
for now, so that we don't mislabel them as root
in the meantime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #1215 to track this, and added it to the backlog for now.
…ted/cst.wit Co-authored-by: Omar Tawfik <[email protected]>
…rs.jinja2 Co-authored-by: Omar Tawfik <[email protected]>
…ted/cst.wit Co-authored-by: Omar Tawfik <[email protected]>
…geLabel, Node)>`
…o `Parent::Disconnected` * Change the inner type of `Parent::Disconnected` from another PathAncestor to `T::EdgeLabel` so that an ancestor can't be misused
I've added an All the other comments should be addressed now so this PR is ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made another pass on all unresoved comments.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is one unresolved comment still: #1205 (comment)
So, for the time being, WDYT of adding a similar EdgeLabel::MISSING for now, so that we don't mislabel them as root in the meantime?
Additionally, I suggest adding a changeset to describe the changes here.
Thanks!
Wasn't that added to the backlog as #1215? I thought that that was going to be resolved in the future. |
This involves a couple of changes outside of just changing the field type:
CursorIterator
must be able to produce a label for every node now. This wasn't possible before because the root nodes of a cursor had no parent, and so could not derive a label. I've changedCursor
in the following ways to fix this:Cursor::parent
is a new type,Parent<T>
, instead ofOption<Rc<PathAncestor<T>>>
.Parent<T>
is an enum with three variants -None
,Open(Rc<PathAncestor<T>>)
, andClosed(Rc<PathAncestor<T>>)
. AClosed
parent is used when a cursor is spawned from an arbitrary non-root node, and means that the parent can be read but not traversed to.None
is only used for the true root node.KindTypes::EdgeLabel
is given aDefault
implementation, which for now just returns the firstPredefinedLabel
variant. This is needed in order to be able to set a "concrete"EdgeLabel
value from themetaslang_cst
crate.Root
variant toPredefinedLabel
. This will be used when a node is the true root node. For now this will be the default value forKindTypes::EdgeLabel
.Closes #815