override fun execute()

in src/main/kotlin/org/arend/typechecking/execution/configurations/TypeCheckRunState.kt [39:110]


    override fun execute(executor: Executor, runner: ProgramRunner<*>): ExecutionResult? {
        if (environment.runnerSettings !is DebuggingRunnerData && service<ArendSettings>().typecheckingMode == ArendSettings.TypecheckingMode.SMART) {
            val tcService = environment.project.service<TypeCheckingService>()
            val modulePath = if (command.modulePath == "") null else ModulePath(command.modulePath.split('.'))
            if (command.definitionFullName != "" && modulePath == null) {
                NotificationErrorReporter(environment.project).report(DefinitionNotFoundError(command.definitionFullName))
                return null
            }

            val library = if (command.library == "") null else {
                val library = tcService.libraryManager.getRegisteredLibrary(command.library)
                if (library == null) {
                    NotificationErrorReporter(environment.project).report(LibraryError.notFound(command.library))
                    return null
                }
                if (library.isExternal || library !is BaseLibrary) {
                    NotificationErrorReporter(environment.project).report(LibraryError.incorrectLibrary(command.library))
                    return null
                }
                library
            }

            if (modulePath == null) {
                if (library == null) {
                    for (lib in tcService.libraryManager.registeredLibraries) {
                        if (!lib.isExternal) {
                            lib.reset()
                        }
                    }
                } else {
                    library.reset()
                }
            } else {
                if (command.definitionFullName == "") {
                    val group = library?.getModuleGroup(modulePath, command.isTest)
                    if (library == null || group == null) {
                        NotificationErrorReporter(environment.project).report(ModuleNotFoundError(modulePath))
                        return null
                    }
                    ApplicationManager.getApplication().run {
                        executeOnPooledThread {
                            runReadAction {
                                library.resetGroup(group)
                            }
                        }
                    }
                } else {
                    val scope = if (command.isTest) library?.testsModuleScopeProvider?.forModule(modulePath) else library?.moduleScopeProvider?.forModule(modulePath)
                    if (library == null || scope == null) {
                        NotificationErrorReporter(environment.project).report(ModuleNotFoundError(modulePath))
                        return null
                    }
                    val ref = Scope.resolveName(scope, command.definitionFullName.split('.')) as? LocatedReferable
                    if (ref == null) {
                        NotificationErrorReporter(environment.project).report(DefinitionNotFoundError(command.definitionFullName, modulePath))
                        return null
                    }
                    library.resetDefinition(ref)
                }
            }

            PsiManager.getInstance(environment.project).dropPsiCaches()
            DaemonCodeAnalyzer.getInstance(environment.project).restart()
            return null
        }

        val processHandler = TypeCheckProcessHandler(environment.project.service(), command)
        val console = createConsole(executor)
        console?.attachToProcess(processHandler)
        ProcessTerminatedListener.attach(processHandler)
        return DefaultExecutionResult(console, processHandler)
    }