-
-
Notifications
You must be signed in to change notification settings - Fork 133
feat(web): add isSameNode for duplicate quotient-node detection 🚂 #15478
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
base: feat/web/spur-edge-key
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,25 @@ export class SearchQuotientRoot implements SearchQuotientNode { | |
| return ''; | ||
| } | ||
|
|
||
| isSameNode(space: SearchQuotientNode): boolean { | ||
| // Easiest cases: when the instances or their ' `spaceId` matches, we have | ||
| // a perfect match. | ||
| if(this == space || this.spaceId == space.spaceId) { | ||
| return true; | ||
| } | ||
|
|
||
| // If it's falsy or a different SearchQuotientNode type, that's an easy filter. | ||
| if(!space || !(space instanceof SearchQuotientRoot)) { | ||
| return false; | ||
| } | ||
|
|
||
| // The two should be based upon the same LexicalModel. | ||
| if(this.model != space.model) { | ||
| return false; | ||
| } | ||
| return true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these not have parents to check for match?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the 'root' node - there is no parent here. |
||
| } | ||
|
|
||
| split(charIndex: number): [SearchQuotientNode, SearchQuotientNode] { | ||
| return [this, new SearchQuotientRoot(this.model)]; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -495,4 +495,26 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode { | |||||
| const segment = inputSrc.segment; | ||||||
| return `E${inputSrc.subsetId}:${segment.start}${segment.end !== undefined ? `-${segment.end}` : ''}`; | ||||||
| } | ||||||
|
|
||||||
| isSameNode(space: SearchQuotientNode): boolean { | ||||||
| // Easiest cases: when the instances or their ' `spaceId` matches, we have | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| // a perfect match. | ||||||
| if(this == space || this.spaceId == space.spaceId) { | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| // If it's falsy or a different SearchSpace type, that's an easy filter. | ||||||
| if(!space || !(space instanceof SearchQuotientSpur)) { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // If this spur does not match the exact same edge conditions as the other spur, | ||||||
| // they are not duplicates. | ||||||
| if(this.edgeKey != space.edgeKey) { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| // Finally, we recursively verify that the parent matches. | ||||||
| return this.parentNode.isSameNode(space.parentNode); | ||||||
| } | ||||||
| } | ||||||
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.
Do we have to check that
thisandspacehave the same number of parents?