Skip to content

Commit

Permalink
Fix missed references to DepsWatcher as project component
Browse files Browse the repository at this point in the history
Fixes #1871

`DepsWatcher` was converted to a Project Listener in #1844 to support installing the plugin from the Marketplace without reloading, but some references to `DepsWatcher` were still trying to get its instance for project using `project.getComponent()`, which would now return `null`.
  • Loading branch information
KronicDeth committed Jan 15, 2021
1 parent 11719da commit f809f06
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
The docs from the `Docs` chunk may contain interpolation in the code samples or `#{` in regex examples, but these should not be treated as an interpolation start as the `Docs` format does not support interpolation. Anything that looks like interpolation in the docs text was actually escaped in the original docs, so also escape it here by using `S"""`, which turns off interpolation.
* Log an error if `Code` function can't be matched to decompiled source.
Unlike the old `InvalidMirrorException`, this won't be an exception and the binary <-> decompile will still work for the other functions/macros in the file, so it will be a more graceful degradation.
* [1878](https://github.com/KronicDeth/intellij-elixir/pull/1878) - [@KronicDeth](https://github.com/KronicDeth)
* Fix missed references to `DepsWatcher` as project component
`DepsWatcher` was converted to a Project Listener in #1844 to support installing the plugin from the Marketplace without reloading, but some references to `DepsWatcher` were still trying to get its instance for project using `project.getComponent()`, which would now return `null`.

## v11.9.0

Expand Down
8 changes: 8 additions & 0 deletions resources/META-INF/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ <h1>v11.9.1</h1>
</li>
</ul>
</li>
<li>
Fix missed references to <code>DepsWatcher</code> as project component<br>
<code>DepsWatcher</code> was converted to a Project Listener in
<a href="https://github.com/KronicDeth/intellij-elixir/pull/1844">#1844</a>
to support installing the plugin from the Marketplace without reloading, but some references to
<code>DepsWatcher</code> were still trying to get its instance for project using
<code>project.getComponent()</code>, which would now return <code>null</code>.
</li>
</ul>
</li>
</ul>
Expand Down
8 changes: 4 additions & 4 deletions src/org/elixir_lang/DepsWatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ class DepsWatcher(val project: Project) : BulkFileListener {
if (fileName == "_build" && isModuleContentRoot(parent, project)) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Syncing Libraries in _build", true) {
override fun run(indicator: ProgressIndicator) {
syncLibraries(project, indicator)
syncLibraries(indicator)
}
})
} else {
parent.parent?.let { grandParent ->
if (parent.name == "_build" && isModuleContentRoot(grandParent, project)) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Syncing Libraries in _build/$fileName", true) {
override fun run(indicator: ProgressIndicator) {
syncLibraries(project, indicator)
syncLibraries(indicator)
}
})
} else {
grandParent.parent?.let { greatGrandParent ->
if (fileName in arrayOf("consolidated", "lib") && grandParent.name == "_build" && isModuleContentRoot(greatGrandParent, project)) {
ProgressManager.getInstance().run(object : Task.Backgroundable(project, "Syncing Libraries in _build/${parent.name}/$fileName", true) {
override fun run(indicator: ProgressIndicator) {
syncLibraries(project, indicator)
syncLibraries(indicator)
}
})
} else if (fileName in SOURCE_NAMES && grandParent.name == "deps" && isModuleContentRoot(greatGrandParent, project)) {
Expand Down Expand Up @@ -168,7 +168,7 @@ class DepsWatcher(val project: Project) : BulkFileListener {
}
}

fun syncLibraries(project: Project, progressIndicator: ProgressIndicator) {
fun syncLibraries(progressIndicator: ProgressIndicator) {
ProjectRootManager
.getInstance(project)
.contentRootsFromAllModules
Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/mix/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ object Project {

ProgressManager.getInstance().run(object : Task.Modal(project, "Scanning dependencies for Libraries", true) {
override fun run(indicator: ProgressIndicator) {
project.getComponent(DepsWatcher::class.java).syncLibraries(project, indicator)
DepsWatcher(project).syncLibraries(indicator)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/mix/Watcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Watcher(private val project: Project) : BulkFileListener {
if (externalPaths.isNotEmpty()) {
val libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project)

project.getComponent(DepsWatcher::class.java).syncLibraries(externalPaths, libraryTable, progressIndicator)
DepsWatcher(project).syncLibraries(externalPaths, libraryTable, progressIndicator)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/mix/project/DirectoryConfigurator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DirectoryConfigurator : com.intellij.platform.DirectoryProjectConfigurator

ProgressManager.getInstance().run(object : Task.Modal(project, "Scanning dependencies for Libraries", true) {
override fun run(indicator: ProgressIndicator) {
project.getComponent(DepsWatcher::class.java).syncLibraries(project, indicator)
DepsWatcher(project).syncLibraries(indicator)
}
})
}
Expand Down

0 comments on commit f809f06

Please sign in to comment.