Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<platform.backend.documentation.targetProvider
implementation="com.intellij.platform.dartlsp.impl.features.documentation.LspDocumentationTargetProvider"/>
<formattingService implementation="com.intellij.platform.dartlsp.impl.features.formatter.LspFormattingService"/>
<lang.importOptimizer language="" implementationClass="com.intellij.platform.dartlsp.impl.features.formatter.LspImportOptimizer" order="last"/>
<lang.importOptimizer language="Dart" implementationClass="com.intellij.platform.dartlsp.impl.features.formatter.LspImportOptimizer" order="last"/>
<lang.foldingBuilder language="" implementationClass="com.intellij.platform.dartlsp.impl.features.folding.LspFoldingBuilder"/>
<gotoSymbolContributor implementation="com.intellij.platform.dartlsp.impl.features.workspaceSymbol.LspGoToSymbolContributor"/>
<gotoClassContributor implementation="com.intellij.platform.dartlsp.impl.features.workspaceSymbol.LspGoToClassContributor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class LspServerImpl internal constructor(
val exToLog = (e as? LspInitializationException)?.cause ?: e
logWarn("Failed to start LSP server", exToLog)

val lspServerManager = ReadAction.computeBlocking<LspServerManagerImpl?, Throwable> {
val lspServerManager = ReadAction.compute<LspServerManagerImpl?, Throwable> {
if (!project.isDisposed) LspServerManagerImpl.getInstanceImpl(project) else null
}
val text = (if (e is LspInitializationException) "$e\nCaused by:\n" else "") + exToLog.stackTraceToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal abstract class Lsp4jServerConnector protected constructor(private val l
}
finally {
logger.debug("$descriptor: LSP server listener thread finished")
val lspServerManager = ReadAction.computeBlocking<LspServerManagerImpl?, Throwable> {
val lspServerManager = ReadAction.compute<LspServerManagerImpl?, Throwable> {
if (!lspServer.project.isDisposed) LspServerManagerImpl.getInstanceImpl(lspServer.project) else null
}
val text = "${descriptor.lspCommunicationChannel.javaClass.simpleName} connection closed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal open class LspServerProcessListenerBase(private val lspServer: LspServe
val text = "Exit code: ${event.exitCode}\nCommand line: ${event.processHandler}"
lspServer.logInfo("LSP server process terminated. $text")

val lspServerManager = ReadAction.computeBlocking<LspServerManagerImpl?, Throwable> {
val lspServerManager = ReadAction.compute<LspServerManagerImpl?, Throwable> {
if (!lspServer.project.isDisposed) LspServerManagerImpl.getInstanceImpl(lspServer.project) else null
}
lspServerManager?.handleMaybeUnexpectedServerStop(lspServer, text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ internal class LspCodeVisionProvider : CodeVisionProvider<Unit>, DumbAware {
override val relativeOrderings: List<CodeVisionRelativeOrdering> = emptyList()
override val id: String = LSP_CODE_VISION_PROVIDER_ID
override val name: String = LspBundle.message("codeLens.LspCodeVisionProvider.name")
override val singleEntryPerLine: Boolean = false
//override val singleEntryPerLine: Boolean = false
Comment thread
alexander-doroshko marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.intellij.formatting.service.FormattingService.Feature
import com.intellij.injected.editor.VirtualFileWindow
import com.intellij.lang.ImportOptimizer
import com.intellij.lang.LanguageFormatting
import com.intellij.openapi.application.runReadActionBlocking
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.impl.DocumentImpl
import com.intellij.openapi.vfs.VirtualFile
Expand All @@ -30,15 +30,13 @@ import org.eclipse.lsp4j.TextEdit
internal class LspFormattingService : AsyncDocumentFormattingService() {
override fun getName() = LspBundle.message("lsp.based.formatter")
override fun getNotificationGroupId() = LspServerNotificationsHandlerImpl.SHOW_MESSAGE_NOTIFICATION_GROUP
override fun getFeatures() = setOf(Feature.FORMAT_FRAGMENTS, Feature.OPTIMIZE_IMPORTS)
override fun getFeatures() = setOf(Feature.FORMAT_FRAGMENTS/*, Feature.OPTIMIZE_IMPORTS*/)

// No need to save the document, LSP servers work fine with unsaved content
override fun prepareForFormatting(document: Document, formattingContext: FormattingContext): Unit = Unit

override fun canFormat(psiFile: PsiFile): Boolean = canFormat(psiFile, *emptyArray<Feature>())

override fun canFormat(psiFile: PsiFile, vararg features: Feature): Boolean {
val goal = LspFormattingGoal.getFormattingGoal(features) ?: return false
override fun canFormat(psiFile: PsiFile): Boolean {
val goal = LspFormattingGoal.FullFileFormatting
val lspServer: LspServer? = when (goal) {
LspFormattingGoal.FullFileFormatting -> findServerToFormatThisFile(psiFile, true)
LspFormattingGoal.RangeFormatting -> findServerToFormatThisFile(psiFile, false)
Expand Down Expand Up @@ -164,10 +162,10 @@ internal class LspFormattingService : AsyncDocumentFormattingService() {
) : LspFormattingTask(lspServer, file, formattingRequest) {
override fun fetchTextEdits(): List<TextEdit> {
val formattingOptions = createFormattingOptions()
val document = runReadActionBlocking { formattingRequest.context.containingFile.fileDocument }
val document = runReadAction { formattingRequest.context.containingFile.fileDocument }

return formattingRequest.formattingRanges.flatMap { textRange ->
val lspDocuments = runReadActionBlocking {
val lspDocuments = runReadAction {
val range = getLsp4jRange(document, textRange.startOffset, textRange.length)
lspServer.documentMapping.getDocumentRangesSync(file, document, range)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private fun doesOtherFormattingServiceWantToWork(psiFile: PsiFile): Boolean =
it !is LspFormattingService &&
it !is CoreFormattingService &&
it.getFeatures().contains(FormattingService.Feature.OPTIMIZE_IMPORTS) &&
it.canFormat(psiFile, FormattingService.Feature.OPTIMIZE_IMPORTS) &&
//it.canFormat(psiFile, FormattingService.Feature.OPTIMIZE_IMPORTS) &&
it.getImportOptimizers(psiFile).any { optimizer -> optimizer !is LspImportOptimizer && optimizer.supports(psiFile) }
Comment thread
alexander-doroshko marked this conversation as resolved.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.find.usages.api.PsiUsage
import com.intellij.find.usages.api.Usage
import com.intellij.find.usages.api.UsageSearchParameters
import com.intellij.find.usages.api.UsageSearcher
import com.intellij.openapi.application.runReadActionBlocking
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.platform.dartlsp.impl.documentMapping
import com.intellij.platform.dartlsp.impl.mapLocation
Expand Down Expand Up @@ -33,9 +33,9 @@ internal class LspUsageSearcher : UsageSearcher {
private class LspReferencesQuery(private val searchTarget: LspSearchTarget) : AbstractQuery<Usage>() {
override fun processResults(consumer: Processor<in Usage>): Boolean {
for (lspServer in searchTarget.lspServers) {
val docPosition = runReadActionBlocking {
val document = FileDocumentManager.getInstance().getDocument(searchTarget.file) ?: return@runReadActionBlocking null
val offset = getOffsetInDocument(document, searchTarget.position) ?: return@runReadActionBlocking null
val docPosition = runReadAction {
val document = FileDocumentManager.getInstance().getDocument(searchTarget.file) ?: return@runReadAction null
val offset = getOffsetInDocument(document, searchTarget.position) ?: return@runReadAction null
lspServer.documentMapping.getDocumentPosition(searchTarget.file, document, offset)
} ?: continue
val documentIdentifier = docPosition.document.id
Expand All @@ -49,7 +49,7 @@ private class LspReferencesQuery(private val searchTarget: LspSearchTarget) : Ab

if (resultLocations.isNullOrEmpty()) continue

runReadActionBlocking {
runReadAction {
val psiManager = PsiManager.getInstance(lspServer.project)

for (resultLocation in resultLocations) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.dartlsp.util

import com.intellij.openapi.application.runReadActionBlocking
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.OpenFileDescriptor
Expand Down Expand Up @@ -68,7 +68,7 @@ fun showLspNavigationPopup(server: LspServer, locations: List<Location>, @Nls ti
}
icon = file.fileType.icon

val document = runReadActionBlocking {
val document = runReadAction {
FileDocumentManager.getInstance().getDocument(file)
}
val range = value.range
Expand Down
Loading