refactor block queries to remove InsertionQuery system#29
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unify InsertionQuery into BoundaryQuery API
Summary
Replaces the separate
InsertionQuerysystem with a cleanerBoundaryQueryapproach that integrates naturally with the existing query system. This simplifies the API for inserting content at block boundaries while maintaining full functionality.Motivation
The previous
InsertionQuerywas a parallel system with its own types (InsertionQuery,InsertionSide, extension methods like.Before(),.After(),.InnerStart(),.InnerEnd()) that only worked withSyntaxEditor.Insert(). This created API confusion and duplicated concepts.The new design uses
BoundaryQueryas a regularINodeQuerythat selects block boundaries (opener/closer), working naturally with the existingInsertBefore/InsertAftermethods.Changes
New
BoundaryQuerytype:INodeQueryfor consistency with the query systemSyntaxEditorfor empty block supportAPI Changes:
.Insert(query.Before(), text).InsertBefore(query, text).Insert(query.After(), text).InsertAfter(query, text).Insert(block.InnerStart(), text).InsertAfter(block.Start(), text).Insert(block.InnerEnd(), text).InsertBefore(block.End(), text)Removed:
InsertionQueryrecordInsertionSideenumInsertionQueryExtensionsclass.Before(),.After(),.InnerStart(),.InnerEnd()extension methods on query typesSyntaxEditor.Insert(InsertionQuery, ...)overloadsAdded:
BoundaryQueryrecord implementingINodeQueryBoundarySideenum (Start/End).Start()and.End()methods onBlockNodeQueryandNamedBlockQuery.InnerStart(blockName)and.InnerEnd(blockName)convenience extensions forIBlockContainerNodequeriesExample
Testing
SyntaxNodeTests.cs,SyntaxTreeTests.cs