From a86e9a4021ebd883696c31199da78557b440b26e Mon Sep 17 00:00:00 2001 From: michaelangeloio Date: Wed, 10 Jan 2024 12:14:25 -0500 Subject: [PATCH] save work --- .../plugins/dit/lsp/LspServerDescriptor.kt | 8 +++--- .../dit/settings/DoesItThrowConfigurable.kt | 19 +++++++++++++ .../dit/settings/DoesItThrowSettings.kt | 28 ++++++------------- .../messages/DoesItThrowBundle.properties | 7 +++-- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/lsp/LspServerDescriptor.kt b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/lsp/LspServerDescriptor.kt index dab9009..4e0d91e 100644 --- a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/lsp/LspServerDescriptor.kt +++ b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/lsp/LspServerDescriptor.kt @@ -40,10 +40,10 @@ class DoesItThrowLspServerDescriptor(project: Project) : ProjectWideLspServerDes override fun getWorkspaceConfiguration(item: ConfigurationItem): Any { LOG.info(item.scopeUri) return mapOf( - "throwStatementSeverity" to "Error", - "functionThrowSeverity" to "Error", - "callToThrowSeverity" to "Error", - "callToImportedThrowSeverity" to "Error", + "throwStatementSeverity" to DoesItThrowSettings.getInstance(project).throwStatementSeverity, + "functionThrowSeverity" to DoesItThrowSettings.getInstance(project).functionThrowSeverity, + "callToThrowSeverity" to DoesItThrowSettings.getInstance(project).callToThrowSeverity, + "callToImportedThrowSeverity" to DoesItThrowSettings.getInstance(project).callToImportedThrowSeverity, "includeTryStatementThrows" to DoesItThrowSettings.getInstance(project).includeTryStatementThrows, "maxNumberOfProblems" to DoesItThrowSettings.getInstance(project).maxNumberOfProblems, "ignoreStatements" to DoesItThrowSettings.getInstance(project).ignoreStatements diff --git a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowConfigurable.kt b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowConfigurable.kt index 601d42d..d1d0aac 100644 --- a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowConfigurable.kt +++ b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowConfigurable.kt @@ -18,6 +18,7 @@ class DoesItThrowSettingsConfigurable(private val project: Project) : override fun createPanel(): DialogPanel = panel { + row(DoesItThrowBundle.message("does-it-throw.settings.includeTryStatementThrows.label")) { checkBox("").bindSelected(settings::includeTryStatementThrows) } @@ -34,6 +35,24 @@ class DoesItThrowSettingsConfigurable(private val project: Project) : textArea.rows(10) // Sets the number of visible rows in the text area. } + group("Severity Configuration") { + row{ + label("Allowed Values: Information, Hint, Warning, Error") + } + row(DoesItThrowBundle.message("does-it-throw.settings.throwStatementSeverity.label")) { + textField().bindText(settings::throwStatementSeverity) + } + row (DoesItThrowBundle.message("does-it-throw.settings.functionThrowSeverity.label")) { + textField().bindText(settings::functionThrowSeverity) + } + row (DoesItThrowBundle.message("does-it-throw.settings.callToThrowSeverity.label")) { + textField().bindText(settings::callToThrowSeverity) + } + row (DoesItThrowBundle.message("does-it-throw.settings.callToImportedThrowSeverity.label")) { + textField().bindText(settings::callToImportedThrowSeverity) + } + } + onApply { doesItThrowServerService.restartDoesItThrowServer() doesItThrowServerService.notifyRestart() diff --git a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowSettings.kt b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowSettings.kt index 2a2f652..f0d8a1f 100644 --- a/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowSettings.kt +++ b/jetbrains/src/main/kotlin/org/michaelangeloio/plugins/dit/settings/DoesItThrowSettings.kt @@ -3,25 +3,16 @@ package org.michaelangeloio.plugins.dit.settings import com.intellij.openapi.components.* import com.intellij.openapi.project.Project -//class StringMutableProperty(private var value: String?) : MutableProperty { -// override fun get(): String? = value -// -// override fun set(value: String?) { -// this.value = value -// } -//} - @Service(Service.Level.PROJECT) @State(name = "DoesItThrowSettings", storages = [(Storage("does-it-throw.xml"))]) class DoesItThrowSettings : - SimplePersistentStateComponent(DoesItThrowSettingsState()) { -// private val throwStatementSeverityProperty = StringMutableProperty(throwStatementSeverity) -// -var throwStatementSeverity: String - get() = state.throwStatementSeverity ?: "Hint" - set(value) { - state.throwStatementSeverity = value - } + SimplePersistentStateComponent(DoesItThrowSettingsState()) { + + var throwStatementSeverity: String + get() = state.throwStatementSeverity ?: "Hint" + set(value) { + state.throwStatementSeverity = value + } var functionThrowSeverity: String get() = state.functionThrowSeverity ?: "Hint" @@ -39,7 +30,6 @@ var throwStatementSeverity: String state.callToImportedThrowSeverity = value } var includeTryStatementThrows: Boolean - get() = state.includeTryStatementThrows ?: false set(value) { state.includeTryStatementThrows = value @@ -51,8 +41,8 @@ var throwStatementSeverity: String } var ignoreStatements: List get() = state.ignoreStatements ?: listOf( - "@it-throws", - "@does-it-throw-ignore" + "@it-throws", + "@does-it-throw-ignore" ) set(value) { state.ignoreStatements = value diff --git a/jetbrains/src/main/resources/messages/DoesItThrowBundle.properties b/jetbrains/src/main/resources/messages/DoesItThrowBundle.properties index d758b14..20efdde 100644 --- a/jetbrains/src/main/resources/messages/DoesItThrowBundle.properties +++ b/jetbrains/src/main/resources/messages/DoesItThrowBundle.properties @@ -1,9 +1,10 @@ name=Does It Throw? does-it-throw.settings.name = Does It Throw Settings -does-it-throw.settings.throwStatementSeverity.label = Throw Statement severity -does-it-throw.settings.callToThrowSeverity.label = Call to Throw severity -does-it-throw.settings.callToImportedThrowSeverity.label = Call to Imported Throw severity +does-it-throw.settings.throwStatementSeverity.label = Throw Statement Severity +does-it-throw.settings.functionThrowSeverity.label = Function Throw Severity +does-it-throw.settings.callToThrowSeverity.label = Call to Throw Severity +does-it-throw.settings.callToImportedThrowSeverity.label = Call to Imported Throw Severity does-it-throw.settings.includeTryStatementThrows.label = Include Try Statement Throws does-it-throw.settings.maxNumberOfProblems.label = Max Number of Problems does-it-throw.settings.ignoreStatements.label = Ignore Statements