Skip to content

Commit

Permalink
Merge pull request #140 from pontem-network/1.36.0
Browse files Browse the repository at this point in the history
1.36.0
  • Loading branch information
mkurnikov authored Apr 30, 2024
2 parents 9f55d37 + 5286448 commit 96a58c2
Show file tree
Hide file tree
Showing 149 changed files with 5,792 additions and 1,391 deletions.
39 changes: 38 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fun prop(name: String): String =
?: error("Property `$name` is not defined in gradle.properties for environment `$shortPlatformVersion`")

val shortPlatformVersion = prop("shortPlatformVersion")
val codeVersion = "1.35.0"
val codeVersion = "1.36.0"
val pluginVersion = "$codeVersion.$shortPlatformVersion"
val pluginGroup = "org.move"
val javaVersion = JavaVersion.VERSION_17
Expand All @@ -21,6 +21,8 @@ val pluginJarName = "intellij-move-$pluginVersion"
val kotlinReflectVersion = "1.8.10"
val aptosVersion = "3.1.0"

val remoteRobotVersion = "0.11.22"

group = pluginGroup
version = pluginVersion

Expand Down Expand Up @@ -254,6 +256,41 @@ project(":plugin") {
}
}
}

downloadRobotServerPlugin {
version.set(remoteRobotVersion)
}

runIdeForUiTests {
systemProperty("robot-server.port", "8082")
// systemProperty "ide.mac.message.dialogs.as.sheets", "false"
// systemProperty "jb.privacy.policy.text", "<!--999.999-->"
// systemProperty "jb.consents.confirmation.enabled", "false"
// systemProperty "ide.mac.file.chooser.native", "false"
// systemProperty "jbScreenMenuBar.enabled", "false"
// systemProperty "apple.laf.useScreenMenuBar", "false"
systemProperty("idea.trust.all.projects", "true")
systemProperty("ide.show.tips.on.startup.default.value", "false")
}
}
}

project(":ui-tests") {
dependencies {
implementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
implementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
implementation("org.junit.jupiter:junit-jupiter-api:5.10.0")

implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.0")

implementation("com.automation-remarks:video-recorder-junit5:2.0")
}

tasks.named<Test>("test") {
useJUnitPlatform()
}
}

Expand Down
5 changes: 4 additions & 1 deletion plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<idea-plugin xmlns:xi="http://www.w3.org/2001/XInclude">
<idea-plugin
require-restart="true"
xmlns:xi="http://www.w3.org/2001/XInclude">

<id>org.move.lang</id>
<name>Move Language</name>

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pluginManagement {
}

include("plugin")
include("ui-tests")
37 changes: 29 additions & 8 deletions src/main/grammars/MoveParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ private TypeParamBound_items ::= Ability ( '+' Ability )*
}
private TypeParamBound_items_recover ::= !('>' | ',')

TypeArgumentList ::= '<' <<non_empty_comma_sep_items (TypeArgument &(','|'>'))>>? '>' {
TypeArgumentList ::= '<' !'=' <<non_empty_comma_sep_items (TypeArgument &(','|'>'))>>? '>' {
name = "type arguments"
}
TypeArgument ::= Type
Expand Down Expand Up @@ -930,7 +930,10 @@ AddressLit ::= '@' AddressRef { pin = 1 }

CallExpr ::= (Path &'(') ValueArgumentList {
pin = 1
implements = ["org.move.lang.core.psi.PathExpr"]
implements = [
"org.move.lang.core.psi.PathExpr"
"org.move.lang.core.psi.ext.MvCallable"
]
}
ValueArgumentList ::= '(' ValueArgumentList_items? ')' {
pin = 1
Expand Down Expand Up @@ -972,17 +975,29 @@ Initializer ::= '=' Expr { pin = 1 }

BorrowExpr ::= '&' mut? Expr

DotExpr ::= Expr DotExpr_field
DotExpr ::= Expr DotExpr_inner
// Do not inline this rule, it breaks expression parsing
private DotExpr_field ::= '.' (!'.') StructDotField {
private DotExpr_inner ::= '.' !('.' | VectorStart) (MethodCall | StructDotField) {
pin = 2
consumeTokenMethod = "consumeTokenFast"
}
StructDotField ::= !(<<VECTOR_IDENTIFIER>> ('[' | '<')) IDENTIFIER !('(' | '::' | '!' | '{')

private VectorStart ::= (<<VECTOR_IDENTIFIER>> ('[' | '<'))

StructDotField ::= IDENTIFIER !('(' | '::' | '!' | '{')
{
implements = ["org.move.lang.core.resolve.ref.MvMandatoryReferenceElement"]
implements = ["org.move.lang.core.psi.ext.MvMethodOrField"]
mixin = "org.move.lang.core.psi.ext.MvStructDotFieldMixin"
}
MethodCall ::= IDENTIFIER TypeArgumentList? ValueArgumentList
{
implements = [
"org.move.lang.core.psi.ext.MvMethodOrField"
"org.move.lang.core.psi.ext.MvMethodOrPath"
"org.move.lang.core.psi.ext.MvCallable"
]
mixin = "org.move.lang.core.psi.ext.MvMethodCallMixin"
}

IndexExpr ::= Expr IndexArg
// Do not inline this rule, it breaks expression parsing
Expand All @@ -994,7 +1009,10 @@ RefExpr ::= Path !'{' {

Path ::= (ModulePathIdent | FQModulePathIdent | LocalPathIdent) TypeArgumentList?
{
implements = ["org.move.lang.core.resolve.ref.MvPathReferenceElement"]
implements = [
"org.move.lang.core.resolve.ref.MvPathReferenceElement"
"org.move.lang.core.psi.ext.MvMethodOrPath"
]
mixin = "org.move.lang.core.psi.ext.MvPathMixin"
}

Expand Down Expand Up @@ -1037,7 +1055,10 @@ NamedAddress ::= IDENTIFIER
}

/// Macros
AssertBangExpr ::= <<ASSERT_IDENTIFIER>> '!' ValueArgumentList { pin = 2 }
AssertBangExpr ::= <<ASSERT_IDENTIFIER>> '!' ValueArgumentList {
pin = 2
implements = [ "org.move.lang.core.psi.ext.MvCallable" ]
}
//AssertBangExpr ::= MacroIdent ValueArgumentList { pin = 1 }
//MacroIdent ::= IDENTIFIER '!'

Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/org/move/cli/LibraryRootsProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ private val MoveProject.ideaLibraries: Collection<SyntheticLibrary>
}
.map {
val sourceRoots = it.layoutPaths().mapNotNull { p -> p.toVirtualFile() }.toMutableSet()
it.moveToml.tomlFile
?.virtualFile?.let { f -> sourceRoots.add(f) }
val tomlFile = it.moveToml.tomlFile.virtualFile
sourceRoots.add(tomlFile)
// it.moveToml.tomlFile
// .virtualFile.let { f -> sourceRoots.add(f) }
MoveLangLibrary(it.packageName, sourceRoots, emptySet(), MoveIcons.MOVE_LOGO, null)
}

Expand Down
40 changes: 20 additions & 20 deletions src/main/kotlin/org/move/cli/MovePackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.intellij.openapi.vfs.VirtualFile
import org.move.cli.manifest.AptosConfigYaml
import org.move.cli.manifest.MoveToml
import org.move.lang.toNioPathOrNull
import org.move.openapiext.checkReadAccessAllowed
import org.move.openapiext.pathAsPath
import org.move.openapiext.resolveExisting
import java.nio.file.Path
Expand All @@ -14,13 +13,29 @@ data class MovePackage(
val project: Project,
val contentRoot: VirtualFile,
val moveToml: MoveToml,
val aptosConfigYaml: AptosConfigYaml?,
) {
val packageName = this.moveToml.packageName ?: ""

val sourcesFolder: VirtualFile? get() = contentRoot.takeIf { it.isValid }?.findChild("sources")
val testsFolder: VirtualFile? get() = contentRoot.takeIf { it.isValid }?.findChild("tests")

val aptosConfigYaml: AptosConfigYaml?
get() {
var root: VirtualFile? = contentRoot
while (true) {
if (root == null) break
val candidatePath = root
.findChild(".aptos")
?.takeIf { it.isDirectory }
?.findChild("config.yaml")
if (candidatePath != null) {
return AptosConfigYaml.fromPath(candidatePath.pathAsPath)
}
root = root.parent
}
return null
}

fun moveFolders(): List<VirtualFile> = listOfNotNull(sourcesFolder, testsFolder)

fun layoutPaths(): List<Path> {
Expand Down Expand Up @@ -48,24 +63,9 @@ data class MovePackage(
}

companion object {
fun fromMoveToml(moveToml: MoveToml): MovePackage? {
checkReadAccessAllowed()
val contentRoot = moveToml.tomlFile?.parent?.virtualFile ?: return null

var aptosConfigYaml: AptosConfigYaml? = null
var root: VirtualFile? = contentRoot
while (true) {
if (root == null) break
val candidatePath = root
.findChild(".aptos")
?.takeIf { it.isDirectory }
?.findChild("config.yaml")
if (candidatePath != null) {
aptosConfigYaml = AptosConfigYaml.fromPath(candidatePath.pathAsPath) ?: break
}
root = root.parent
}
return MovePackage(moveToml.project, contentRoot, moveToml, aptosConfigYaml)
fun fromMoveToml(moveToml: MoveToml): MovePackage {
val contentRoot = moveToml.tomlFile.virtualFile.parent
return MovePackage(moveToml.project, contentRoot, moveToml)
}
}
}
27 changes: 24 additions & 3 deletions src/main/kotlin/org/move/cli/MoveProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.move.cli
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.UserDataHolderBase
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFileFactory
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.GlobalSearchScopes
import com.intellij.psi.util.CachedValueProvider
Expand All @@ -11,22 +12,26 @@ import com.intellij.psi.util.PsiModificationTracker
import org.move.cli.manifest.AptosConfigYaml
import org.move.cli.manifest.MoveToml
import org.move.lang.MoveFile
import org.move.lang.core.psi.MvModule
import org.move.lang.core.types.Address
import org.move.lang.core.types.AddressLit
import org.move.lang.index.MvNamedElementIndex
import org.move.lang.toMoveFile
import org.move.lang.toNioPathOrNull
import org.move.openapiext.common.checkUnitTestMode
import org.move.openapiext.contentRoots
import org.move.stdext.chain
import org.move.stdext.iterateMoveVirtualFiles
import org.move.stdext.wrapWithList
import org.toml.lang.TomlLanguage
import org.toml.lang.psi.TomlFile
import java.nio.file.Path

data class MoveProject(
val project: Project,
val currentPackage: MovePackage,
val dependencies: List<Pair<MovePackage, RawAddressMap>>,
) : UserDataHolderBase() {
): UserDataHolderBase() {

val contentRoot: VirtualFile get() = this.currentPackage.contentRoot
val contentRootPath: Path? get() = this.currentPackage.contentRoot.toNioPathOrNull()
Expand Down Expand Up @@ -101,6 +106,12 @@ data class MoveProject(
return searchScope
}

fun getModulesFromIndex(name: String): Collection<MvModule> {
return MvNamedElementIndex
.getElementsByName(project, name, searchScope())
.filterIsInstance<MvModule>()
}

val aptosConfigYaml: AptosConfigYaml? get() = this.currentPackage.aptosConfigYaml

val profiles: Set<String> = this.aptosConfigYaml?.profiles.orEmpty()
Expand Down Expand Up @@ -129,8 +140,18 @@ data class MoveProject(
fun forTests(project: Project): MoveProject {
checkUnitTestMode()
val contentRoot = project.contentRoots.first()
val moveToml = MoveToml(project)
val movePackage = MovePackage(project, contentRoot, moveToml, null)
val tomlFile =
PsiFileFactory.getInstance(project)
.createFileFromText(
TomlLanguage,
"""
[package]
name = "MyPackage"
"""
) as TomlFile

val moveToml = MoveToml(project, tomlFile)
val movePackage = MovePackage(project, contentRoot, moveToml)
return MoveProject(
project,
movePackage,
Expand Down
Loading

0 comments on commit 96a58c2

Please sign in to comment.