Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] enabled_rules section is reread on each sync
Browse files Browse the repository at this point in the history
Merge-request: BAZEL-MR-966
Merged-by: Marcin Abramowicz <marcin.abramowicz@jetbrains.com>
  • Loading branch information
abrams27 authored and qodana-bot committed Mar 25, 2024
1 parent 33daf98 commit b1655d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -170,14 +167,14 @@ class BazelBspServer(

val projectResolver = ProjectResolver(
bazelBspAspectsManager = bazelBspAspectsManager,
bazelExternalRulesQuery = bazelExternalRulesQuery,
bazelBspLanguageExtensionsGenerator = bazelBspLanguageExtensionsGenerator,
bazelBspFallbackAspectsManager = bazelBspFallbackAspectsManager,
workspaceContextProvider = workspaceContextProvider,
bazelProjectMapper = bazelProjectMapper,
bspLogger = bspClientLogger,
targetInfoReader = targetInfoReader,
bazelInfo = bazelInfo,
bazelRunner = bazelRunner,
metricsLogger = metricsLogger
)
val projectStorage = FileProjectStorage(bspInfo, bspClientLogger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ 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
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
Expand All @@ -17,14 +19,14 @@ 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,
private val bazelProjectMapper: BazelProjectMapper,
private val bspLogger: BspClientLogger,
private val targetInfoReader: TargetInfoReader,
private val bazelInfo: BazelInfo,
private val bazelRunner: BazelRunner,
private val metricsLogger: MetricsLogger?
) {
private fun <T> measured(description: String, f: () -> T): T {
Expand All @@ -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) }
Expand Down

0 comments on commit b1655d9

Please sign in to comment.