func updateAndNotifyStatuses()

in Sources/SKCore/BuildSystemManager.swift [243:274]


  func updateAndNotifyStatuses(changes: [DocumentURI: MainFileStatus]) {
    var changedWatchedFiles = [DocumentURI: FileBuildSettingsChange]()
    for (mainFile, status) in changes {
      let watches = self.watchedFiles.filter { $1.mainFile == mainFile }
      guard !watches.isEmpty else {
        // Possible notification after the file was unregistered. Ignore.
        continue
      }
      let prevStatus = self.mainFileStatuses[mainFile]
      self.mainFileStatuses[mainFile] = status

      // It's possible that the command line arguments didn't change
      // (waitingFallback --> fallback), in that case we don't need to report a change.
      // If we were waiting though, we need to emit an initial change.
      guard prevStatus == .waiting || status.buildSettings != prevStatus?.buildSettings else {
        continue
      }
      if let change = status.buildSettingsChange {
        for watch in watches {
          let newChange =
            self.convert(change: change, ofMainFile: mainFile, to: watch.key)
          changedWatchedFiles[watch.key] = newChange
        }
      }
    }

    if !changedWatchedFiles.isEmpty, let delegate = self._delegate {
      self.notifyQueue.async {
        delegate.fileBuildSettingsChanged(changedWatchedFiles)
      }
    }
  }