Skip to content

Commit

Permalink
Merge pull request #46 from ramonvermeulen/ramon/cleanup
Browse files Browse the repository at this point in the history
small clean-up, fixing warnings
  • Loading branch information
ramonvermeulen authored Jul 16, 2024
2 parents 0996dcd + 54fc737 commit 348579d
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActiveFileService>()

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.google.gson.JsonObject

data class Node(
val id: String,
val tests: List<String> = listOf(),
val tests: Set<String> = setOf(),
val isSelected: Boolean = false,
val relativePath: String,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +14,7 @@ import java.io.InputStreamReader
storages = [Storage("dbtToolkitSettings.xml")],
)
@Service(Service.Level.PROJECT)
class DbtToolkitSettingsService(private var project: Project) : PersistentStateComponent<DbtToolkitSettingsService.State> {
class DbtToolkitSettingsService : PersistentStateComponent<DbtToolkitSettingsService.State> {
data class State(
var settingsDbtProjectDir: String = "",
var settingsDbtTargetDir: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DbtCommandExecutorService>()
private val settings = project.service<DbtToolkitSettingsService>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LineageInfoService>()
private var settingsService = project.service<DbtToolkitSettingsService>()
private val dbtCommandExecutorService = project.service<DbtCommandExecutorService>()
Expand All @@ -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()) {
Expand Down Expand Up @@ -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.")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DbtToolkitSettingsService>()
private val venvInitializerService = project.service<VenvInitializerService>()
private val loggingService = project.service<LoggingService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DbtToolkitSettingsService>()
private val loggingService = project.service<LoggingService>()
private val notificationService = project.service<NotificationService>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, IdeaPanel>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocsService>()
private val settings = project.service<DbtToolkitSettingsService>()
private val ourCefClient = JBCefApp.getInstance().createClient()
Expand Down Expand Up @@ -69,7 +69,7 @@ class DocsPanel(private var project: Project) : IdeaPanel, Disposable {
val executor = Executors.newSingleThreadExecutor()
val future =
CompletableFuture.runAsync(
Runnable {
{
initiateCefRequestHandler()
},
executor,
Expand Down

0 comments on commit 348579d

Please sign in to comment.