-
Notifications
You must be signed in to change notification settings - Fork 121
sbt.internal.inc.Position: add startOffset and endOffset #571
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
Conversation
(Running the validation against sbt/util#173) |
The validator has checked the following projects against Scala 2.12,
✅ The result is: SUCCESS |
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.
Let's not upgrade to sbt 1.2.1 here, since it causes build problems (last time I tried). Alternatively, I guess the build also fails here because we have yet to publish a jar with sbt/util#173 (review). Otherwise the patch LGTM!
A position now has a start, an end, and a point (the existing `offset`), just like it does in the Scala compiler. This information is especially useful for displaying squiggly lines in an IDE. This commit and the next one are required for sbt/zinc#571
So should this PR target 1.x branch? |
Any reason it couldn't get in the next 1.2 release? |
Targeting 1.x is better, we could branch out (or cherry pick) in 1.2.2 from there. |
I think it depends on how critical this change is. For sbt, we don't go through RC cycle for patch releases, so we try to keep them to bug fixes. Considering that 1.3.0 will be a few months away, I'm open to a few enhancements added during 1.2.x but we need to be fairly confident that it won't cause compatibility problems. |
It's critical to getting any BSP implementation for Scala working. My goal is for us to be able to give the Intro to FP course at EPFL that starts in mid-September using Dotty, which means using the Dotty IDE, which would really benefit from the BSP. |
I second this change, compatibility issues with this patch are close to zero IMO. |
82b57d6
to
9d9741f
Compare
9d9741f
to
ed1b515
Compare
Moved to 1.x as requested, and I'll make a PR for backporting it as soon as it is merged.
|
||
// Same logic as Position#line | ||
def lineOf(offset: Int) = src.offsetToLine(offset) + 1 | ||
def columnOf(offset: Int) = offset - src.lineToOffset(src.offsetToLine(offset)) |
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.
It's always been this way, but isn't it weird that lines in the zinc Reporter are 1-based and columns are 0-based ?
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.
Yes, I would welcome a change here, I have no idea of the rationale of the previous change.
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.
LGTM
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.
LGTM
This is a backport of sbt#571.
This is a backport of sbt#571 to the 1.2.x branch.
A position now has a start, an end, and a point (the existing `offset`), just like it does in the Scala compiler. This information is especially useful for displaying squiggly lines in an IDE. This commit and the next one are required for sbt/zinc#571
This change seems to interact poorly with Scaladoc. I think the root bug is in Scaladoc which is spitting out an invalid end position for use cases. Minimized: https://github.com/retronym/sbt-scaladoc-aioooe
Zinc could guard against the dodgy positions here. I'll see if I can figure out how to fix the positions in Scaladoc itself. |
Submitted a Scala bug for this: scala/bug#11865 |
This is a follow-up to sbt/util#173