Skip to content
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

Add support for Scala 2.13.3 #1857

Merged
merged 1 commit into from Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions build.sbt
Expand Up @@ -162,11 +162,11 @@ lazy val V = new {
val scala210 = "2.10.7"
val scala211 = "2.11.12"
val scala212 = "2.12.11"
val scala213 = "2.13.2"
val scalameta = "4.3.15"
val scala213 = "2.13.3"
val scalameta = "4.3.18"
val semanticdb = scalameta
val bsp = "2.0.0-M4+10-61e61e87"
val bloop = "1.4.2"
val bloop = "1.4.3"
val scala3 = "0.25.0-RC2"
val bloopNightly = bloop
val sbtBloop = bloop
Expand All @@ -186,12 +186,13 @@ lazy val V = new {

// Scala 2
def deprecatedScala2Versions = Seq(scala211, "2.12.8", "2.12.9", "2.13.0")
def nonDeprecatedScala2Versions = Seq(scala213, scala212, "2.12.10", "2.13.1")
def nonDeprecatedScala2Versions =
Seq(scala213, scala212, "2.12.10", "2.13.1", "2.13.2")
def scala2Versions = nonDeprecatedScala2Versions ++ deprecatedScala2Versions

// Scala 3
def nonDeprecatedScala3Versions = Seq(scala3, "0.24.0")
def deprecatedScala3Versions = Seq()
def deprecatedScala3Versions = Seq("0.24.0-RC1")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this back, since I figured it we should not be just dropping it on users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also added 0.23.0, which doesn't influence the tests

def scala3Versions = nonDeprecatedScala3Versions ++ deprecatedScala3Versions

def supportedScalaVersions = scala2Versions ++ scala3Versions
Expand All @@ -206,7 +207,7 @@ lazy val V = new {
"org.eclipse.lsp4j" % "org.eclipse.lsp4j.debug" % "0.9.0"
val coursier = "2.0.0-RC6-21"
val coursierInterfaces = "0.0.22"
val ammonite = "2.1.4-6-2179b35"
val ammonite = "2.1.4-8-5d0c097"
}

val genyVersion = Def.setting {
Expand Down
Expand Up @@ -7,11 +7,8 @@ import scala.collection.immutable.Nil
import scala.util.control.NonFatal

import scala.meta.internal.pc.CompletionFuzzy
import scala.meta.internal.pc.CompletionFuzzy
Copy link
Member

Choose a reason for hiding this comment

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

Random side note, the next release of OrganizeImports will also remove duplicated ones like this 🥳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that was actually removed by that rule 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe it was due to warnings I saw?

Copy link
Member

Choose a reason for hiding this comment

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

O really? Haha, nevermind then. I thought you did it manually.

import scala.meta.internal.pc.MetalsGlobal
import scala.meta.internal.pc.MetalsGlobal

import org.eclipse.{lsp4j => l}
import org.eclipse.{lsp4j => l}

trait FilenameCompletions { this: MetalsGlobal =>
Expand Down
229 changes: 119 additions & 110 deletions tests/cross/src/test/scala/tests/pc/CompletionDocSuite.scala
Expand Up @@ -213,6 +213,91 @@ class CompletionDocSuite extends BaseCompletionSuite {
|""".stripMargin
)
)

val iteratorDocs213: String =
"""|> Iterators are data structures that allow to iterate over a sequence
|of elements. They have a `hasNext` method for checking
|if there is a next element available, and a `next` method
|which returns the next element and advances the iterator.
|
|An iterator is mutable: most operations on it change its state. While it is often used
|to iterate through the elements of a collection, it can also be used without
|being backed by any collection (see constructors on the companion object).
|
|It is of particular importance to note that, unless stated otherwise, *one should never
|use an iterator after calling a method on it*. The two most important exceptions
|are also the sole abstract methods: `next` and `hasNext`.
|
|Both these methods can be called any number of times without having to discard the
|iterator. Note that even `hasNext` may cause mutation -- such as when iterating
|from an input stream, where it will block until the stream is closed or some
|input becomes available.
|
|Consider this example for safe and unsafe use:
|
|```
|def f[A](it: Iterator[A]) = {
| if (it.hasNext) { // Safe to reuse "it" after "hasNext"
| it.next // Safe to reuse "it" after "next"
| val remainder = it.drop(2) // it is *not* safe to use "it" again after this line!
| remainder.take(2) // it is *not* safe to use "remainder" after this line!
| } else it
|}
|```
|Iterator scala.collection
|> Explicit instantiation of the `Iterator` trait to reduce class file size in subclasses.
|AbstractIterator scala.collection
|> Buffered iterators are iterators which provide a method `head`
| that inspects the next element without discarding it.
|BufferedIterator scala.collection
|> A specialized Iterator for LinearSeqs that is lazy enough for Stream and LazyList. This is accomplished by not
|evaluating the tail after returning the current head.
|LinearSeqIterator scala.collection
|> Base trait for companion objects of collections that require an implicit `ClassTag`.
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `ArraySeq`)
|ClassTagIterableFactory scala.collection
|> Base trait for companion objects of collections that require an implicit evidence.
|
|**Type Parameters**
|- `Ev`: Unary type constructor for the implicit evidence required for an element type
| (typically `Ordering` or `ClassTag`)
|- `CC`: Collection type constructor (e.g. `ArraySeq`)
|EvidenceIterableFactory scala.collection
|> This trait provides default implementations for the factory methods `fromSpecific` and
|`newSpecificBuilder` that need to be refined when implementing a collection type that refines
|the `CC` and `C` type parameters. It is used for collections that have an additional constraint,
|expressed by the `evidenceIterableFactory` method.
|
|The default implementations in this trait can be used in the common case when `CC[A]` is the
|same as `C`.
|EvidenceIterableFactoryDefaults scala.collection
|> Base trait for companion objects of unconstrained collection types that may require
|multiple traversals of a source collection to build a target collection `CC`.
|
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `List`)
|IterableFactory scala.collection
|> This trait provides default implementations for the factory methods `fromSpecific` and
|`newSpecificBuilder` that need to be refined when implementing a collection type that refines
|the `CC` and `C` type parameters.
|
|The default implementations in this trait can be used in the common case when `CC[A]` is the
|same as `C`.
|IterableFactoryDefaults scala.collection
|> Base trait for companion objects of collections that require an implicit `Ordering`.
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `SortedSet`)
|SortedIterableFactory scala.collection
|> **Type Parameters**
|- `A`: Type of elements (e.g. `Int`, `Boolean`, etc.)
|- `C`: Type of collection (e.g. `List[Int]`, `TreeMap[Int, String]`, etc.)
|SpecificIterableFactory scala.collection
|""".stripMargin

check(
"scala4",
"""
Expand Down Expand Up @@ -263,89 +348,9 @@ class CompletionDocSuite extends BaseCompletionSuite {
|""".stripMargin,
includeDocs = true,
compat = Map(
"2.13" ->
"""|> Iterators are data structures that allow to iterate over a sequence
|of elements. They have a `hasNext` method for checking
|if there is a next element available, and a `next` method
|which returns the next element and advances the iterator.
|
|An iterator is mutable: most operations on it change its state. While it is often used
|to iterate through the elements of a collection, it can also be used without
|being backed by any collection (see constructors on the companion object).
|
|It is of particular importance to note that, unless stated otherwise, *one should never
|use an iterator after calling a method on it*. The two most important exceptions
|are also the sole abstract methods: `next` and `hasNext`.
|
|Both these methods can be called any number of times without having to discard the
|iterator. Note that even `hasNext` may cause mutation -- such as when iterating
|from an input stream, where it will block until the stream is closed or some
|input becomes available.
|
|Consider this example for safe and unsafe use:
|
|```
|def f[A](it: Iterator[A]) = {
| if (it.hasNext) { // Safe to reuse "it" after "hasNext"
| it.next // Safe to reuse "it" after "next"
| val remainder = it.drop(2) // it is *not* safe to use "it" again after this line!
| remainder.take(2) // it is *not* safe to use "remainder" after this line!
| } else it
|}
|```
|Iterator scala.collection
|> Explicit instantiation of the `Iterator` trait to reduce class file size in subclasses.
|AbstractIterator scala.collection
|> Buffered iterators are iterators which provide a method `head`
| that inspects the next element without discarding it.
|BufferedIterator scala.collection
|> A specialized Iterator for LinearSeqs that is lazy enough for Stream and LazyList. This is accomplished by not
|evaluating the tail after returning the current head.
|LinearSeqIterator scala.collection
|> Base trait for companion objects of collections that require an implicit `ClassTag`.
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `ArraySeq`)
|ClassTagIterableFactory scala.collection
|> Base trait for companion objects of collections that require an implicit evidence.
|
|**Type Parameters**
|- `Ev`: Unary type constructor for the implicit evidence required for an element type
| (typically `Ordering` or `ClassTag`)
|- `CC`: Collection type constructor (e.g. `ArraySeq`)
|EvidenceIterableFactory scala.collection
|> This trait provides default implementations for the factory methods `fromSpecific` and
|`newSpecificBuilder` that need to be refined when implementing a collection type that refines
|the `CC` and `C` type parameters. It is used for collections that have an additional constraint,
|expressed by the `evidenceIterableFactory` method.
|
|The default implementations in this trait can be used in the common case when `CC[A]` is the
|same as `C`.
|EvidenceIterableFactoryDefaults scala.collection
|> Base trait for companion objects of unconstrained collection types that may require
|multiple traversals of a source collection to build a target collection `CC`.
|
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `List`)
|IterableFactory scala.collection
|> This trait provides default implementations for the factory methods `fromSpecific` and
|`newSpecificBuilder` that need to be refined when implementing a collection type that refines
|the `CC` and `C` type parameters.
|
|The default implementations in this trait can be used in the common case when `CC[A]` is the
|same as `C`.
|IterableFactoryDefaults scala.collection
|> Base trait for companion objects of collections that require an implicit `Ordering`.
|
|**Type Parameters**
|- `CC`: Collection type constructor (e.g. `SortedSet`)
|SortedIterableFactory scala.collection
|> **Type Parameters**
|- `A`: Type of elements (e.g. `Int`, `Boolean`, etc.)
|- `C`: Type of collection (e.g. `List[Int]`, `TreeMap[Int, String]`, etc.)
|SpecificIterableFactory scala.collection
|""".stripMargin
"2.13.1" -> iteratorDocs213,
"2.13.2" -> iteratorDocs213,
"2.13.3" -> iteratorDocs213.replace("it.next ", "it.next()")
)
)

Expand Down Expand Up @@ -461,6 +466,35 @@ class CompletionDocSuite extends BaseCompletionSuite {
|""".stripMargin
)
)

val vectorDocs213: String =
"""|> ### class Vector
|Vector is a general-purpose, immutable data structure. It provides random access and updates
|in O(log n) time, as well as very fast append/prepend/tail/init (amortized O(1), worst case O(log n)).
|Because vectors strike a good balance between fast random selections and fast random functional updates,
|they are currently the default implementation of immutable indexed sequences.
|
|Vectors are implemented by radix-balanced finger trees of width 32. There is a separate subclass
|for each level (0 to 6, with 0 being the empty vector and 6 a tree with a maximum width of 64 at the
|top level).
|
|Tree balancing:
|- Only the first dimension of an array may have a size < WIDTH
|- In a `data` (central) array the first dimension may be up to WIDTH-2 long, in `prefix1` and `suffix1` up
| to WIDTH, and in other `prefix` and `suffix` arrays up to WIDTH-1
|- `prefix1` and `suffix1` are never empty
|- Balancing does not cross the main data array (i.e. prepending never touches the suffix and appending never touches
| the prefix). The level is increased/decreased when the affected side plus main data is already full/empty
|- All arrays are left-aligned and truncated
|
|In addition to the data slices (`prefix1`, `prefix2`, ..., `dataN`, ..., `suffix2`, `suffix1`) we store a running
|count of elements after each prefix for more efficient indexing without having to dereference all prefix arrays.
|
|### object Vector
|$factoryInfo
|Vector scala.collection.immutable
|""".stripMargin

check(
"scala8",
"""
Expand Down Expand Up @@ -513,33 +547,8 @@ class CompletionDocSuite extends BaseCompletionSuite {
|$factoryInfo
|Vector scala.collection.immutable
|""".stripMargin,
"2.13.2" ->
"""|> ### class Vector
|Vector is a general-purpose, immutable data structure. It provides random access and updates
|in O(log n) time, as well as very fast append/prepend/tail/init (amortized O(1), worst case O(log n)).
|Because vectors strike a good balance between fast random selections and fast random functional updates,
|they are currently the default implementation of immutable indexed sequences.
|
|Vectors are implemented by radix-balanced finger trees of width 32. There is a separate subclass
|for each level (0 to 6, with 0 being the empty vector and 6 a tree with a maximum width of 64 at the
|top level).
|
|Tree balancing:
|- Only the first dimension of an array may have a size < WIDTH
|- In a `data` (central) array the first dimension may be up to WIDTH-2 long, in `prefix1` and `suffix1` up
| to WIDTH, and in other `prefix` and `suffix` arrays up to WIDTH-1
|- `prefix1` and `suffix1` are never empty
|- Balancing does not cross the main data array (i.e. prepending never touches the suffix and appending never touches
| the prefix). The level is increased/decreased when the affected side plus main data is already full/empty
|- All arrays are left-aligned and truncated
|
|In addition to the data slices (`prefix1`, `prefix2`, ..., `dataN`, ..., `suffix2`, `suffix1`) we store a running
|count of elements after each prefix for more efficient indexing without having to dereference all prefix arrays.
|
|### object Vector
|$factoryInfo
|Vector scala.collection.immutable
|""".stripMargin
"2.13.2" -> vectorDocs213,
"2.13.3" -> vectorDocs213
)
)
check(
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala
Expand Up @@ -5,6 +5,7 @@ import scala.concurrent.Promise
import scala.meta.internal.metals.InitializationOptions
import scala.meta.internal.metals.MetalsSlowTaskResult
import scala.meta.internal.metals.UserConfiguration
import scala.meta.internal.metals.{BuildInfo => V}

abstract class BaseWorksheetLspSuite(scalaVersion: String)
extends BaseLspSuite("worksheet") {
Expand Down Expand Up @@ -392,7 +393,7 @@ abstract class BaseWorksheetLspSuite(scalaVersion: String)
|^
|""".stripMargin,
compat = Map(
"2.13.2" ->
V.scala213 ->
"""|a/src/main/scala/Main.worksheet.sc:1:1: warning: 1 feature warning; re-run with -feature for details
|type Structural = {
|^
Expand Down