From 54fc737d8c72f8453995b434f719a7d1ab25a71c Mon Sep 17 00:00:00 2001 From: Ramon Vermeulen Date: Tue, 16 Jul 2024 10:46:00 +0200 Subject: [PATCH] small clean-up, fixing warnings --- .../dbtToolkit/listeners/DbtToolkitFileListener.kt | 2 +- .../com/github/ramonvermeulen/dbtToolkit/models/Node.kt | 2 +- .../dbtToolkit/services/DbtToolkitSettingsService.kt | 3 +-- .../ramonvermeulen/dbtToolkit/services/DocsService.kt | 2 +- .../ramonvermeulen/dbtToolkit/services/LoggingService.kt | 6 +----- .../ramonvermeulen/dbtToolkit/services/ManifestService.kt | 5 ++--- .../dbtToolkit/services/ProcessExecutorService.kt | 2 +- .../dbtToolkit/services/ProcessOutputHandlerService.kt | 2 +- .../dbtToolkit/ui/DbtToolkitMainToolWindow.kt | 6 +++--- .../dbtToolkit/ui/console/ConsoleOutputPanel.kt | 3 +-- .../github/ramonvermeulen/dbtToolkit/ui/docs/DocsPanel.kt | 4 ++-- 11 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/listeners/DbtToolkitFileListener.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/listeners/DbtToolkitFileListener.kt index 69d2962e..1b5f6e60 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/listeners/DbtToolkitFileListener.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/listeners/DbtToolkitFileListener.kt @@ -7,7 +7,7 @@ import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -class DbtToolkitFileListener(private val project: Project) : FileEditorManagerListener { +class DbtToolkitFileListener(project: Project) : FileEditorManagerListener { private val activeFileService = project.service() companion object { diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/models/Node.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/models/Node.kt index 76f1e74a..3f4a7f6d 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/models/Node.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/models/Node.kt @@ -5,7 +5,7 @@ import com.google.gson.JsonObject data class Node( val id: String, - val tests: List = listOf(), + val tests: Set = setOf(), val isSelected: Boolean = false, val relativePath: String, ) { diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DbtToolkitSettingsService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DbtToolkitSettingsService.kt index 0d9b7a03..b8d04ad2 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DbtToolkitSettingsService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DbtToolkitSettingsService.kt @@ -4,7 +4,6 @@ import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.Service import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage -import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import org.yaml.snakeyaml.Yaml import java.io.BufferedReader @@ -15,7 +14,7 @@ import java.io.InputStreamReader storages = [Storage("dbtToolkitSettings.xml")], ) @Service(Service.Level.PROJECT) -class DbtToolkitSettingsService(private var project: Project) : PersistentStateComponent { +class DbtToolkitSettingsService : PersistentStateComponent { data class State( var settingsDbtProjectDir: String = "", var settingsDbtTargetDir: String = "", diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DocsService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DocsService.kt index 4402b48a..c9f3bab9 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DocsService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/DocsService.kt @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project import java.io.File @Service(Service.Level.PROJECT) -class DocsService(private var project: Project) { +class DocsService(project: Project) { private val dbtCommandExecutorService = project.service() private val settings = project.service() diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/LoggingService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/LoggingService.kt index d759b08f..c203125b 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/LoggingService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/LoggingService.kt @@ -14,7 +14,7 @@ interface LoggingListener { } @Service(Service.Level.PROJECT) -class LoggingService(private val project: Project) { +class LoggingService(project: Project) { private val publisher: LoggingListener = project.messageBus.syncPublisher(TOPIC) init { @@ -33,10 +33,6 @@ class LoggingService(private val project: Project) { publisher.logEvent(LoggingEvent(message, type)) } - fun flush() { - publisher.flush() - } - companion object { val TOPIC = Topic("LoggingTopic", LoggingListener::class.java) } diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ManifestService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ManifestService.kt index 16095d39..b2dd41c5 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ManifestService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ManifestService.kt @@ -13,7 +13,7 @@ import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.withLock @Service(Service.Level.PROJECT) -class ManifestService(private var project: Project) { +class ManifestService(project: Project) { private val lineageInfoService = project.service() private var settingsService = project.service() private val dbtCommandExecutorService = project.service() @@ -22,7 +22,6 @@ class ManifestService(private var project: Project) { @Synchronized private fun parseManifest() { - // todo(ramon) maybe remove --no-partial-parse flag since it is dbt 1.6 > dbtCommandExecutorService.executeCommand(listOf("parse")) val file = File("${settingsService.state.settingsDbtTargetDir}/manifest.json") if (file.exists()) { @@ -62,7 +61,7 @@ class ManifestService(private var project: Project) { val tests = children?.mapNotNull { child -> child.asString.takeIf { it.startsWith("test.") } - } ?: emptyList() + }?.toSet() ?: emptySet() children?.forEach { child -> if (!child.asString.startsWith("test.")) { diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessExecutorService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessExecutorService.kt index 1587bb84..eaa92641 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessExecutorService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessExecutorService.kt @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project import java.io.File @Service(Service.Level.PROJECT) -class ProcessExecutorService(private var project: Project) { +class ProcessExecutorService(project: Project) { private val settings = project.service() private val venvInitializerService = project.service() private val loggingService = project.service() diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessOutputHandlerService.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessOutputHandlerService.kt index bbda942b..ad6c0c12 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessOutputHandlerService.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessOutputHandlerService.kt @@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project import java.util.concurrent.TimeUnit @Service(Service.Level.PROJECT) -class ProcessOutputHandlerService(private var project: Project) { +class ProcessOutputHandlerService(project: Project) { private val settings = project.service() private val loggingService = project.service() private val notificationService = project.service() diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/DbtToolkitMainToolWindow.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/DbtToolkitMainToolWindow.kt index 29f1eb8c..65c78262 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/DbtToolkitMainToolWindow.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/DbtToolkitMainToolWindow.kt @@ -31,9 +31,9 @@ class DbtToolkitMainToolWindow : ToolWindowFactory, DumbAware { val panelCreators = mapOf( - "dbt lineage" to PanelInfo(Supplier { LineagePanel(project) }, false), - "dbt docs" to PanelInfo(Supplier { DocsPanel(project) }, true), - "console (read-only)" to PanelInfo(Supplier { ConsoleOutputPanel(project, toolWindow) }, false), + "dbt lineage" to PanelInfo({ LineagePanel(project) }, false), + "dbt docs" to PanelInfo({ DocsPanel(project) }, true), + "console (read-only)" to PanelInfo({ ConsoleOutputPanel(project) }, false), ) val panels = mutableMapOf() diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/console/ConsoleOutputPanel.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/console/ConsoleOutputPanel.kt index 3a947a8f..449541a9 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/console/ConsoleOutputPanel.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/console/ConsoleOutputPanel.kt @@ -8,13 +8,12 @@ import com.intellij.execution.impl.ConsoleViewImpl import com.intellij.execution.ui.ConsoleView import com.intellij.openapi.Disposable import com.intellij.openapi.project.Project -import com.intellij.openapi.wm.ToolWindow import java.awt.BorderLayout import javax.swing.JComponent import javax.swing.JPanel import javax.swing.SwingUtilities -class ConsoleOutputPanel(private val project: Project, private val toolWindow: ToolWindow) : IdeaPanel, Disposable, LoggingListener { +class ConsoleOutputPanel(project: Project) : IdeaPanel, Disposable, LoggingListener { private val mainPanel: JPanel = JPanel(BorderLayout()) private val consoleView: ConsoleView = ConsoleViewImpl(project, false) diff --git a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/docs/DocsPanel.kt b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/docs/DocsPanel.kt index f7699b43..ecc19363 100644 --- a/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/docs/DocsPanel.kt +++ b/src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/ui/docs/DocsPanel.kt @@ -29,7 +29,7 @@ import javax.swing.JLabel import javax.swing.JPanel import javax.swing.SwingUtilities -class DocsPanel(private var project: Project) : IdeaPanel, Disposable { +class DocsPanel(project: Project) : IdeaPanel, Disposable { private val docsService = project.service() private val settings = project.service() private val ourCefClient = JBCefApp.getInstance().createClient() @@ -69,7 +69,7 @@ class DocsPanel(private var project: Project) : IdeaPanel, Disposable { val executor = Executors.newSingleThreadExecutor() val future = CompletableFuture.runAsync( - Runnable { + { initiateCefRequestHandler() }, executor,