Skip to content

Commit

Permalink
Merge pull request #1463 from ckipp01/rename-provider
Browse files Browse the repository at this point in the history
add openFilesOnRenameProvider to experimental
  • Loading branch information
ckipp01 authored Feb 24, 2020
2 parents b897fe2 + b3e3bd0 commit 40759eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final case class ClientExperimentalCapabilities(
didFocusProvider: java.lang.Boolean = false,
slowTaskProvider: java.lang.Boolean = false,
executeClientCommandProvider: java.lang.Boolean = false,
openFilesOnRenameProvider: java.lang.Boolean = false,
doctorProvider: String = "html",
statusBarProvider: String = "off"
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ class MetalsLanguageServer(
languageClient,
buffers,
compilations,
config
config,
clientExperimentalCapabilities
)
semanticDBIndexer = new SemanticdbIndexer(
referencesProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import scala.meta.internal.async.ConcurrentQueue
import scala.meta.internal.semanticdb.Synthetic
import scala.meta.internal.semanticdb.SelectTree
import scala.meta.internal.metals.MetalsServerConfig
import scala.meta.internal.metals.ClientExperimentalCapabilities

final class RenameProvider(
referenceProvider: ReferenceProvider,
Expand All @@ -46,7 +47,8 @@ final class RenameProvider(
client: MetalsLanguageClient,
buffers: Buffers,
compilations: Compilations,
metalsConfig: MetalsServerConfig
metalsConfig: MetalsServerConfig,
clientExperimentalCapabilities: ClientExperimentalCapabilities
) {

private var awaitingSave = new ConcurrentLinkedQueue[() => Unit]
Expand Down Expand Up @@ -144,12 +146,13 @@ final class RenameProvider(
Seq(uri.toAbsolutePath -> textEdits.toList)
}
val fileChanges = allChanges.flatten.toMap
val openFilesOnRenameProvider =
metalsConfig.openFilesOnRenames || clientExperimentalCapabilities.openFilesOnRenameProvider
val shouldRenameInBackground =
!metalsConfig.openFilesOnRenames ||
fileChanges.keySet.size >= metalsConfig.renameFileThreshold
!openFilesOnRenameProvider || fileChanges.keySet.size >= metalsConfig.renameFileThreshold
val (openedEdits, closedEdits) =
if (shouldRenameInBackground) {
if (metalsConfig.openFilesOnRenames) {
if (openFilesOnRenameProvider) {
client.showMessage(fileThreshold(fileChanges.keySet.size))
}
fileChanges.partition {
Expand Down

0 comments on commit 40759eb

Please sign in to comment.