This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Unify position and range types in parser and syntax tree #523
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
Contributor
Author
|
C# generation tests are currently broken for an unknown reason (they pass on my computer, but fail on the CI with an unhelpful error message). Other than that, I think it's ready to review. |
This reverts commit ec0273f.
Contributor
Author
|
All tests re-enabled and passing now. |
ScottCarda-MS
approved these changes
Jul 20, 2020
Contributor
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 pretty good! Standardizing this concept across the repo really makes things easier to understand and work with. I was a bit over my head with some of the FParsec parsing stuff, but other than that everything made sense to me.
4 tasks
bamarsha
added a commit
that referenced
this pull request
Aug 26, 2020
* Unify position and range types in parser and syntax tree (#523) * Add new Position and Range types * Require line and column to be non-negative * Require start <= end * Replace private record with DU case * Add documentation * Fix sln file * Remove custom equality/comparison * Add backwards-compatible JSON serializers * Disable Example test target for now * Fix RangePosition serialization * Generate valid ranges in SymbolManagementTests * Skip execution tests for now * Fix null offset in QsDeclarationAttribute * Fix position + range * Remove range + position * Write private constructor on one line * Rename Range.Combine to Range.Span * Add more documentation * Use 1-based range positions in serialization * Re-enable C# generation tests * Disable execution tests again * Revert "Disable execution tests again" This reverts commit ec0273f. * Update package references * Subtract 1 from all range positions in SerializationTests * Replace TryGetFileId with GetFileId in SerializationTests * Rename id to ident * Replace some LSP positions with Q# positions * Replace LSP positions in DataStructures.cs * Replace LSP positions in ContextBuilder.cs * Replace LSP positions in TextProcessor.cs * Replace LSP positions in TypeChecking.cs * Remove type parameters from SymbolTracker and ScopeContext * Replace LSP positions in CodeActions.cs * Replace LSP positions in CodeCompletion.cs * Replace LSP positions in EditorCommands.cs * Replace LSP positions in Diagnostics.cs * Remove unused functions * Remove more unnecessary functions * Remove IsSmallerThan and IsSmallerThanOrEqualTo * Add Range.Contains * Update docs and variable names for + and - * Convert some LSP ranges to Q# ranges * Rename IsValidPosition/Range with file to ContainsPosition/Range * Remove IsValidPosition and IsValidRange * Replace more ranges * Avoid unnecessary conversion * Replace GetRange() with Range * Use properties for positions in TreeNode * Replace HeaderEntry.GetPosition() with property * Fix build errors after merge * Add position in CheckDefinedTypesForCycles and ResolveAll * Add positions in verifyResultConditionalBlocks * Add positions in NewConjugation * Add positions in AllPathsReturnValueOrFail * Use lambda in CheckDefinedTypesForCycles * Update range type * Use original OnRangeInformation names * Use ContainsEnd * Specify end point is excluded in doc comment * Preserve comments * Rename TranslateLines to WithLineNumOffset
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
I added two new types,
PositionandRange, replacing these types:FParsec.Positionint * intQsPositionInfoQsPositionInfo * QsPositionInfoQsRangeInfoThe new
Positiontype is zero-based, so it has a well-defined addition operator. I replaced FParsec'sgetPositionparser with one that returns the new zero-basedPositiontype directly, so the compiler never has to deal with one-based positions anymore.This is the first step in #506. Now that these types are defined, in the next PR I'll continue updating the diagnostics code to use them, replacing the LSP position and range types as much as possible.