-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add a way to construct custom position in TASTy Reflect #6148
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
Add a way to construct custom position in TASTy Reflect #6148
Conversation
|
@alemannosara here I will add a way for you to create the precise positions inside string literals you need. |
|
I thought we discussed this and decided to not allow users to define custom positions since they're too easy to get wrong which might lead to crash when they're checked later ? |
|
This PR doesn't actually allow the position to be set on a tree. The only way to use it is in an error message. Though I could add a special error method that receives custom offsets instead. |
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.
Otherwise, LGTM
| * @param start index of the start of the range (0 <= start < end) | ||
| * @param end index of the end of the range (start < end <= sizeOf(pos.sourceFile)) | ||
| */ | ||
| def Position_withOffset(self: Position)(start: Int, end: Int): Position |
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.
When I see this API, the first guess is that the offset is relative to the given position self. But in the implementation, only the source file is used. It seems this is better to be defined as a constructor for Position which takes sourceFile directly.
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.
That would be terrible, each source position will try to reload the file.
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.
Maybe we should have the source file abstraction in TASTy reflect
|
Replaced by #6158 |
No description provided.