Skip to content

Commit

Permalink
changed java files to kotlin files
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammadMD1383 committed Nov 2, 2023
1 parent fb7288c commit d167761
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import com.intellij.util.io.HttpRequests
import com.intellij.util.io.ZipUtil
import ir.mmd.intellijDev.Actionable.action.ActionBase
import ir.mmd.intellijDev.Actionable.action.LazyEventContext
import ir.mmd.intellijDev.Actionable.app.Actionable.*
import ir.mmd.intellijDev.Actionable.app.Actionable.AUTHOR
import ir.mmd.intellijDev.Actionable.app.Actionable.PLUGIN_ID
import ir.mmd.intellijDev.Actionable.app.Actionable.PLUGIN_NAME
import ir.mmd.intellijDev.Actionable.app.Actionable.UpToDateException
import ir.mmd.intellijDev.Actionable.app.Actionable.showNotification
import ir.mmd.intellijDev.Actionable.util.ext.plus
import java.nio.file.Path
import kotlin.io.path.ExperimentalPathApi
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/ir/mmd/intellijDev/Actionable/action/Actions.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package ir.mmd.intellijDev.Actionable.action;
package ir.mmd.intellijDev.Actionable.action

/**
* List of action names needed by this plugin
*/
public final class Actions {
private Actions() {
}

public static final String MACRO_PREFIX = "Actionable.Macro";
object Actions {
const val MACRO_PREFIX: String = "Actionable.Macro"

/**
* List of action group names needed bt this plugin
*/
public static final class Groups {
private Groups() {
}

public static final String MACROS = "ir.mmd.intellijDev.Actionable.text.macro.MacrosActionGroup";
object Groups {
const val MACROS: String = "ir.mmd.intellijDev.Actionable.text.macro.MacrosActionGroup"
}
}
35 changes: 15 additions & 20 deletions src/main/java/ir/mmd/intellijDev/Actionable/app/Actionable.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
package ir.mmd.intellijDev.Actionable.app;
package ir.mmd.intellijDev.Actionable.app

import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.project.Project

public class Actionable {
private Actionable() {
}

public static final String PLUGIN_ID = "ir.mmd.intellijDev.Actionable";
public static final String PLUGIN_NAME = "Actionable";
public static final String AUTHOR = "MohammadMD1383";
object Actionable {
const val PLUGIN_ID: String = "ir.mmd.intellijDev.Actionable"
const val PLUGIN_NAME: String = "Actionable"
const val AUTHOR: String = "MohammadMD1383"

public static final String NOTIFICATION_GROUP = "Actionable Notifications";
public static final String DOCS_TOOLWINDOW_ID = "Actionable Docs";
const val NOTIFICATION_GROUP: String = "Actionable Notifications"
const val DOCS_TOOLWINDOW_ID: String = "Actionable Docs"

public static void showNotification(@NotNull Project project, String content, NotificationType type) {
fun showNotification(project: Project, content: String, type: NotificationType) {
Notifications.Bus.notify(
new Notification(NOTIFICATION_GROUP, content, type),
Notification(NOTIFICATION_GROUP, content, type),
project
);
)
}

public static class UpToDateException extends Exception {
}
class UpToDateException : Exception()
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
package ir.mmd.intellijDev.Actionable.caret.editing.settings;
package ir.mmd.intellijDev.Actionable.caret.editing.settings

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

/**
* Settings State for {@code Actionable > Caret > Editing}
* Settings State for `Actionable > Caret > Editing`
*/
@State(
name = "ir.mmd.intellijDev.Actionable.caret.editing.settings",
storages = @Storage("Actionable.CaretEditingSettingsState.xml")
storages = [Storage("Actionable.CaretEditingSettingsState.xml")]
)
public class SettingsState implements PersistentStateComponent<SettingsState> {
class SettingsState : PersistentStateComponent<SettingsState?> {
/**
* This class holds the default values for the settings
*/
public static class Defaults {
public static final boolean showPasteActionHints = true;
@Suppress("ConstPropertyName")
object Defaults {
const val showPasteActionHints: Boolean = true
}

public boolean showPasteActionHints = Defaults.showPasteActionHints;
var showPasteActionHints: Boolean = Defaults.showPasteActionHints

@Override
public @Nullable SettingsState getState() {
return this;
}

@Override
public void loadState(@NotNull SettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
override fun getState() = this
override fun loadState(state: SettingsState) = XmlSerializerUtil.copyBean(state, this)
}
Original file line number Diff line number Diff line change
@@ -1,80 +1,74 @@
package ir.mmd.intellijDev.Actionable.caret.movement.settings;
package ir.mmd.intellijDev.Actionable.caret.movement.settings

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

/**
* Settings State for {@code Actionable > Caret > Editing}
* Settings State for `Actionable > Caret > Editing`
*/
@State(
name = "ir.mmd.intellijDev.Actionable.caret.movement.settings.SettingsState",
storages = @Storage("Actionable.CaretMovementSettingsState.xml")
storages = [Storage("Actionable.CaretMovementSettingsState.xml")]
)
public class SettingsState implements PersistentStateComponent<SettingsState> {
class SettingsState : PersistentStateComponent<SettingsState?> {
/**
* <b>enum</b><br>
* for behaviour of <code>move caret ...</code> actions<br>
* see {@link UI} for what these constants mean
* **enum**
*
* for behaviour of `move caret ...` actions
*
* see [UI] for what these constants mean
*/
public enum WSBehaviour {
enum class WSBehaviour {
/**
* Example of moving caret with this mode
* <pre>
* hello| world from java
* hello |world from java
* hello world| from java
* hello world |from java
* ...
* </pre>
* ```
* hello| world from java
* hello |world from java
* hello world| from java
* hello world |from java
* ...
* ```
*/
StopAtCharTypeChange,

/**
* Example of moving caret with this mode
* <pre>
* hello| world from java
* hello world| from java
* hello world from| java
* hello world from java|
* ...
* </pre>
* ```
* hello| world from java
* hello world| from java
* hello world from| java
* hello world from java|
* ...
* ```
*/
StopAtNextSameCharType
}

public enum SEMBehaviour {
enum class SEMBehaviour {
Start, Offset, End
}

/**
* this class holds default values for settings
*/
public static class Defaults {
public static final @NotNull String wordSeparators = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?\n\t";
public static final @NotNull WSBehaviour wordSeparatorsBehaviour = WSBehaviour.StopAtCharTypeChange;
public static final @NotNull String hardStopSeparators = " ";
public static final @NotNull SettingsState.SEMBehaviour sameElementMovementBehaviour = SEMBehaviour.Start;
object Defaults {
const val wordSeparators: String = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?\n\t"

@JvmField
val wordSeparatorsBehaviour: WSBehaviour = WSBehaviour.StopAtCharTypeChange
const val hardStopSeparators: String = " "

@JvmField
val sameElementMovementBehaviour: SEMBehaviour = SEMBehaviour.Start
}

public @NotNull String wordSeparators = Defaults.wordSeparators;

public @NotNull WSBehaviour wordSeparatorsBehaviour = Defaults.wordSeparatorsBehaviour;

public @NotNull String hardStopCharacters = Defaults.hardStopSeparators;
var wordSeparators: String = Defaults.wordSeparators
var wordSeparatorsBehaviour: WSBehaviour = Defaults.wordSeparatorsBehaviour
var hardStopCharacters: String = Defaults.hardStopSeparators
var sameElementMovementBehaviour: SEMBehaviour = Defaults.sameElementMovementBehaviour

public @NotNull SettingsState.SEMBehaviour sameElementMovementBehaviour = Defaults.sameElementMovementBehaviour;

@Override
public @Nullable SettingsState getState() {
return this;
}

@Override
public void loadState(@NotNull SettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
override fun getState() = this
override fun loadState(state: SettingsState) = XmlSerializerUtil.copyBean(state, this)
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
package ir.mmd.intellijDev.Actionable.find.settings;
package ir.mmd.intellijDev.Actionable.find.settings

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

/**
* Settings State for {@code Actionable > Find}
* Settings State for `Actionable > Find`
*/
@State(
name = "ir.mmd.intellijDev.Actionable.find.settings.SettingsState",
storages = @Storage("Actionable.FindSettingsState.xml")
storages = [Storage("Actionable.FindSettingsState.xml")]
)
public class SettingsState implements PersistentStateComponent<SettingsState> {
class SettingsState : PersistentStateComponent<SettingsState?> {
/**
* This class contains the default values for the settings
*/
public static class Defaults {
public static final boolean IS_CASE_SENSITIVE = true;
@Suppress("ConstPropertyName")
object Defaults {
const val isCaseSensitive: Boolean = true
}

public boolean isCaseSensitive = Defaults.IS_CASE_SENSITIVE;
var isCaseSensitive: Boolean = Defaults.isCaseSensitive

@Override
public @Nullable SettingsState getState() {
return this;
}

@Override
public void loadState(@NotNull SettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
override fun getState() = this
override fun loadState(state: SettingsState) = XmlSerializerUtil.copyBean(state, this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private void initListeners() {
caseSensitiveCheckBoxDefault.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
caseSensitiveCheckBox.setSelected(SettingsState.Defaults.IS_CASE_SENSITIVE);
caseSensitiveCheckBox.setSelected(SettingsState.Defaults.isCaseSensitive);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
package ir.mmd.intellijDev.Actionable.lang.html.settings;
package ir.mmd.intellijDev.Actionable.lang.html.settings

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import ir.mmd.intellijDev.Actionable.lang.html.type.ExpandTagOnType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

@State(
name = "ir.mmd.intellijDev.Actionable.lang.html.settings.SettingsState",
storages = @Storage("Actionable.Lang.HTML.SettingsState.xml")
storages = [Storage("Actionable.Lang.HTML.SettingsState.xml")]
)
public class SettingsState implements PersistentStateComponent<SettingsState> {
class SettingsState : PersistentStateComponent<SettingsState?> {
/**
* @see ExpandTagOnType
* @see ir.mmd.intellijDev.Actionable.lang.html.type.ExpandTagOnType
*/
public boolean expandTagOnTypeEnabled = false;
var expandTagOnTypeEnabled: Boolean = false

@Override
public @Nullable SettingsState getState() {
return this;
}

@Override
public void loadState(@NotNull SettingsState state) {
XmlSerializerUtil.copyBean(state, this);
}
override fun getState() = this
override fun loadState(state: SettingsState) = XmlSerializerUtil.copyBean(state, this)
}
Loading

0 comments on commit d167761

Please sign in to comment.