Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelangeloio committed Jan 10, 2024
1 parent 6521d0d commit a86e9a4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String?> {
// 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>(DoesItThrowSettingsState()) {
// private val throwStatementSeverityProperty = StringMutableProperty(throwStatementSeverity)
//
var throwStatementSeverity: String
get() = state.throwStatementSeverity ?: "Hint"
set(value) {
state.throwStatementSeverity = value
}
SimplePersistentStateComponent<DoesItThrowSettingsState>(DoesItThrowSettingsState()) {

var throwStatementSeverity: String
get() = state.throwStatementSeverity ?: "Hint"
set(value) {
state.throwStatementSeverity = value
}

var functionThrowSeverity: String
get() = state.functionThrowSeverity ?: "Hint"
Expand All @@ -39,7 +30,6 @@ var throwStatementSeverity: String
state.callToImportedThrowSeverity = value
}
var includeTryStatementThrows: Boolean

get() = state.includeTryStatementThrows ?: false
set(value) {
state.includeTryStatementThrows = value
Expand All @@ -51,8 +41,8 @@ var throwStatementSeverity: String
}
var ignoreStatements: List<String>
get() = state.ignoreStatements ?: listOf(
"@it-throws",
"@does-it-throw-ignore"
"@it-throws",
"@does-it-throw-ignore"
)
set(value) {
state.ignoreStatements = value
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a86e9a4

Please sign in to comment.