Skip to content

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

Merged
merged 3 commits into from
Sep 22, 2016
Merged

Conversation

MasseGuillaume
Copy link
Contributor

@MasseGuillaume MasseGuillaume commented Sep 21, 2016

replaces #1528

dotty-bridge/scripted compilerReporter/simple

@@ -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")
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

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),
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, finally!

Copy link
Contributor Author

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

Copy link
Contributor Author

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))
Copy link
Member

@smarter smarter Sep 22, 2016

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

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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) {
Copy link
Member

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)

Copy link
Contributor Author

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))
Copy link
Member

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]

Copy link
Contributor Author

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 {
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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[...]

Copy link
Contributor Author

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("")
Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@MasseGuillaume MasseGuillaume force-pushed the feature/sbt-bridge-reporter branch from ad9d8cf to df0942f Compare September 22, 2016 14:54
@MasseGuillaume
Copy link
Contributor Author

@smarter all issues resolved!

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work!

@smarter
Copy link
Member

smarter commented Sep 22, 2016

Though please squash the last commit with the review fixes in a previous one if possible

@MasseGuillaume MasseGuillaume force-pushed the feature/sbt-bridge-reporter branch from df0942f to 1e2bbb2 Compare September 22, 2016 17:44
@MasseGuillaume
Copy link
Contributor Author

@smarter rebased

@smarter
Copy link
Member

smarter commented Sep 22, 2016

/rebuild

@smarter smarter merged commit a27ac72 into scala:master Sep 22, 2016
@MasseGuillaume MasseGuillaume deleted the feature/sbt-bridge-reporter branch September 23, 2016 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants