fun updateDependentPlaceholders()

in intellij-plugin/educational-core/src/com/jetbrains/edu/learning/placeholderDependencies/PlaceholderDependencyManager.kt [21:55]


  fun updateDependentPlaceholders(project: Project, task: Task) {
    if (CCUtils.isCourseCreator(project)) {
      return
    }

    for (taskFile in task.taskFiles.values) {
      val virtualFile = taskFile.findTaskFileInDir(task.getDir(project.courseDir) ?: break) ?: continue
      EditorNotifications.getInstance(project).updateNotifications(virtualFile)
    }

    if (task.status != CheckStatus.Unchecked) {
      return
    }
    if (task.placeholderDependencies.isEmpty()) {
      return
    }

    if (task.hasChangedFiles(project)) {
      return
    }

    val unsolvedTasks = task.getUnsolvedTaskDependencies()
    if (unsolvedTasks.isNotEmpty()) {
      //everything will be handled by editor notification
      return
    }

    for (dependency in task.placeholderDependencies) {
      val replacementText = getReplacementText(project, dependency)
      val placeholderToReplace = dependency.answerPlaceholder
      runUndoTransparentWriteAction {
        replacePlaceholderText(project, placeholderToReplace, replacementText)
      }
    }
  }