diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/DotcPrinter.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/DotcPrinter.scala index bd4c5996f50..58d331a4f75 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/DotcPrinter.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/DotcPrinter.scala @@ -61,12 +61,22 @@ object DotcPrinter: */ private def printPrefix(tp: Type): Text = homogenize(tp) match case NoPrefix => "" - case tp: SingletonType => toTextRef(tp) ~ "." + case tp: SingletonType => + toTextRef(tp) ~ "." case tp => trimPrefix(toTextLocal(tp)) ~ "#" def fullName(sym: Symbol): String = fullNameString(sym) + override def toTextRef(tp: SingletonType): Text = controlled { + tp match + case tp: TermRef if !printDebug && tp.symbol.is(Package) => + toTextPrefix(tp.prefix) ~ + tp.symbol.name.stripModuleClassSuffix.toString() + case _ => + super.toTextRef(tp) + } + override def toText(tp: Type): Text = // Override the behavior for `AppliedType` because // `toText` in RefinedPrinter doesn't pretty print AppliedType diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala index 791b1ba81f2..670774d6a7d 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/printer/ShortenedNames.scala @@ -65,9 +65,9 @@ class ShortenedNames( true else false case founds => - founds.exists(s => + founds.exists { s => s == short.symbol || s.typeRef.metalsDealias.typeSymbol == short.symbol - ) + } if isOk then history(short.name) = short true diff --git a/tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala index 0ab5cbdb32a..645a9459d11 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala @@ -512,8 +512,9 @@ class CompletionDocSuite extends BaseCompletionSuite { |Try[T](r: => T): Try[T]""".stripMargin ), ) + check( - "scala7", + "scala7".tag(IgnoreScalaVersion(ver => ver.contains("NIGHTLY"))), """ |object A { | scala.collection.mutable.StringBuilder@@ @@ -561,31 +562,6 @@ class CompletionDocSuite extends BaseCompletionSuite { |StringBuilder(capacity: Int): StringBuilder |StringBuilder(initCapacity: Int, initValue: String): StringBuilder |""".stripMargin, - "2.13.11" -> - """|> A builder of `String` which is also a mutable sequence of characters. - | - | This class provides an API mostly compatible with `java.lang.StringBuilder`, - | except where there are conflicts with the Scala collections API, such as the `reverse` method: - | [reverse](reverse) produces a new `StringBuilder`, and [reverseInPlace](reverseInPlace) mutates this builder. - | - | Mutating operations return either `this.type`, i.e., the current builder, or `Unit`. - | - | Other methods extract data or information from the builder without mutating it. - | - | The distinction is also reflected in naming conventions used by collections, - | such as `append`, which mutates, and `appended`, which does not, or `reverse`, - | which does not mutate, and `reverseInPlace`, which does. - | - | The `String` result may be obtained using either `result()` or `toString`. - | - | $multipleResults - | - | - |**See** - |- ["Scala's Collection Library overview"](https://docs.scala-lang.org/overviews/collections-2.13/concrete-mutable-collection-classes.html#stringbuilders) - | section on `StringBuilders` for more information. - |StringBuilder scala.collection.mutable - |""".stripMargin, ), ) diff --git a/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala index d977de454df..c44bd2e4262 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionSuite.scala @@ -1245,6 +1245,14 @@ class CompletionSuite extends BaseCompletionSuite { |""".stripMargin, ) + val pre331: String = + """|dynamics scala.languageFeature + |existentials scala.languageFeature + |experimental scala.languageFeature + |higherKinds scala.languageFeature + |implicitConversions scala.languageFeature + |""".stripMargin + check( "ordering-1", s"""|object Main { @@ -1265,7 +1273,18 @@ class CompletionSuite extends BaseCompletionSuite { |experimental scala.languageFeature |implicitConversions scala.languageFeature |postfixOps scala.languageFeature - |""".stripMargin + |""".stripMargin, + "3.2" -> pre331, + "3.1" -> pre331, + "3.3.0" -> pre331, + "3.3.1" -> pre331, + "3" -> + """|dynamics languageFeature + |existentials languageFeature + |experimental languageFeature + |higherKinds languageFeature + |implicitConversions languageFeature + |""".stripMargin, ), ) diff --git a/tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala b/tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala index ea979ef2d77..3fceaa135d7 100644 --- a/tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/SignatureHelpDocSuite.scala @@ -1,7 +1,6 @@ package tests.pc import tests.BaseSignatureHelpSuite -import scala.meta.internal.mtags.BuildInfo class SignatureHelpDocSuite extends BaseSignatureHelpSuite { @@ -134,7 +133,13 @@ class SignatureHelpDocSuite extends BaseSignatureHelpSuite { ), ) - val addedSpace = if (BuildInfo.scalaCompilerVersion == "2.13.11") "" else " " + val addedSpace = + if ( + scalaVersion == "2.13.11" || + (scalaVersion.startsWith("3.3") && + !(scalaVersion.startsWith("3.3.0") || scalaVersion.startsWith("3.3.1"))) + ) "" + else " " checkDoc( "curry3", """ @@ -200,30 +205,30 @@ class SignatureHelpDocSuite extends BaseSignatureHelpSuite { | @param op (Int, Int) => Int |""".stripMargin, "3" -> - """|Applies a binary operator to a start value and all elements of this collection, - | going left to right. - | - | Note: will not terminate for infinite-sized collections. - | Note: might return different results for different runs, unless the - |underlying collection type is ordered or the operator is associative - |and commutative. - | - | - |**Type Parameters** - |- `B`: the result type of the binary operator. - | - |**Parameters** - |- `z`: the start value. - |- `op`: the binary operator. - | - |**Returns:** the result of inserting `op` between consecutive elements of this collection, - | going left to right with the start value `z` on the left: - | `op(...op(z, x), x, ..., x)` where `x, ..., x` - | are the elements of this collection. - | Returns `z` if this collection is empty. - |foldLeft[B](z: B)(op: (B, Int) => B): B - | ^^^^^^^^^^^^^^^^^ - |""".stripMargin, + s"""|Applies a binary operator to a start value and all elements of this collection, + | going left to right. + | + | Note: will not terminate for infinite-sized collections. + | Note: might return different results for different runs, unless the + |underlying collection type is ordered or the operator is associative + |and commutative. + | + | + |**Type Parameters** + |- `B`: the result type of the binary operator. + | + |**Parameters** + |- `z`: the start value. + |- `op`: the binary operator. + | + |**Returns:** the result of inserting `op` between consecutive elements of this collection, + | going left to right with the start value `z` on the left: + | `op(...op(z, x), x, ..., x)` where `x, ..., x` + | ${addedSpace}are the elements of this collection. + | Returns `z` if this collection is empty. + |foldLeft[B](z: B)(op: (B, Int) => B): B + | ^^^^^^^^^^^^^^^^^ + |""".stripMargin, ), )