Skip to content

Commit

Permalink
[ settings ] Use default value instead of assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed May 10, 2019
1 parent cb5c32d commit 2b6c7d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 7 additions & 3 deletions buildSrc/src/generator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ class ${languageName}ProjectSettingsService : PersistentStateComponent<${languag
}
val Project.${nickname}Settings: ${languageName}ProjectSettingsService
get() = ${nickname}SettingsNullable!!
get() = ${nickname}SettingsNullable ?: ${languageName}ProjectSettingsService()
/** For building plugin searchable options */
/**
* When building plugin searchable options,
* `ServiceManager.getService(this, ${languageName}ProjectSettingsService::class.java)
* may return null.
*/
val Project.${nickname}SettingsNullable: ${languageName}ProjectSettingsService?
get() = ServiceManager.getService(this, ${languageName}ProjectSettingsService::class.java)
Expand All @@ -135,7 +139,7 @@ internal fun CommonConfigurable.configure$languageName(project: Project) {
${if (generateSettings) """
class ${languageName}ProjectConfigurable(project: Project) : VersionedExecutableProjectConfigurableImpl() {
/** For building searchable options */
override val settings: ${languageName}Settings = project.${nickname}SettingsNullable?.settings ?: ${languageName}Settings()
override val settings: ${languageName}Settings = project.${nickname}Settings.settings
init {
init()
Expand Down
1 change: 0 additions & 1 deletion src/org/ice1000/tt/error/error-report.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import org.eclipse.egit.github.core.RepositoryId
import org.eclipse.egit.github.core.client.GitHubClient
import org.eclipse.egit.github.core.service.IssueService
import org.ice1000.tt.TT_PLUGIN_ID
import org.ice1000.tt.project.acoreSettingsNullable
import org.ice1000.tt.project.agdaSettingsNullable
import org.ice1000.tt.project.minittSettingsNullable
import org.jetbrains.annotations.NonNls
Expand Down
2 changes: 1 addition & 1 deletion src/org/ice1000/tt/project/acore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class ACoreSettings(
)

class ACoreProjectConfigurable(project: Project) : OnlyExecutableProjectConfigurable() {
private val settings = project.acoreSettingsNullable?.settings ?: ACoreSettings()
private val settings = project.acoreSettings.settings

init {
exePathField.text = settings.exePath
Expand Down
3 changes: 1 addition & 2 deletions src/org/ice1000/tt/project/mlpolyr.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ data class MLPolyRSettings(
)

class MLPolyRProjectConfigurable(project: Project) : OnlyExecutableProjectConfigurable() {
private val settings = project.mlpolyrSettingsNullable?.settings
?: MLPolyRSettings()
private val settings = project.mlpolyrSettings.settings

init {
exePathField.text = settings.exePath
Expand Down

0 comments on commit 2b6c7d2

Please sign in to comment.