Skip to content

Commit

Permalink
support Sui in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov committed Feb 3, 2024
1 parent 8d7cc84 commit 3815104
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.move.cli.settings.aptos.AptosExec
import org.move.openapiext.debugInProduction
import org.move.stdext.exists
import org.move.stdext.isExecutableFile
import org.move.stdext.toPathOrNull
import java.nio.file.Path
import kotlin.reflect.KProperty1
import kotlin.reflect.full.memberProperties
Expand All @@ -34,6 +35,8 @@ interface MoveSettingsListener {

enum class Blockchain {
APTOS, SUI;

fun name(): String = if (this == APTOS) "Aptos" else "Sui"
}

private const val settingsServiceName: String = "MoveProjectSettingsService_1"
Expand Down Expand Up @@ -156,10 +159,14 @@ val Project.moveSettings: MoveProjectSettingsService get() = service()

val Project.collapseSpecs: Boolean get() = this.moveSettings.state.foldSpecs

val Project.blockchain: Blockchain get() = this.moveSettings.state.blockchain

val Project.aptosExec: AptosExec get() = this.moveSettings.state.aptosExec()

val Project.aptosPath: Path? get() = this.aptosExec.toPathOrNull()

val Project.suiPath: Path? get() = this.moveSettings.state.suiPath.toPathOrNull()

fun Path?.isValidExecutable(): Boolean {
return this != null
&& this.toString().isNotBlank()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.ui.EditorNotificationPanel
import org.move.cli.settings.PerProjectMoveConfigurable
import org.move.cli.settings.aptosExec
import org.move.cli.settings.*
import org.move.lang.isMoveFile
import org.move.lang.isMoveTomlManifestFile
import org.move.openapiext.common.isUnitTestMode
import org.move.openapiext.showSettings

class InvalidAptosExecNotification(project: Project): MvEditorNotificationProvider(project),
DumbAware {
class InvalidBlockchainCliConfiguration(project: Project): MvEditorNotificationProvider(project),
DumbAware {

override val VirtualFile.disablingKey: String get() = NOTIFICATION_STATUS_KEY + path

Expand All @@ -24,11 +23,18 @@ class InvalidAptosExecNotification(project: Project): MvEditorNotificationProvid
if (!project.isTrusted()) return null
if (isNotificationDisabled(file)) return null

if (project.aptosExec.isValid()) return null
// if (project.aptosPath.isValidExecutable()) return null
val blockchain = project.blockchain
when (blockchain) {
Blockchain.APTOS -> {
if (project.aptosExec.isValid()) return null
}
Blockchain.SUI -> {
if (project.suiPath.isValidExecutable()) return null
}
}

return EditorNotificationPanel().apply {
text = "Aptos binary path is not provided or invalid"
text = "${blockchain.name()} CLI path is not provided or invalid"
createActionLabel("Configure") {
project.showSettings<PerProjectMoveConfigurable>()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.ui.EditorNotificationPanel
import org.move.cli.moveProjectsService
import org.move.cli.settings.blockchain
import org.move.lang.isMoveFile
import org.move.lang.isMoveTomlManifestFile
import org.move.openapiext.common.isDispatchThread
Expand Down Expand Up @@ -38,7 +39,7 @@ class NoMoveProjectDetectedNotificationProvider(project: Project): MvEditorNotif
if (moveProjectsService.allProjects.isEmpty()) {
// no move projects available
return EditorNotificationPanel().apply {
text = "No Aptos projects found"
text = "No ${project.blockchain.name()} projects found"
createActionLabel("Do not show again") {
disableNotification(file)
updateAllNotifications(project)
Expand All @@ -48,7 +49,7 @@ class NoMoveProjectDetectedNotificationProvider(project: Project): MvEditorNotif

if (moveProjectsService.findMoveProjectForFile(file) == null) {
return EditorNotificationPanel().apply {
text = "File does not belong to any known Aptos project"
text = "File does not belong to any known ${project.blockchain.name()} project"
createActionLabel("Do not show again") {
disableNotification(file)
updateAllNotifications(project)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/intellij-move-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
<!-- Notifications -->
<notificationGroup id="Move Language" displayType="BALLOON" />
<editorNotificationProvider
implementation="org.move.ide.notifications.InvalidAptosExecNotification" />
implementation="org.move.ide.notifications.InvalidBlockchainCliConfiguration" />
<editorNotificationProvider
implementation="org.move.ide.notifications.NoMoveProjectDetectedNotificationProvider" />

Expand Down

0 comments on commit 3815104

Please sign in to comment.