Skip to content

Commit 682d19a

Browse files
committed
Refactor code for clarity and efficiency
Simplified several implementations for better readability and maintainability. Removed unused variables, improved Kotlin lambda usage, and streamlined function calls to reduce redundancy. These changes aim to improve overall code quality and consistency.
1 parent 6e54137 commit 682d19a

4 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/main/kotlin/il/co/sysbind/intellij/moodledev/MoodlePluginGenerator.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import com.intellij.ui.dsl.builder.Cell
1616
import com.intellij.ui.dsl.builder.panel
1717
import il.co.sysbind.intellij.moodledev.moodle.Component
1818
import il.co.sysbind.intellij.moodledev.project.MoodleProjectSettings
19-
import java.awt.event.ActionListener
2019
import javax.swing.Icon
2120
import javax.swing.JComponent
2221
import javax.swing.JTextField
@@ -78,10 +77,10 @@ class MoodlePluginGenerator : WebProjectTemplate<MoodlePluginGeneratorSettings>(
7877
val myPanel = panel {
7978
row("Plugin Type:") {
8079
val pluginTypeComboBox = comboBox(moodleTree.getPluginTypes().toList())
81-
pluginTypeComboBox.component.addActionListener(ActionListener {
80+
pluginTypeComboBox.component.addActionListener {
8281
// Call checkValid whenever plugin type changes
8382
checkValid.run()
84-
})
83+
}
8584
}
8685
row("Plugin Name:") {
8786
val pluginNameTextField = JTextField()

src/main/kotlin/il/co/sysbind/intellij/moodledev/actions/generation/MoodlePHPNewClassAction.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ class MoodlePHPNewClassAction : PhpNewBaseAction(CAPTION, "", PhpFileType.INSTAN
179179
val interfaceQualifiedName =
180180
if (scope != null) PhpCodeInsightUtil.createQualifiedName(scope, interfaceFqn) else interfaceFqn
181181
val implementsClause = PhpPsiElementFactory.createImplementsList(project, interfaceQualifiedName)
182-
if (phpClass.implementsList != null) {
183-
phpClass.implementsList!!.add(implementsClause)
184-
} else {
185-
phpClass.add(implementsClause)
186-
}
182+
phpClass.implementsList.add(implementsClause)
187183
if (PhpReferenceInsertHandler.shouldInsertImport(phpClass, phpClass, interfaceFqn)) {
188184
PhpImportClassIntention.apply(
189185
project,

src/main/kotlin/il/co/sysbind/intellij/moodledev/project/MoodleSettings.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ class MoodleSettings {
55
var moodlePath: String = ""
66
var userName: String = ""
77
var userEmail: String = ""
8-
var moodleVersion: String = "master"
9-
val defaultMoodleTablePrefix = "mdl_"
108
}

src/main/kotlin/il/co/sysbind/intellij/moodledev/project/MoodleSettingsForm.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
4545
}
4646

4747
row("Moodle project directory:") {
48-
moodlePath =
49-
textFieldWithBrowseButton(
50-
FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(MoodleBundle.message("configurable.moodlePath")),
51-
project
52-
).bindText(settings::moodlePath).enabledIf(pluginEnabled.selected)
48+
moodlePath = textFieldWithBrowseButton(
49+
FileChooserDescriptorFactory.createSingleFolderDescriptor()
50+
.withTitle(MoodleBundle.message("configurable.moodlePath")),
51+
project
52+
).bindText(settings::moodlePath)
53+
.enabledIf(pluginEnabled.selected)
5354
}
5455
}
5556

0 commit comments

Comments
 (0)