-
Notifications
You must be signed in to change notification settings - Fork 1.1k
sbt bridge reporter #1530
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
sbt bridge reporter #1530
Conversation
19265b9
to
7fea64c
Compare
7fea64c
to
251b385
Compare
@@ -207,11 +207,28 @@ object DottyBuild extends Build { | |||
). | |||
settings(publishing) | |||
|
|||
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402) | |||
lazy val cleanBridge = TaskKey[Unit]("clean-sbt-bridge", "delete dotty-sbt-bridge cache") |
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.
I would call this cleanSbtBridge
since that's how you would call this from sbt
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.
the convention is to use a-b-c
http://www.scala-sbt.org/0.13/sxr/sbt/Keys.scala.html#sbt.Keys.logLevel
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.
ah more or less: http://www.scala-sbt.org/0.13/sxr/sbt/Keys.scala.html#sbt.Keys.compileAnalysisFilename
:P. I will do as you said
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.
done
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.
Sorry if I wasn't totally clear, I meant that the val
should be called cleanSbtBridge
, but I'm fine with changing the key name too :)
IO.delete(file(home) / ".ivy2" / "cache" / "org.scala-sbt" / s"$org-$artifact-$dottyBridgeVersion-bin_${dottyVersion}__$classVersion") | ||
IO.delete(file(home) / ".sbt" / "boot" / "scala-2.10.6" / "org.scala-sbt" / "sbt" / sbtV / s"$org-$artifact-$dottyBridgeVersion-bin_${dottyVersion}__$classVersion") | ||
}, | ||
publishLocal <<= publishLocal.dependsOn(cleanBridge), |
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.
<<=
is deprecated: sbt/sbt#2716
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.
Awesome, finally!
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.
oki publishLocal := (publishLocal.dependsOn(cleanBridge)).value
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.
done
val ctx = (new ContextBase).initialCtx.fresh | ||
.setSbtCallback(callback) | ||
val freshContext = (new ContextBase).initialCtx.fresh | ||
val ctx = freshContext.setSbtCallback(callback).setReporter(DelegatingReporter(delegate)) |
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.
The set*
methods mutate the context and return this.type
, so it's misleading to give two different names (freshContext
and ctx
) to the same context
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 crashes the compiler if I don't write it like this.
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.
OK, could you come up with a minimal example and open an issue? and leave a comment to indicate that you're working around a crash with the issue number
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.
strange, I just tested and it works fine.
import xsbti.Maybe | ||
|
||
object DelegatingReporter { | ||
def apply(delegate: xsbti.Reporter) = new DelegatingReporter(delegate) |
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.
I would get rid of this and either make DelegatingReporter
a case class or construct it with new
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.
done
else None | ||
|
||
val file = | ||
if(d.pos.source.file.exists) { |
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.
Style: if (
, not if(
(same issue in other parts of this 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.
done
val offset0 = pos.map(_.point) | ||
|
||
val position = new xsbti.Position { | ||
def line: Maybe[Integer] = maybe(pos.map(_.line)) |
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[Int]
and Maybe[Integer]
are the same thing so just use Maybe[Int]
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.
case Some(s) => Maybe.just[T](s) | ||
} | ||
import java.lang.{ Integer => I } | ||
private[this] def maybeInt(opt: Option[Int]): Maybe[I] = opt match { |
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.
This method is unnecessary, just use maybe
above
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.
the compiler fails to infer with only maybe
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.
then write maybe[Int]
, please open an issue for this too if this is an issue specific to dotty
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.
scalac:
trait Position {
def offset(): Integer
}
object A {
val p = new Position {
def offset(): Int = 1
}
}
overriding method offset in trait Position of type ()Integer;
method offset has incompatible type
val position = new xsbti.Position { | ||
def line: Maybe[Integer] = maybe(pos.map(_.line)) | ||
def lineContent(): String = pos.map(_.lineContent).getOrElse("") | ||
def offset(): xsbti.Maybe[Integer] = maybeInt(offset0) |
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.
xsbti.Maybe
is imported so you can just write Maybe[...]
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.
done
|
||
val position = new xsbti.Position { | ||
def line: Maybe[Integer] = maybe(pos.map(_.line)) | ||
def lineContent(): String = pos.map(_.lineContent).getOrElse("") |
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.
Drop the empty param list ()
(same below)
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.
done
val file = | ||
if(d.pos.source.file.exists) { | ||
val r = d.pos.source.file.file | ||
if(r == null) None |
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.
Just write Option(d.pos.source.file.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.
done
ad9d8cf
to
df0942f
Compare
@smarter all issues resolved! |
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, great work!
Though please squash the last commit with the review fixes in a previous one if possible |
df0942f
to
1e2bbb2
Compare
@smarter rebased |
/rebuild |
replaces #1528
dotty-bridge/scripted compilerReporter/simple