func cachedStatusOrRegisterForSettings()

in Sources/SKCore/BuildSystemManager.swift [198:239]


  func cachedStatusOrRegisterForSettings(
    for mainFile: DocumentURI,
    language: Language
  ) -> MainFileStatus {
    // If we already have a status for the main file, use that.
    // Don't update any existing timeout.
    if let status = self.mainFileStatuses[mainFile] {
      return status
    }
    // This is a new `mainFile` that we need to handle. We need to fetch the
    // build settings.
    let newStatus: MainFileStatus
    if let buildSystem = self.buildSystem {
      // Register the timeout if it's applicable.
      if let fallback = self.fallbackBuildSystem {
        self.queue.asyncAfter(deadline: DispatchTime.now() + self.fallbackSettingsTimeout) { [weak self] in
          guard let self = self else { return }
          self.handleFallbackTimer(for: mainFile, language: language, fallback)
        }
      }

      // Intentionally register with the `BuildSystem` after setting the fallback to allow for
      // testing of the fallback system triggering before the `BuildSystem` can reply (e.g. if a
      // fallback time of 0 is specified).
      buildSystem.registerForChangeNotifications(for: mainFile, language: language)


      newStatus = .waiting
    } else if let fallback = self.fallbackBuildSystem {
      // Only have a fallback build system. We consider it be a primary build
      // system that functions synchronously.
      if let settings = fallback.settings(for: mainFile, language) {
        newStatus = .primary(settings)
      } else {
        newStatus = .unsupported
      }
    } else {  // Don't have any build systems.
      newStatus = .unsupported
    }
    self.mainFileStatuses[mainFile] = newStatus
    return newStatus
  }