diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala index d85657756f6..844cad3e972 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/HoverProvider.scala @@ -111,7 +111,7 @@ class HoverProvider(val compiler: MetalsGlobal, params: OffsetParams) { pos = pos, range = pos ) - case _: Literal => + case _: Literal if params.isInstanceOf[RangeParams] => val symbol = tree.symbol toHover( symbol = symbol, @@ -204,7 +204,9 @@ class HoverProvider(val compiler: MetalsGlobal, params: OffsetParams) { range: Position ): Option[Hover] = { if (tpe == null || tpe.isErroneous || tpe == NoType) None - else if (symbol == null || symbol == NoSymbol || symbol.isErroneous) { + else if ( + pos.start != pos.end && (symbol == null || symbol == NoSymbol || symbol.isErroneous) + ) { val context = doLocateContext(pos) val history = new ShortenedNames( lookupSymbol = name => context.lookupSymbol(name, _ => true) :: Nil @@ -258,7 +260,12 @@ class HoverProvider(val compiler: MetalsGlobal, params: OffsetParams) { } else { "" } - val markdown = HoverMarkup(prettyType, prettySignature, docstring) + val markdown = HoverMarkup( + prettyType, + prettySignature, + docstring, + pos.start != pos.end + ) val hover = new Hover(markdown.toMarkupContent) if (range.isRange) { hover.setRange(range.toLSP) diff --git a/mtags/src/main/scala/scala/meta/internal/metals/CompilerOffsetParams.scala b/mtags/src/main/scala/scala/meta/internal/metals/CompilerOffsetParams.scala index f9bfec88718..e1d2e257948 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/CompilerOffsetParams.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/CompilerOffsetParams.scala @@ -10,6 +10,20 @@ import scala.meta.pc.CancelToken import scala.meta.pc.OffsetParams import scala.meta.pc.RangeParams +trait OffsetParamsUtils { + protected def syntaxURI(pos: Position): URI = { + val syntax = pos.input.syntax + try { + val uri = URI.create(syntax) + Paths.get(uri) + uri + } catch { + case _: IllegalArgumentException | _: URISyntaxException => + Paths.get(syntax).toUri + } + } +} + case class CompilerOffsetParams( uri: URI, text: String, @@ -17,19 +31,10 @@ case class CompilerOffsetParams( token: CancelToken = EmptyCancelToken ) extends OffsetParams -object CompilerOffsetParams { +object CompilerOffsetParams extends OffsetParamsUtils { def fromPos(pos: Position, token: CancelToken): CompilerOffsetParams = { - val syntax = pos.input.syntax - val uri = - try { - val uri = URI.create(syntax) - Paths.get(uri) - uri - } catch { - case _: IllegalArgumentException | _: URISyntaxException => - Paths.get(syntax).toUri - } + val uri = syntaxURI(pos) CompilerOffsetParams( uri, pos.input.text, @@ -55,19 +60,10 @@ case class CompilerRangeParams( ) } -object CompilerRangeParams { +object CompilerRangeParams extends OffsetParamsUtils { def fromPos(pos: Position, token: CancelToken): CompilerRangeParams = { - val syntax = pos.input.syntax - val uri = - try { - val uri = URI.create(syntax) - Paths.get(uri) - uri - } catch { - case _: IllegalArgumentException | _: URISyntaxException => - Paths.get(syntax).toUri - } + val uri = syntaxURI(pos) CompilerRangeParams( uri, pos.input.text, diff --git a/mtags/src/main/scala/scala/meta/internal/pc/HoverMarkup.scala b/mtags/src/main/scala/scala/meta/internal/pc/HoverMarkup.scala index d6ac65b94df..5018343a650 100644 --- a/mtags/src/main/scala/scala/meta/internal/pc/HoverMarkup.scala +++ b/mtags/src/main/scala/scala/meta/internal/pc/HoverMarkup.scala @@ -13,17 +13,22 @@ object HoverMarkup { def apply( expressionType: String, symbolSignature: String, - docstring: String + docstring: String, + forceExpressionType: Boolean = false ): String = { val markdown = new StringBuilder() - markdown - .append("**Expression type**:\n") - .append("```scala\n") - .append(expressionType) - .append("\n```\n") + val needsExpressionType = + forceExpressionType || !symbolSignature.endsWith(expressionType) + if (needsExpressionType) { + markdown + .append("**Expression type**:\n") + .append("```scala\n") + .append(expressionType) + .append("\n```\n") + } if (symbolSignature.nonEmpty) { markdown - .append("**Symbol signature**:\n") + .append(if (needsExpressionType) "**Symbol signature**:\n" else "") .append("```scala\n") .append(symbolSignature) .append("\n```") diff --git a/tests/cross/src/test/scala/tests/hover/HoverDefnSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverDefnSuite.scala index 17d6ee0b971..60dd6a7edad 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverDefnSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverDefnSuite.scala @@ -10,12 +10,8 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|List[Int] - |val x: List[Int] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: List[Int]".hover - ) + """|val x: List[Int] + |""".stripMargin.hover ) check( @@ -24,12 +20,8 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|List[Int] - |var x: List[Int] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "var x: List[Int]".hover - ) + """|var x: List[Int] + |""".stripMargin.hover ) check( @@ -38,12 +30,8 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|List[Int] - |def x: List[Int] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "def x: List[Int]".hover - ) + """|def x: List[Int] + |""".stripMargin.hover ) check( @@ -52,12 +40,8 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|List[Int] - |def method(x: Int): List[Int] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "def method(x: Int): List[Int]".hover - ) + """|def method(x: Int): List[Int] + |""".stripMargin.hover ) check( @@ -66,12 +50,8 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|Option[T] - |def empty[T]: Option[T] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "def empty[T]: Option[T]".hover - ) + """|def empty[T]: Option[T] + |""".stripMargin.hover ) check( @@ -83,10 +63,7 @@ class HoverDefnSuite extends BaseHoverSuite { """ |Option[T] |def empty[T: Ordering]: Option[T] - |""".stripMargin.hover, - compat = Map( - "3.0" -> "def empty[T: Ordering]: Option[T]".hover - ) + |""".stripMargin.hover ) check( @@ -95,12 +72,10 @@ class HoverDefnSuite extends BaseHoverSuite { | List(1).map(<<@@x>> => ) |} |""".stripMargin, - """|Int + """|```scala |x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "x: Int".hover - ) + |``` + |""".stripMargin ) check( @@ -109,12 +84,10 @@ class HoverDefnSuite extends BaseHoverSuite { | def method(<<@@x: Int>>): Int = x |} |""".stripMargin, - """|Int + """|```scala |x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "x: Int".hover - ) + |``` + |""".stripMargin ) check( @@ -123,9 +96,10 @@ class HoverDefnSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|a + """|```scala |def this(x: Int): a - |""".stripMargin.hover, + |``` + |""".stripMargin, compat = Map( "3.0" -> "def (x: Int): a".hover ) @@ -137,12 +111,10 @@ class HoverDefnSuite extends BaseHoverSuite { | def this(<<@@x: Int>>) = this() |} |""".stripMargin, - """|Int + """|```scala |x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "x: Int".hover - ) + |``` + |""".stripMargin ) check( @@ -151,12 +123,10 @@ class HoverDefnSuite extends BaseHoverSuite { | def method(implicit <<@@x: Int>>) = this() |} |""".stripMargin, - """|Int + """|```scala |implicit x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "implicit x: Int".hover - ) + |``` + |""".stripMargin ) check( @@ -165,12 +135,10 @@ class HoverDefnSuite extends BaseHoverSuite { | def method(implicit y: Int, <<@@x: Int>>) = this() |} |""".stripMargin, - """|Int + """|```scala |implicit x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "implicit x: Int".hover - ) + |``` + |""".stripMargin ) check( @@ -228,8 +196,7 @@ class HoverDefnSuite extends BaseHoverSuite { | } |} |""".stripMargin, - """|Int - |head: Int""".stripMargin.hover, + "head: Int".hover, compat = Map( "3.0" -> "val head: Int".hover ) @@ -244,8 +211,7 @@ class HoverDefnSuite extends BaseHoverSuite { | } |} |""".stripMargin, - """|Int - |value: Int""".stripMargin.hover, + "value: Int".hover, compat = Map( "3.0" -> "val value: Int".hover ) diff --git a/tests/cross/src/test/scala/tests/hover/HoverLiteralSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverLiteralSuite.scala deleted file mode 100644 index 50882accd9c..00000000000 --- a/tests/cross/src/test/scala/tests/hover/HoverLiteralSuite.scala +++ /dev/null @@ -1,92 +0,0 @@ -package tests.hover - -import tests.pc.BaseHoverSuite - -class HoverLiteralSuite extends BaseHoverSuite { - - check( - "literal-int", - """object a { - | val x = 4@@2 - |} - |""".stripMargin, - """|```scala - |Int - |```""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: Int".hover - ) - ) - - check( - "literal-double", - """object a { - | val x = 4@@2d - |} - |""".stripMargin, - """|```scala - |Double - |```""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: Double".hover - ) - ) - - check( - "literal-float", - """object a { - | val x = 4@@2f - |} - |""".stripMargin, - """|```scala - |Float - |```""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: Float".hover - ) - ) - - check( - "literal-long", - """object a { - | val x = 4@@2L - |} - |""".stripMargin, - """|```scala - |Long - |```""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: Long".hover - ) - ) - - check( - "literal-string", - """object a { - | val x = "Hel@@lo" - |} - |""".stripMargin, - """|```scala - |String - |```""".stripMargin.hover, - compat = Map( - "3.0" -> "val x: String".hover - ) - ) - - check( - "interpolator-part", - """object a { - | val name = "John" - | s"Hel@@lo $name" - |} - |""".stripMargin, - """|```scala - |String - |```""".stripMargin, - compat = Map( - "3.0" -> "final object StringContext: String".hover - ) - ) - -} diff --git a/tests/cross/src/test/scala/tests/hover/HoverNamedArgSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverNamedArgSuite.scala index e2027737b7c..0fc36648573 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverNamedArgSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverNamedArgSuite.scala @@ -16,12 +16,7 @@ class HoverNamedArgSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|**Expression type**: - |```scala - |Unit - |``` - |**Symbol signature**: - |```scala + """|```scala |def foo(named: Int): Unit |``` |Runs foo @@ -67,8 +62,7 @@ class HoverNamedArgSuite extends BaseHoverSuite { | println(<>) |} |""".stripMargin, - """|User - |def this(name: String, age: Int): User""".stripMargin.hover, + "def this(name: String, age: Int): User".hover, compat = Map( "3.0" -> "name: String".hover ) diff --git a/tests/cross/src/test/scala/tests/hover/HoverNegativeSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverNegativeSuite.scala index 4d681fe9534..76645c6c19b 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverNegativeSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverNegativeSuite.scala @@ -65,4 +65,53 @@ class HoverNegativeSuite extends BaseHoverSuite { |""".stripMargin ) + checkNegative( + "literal-int", + """object a { + | val x = 4@@2 + |} + |""".stripMargin + ) + + checkNegative( + "literal-double", + """object a { + | val x = 4@@2d + |} + |""".stripMargin + ) + + checkNegative( + "literal-float", + """object a { + | val x = 4@@2f + |} + |""".stripMargin + ) + + checkNegative( + "literal-long", + """object a { + | val x = 4@@2L + |} + |""".stripMargin + ) + + checkNegative( + "literal-string", + """object a { + | val x = "Hel@@lo" + |} + |""".stripMargin + ) + + checkNegative( + "interpolator-part", + """object a { + | val name = "John" + | s"Hel@@lo $name" + |} + |""".stripMargin + ) + } diff --git a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala index d9b2957de8f..c1ca8ec8a79 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala @@ -22,8 +22,7 @@ class HoverTermSuite extends BaseHoverSuite { "app", """|object Main extends <>{} |""".stripMargin, - """|App - |abstract trait App: App""".stripMargin.hover, + "abstract trait App: App".hover, compat = Map( "3.0" -> "trait App: App".hover ) @@ -54,8 +53,7 @@ class HoverTermSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|Person - |def apply(name: String): Person + """|def apply(name: String): Person |""".stripMargin.hover, compat = Map( "3.0" -> "case class Person: `case-apply`".hover @@ -70,12 +68,8 @@ class HoverTermSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|String - |val name: String - |""".stripMargin.hover, - compat = Map( - "3.0" -> "val name: String".hover - ) + """|val name: String + |""".stripMargin.hover ) check( @@ -86,15 +80,13 @@ class HoverTermSuite extends BaseHoverSuite { | <<@@s"Hello ${name}">> |} |""".stripMargin, - """|String - |def s(args: Any*): String + """|def s(args: Any*): String |""".stripMargin.hover, compat = Map( "2.13" -> """|String |def s(args: Any*): String = macro - |""".stripMargin.hover, - "3.0" -> "def s(args: Any*): String".hover + |""".stripMargin.hover ) ) @@ -167,8 +159,7 @@ class HoverTermSuite extends BaseHoverSuite { | <> |} |""".stripMargin, - """|Foo - |def this(name: String, age: Int): Foo + """|def this(name: String, age: Int): Foo |""".stripMargin.hover, compat = Map( "3.0" -> "class Foo: Foo".hover @@ -233,12 +224,8 @@ class HoverTermSuite extends BaseHoverSuite { | } yield x |} |""".stripMargin, - """|Int - |x: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "x: Int".hover - ) + """|x: Int + |""".stripMargin.hover ) check( @@ -328,8 +315,7 @@ class HoverTermSuite extends BaseHoverSuite { | } yield x.toString |} |""".stripMargin, - """|Option[Int]#WithFilter - |final def withFilter(p: Int => Boolean): Option[Int]#WithFilter + """|final def withFilter(p: Int => Boolean): Option[Int]#WithFilter |""".stripMargin.hover, compat = Map( "3.0" -> "val : (x: Int): Boolean".hover @@ -414,9 +400,8 @@ class HoverTermSuite extends BaseHoverSuite { """ |import java.nio.file.{Fil@@es => File,Paths} |""".stripMargin, - """|```scala - |class java.nio.file.Files - |```""".stripMargin.hover, + """|class java.nio.file.Files + |""".stripMargin.hover, compat = Map( "3.0" -> "object Files: java.nio.file".hover ) @@ -427,9 +412,8 @@ class HoverTermSuite extends BaseHoverSuite { """ |import java.nio.file.{Files => File,P@@aths} |""".stripMargin, - """|```scala - |class java.nio.file.Paths - |```""".stripMargin.hover, + """|class java.nio.file.Paths + |""".stripMargin.hover, compat = Map( "3.0" -> "object Paths: java.nio.file".hover ) @@ -442,12 +426,8 @@ class HoverTermSuite extends BaseHoverSuite { | <<"".substring(0, 1).stripSu@@ffix("")>> |} |""".stripMargin, - """|String - |def stripSuffix(suffix: String): String - |""".stripMargin.hover, - compat = Map( - "3.0" -> "def stripSuffix(suffix: String): String".hover - ) + """|def stripSuffix(suffix: String): String + |""".stripMargin.hover ) check( @@ -463,12 +443,8 @@ class HoverTermSuite extends BaseHoverSuite { | foo(<>) |} |""".stripMargin, - """|Int - |val number: Int - |""".stripMargin.hover, - compat = Map( - "3.0" -> "val number: Int".hover - ) + """|val number: Int + |""".stripMargin.hover ) check( @@ -478,8 +454,7 @@ class HoverTermSuite extends BaseHoverSuite { | println(<>) |} |""".stripMargin, - """|FileVisitResult - |final val CONTINUE: FileVisitResult""".stripMargin.hover, + """final val CONTINUE: FileVisitResult""".hover, compat = Map( "3.0" -> "case CONTINUE: FileVisitResult".hover ) diff --git a/tests/cross/src/test/scala/tests/hover/RangeHoverSuite.scala b/tests/cross/src/test/scala/tests/hover/RangeHoverSuite.scala index 10d397a88d2..e04aecd469f 100644 --- a/tests/cross/src/test/scala/tests/hover/RangeHoverSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/RangeHoverSuite.scala @@ -22,34 +22,9 @@ class RangeHoverSuite extends BaseHoverSuite { |} |""".stripMargin, """|B - |def sum[B >: Int](implicit num: Numeric[B]): B""".stripMargin.hover, + |def sum[B >: Int](implicit num: Numeric[B]): B""".stripMargin.hoveRanger, compat = Map( - "3.0" -> "def sum[B >: A](implicit num: Numeric[B]): B".hover - ) - ) - - check( - "range-literal", - """|package helpers - | - |class XDClass { - | def xd: Int = { - | val l = List(1,2,3) - | l.map { x => - | x.to(x*x) - | .flatMap { y => - | List(y + <<%<%2137%>%>>) - | } - | .sum - | }.sum - | } - |} - |""".stripMargin, - """|```scala - |Int - |```""".stripMargin, - compat = Map( - "3.0" -> "def +(x: Int): Int".hover + "3.0" -> "def sum[B >: A](implicit num: Numeric[B]): B".hoveRanger ) ) @@ -72,9 +47,9 @@ class RangeHoverSuite extends BaseHoverSuite { |} |""".stripMargin, """|B - |def sum[B >: Int](implicit num: Numeric[B]): B""".stripMargin.hover, + |def sum[B >: Int](implicit num: Numeric[B]): B""".stripMargin.hoveRanger, compat = Map( - "3.0" -> "val l: List[Int]".hover + "3.0" -> "val l: List[Int]".hoveRanger ) ) @@ -96,12 +71,12 @@ class RangeHoverSuite extends BaseHoverSuite { |} |""".stripMargin, """|immutable.IndexedSeq[Int] - |def flatMap[B, That](f: Int => GenTraversableOnce[B])(implicit bf: CanBuildFrom[immutable.IndexedSeq[Int],B,That]): That""".stripMargin.hover, + |def flatMap[B, That](f: Int => GenTraversableOnce[B])(implicit bf: CanBuildFrom[immutable.IndexedSeq[Int],B,That]): That""".stripMargin.hoveRanger, compat = Map( "2.13" -> """|IndexedSeq[Int] - |override def flatMap[B](f: Int => IterableOnce[B]): IndexedSeq[B]""".stripMargin.hover, - "3.0" -> "x: Int".hover + |override def flatMap[B](f: Int => IterableOnce[B]): IndexedSeq[B]""".stripMargin.hoveRanger, + "3.0" -> "x: Int".hoveRanger ) ) @@ -123,12 +98,12 @@ class RangeHoverSuite extends BaseHoverSuite { |} |""".stripMargin, """|List[Int] - |override def apply[A](xs: A*): List[A]""".stripMargin.hover, + |override def apply[A](xs: A*): List[A]""".stripMargin.hoveRanger, compat = Map( "2.13" -> """|List[Int] - |def apply[A](elems: A*): List[A]""".stripMargin.hover, - "3.0" -> "def apply[A](elems: A*): Int".hover + |def apply[A](elems: A*): List[A]""".stripMargin.hoveRanger, + "3.0" -> "def apply[A](elems: A*): Int".hoveRanger ) ) @@ -150,9 +125,9 @@ class RangeHoverSuite extends BaseHoverSuite { |} |""".stripMargin, """|List[Int] - |val l: List[Int]""".stripMargin.hover, + |val l: List[Int]""".stripMargin.hoveRanger, compat = Map( - "3.0" -> "val l: List[Int]".hover + "3.0" -> "val l: List[Int]".hoveRanger ) ) } diff --git a/tests/mtest/src/main/scala/tests/TestHovers.scala b/tests/mtest/src/main/scala/tests/TestHovers.scala index e95f9fd6c05..db42e5fcd85 100644 --- a/tests/mtest/src/main/scala/tests/TestHovers.scala +++ b/tests/mtest/src/main/scala/tests/TestHovers.scala @@ -12,12 +12,27 @@ trait TestHovers { def hover: String = string.trim.linesIterator.toList match { case List(symbolSignature) => - HoverMarkup(symbolSignature) + HoverMarkup("", symbolSignature, "") case List(expressionType, symbolSignature) => HoverMarkup(expressionType, symbolSignature, "") case _ => string } + + def hoveRanger: String = + string.trim.linesIterator.toList match { + case List(symbolSignature) => + HoverMarkup(symbolSignature) + case List(expressionType, symbolSignature) => + HoverMarkup( + expressionType, + symbolSignature, + "", + forceExpressionType = true + ) + case _ => + string + } } def renderAsString( diff --git a/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala b/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala index 7b5fe0782e1..2b81506f565 100644 --- a/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala +++ b/tests/slow/src/test/scala/tests/sbt/SbtBloopLspSuite.scala @@ -543,12 +543,7 @@ class SbtBloopLspSuite ) hoverRes <- assertHoverAtPos("project/Deps.scala", 3, 9) expectedHoverRes = - """|**Expression type**: - |```scala - |ModuleID - |``` - |**Symbol signature**: - |```scala + """|```scala |val scalatest: ModuleID |``` |```range diff --git a/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala b/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala index 69813caf12f..f3819d3cb19 100644 --- a/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala @@ -27,11 +27,11 @@ class BuildTargetsLspSuite // Assert that a supported Scala version target is picked over 2.10. _ <- server.assertHover( "shared/Main.scala", - """|object Main { - | sourcecode.Line(1).val@@ue - |}""".stripMargin, - """|Int - |val value: Int""".stripMargin.hover + """ + |object Main { + | sourcecode.Line(1).val@@ue + |}""".stripMargin, + """val value: Int""".hover ) } yield () } diff --git a/tests/unit/src/test/scala/tests/HoverLspSuite.scala b/tests/unit/src/test/scala/tests/HoverLspSuite.scala index 2a855778c6f..3b1bb47b78d 100644 --- a/tests/unit/src/test/scala/tests/HoverLspSuite.scala +++ b/tests/unit/src/test/scala/tests/HoverLspSuite.scala @@ -17,8 +17,7 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | Option(1).he@@ad |}""".stripMargin, - """|Int - |override def head: Int""".stripMargin.hover + """override def head: Int""".hover ) } yield () } @@ -39,8 +38,7 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | Option(1).he@@ad |}""".stripMargin, - """|Int - |override def head: Int""".stripMargin.hover + """override def head: Int""".hover ) } yield () } @@ -68,15 +66,11 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | val res = Def.fo@@o(1) |}""".stripMargin, - """|**Expression type**: - |```scala - |Int - |``` - |**Symbol signature**: - |```scala + """|```scala |def foo(x: Int): Int |``` - |test""".stripMargin + |test + |""".stripMargin.hover ) } yield () } @@ -104,15 +98,11 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | val res = Def.fo@@o(1) |}""".stripMargin, - """|**Expression type**: - |```scala - |Int - |``` - |**Symbol signature**: - |```scala + """|```scala |def foo(x: Int): Int |``` - |test""".stripMargin + |test + |""".stripMargin.hover ) _ <- server.didSave("a/src/main/scala/a/Def.scala")(s => s.replace("test", "test2") @@ -124,15 +114,11 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | val res = Def.fo@@o(1) |}""".stripMargin, - """|**Expression type**: - |```scala - |Int - |``` - |**Symbol signature**: - |```scala + """|```scala |def foo(x: Int): Int |``` - |test2""".stripMargin + |test2 + |""".stripMargin.hover ) } yield () } @@ -158,8 +144,7 @@ class HoverLspSuite extends BaseLspSuite("hover") with TestHovers { |object Main { | Option(1).he@@ad |}""".stripMargin, - """|Int - |override def head: Int""".stripMargin.hover, + """override def head: Int""".hover, root = workspace.resolve(Directories.readonly) ) } yield () diff --git a/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala b/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala index 2f53d755477..75bcbcd8878 100644 --- a/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/decorations/SyntheticDecorationsLspSuite.scala @@ -97,11 +97,7 @@ class SyntheticDecorationsLspSuite extends BaseLspSuite("implicits") { _ <- server.assertHoverAtLine( "a/src/main/scala/Main.scala", " @@\"foo\".map(c => c.toUpper)", - """|```scala - |String - |``` - | - |**Synthetics**: + """|**Synthetics**: |```scala |scala.Predef.augmentString |``` @@ -282,11 +278,7 @@ class SyntheticDecorationsLspSuite extends BaseLspSuite("implicits") { _ <- server.assertHoverAtLine( "a/src/main/scala/Main.scala", " (@@\"1\" + \"2\")", - """|```scala - |String - |``` - | - |**Synthetics**: + """|**Synthetics**: |```scala |scala.Predef.augmentString |``` @@ -329,11 +321,7 @@ class SyntheticDecorationsLspSuite extends BaseLspSuite("implicits") { _ <- server.assertHoverAtLine( "standalone/Main.scala", " val value = @@\"asd.\".stripSuffix(\".\")", - """|```scala - |String - |``` - | - |**Synthetics**: + """|**Synthetics**: |```scala |scala.Predef.augmentString |``` diff --git a/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala b/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala index 47c54fd012f..48427a26a4a 100644 --- a/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala @@ -43,15 +43,9 @@ class WorksheetNoDecorationsLspSuite |val foo = "bar" /*> : @@String = "bar" */ |println("metals") /*> @@metals */ |""".stripMargin, - """|```scala - |x: Int = 1 - |```""".stripMargin, - """|```scala - |foo: String = "bar" - |```""".stripMargin, - """|```scala - |// metals - |```""".stripMargin + """x: Int = 1""".hover, + """foo: String = "bar"""".hover, + """// metals""".hover ) } yield () } @@ -87,15 +81,9 @@ class WorksheetNoDecorationsLspSuite |val foo = "baz" /*> : String = "baz"@@ */ |println("meta ls") /*> meta@@ ls */ |""".stripMargin, - """|```scala - |x: Int = 2 - |```""".stripMargin, - """|```scala - |foo: String = "baz" - |```""".stripMargin, - """|```scala - |// meta ls - |```""".stripMargin + """x: Int = 2""".hover, + """foo: String = "baz"""".hover, + """// meta ls""".hover ) } yield () }