diff --git a/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/BazelBspServer.kt b/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/BazelBspServer.kt index edd607452..0820dd829 100644 --- a/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/BazelBspServer.kt +++ b/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/BazelBspServer.kt @@ -150,9 +150,6 @@ class BazelBspServer( bazelBspCompilationManager = compilationManager, aspectsResolver = aspectsResolver ) - val currentContext = workspaceContextProvider.currentWorkspaceContext() - val bazelExternalRulesQuery = - BazelExternalRulesQueryImpl(bazelRunner, bazelInfo.isBzlModEnabled, currentContext.enabledRules) val bazelBspLanguageExtensionsGenerator = BazelBspLanguageExtensionsGenerator(aspectsResolver, bazelInfo.release) val bazelBspFallbackAspectsManager = BazelBspFallbackAspectsManager(bazelRunner, workspaceContextProvider) val targetKindResolver = TargetKindResolver() @@ -170,7 +167,6 @@ class BazelBspServer( val projectResolver = ProjectResolver( bazelBspAspectsManager = bazelBspAspectsManager, - bazelExternalRulesQuery = bazelExternalRulesQuery, bazelBspLanguageExtensionsGenerator = bazelBspLanguageExtensionsGenerator, bazelBspFallbackAspectsManager = bazelBspFallbackAspectsManager, workspaceContextProvider = workspaceContextProvider, @@ -178,6 +174,7 @@ class BazelBspServer( bspLogger = bspClientLogger, targetInfoReader = targetInfoReader, bazelInfo = bazelInfo, + bazelRunner = bazelRunner, metricsLogger = metricsLogger ) val projectStorage = FileProjectStorage(bspInfo, bspClientLogger) diff --git a/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/sync/ProjectResolver.kt b/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/sync/ProjectResolver.kt index 9b76ec60d..c04ca1727 100644 --- a/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/sync/ProjectResolver.kt +++ b/server/src/main/kotlin/org/jetbrains/bsp/bazel/server/sync/ProjectResolver.kt @@ -2,6 +2,7 @@ package org.jetbrains.bsp.bazel.server.sync import org.eclipse.lsp4j.jsonrpc.CancelChecker import org.jetbrains.bsp.bazel.bazelrunner.BazelInfo +import org.jetbrains.bsp.bazel.bazelrunner.BazelRunner import org.jetbrains.bsp.bazel.info.BspTargetInfo import org.jetbrains.bsp.bazel.logger.BspClientLogger import org.jetbrains.bsp.bazel.server.bsp.managers.BazelBspAspectsManager @@ -9,6 +10,7 @@ import org.jetbrains.bsp.bazel.server.bsp.managers.BazelBspAspectsManagerResult import org.jetbrains.bsp.bazel.server.bsp.managers.BazelBspFallbackAspectsManager import org.jetbrains.bsp.bazel.server.bsp.managers.BazelBspLanguageExtensionsGenerator import org.jetbrains.bsp.bazel.server.bsp.managers.BazelExternalRulesQuery +import org.jetbrains.bsp.bazel.server.bsp.managers.BazelExternalRulesQueryImpl import org.jetbrains.bsp.bazel.server.sync.model.Project import org.jetbrains.bsp.bazel.workspacecontext.WorkspaceContext import org.jetbrains.bsp.bazel.workspacecontext.WorkspaceContextProvider @@ -17,7 +19,6 @@ import org.jetbrains.bsp.bazel.workspacecontext.isAndroidEnabled /** Responsible for querying bazel and constructing Project instance */ class ProjectResolver( private val bazelBspAspectsManager: BazelBspAspectsManager, - private val bazelExternalRulesQuery: BazelExternalRulesQuery, private val bazelBspLanguageExtensionsGenerator: BazelBspLanguageExtensionsGenerator, private val bazelBspFallbackAspectsManager: BazelBspFallbackAspectsManager, private val workspaceContextProvider: WorkspaceContextProvider, @@ -25,6 +26,7 @@ class ProjectResolver( private val bspLogger: BspClientLogger, private val targetInfoReader: TargetInfoReader, private val bazelInfo: BazelInfo, + private val bazelRunner: BazelRunner, private val metricsLogger: MetricsLogger? ) { private fun measured(description: String, f: () -> T): T { @@ -38,6 +40,9 @@ class ProjectResolver( workspaceContextProvider::currentWorkspaceContext ) + val bazelExternalRulesQuery = + BazelExternalRulesQueryImpl(bazelRunner, bazelInfo.isBzlModEnabled, workspaceContext.enabledRules) + val externalRuleNames = measured( "Discovering supported external rules" ) { bazelExternalRulesQuery.fetchExternalRuleNames(cancelChecker) }