Skip to content

Commit

Permalink
Merge pull request #133 from pontem-network/1.35.0
Browse files Browse the repository at this point in the history
1.35.0
  • Loading branch information
mkurnikov authored Mar 24, 2024
2 parents 6ebc023 + 33b10a4 commit 9944fd2
Show file tree
Hide file tree
Showing 41 changed files with 381 additions and 332 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
gradle-properties-version: [ 231, 232, 233 ]
gradle-properties-version: [ 232, 233 ]

runs-on: ${{ matrix.os }}
env:
Expand All @@ -27,7 +27,7 @@ jobs:
java-version: 17

- name: Setup Gradle and dependencies
uses: gradle/gradle-build-action@v2.7.0
uses: gradle/actions/setup-gradle@v3.1.0
with:
gradle-version: wrapper
cache-read-only: false
Expand Down
13 changes: 6 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ fun prop(name: String): String =
?: error("Property `$name` is not defined in gradle.properties for environment `$shortPlatformVersion`")

val shortPlatformVersion = prop("shortPlatformVersion")
val codeVersion = "1.34.0"
val codeVersion = "1.35.0"
val pluginVersion = "$codeVersion.$shortPlatformVersion"
val pluginGroup = "org.move"
val javaVersion = JavaVersion.VERSION_17
val pluginJarName = "intellij-move-$pluginVersion"

val kotlinReflectVersion = "1.8.10"
val aptosVersion = "2.4.0"
val aptosVersion = "3.1.0"

group = pluginGroup
version = pluginVersion

plugins {
id("java")
kotlin("jvm") version "1.9.22"
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.grammarkit") version "2022.3.2.1"
id("org.jetbrains.intellij") version "1.17.2"
id("org.jetbrains.grammarkit") version "2022.3.2.2"
id("net.saliman.properties") version "1.5.2"
id("org.gradle.idea")
id("de.undercouch.download") version "5.5.0"
Expand Down Expand Up @@ -170,13 +170,12 @@ project(":") {
tasks {
generateLexer {
sourceFile.set(file("src/main/grammars/MoveLexer.flex"))
targetDir.set("src/main/gen/org/move/lang")
targetClass.set("_MoveLexer")
targetOutputDir.set(file("src/main/gen/org/move/lang"))
purgeOldFiles.set(true)
}
generateParser {
sourceFile.set(file("src/main/grammars/MoveParser.bnf"))
targetRoot.set("src/main/gen")
targetRootOutputDir.set(file("src/main/gen"))
pathToParser.set("/org/move/lang/MoveParser.java")
pathToPsiRoot.set("/org/move/lang/psi")
purgeOldFiles.set(true)
Expand Down
17 changes: 17 additions & 0 deletions changelog/1.35.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# INTELLIJ MOVE CHANGELOG: 1.35.0

24 Mar 2024

## Features

* Add support for the nested attributes (Sui lints).

## Fixes

* Fix issue with saving Aptos-Cli path in Settings.
* Fix Run / View function Run Configuration dialog.

## Internal

* Update bundled Aptos-Cli to 3.1.0.
* Drop 2023.1 support.
13 changes: 0 additions & 13 deletions gradle-231.properties

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ propertiesPluginEnvironmentNameProperty=shortPlatformVersion
# properties files
# supported versions are 231, 232, 233, default is 231
# pass ORG_GRADLE_PROJECT_shortPlatformVersion environment variable to overwrite
shortPlatformVersion=233
shortPlatformVersion=232
18 changes: 10 additions & 8 deletions src/main/grammars/MoveParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,21 @@ File ::= (NamedAddressDef | Script | AddressDef | Module | ModuleSpec)*
QualPathCodeFragmentElement ::= FQModulePathIdent? TypeArgumentList?

Attr ::= '#' '[' <<non_empty_comma_sep_items AttrItem>> ']' { pin = 1 }
AttrItem ::= IDENTIFIER (AttrItemArguments | AttrItemInitializer)?
{
implements = [ "org.move.lang.core.psi.MvNamedElement" ]
mixin = "org.move.lang.core.psi.ext.MvAttrItemMixin"
}
AttrItemArguments ::= '(' <<non_empty_comma_sep_items AttrItemArgument>>? ')' { pin = 1 }
AttrItemArgument ::= IDENTIFIER ('=' Expr)?
AttrItem ::= IDENTIFIER (AttrItemList | AttrItemInitializer)?
{
implements = [
"org.move.lang.core.resolve.ref.MvReferenceElement"
]
mixin = "org.move.lang.core.psi.ext.MvAttrItemArgumentMixin"
mixin = "org.move.lang.core.psi.ext.MvAttrItemMixin"
}
AttrItemList ::= '(' <<non_empty_comma_sep_items AttrItem>>? ')' { pin = 1 }
//AttrItemArgument ::= IDENTIFIER ('=' Expr)?
//{
// implements = [
// "org.move.lang.core.resolve.ref.MvReferenceElement"
// ]
// mixin = "org.move.lang.core.psi.ext.MvAttrItemArgumentMixin"
//}
AttrItemInitializer ::= '=' Expr { pin = 1 }

NamedAddressDef ::= address IDENTIFIER '=' AddressRef ';' { pin = 3 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import org.move.utils.MvBackgroundTaskQueue

@Service
@Service(Service.Level.PROJECT)
class MvProjectTaskQueueService(val project: Project): Disposable {
private val queue = MvBackgroundTaskQueue()

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/move/cli/MoveProjectsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class MoveProjectsService(val project: Project): Disposable {
}

// requires ReadAccess
fun findMoveProject(psiElement: PsiElement): MoveProject? {
fun findMoveProjectForPsiElement(psiElement: PsiElement): MoveProject? {
// read access required for the psiElement.containingFile
checkReadAccessAllowed()
val file = when (psiElement) {
Expand Down Expand Up @@ -115,7 +115,7 @@ class MoveProjectsService(val project: Project): Disposable {
return findMoveProjectForFile(file)
}

fun findMoveProject(path: Path): MoveProject? {
fun findMoveProjectForPath(path: Path): MoveProject? {
val file = path.toVirtualFile() ?: return null
return findMoveProjectForFile(file)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/move/cli/manifest/AptosConfigYaml.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.move.cli.manifest

import com.intellij.util.io.readText
import kotlin.io.path.readText
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.error.YAMLException
import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.intellij.openapi.project.Project
import org.move.cli.Consts
import org.move.cli.moveProjectsService

@Service
@Service(Service.Level.PROJECT)
class MoveSettingsFilesService(private val project: Project) {
fun collectSettingsFiles(): List<String> {
val out = mutableListOf<String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ abstract class CommandConfigurationHandler {

abstract fun getFunctionCompletionVariants(moveProject: MoveProject): Collection<String>

abstract fun getFunction(moveProject: MoveProject, functionQualName: String): MvFunction?
abstract fun getFunctionItem(moveProject: MoveProject, functionQualName: String): MvFunction?

abstract fun getFunctionByCmdName(moveProject: MoveProject, functionCmdName: String): MvFunction?

abstract fun getFunctionParameters(function: MvFunction): List<MvFunctionParameter>

fun generateCommand(
moveProject: MoveProject,
profileName: String,
functionCall: FunctionCall
functionCall: FunctionCall,
signerAccount: String?,
): RsResult<String, String> {
val functionId = functionCall.functionId(moveProject) ?: return RsResult.Err("FunctionId is null")

Expand All @@ -68,12 +68,13 @@ abstract class CommandConfigurationHandler {

val commandArguments = listOf(
subCommand.split(' '),
listOf("--profile", profileName),
listOf("--profile", signerAccount),
listOf("--function-id", functionId),
typeParams,
params
).flatten()
return RsResult.Ok(commandArguments.joinToString(" "))
val command = commandArguments.joinToString(" ")
return RsResult.Ok(command)
}

fun parseCommand(
Expand All @@ -91,14 +92,14 @@ abstract class CommandConfigurationHandler {
val function = getFunctionByCmdName(moveProject, functionId)
?: return RsResult.Err("function with this functionId does not exist in the current project")

val aptosConfig = moveProject.aptosConfigYaml
if (aptosConfig == null) {
return RsResult.Err("Aptos account is not initialized / is invalid for the current project")
}

if (profileName !in aptosConfig.profiles) {
return RsResult.Err("account '$profileName' is not present in the project's accounts")
}
// val aptosConfig = moveProject.aptosConfigYaml
// if (aptosConfig == null) {
// return RsResult.Err("Aptos account is not initialized / is invalid for the current project")
// }
//
// if (profileName !in aptosConfig.profiles) {
// return RsResult.Err("account '$profileName' is not present in the project's accounts")
// }
val transaction = FunctionCall.template(function)

val typeParameterNames = function.typeParameters.mapNotNull { it.name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ abstract class FunctionCallConfigurationBase(
val configurationHandler: CommandConfigurationHandler,
): CommandConfigurationBase(project, factory) {

var moveProject: MoveProject?
get() = workingDirectory?.let { project.moveProjectsService.findMoveProject(it) }
var moveProjectFromWorkingDirectory: MoveProject?
get() = workingDirectory?.let { wdir -> project.moveProjectsService.findMoveProjectForPath(wdir) }
set(value) {
workingDirectory = value?.contentRootPath
}

override fun getCliPath(project: Project): Path? = project.aptosPath

fun firstRunShouldOpenEditor(): Boolean {
val moveProject = moveProject ?: return true
val functionCall = configurationHandler
.parseCommand(moveProject, command).unwrapOrNull()?.second ?: return true
val moveProject = moveProjectFromWorkingDirectory ?: return true
val (_, functionCall) = configurationHandler
.parseCommand(moveProject, command).unwrapOrNull() ?: return true
return functionCall.parametersRequired()
}
}
Loading

0 comments on commit 9944fd2

Please sign in to comment.