Skip to content

Commit

Permalink
Remove line numbers for dependency sources
Browse files Browse the repository at this point in the history
This avoids repeating the situation where upgrading to 2.12.8 broke the
navigation tests. We still keep line numbers in workspace sources
because we test that changes in the buffers are respected.
  • Loading branch information
olafurpg committed Dec 7, 2018
1 parent a04c2cf commit d136bff
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 65 deletions.
6 changes: 4 additions & 2 deletions tests/unit/src/main/scala/tests/TestingServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ final class TestingServer(
if (isSameFile) {
s"L${location.getRange.getStart.getLine}"
} else {
val filename = location.getUri.toAbsolutePath.toNIO.getFileName
s"$filename:${location.getRange.getStart.getLine}"
val path = location.getUri.toAbsolutePath
val filename = path.toNIO.getFileName
if (path.isDependencySource(workspace)) filename.toString
else s"$filename:${location.getRange.getStart.getLine}"
}
}
val occurrence = token match {
Expand Down
81 changes: 39 additions & 42 deletions tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,24 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
_ = assertNoDiff(client.workspaceDiagnostics, "")
_ = assertNoDiff(
server.workspaceDefinitions,
"""|
|/a/src/main/scala/a/Main.scala
"""|/a/src/main/scala/a/Main.scala
|package a
|import java.util.concurrent.Future/*Future.java:95*/ // unused
|import scala.util.Failure/*Try.scala:213*/ // unused
|object Main/*L3*/ extends App/*App.scala:38*/ {
|import java.util.concurrent.Future/*Future.java*/ // unused
|import scala.util.Failure/*Try.scala*/ // unused
|object Main/*L3*/ extends App/*App.scala*/ {
| val message/*L4*/ = Message/*Message.java:1*/.message/*Message.java:2*/
| new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/())
| println/*Predef.scala:396*/(message/*L4*/)
| new java.io.PrintStream/*PrintStream.java*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java*/())
| println/*Predef.scala*/(message/*L4*/)
|}
|/b/src/main/scala/a/MainSuite.scala
|package a
|import java.util.concurrent.Future/*Future.java:95*/ // unused
|import scala.util.Failure/*Try.scala:213*/ // unused
|import org.scalatest.FunSuite/*FunSuite.scala:1559*/
|object MainSuite/*L4*/ extends FunSuite/*FunSuite.scala:1559*/ {
| test/*FunSuiteLike.scala:119*/("a") {
| val condition/*L6*/ = Main/*Main.scala:3*/.message/*Main.scala:4*/.contains/*String.java:2131*/("Hello")
| assert/*Assertions.scala:414*/(condition/*L6*/)
|import java.util.concurrent.Future/*Future.java*/ // unused
|import scala.util.Failure/*Try.scala*/ // unused
|import org.scalatest.FunSuite/*FunSuite.scala*/
|object MainSuite/*L4*/ extends FunSuite/*FunSuite.scala*/ {
| test/*FunSuiteLike.scala*/("a") {
| val condition/*L6*/ = Main/*Main.scala:3*/.message/*Main.scala:4*/.contains/*String.java*/("Hello")
| assert/*Assertions.scala*/(condition/*L6*/)
| }
|}
|""".stripMargin
Expand All @@ -101,29 +100,28 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
// - old references to `message` don't resolve because it has been renamed to `helloMessage`
// - new references to like `testName` don't resolve
server.workspaceDefinitions,
"""|
|/a/src/main/scala/a/Main.scala
"""|/a/src/main/scala/a/Main.scala
|>>>>>>>/*<no symbol>*/
|
|package a
|import java.util.concurrent.Future/*Future.java:95*/ // unused
|import scala.util.Failure/*Try.scala:213*/ // unused
|object Main/*L5*/ extends App/*App.scala:38*/ {
|import java.util.concurrent.Future/*Future.java*/ // unused
|import scala.util.Failure/*Try.scala*/ // unused
|object Main/*L5*/ extends App/*App.scala*/ {
| val helloMessage/*<no symbol>*/ = Message/*Message.java:1*/.message/*Message.java:2*/
| new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/())
| println/*Predef.scala:396*/(message/*<no symbol>*/)
| new java.io.PrintStream/*PrintStream.java*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java*/())
| println/*Predef.scala*/(message/*<no symbol>*/)
|}
|/b/src/main/scala/a/MainSuite.scala
|>>>>>>>/*<no symbol>*/
|
|package a
|import java.util.concurrent.Future/*Future.java:95*/ // unused
|import scala.util.Failure/*Try.scala:213*/ // unused
|import org.scalatest.FunSuite/*FunSuite.scala:1559*/
|object MainSuite/*L6*/ extends FunSuite/*FunSuite.scala:1559*/ {
| test/*FunSuiteLike.scala:119*/(testName/*<no symbol>*/) {
| val condition/*L8*/ = Main/*Main.scala:5*/.message/*<no symbol>*/.contains/*String.java:2131*/("Hello")
| assert/*Assertions.scala:414*/(condition/*L8*/)
|import java.util.concurrent.Future/*Future.java*/ // unused
|import scala.util.Failure/*Try.scala*/ // unused
|import org.scalatest.FunSuite/*FunSuite.scala*/
|object MainSuite/*L6*/ extends FunSuite/*FunSuite.scala*/ {
| test/*FunSuiteLike.scala*/(testName/*<no symbol>*/) {
| val condition/*L8*/ = Main/*Main.scala:5*/.message/*<no symbol>*/.contains/*String.java*/("Hello")
| assert/*Assertions.scala*/(condition/*L8*/)
| }
|}
|""".stripMargin
Expand Down Expand Up @@ -167,12 +165,12 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
|/**
| * Must obey the laws defined in cats.laws.ContravariantLaws.
| */
|@typeclass/*<no symbol>*/ trait Contravariant/*L5*/[F/*L5*/[_]] extends Invariant/*Invariant.scala:7*/[F/*L5*/] { self/*L5*/ =>
|@typeclass/*<no symbol>*/ trait Contravariant/*L5*/[F/*L5*/[_]] extends Invariant/*Invariant.scala*/[F/*L5*/] { self/*L5*/ =>
| def contramap/*L6*/[A/*L6*/, B/*L6*/](fa/*L6*/: F/*L5*/[A/*L6*/])(f/*L6*/: B/*L6*/ => A/*L6*/): F/*L5*/[B/*L6*/]
| override def imap/*L7*/[A/*L7*/, B/*L7*/](fa/*L7*/: F/*L5*/[A/*L7*/])(f/*L7*/: A/*L7*/ => B/*L7*/)(fi/*L7*/: B/*L7*/ => A/*L7*/): F/*L5*/[B/*L7*/] = contramap/*L6*/(fa/*L7*/)(fi/*L7*/)
|
| def compose/*L9*/[G/*L9*/[_]: Contravariant/*L5*/]: Functor/*Functor.scala:11*/[λ/*<no symbol>*/[α/*<no symbol>*/ => F/*<no symbol>*/[G/*<no symbol>*/[α/*<no symbol>*/]]]] =
| new ComposedContravariant/*Composed.scala:107*/[F/*L5*/, G/*L9*/] {
| def compose/*L9*/[G/*L9*/[_]: Contravariant/*L5*/]: Functor/*Functor.scala*/[λ/*<no symbol>*/[α/*<no symbol>*/ => F/*<no symbol>*/[G/*<no symbol>*/[α/*<no symbol>*/]]]] =
| new ComposedContravariant/*Composed.scala*/[F/*L5*/, G/*L9*/] {
| val F/*L11*/ = self/*L5*/
| val G/*L12*/ = Contravariant/*<no symbol>*/[G/*L9*/]
| }
Expand All @@ -185,18 +183,18 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
|
| def liftContravariant/*L21*/[A/*L21*/, B/*L21*/](f/*L21*/: A/*L21*/ => B/*L21*/): F/*L5*/[B/*L21*/] => F/*L5*/[A/*L21*/] = contramap/*L6*/(_: F/*L5*/[B/*L21*/])(f/*L21*/)
|
| override def composeFunctor/*L23*/[G/*L23*/[_]: Functor/*Functor.scala:11*/]: Contravariant/*L5*/[λ/*<no symbol>*/[α/*<no symbol>*/ => F/*<no symbol>*/[G/*<no symbol>*/[α/*<no symbol>*/]]]] =
| new ComposedContravariantCovariant/*Composed.scala:115*/[F/*L5*/, G/*L23*/] {
| override def composeFunctor/*L23*/[G/*L23*/[_]: Functor/*Functor.scala*/]: Contravariant/*L5*/[λ/*<no symbol>*/[α/*<no symbol>*/ => F/*<no symbol>*/[G/*<no symbol>*/[α/*<no symbol>*/]]]] =
| new ComposedContravariantCovariant/*Composed.scala*/[F/*L5*/, G/*L23*/] {
| val F/*L25*/ = self/*L5*/
| val G/*L26*/ = Functor/*Functor.scala:11*/[G/*L23*/]
| val G/*L26*/ = Functor/*Functor.scala*/[G/*L23*/]
| }
|}
|
|/a/src/main/scala/a/Main.scala
|import cats._
|import cats.implicits/*implicits.scala:2*/._
|import cats.implicits/*implicits.scala*/._
|object Main/*L2*/ {
| println/*Predef.scala:396*/(Contravariant/*Contravariant.scala:5*/[Show/*Show.scala:9*/])
| println/*Predef.scala*/(Contravariant/*Contravariant.scala*/[Show/*Show.scala*/])
|}
""".stripMargin
)
Expand Down Expand Up @@ -278,11 +276,10 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
_ <- server.didOpen("a/src/main/scala/a/Main.scala")
_ = assertNoDiff(
server.workspaceDefinitions,
"""
|/a/src/main/scala/a/Main.scala
|object Main/*L0*/ {
| val x/*L1*/: Int/*Int.scala:21*/ = math.max/*package.scala:191*/(1, 2)
|}
"""|/a/src/main/scala/a/Main.scala
|object Main/*L0*/ {
| val x/*L1*/: Int/*Int.scala*/ = math.max/*package.scala*/(1, 2)
|}
""".stripMargin
)
_ <- server.didSave("a/src/main/scala/a/Main.scala")(
Expand All @@ -292,7 +289,7 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") {
server.workspaceDefinitions,
"""|/a/src/main/scala/a/Main.scala
|object Main/*L0*/ {
| val x/*L1*/: Int/*Int.scala:21*/ = math.max/*package.scala:191*/
| val x/*L1*/: Int/*Int.scala*/ = math.max/*package.scala*/
|}
|""".stripMargin
)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ object FileWatcherSlowSuite extends BaseSlowSuite("file-watcher") {
|/c/src/main/scala/C.scala
|package c
|object C/*L1*/ {
| println/*Predef.scala:396*/(a.ScalaFileEvent/*A.scala:3*/)
| println/*Predef.scala:396*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/)
| println/*Predef.scala*/(a.ScalaFileEvent/*A.scala:3*/)
| println/*Predef.scala*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/)
|}
|""".stripMargin
)
Expand Down
37 changes: 18 additions & 19 deletions tests/unit/src/test/scala/tests/QuickBuildSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,24 @@ object QuickBuildSuite extends BaseSlowSuite("quick-build") {
_ <- server.didOpen("a/src/main/scala/a/A.scala")
_ = assertNoDiff(
server.workspaceDefinitions,
"""
|/a/src/main/scala/a/A.scala
|package a
|import com.geirsson.coursiersmall._
|import scala.util.Success/*Try.scala:239*/
|object A/*L3*/ {
| val settings/*L4*/ = new Settings/*Settings.scala:16*/()
|}
|/b/src/main/scala/b/B.scala
|package b
|import a._
|import scala.util.Success/*Try.scala:239*/
|import org.scalatest._
|class B/*L4*/ extends FunSuite/*FunSuite.scala:1559*/ {
| test/*FunSuiteLike.scala:119*/("") {
| println/*Predef.scala:392*/(A/*A.scala:3*/.settings/*A.scala:4*/)
| }
|}
""".stripMargin
"""|/a/src/main/scala/a/A.scala
|package a
|import com.geirsson.coursiersmall._
|import scala.util.Success/*Try.scala*/
|object A/*L3*/ {
| val settings/*L4*/ = new Settings/*Settings.scala*/()
|}
|/b/src/main/scala/b/B.scala
|package b
|import a._
|import scala.util.Success/*Try.scala*/
|import org.scalatest._
|class B/*L4*/ extends FunSuite/*FunSuite.scala*/ {
| test/*FunSuiteLike.scala*/("") {
| println/*Predef.scala*/(A/*A.scala:3*/.settings/*A.scala:4*/)
| }
|}
|""".stripMargin
)
} yield ()
}
Expand Down

0 comments on commit d136bff

Please sign in to comment.