GradleBuildRootsManager, minor: fix notifications
This commit is contained in:
+29
-22
@@ -115,7 +115,6 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
fun markImportingInProgress(workingDir: String, inProgress: Boolean = true) {
|
||||
actualizeBuildRoot(workingDir)?.importing = inProgress
|
||||
updateNotifications { it.startsWith(workingDir) }
|
||||
hideNotificationForProjectImport(project)
|
||||
}
|
||||
|
||||
fun update(build: KotlinDslGradleBuildSync) {
|
||||
@@ -125,8 +124,9 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
if (root is Imported && root.data.models.isEmpty()) return
|
||||
}
|
||||
|
||||
val root = actualizeBuildRoot(build.workingDir) ?: return
|
||||
root.importing = false
|
||||
try {
|
||||
val root = actualizeBuildRoot(build.workingDir) ?: return
|
||||
root.importing = false
|
||||
|
||||
if (root is Legacy) return
|
||||
|
||||
@@ -139,9 +139,10 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
GradleBuildRootDataSerializer.write(newSupport.dir ?: return, mergedData)
|
||||
newSupport.saveLastModifiedFiles()
|
||||
|
||||
add(newSupport)
|
||||
|
||||
hideNotificationForProjectImport(project)
|
||||
add(newSupport)
|
||||
} finally {
|
||||
updateNotifications { it.startsWith(build.workingDir) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun merge(old: GradleBuildRootData, new: GradleBuildRootData): GradleBuildRootData {
|
||||
@@ -172,18 +173,7 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
val changes = StandaloneScriptsUpdater.collectChanges(delegate = roots, update)
|
||||
|
||||
updateNotifications { it in changes.new || it in changes.removed }
|
||||
|
||||
runReadAction {
|
||||
changes.new.forEach {
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(it)
|
||||
if (virtualFile != null) {
|
||||
val ktFile = PsiManager.getInstance(project).findFile(virtualFile) as? KtFile
|
||||
if (ktFile != null) {
|
||||
ScriptConfigurationManager.getInstance(project).getConfiguration(ktFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loadStandaloneScriptConfigurations(changes.new)
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -333,16 +323,19 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
private fun updateNotifications(shouldUpdatePath: (String) -> Boolean) {
|
||||
if (!project.isOpen) return
|
||||
|
||||
// import notification is a balloon, so should be shown only for selected editor
|
||||
FileEditorManager.getInstance(project).selectedEditor?.file?.let {
|
||||
if (shouldUpdatePath(it.path) && maybeAffectedGradleProjectFile(it.path)) {
|
||||
checkUpToDate(it)
|
||||
}
|
||||
}
|
||||
|
||||
val openedScripts = FileEditorManager.getInstance(project).openFiles.filter {
|
||||
shouldUpdatePath(it.path) && maybeAffectedGradleProjectFile(it.path)
|
||||
}
|
||||
|
||||
if (openedScripts.isEmpty()) return
|
||||
|
||||
openedScripts.forEach {
|
||||
checkUpToDate(it)
|
||||
}
|
||||
|
||||
GlobalScope.launch(EDT(project)) {
|
||||
if (project.isDisposed) return@launch
|
||||
|
||||
@@ -354,6 +347,20 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadStandaloneScriptConfigurations(files: MutableSet<String>) {
|
||||
runReadAction {
|
||||
files.forEach {
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(it)
|
||||
if (virtualFile != null) {
|
||||
val ktFile = PsiManager.getInstance(project).findFile(virtualFile) as? KtFile
|
||||
if (ktFile != null) {
|
||||
ScriptConfigurationManager.getInstance(project).getConfiguration(ktFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project): GradleBuildRootsManager =
|
||||
EPN.getPoint(project).extensionList.firstIsInstance()
|
||||
|
||||
Reference in New Issue
Block a user