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) {
|
fun markImportingInProgress(workingDir: String, inProgress: Boolean = true) {
|
||||||
actualizeBuildRoot(workingDir)?.importing = inProgress
|
actualizeBuildRoot(workingDir)?.importing = inProgress
|
||||||
updateNotifications { it.startsWith(workingDir) }
|
updateNotifications { it.startsWith(workingDir) }
|
||||||
hideNotificationForProjectImport(project)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(build: KotlinDslGradleBuildSync) {
|
fun update(build: KotlinDslGradleBuildSync) {
|
||||||
@@ -125,8 +124,9 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
|||||||
if (root is Imported && root.data.models.isEmpty()) return
|
if (root is Imported && root.data.models.isEmpty()) return
|
||||||
}
|
}
|
||||||
|
|
||||||
val root = actualizeBuildRoot(build.workingDir) ?: return
|
try {
|
||||||
root.importing = false
|
val root = actualizeBuildRoot(build.workingDir) ?: return
|
||||||
|
root.importing = false
|
||||||
|
|
||||||
if (root is Legacy) return
|
if (root is Legacy) return
|
||||||
|
|
||||||
@@ -139,9 +139,10 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
|||||||
GradleBuildRootDataSerializer.write(newSupport.dir ?: return, mergedData)
|
GradleBuildRootDataSerializer.write(newSupport.dir ?: return, mergedData)
|
||||||
newSupport.saveLastModifiedFiles()
|
newSupport.saveLastModifiedFiles()
|
||||||
|
|
||||||
add(newSupport)
|
add(newSupport)
|
||||||
|
} finally {
|
||||||
hideNotificationForProjectImport(project)
|
updateNotifications { it.startsWith(build.workingDir) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun merge(old: GradleBuildRootData, new: GradleBuildRootData): GradleBuildRootData {
|
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)
|
val changes = StandaloneScriptsUpdater.collectChanges(delegate = roots, update)
|
||||||
|
|
||||||
updateNotifications { it in changes.new || it in changes.removed }
|
updateNotifications { it in changes.new || it in changes.removed }
|
||||||
|
loadStandaloneScriptConfigurations(changes.new)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -333,16 +323,19 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
|||||||
private fun updateNotifications(shouldUpdatePath: (String) -> Boolean) {
|
private fun updateNotifications(shouldUpdatePath: (String) -> Boolean) {
|
||||||
if (!project.isOpen) return
|
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 {
|
val openedScripts = FileEditorManager.getInstance(project).openFiles.filter {
|
||||||
shouldUpdatePath(it.path) && maybeAffectedGradleProjectFile(it.path)
|
shouldUpdatePath(it.path) && maybeAffectedGradleProjectFile(it.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openedScripts.isEmpty()) return
|
if (openedScripts.isEmpty()) return
|
||||||
|
|
||||||
openedScripts.forEach {
|
|
||||||
checkUpToDate(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
GlobalScope.launch(EDT(project)) {
|
GlobalScope.launch(EDT(project)) {
|
||||||
if (project.isDisposed) return@launch
|
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 {
|
companion object {
|
||||||
fun getInstance(project: Project): GradleBuildRootsManager =
|
fun getInstance(project: Project): GradleBuildRootsManager =
|
||||||
EPN.getPoint(project).extensionList.firstIsInstance()
|
EPN.getPoint(project).extensionList.firstIsInstance()
|
||||||
|
|||||||
Reference in New Issue
Block a user