Skip to content

Commit

Permalink
Merge pull request #72 from pontem-network/1.20.0
Browse files Browse the repository at this point in the history
1.20.0
  • Loading branch information
mkurnikov authored Sep 27, 2022
2 parents 3de2dca + 1192449 commit 1b9fdfb
Show file tree
Hide file tree
Showing 154 changed files with 3,755 additions and 1,671 deletions.
12 changes: 7 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import org.jetbrains.intellij.tasks.RunPluginVerifierTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*

val shortPlatformVersion = prop("shortPlatformVersion")
val platformVersion = prop("shortPlatformVersion")
val publishingToken = System.getenv("JB_PUB_TOKEN") ?: null

fun prop(name: String): String =
extra.properties[name] as? String
?: error("Property `$name` is not defined in gradle.properties for environment `$shortPlatformVersion`")
?: error("Property `$name` is not defined in gradle.properties for environment `$platformVersion`")

//val intellijVersion = prop("intellijVersion", "2021.2")
val kotlinVersion = "1.7.10"

val pluginJarName = "intellij-move-$shortPlatformVersion"
val pluginVersion = "1.19.0"
val pluginJarName = "intellij-move-$platformVersion"
val pluginVersion = "1.20.0"
val pluginGroup = "org.move"

group = pluginGroup
Expand Down Expand Up @@ -62,6 +62,8 @@ allprojects {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
// sourceCompatibility = (if (platformVersion == "222") JavaVersion.VERSION_17 else JavaVersion.VERSION_11)
// targetCompatibility = (if (platformVersion == "222") JavaVersion.VERSION_17 else JavaVersion.VERSION_11)
}

sourceSets {
Expand Down Expand Up @@ -100,7 +102,7 @@ allprojects {
}

patchPluginXml {
version.set("$pluginVersion.$shortPlatformVersion")
version.set("$pluginVersion.$platformVersion")
changeNotes.set("""
<body>
<p><a href="https://github.com/pontem-network/intellij-move/blob/master/changelog/$pluginVersion.md">
Expand Down
37 changes: 37 additions & 0 deletions changelog/1.20.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# INTELLIJ MOVE CHANGELOG: 1.20.0

27 Sep 2022

## New Features

* Remove parameter quickfix

![remove_param](./static/remove_param.gif)

* Highlight hex integer literals

![hex_int](./static/hex_int.png)

* Sort completion in borrow exprs.

* Sort completions by abilities in type parameters.

* Support for imports inside code blocks.

* Allow repeating function signature in spec for readability.

* Type inference support for vector literals.

* Type check calls with not enough arguments.

* Type inference for statements in `loop {}` expr.

## Fixes

* Allow spaces inside `public(friend)` function modifier.

* Fix caching issue that lead to undeterministic type checking in some cases.

* Fix "unused parameter" error on native functions.

* Fix struct unpacking type inference.
Binary file added changelog/static/hex_int.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added changelog/static/remove_param.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gradle-222.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ platformVersion = 2022.2

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = org.toml.lang:222.3345.108
platformPlugins = org.toml.lang
verifierIdeVersions = IC-2022.2
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ propertiesPluginEnvironmentNameProperty=shortPlatformVersion
# properties files
# supported versions are 212, 213, 221, 222, default is 212
# pass ORG_GRADLE_PROJECT_shortPlatformVersion environment variable to overwrite
shortPlatformVersion=212
shortPlatformVersion=222
191 changes: 143 additions & 48 deletions src/main/grammars/MoveParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
extends("(Lambda|Ref|Path|Tuple|Unit)Type")=Type
// extends(".*SpecDef")=AnySpec

extends(".*Stmt")=Stmt
elementType(".+BinExpr")=BinaryExpr
elementType(".+BinOp")=BinaryOp

name(".+BinOp")="operator"
name(".*Expr")="expression"

// consumeTokenMethod(".*Expr") = "consumeTokenFast"
extends(".*Stmt")=Stmt

consumeTokenMethod("((?!.*_with_recover).*_recover)|(.*_first)|(.*Expr)") = "consumeTokenFast"

tokens = [
WHITESPACE='regexp:[ \n\t\r\f]'
Expand Down Expand Up @@ -737,27 +741,43 @@ Expr ::= AssignmentExpr
| SpecVisRestrictedExpr
| RangeExpr
| (ForallQuantExpr | ExistsQuantExpr | ChooseQuantExpr)
| ImplyOperatorsExpr_items
| OrExpr
| AndExpr
| LogicalEqExprItem
| BitOrExpr
| BitXorExpr
| BitAndExpr
| (LeftShiftExpr | RightShiftExpr)
| AddExprItem
| MulExprItem
| ControlFlowExpr
| CastExpr
| ImplyBinExpr_items
| OrBinExpr
| AndBinExpr
| LogicalEqExpr_items
| BitOrBinExpr
| BitXorBinExpr
| BitAndBinExpr
| (LeftShiftBinExpr | RightShiftBinExpr)
| AddExpr_items
| MulExpr_items
| ControlFlowExpr_items
| UnaryExpr
| BorrowExpr
| AtomExpr

private MulExprItem ::= DivExpr | MulExpr | ModExpr
private AddExprItem ::= PlusExpr | MinusExpr
private LogicalEqExprItem ::= EqualsExpr | NotEqualsExpr | LessEqualsExpr | LessExpr | GreaterEqualsExpr | GreaterExpr
fake BinaryExpr ::= Expr BinaryOp Expr {
methods = [
left="/Expr[0]"
right="/Expr[1]"
]
mixin = "org.move.lang.core.psi.ext.MvBinaryExprMixin"
}

fake BinaryOp ::= '==>' | '='
| '==' | '!='
| '<' | '>' | '<=' | '>='
| '<<' | '>>'
| '+' | '-' | '*' | '/' | '%'
| '||' | '&&' | '|' | '&' | '^'

private ControlFlowExpr ::= IfExpr | LoopExpr | WhileExpr

private MulExpr_items ::= DivBinExpr | MulBinExpr | ModBinExpr
private AddExpr_items ::= PlusBinExpr | MinusBinExpr
private LogicalEqExpr_items ::= EqualsBinExpr | NotEqualsBinExpr | LessEqualsBinExpr | LessBinExpr | GreaterEqualsBinExpr | GreaterBinExpr

private ControlFlowExpr_items ::= IfExpr | LoopExpr | WhileExpr
private UnaryExpr ::= CopyExpr | MoveExpr | DerefExpr | BangExpr
| ReturnExpr | ContinueExpr | BreakExpr | AbortExpr
private AtomExpr ::=
Expand All @@ -774,38 +794,71 @@ private AtomExpr ::=
| LitExpr
| CodeBlockExpr

EqualsExpr ::= Expr (!eqeq_gt '==') Expr
NotEqualsExpr ::= Expr '!=' Expr

OrExpr ::= Expr oror Expr
AndExpr ::= Expr andand Expr

LessExpr ::= Expr (!(ltlt | lt_eqeq_gt) '<') Expr
GreaterExpr ::= Expr (!gtgt '>') Expr
LessEqualsExpr ::= Expr lteq Expr
GreaterEqualsExpr ::= Expr gteq Expr

BitOrExpr ::= Expr (!oror '|') Expr
BitAndExpr ::= Expr (!andand '&') Expr
BitXorExpr ::= Expr '^' Expr

CastExpr ::= Expr as Type

private AnnotatedExpPrefix ::= '(' Expr ':'
AnnotatedExpr ::= AnnotatedExpPrefix Type ')' { pin = 1 }

MulExpr ::= Expr '*' Expr
DivExpr ::= Expr '/' Expr
PlusExpr ::= Expr '+' Expr
MinusExpr ::= Expr '-' Expr
ModExpr ::= Expr '%' Expr
EqualsBinExpr ::= Expr (!eqeq_gt EqualsBinOp) Expr
NotEqualsBinExpr ::= Expr NotEqualsBinOp Expr

EqualsBinOp ::= '=='
NotEqualsBinOp ::= '!='

LeftShiftExpr ::= Expr ltlt Expr
RightShiftExpr ::= Expr gtgt Expr
// booleans
OrBinExpr ::= Expr OrBinOp Expr
AndBinExpr ::= Expr AndBinOp Expr

private ImplyOperatorsExpr_items ::= ImplyOperatorExpr | PartialImplyOperatorExpr
ImplyOperatorExpr ::= Expr <<implyMslOnly eqeq_gt>> Expr
PartialImplyOperatorExpr ::= Expr <<implyMslOnly lt_eqeq_gt>> Expr
OrBinOp ::= oror
AndBinOp ::= andand

LessBinExpr ::= Expr (!(ltlt | lt_eqeq_gt) LessBinOp) Expr
GreaterBinExpr ::= Expr (!gtgt GreaterBinOp) Expr
LessEqualsBinExpr ::= Expr LessEqualsBinOp Expr
GreaterEqualsBinExpr ::= Expr GreaterEqualsBinOp Expr

LessBinOp ::= '<'
GreaterBinOp ::= '>'
LessEqualsBinOp ::= lteq
GreaterEqualsBinOp ::= gteq

// bitwise ops
BitOrBinExpr ::= Expr (!oror BitOrBinOp) Expr
BitAndBinExpr ::= Expr (!andand BitAndBinOp) Expr
BitXorBinExpr ::= Expr BitXorBinOp Expr

BitOrBinOp ::= '|'
BitAndBinOp ::= '&'
BitXorBinOp ::= '^'

// arithmetic
MulBinExpr ::= Expr MulBinOp Expr
DivBinExpr ::= Expr DivBinOp Expr
PlusBinExpr ::= Expr PlusBinOp Expr
MinusBinExpr ::= Expr MinusBinOp Expr
ModBinExpr ::= Expr ModBinOp Expr

MulBinOp ::= '*'
DivBinOp ::= '/'
PlusBinOp ::= '+'
MinusBinOp ::= '-'
ModBinOp ::= '%'

// bit shifts
LeftShiftBinExpr ::= Expr LeftShiftBinOp Expr
RightShiftBinExpr ::= Expr RightShiftBinOp Expr

LeftShiftBinOp ::= ltlt
RightShiftBinOp ::= gtgt

// imply
private ImplyBinExpr_items ::= ImplyBinExpr | PartialImplyBinExpr
ImplyBinExpr ::= Expr ImplyBinOp Expr
PartialImplyBinExpr ::= Expr PartialImplyBinOp Expr

ImplyBinOp ::= <<implyMslOnly eqeq_gt>>
PartialImplyBinOp ::= <<implyMslOnly lt_eqeq_gt>>

BangExpr ::= '!' Expr
DerefExpr ::= '*' Expr
Expand Down Expand Up @@ -864,13 +917,15 @@ LitExpr ::= HEX_INTEGER_LITERAL
| AddressLit
AddressLit ::= '@' AddressRef { pin = 1 }

CallExpr ::= (Path &'(') CallArgumentList { pin = 1 }
CallArgumentList ::= '(' CallArgumentList_items? ')' { pin = 1 }
private CallArgumentList_items ::= <<comma_sep_items Expr>>
CallExpr ::= (Path &'(') ValueArgumentList { pin = 1 }
ValueArgumentList ::= '(' ValueArgumentList_items? ')' { pin = 1 }
private ValueArgumentList_items ::= <<comma_sep_items ValueArgument>>
{
recoverWhile = CallArgumentList_items_recovery
recoverWhile = ValueArgumentList_items_recovery
}
private CallArgumentList_items_recovery ::= !(')' | ';')
private ValueArgumentList_items_recovery ::= !(';' | ')')

ValueArgument ::= Expr

IfExpr ::= if Condition AnyBlock ElseBlock? { pin = 1 }

Expand Down Expand Up @@ -960,7 +1015,7 @@ NamedAddress ::= IDENTIFIER
}

/// Macros
MacroCallExpr ::= MacroIdent CallArgumentList { pin = 1 }
MacroCallExpr ::= MacroIdent ValueArgumentList { pin = 1 }
MacroIdent ::= IDENTIFIER '!'

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1024,9 +1079,49 @@ private ModuleSpecBlock_item_recover ::= !('}' | <<eof>> | spec | use)

//AnySpec ::= ItemSpec | ModuleKeywordSpec

ItemSpec ::= spec ItemSpecRef <<msl ItemSpecBlock>>
ItemSpec ::= spec ItemSpecRef ItemSpecTypeParameterList? ItemSpecFunctionParameterList? ReturnType?
<<msl ItemSpecBlock>>
{
pin = 1
implements = [
"org.move.lang.core.types.infer.MvInferenceContextOwner"
]
mixin = "org.move.lang.core.psi.ext.MvItemSpecMixin"
}

ItemSpecTypeParameterList ::= '<' ItemSpecTypeParameter_with_recover* '>'
{
pin = 1
}
private ItemSpecTypeParameter_with_recover ::= !'>' ItemSpecTypeParameter (',' | &'>')
{
pin = 1
recoverWhile = ItemSpecTypeParameter_recover
}
private ItemSpecTypeParameter_recover ::= !('>' | '(' | '{' | phantom | IDENTIFIER)

ItemSpecTypeParameter ::= IDENTIFIER {
pin = 2
// implements = [
// "org.move.lang.core.resolve.MvMandatoryReferenceElement"
// ]
// mixin = "org.move.lang.core.psi.ext.MvItemSpecTypeParameterMixin"
}

ItemSpecFunctionParameterList ::= '(' ItemSpecFunctionParameter_with_recover* ')' { pin = 1 }
private ItemSpecFunctionParameter_with_recover ::= !(')' | '{' | ';') ItemSpecFunctionParameter (',' | &')')
{
pin = 1
recoverWhile = ItemSpecFunctionParameter_recover
}
private ItemSpecFunctionParameter_recover ::= !(')' | '{' | ';' | IDENTIFIER)

ItemSpecFunctionParameter ::= IDENTIFIER TypeAnnotation {
pin = 1
// implements = [
// "org.move.lang.core.resolve.MvMandatoryReferenceElement"
// ]
// mixin = "org.move.lang.core.psi.ext.MvItemSpecFunctionParameterMixin"
}

ItemSpecRef ::= MODULE_KW | IDENTIFIER
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/move/cli/MovePackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ data class MovePackage(
) {
val packageName = this.moveToml.packageName ?: ""

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

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

fun layoutPaths(): List<Path> {
val rootPath = contentRoot.toNioPathOrNull() ?: return emptyList()
val rootPath = contentRoot.takeIf { it.isValid }?.toNioPathOrNull() ?: return emptyList()
val names = listOf(
*MvProjectLayout.sourcesDirs,
MvProjectLayout.testsDir,
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/org/move/cli/MoveProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import com.intellij.psi.util.PsiModificationTracker
import com.intellij.util.containers.addIfNotNull
import org.move.cli.manifest.MoveToml
import org.move.lang.MoveFile
import org.move.lang.core.psi.ext.wrapWithList
import org.move.lang.core.types.Address
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 java.nio.file.Path

data class MoveProject(
Expand All @@ -45,7 +45,8 @@ data class MoveProject(

fun addresses(): PackageAddresses {
return CachedValuesManager.getManager(this.project).getCachedValue(this) {
val packageName = currentPackage.packageName
val packageName = this.currentPackage.packageName

val cumulativeAddresses = PackageAddresses(mutableAddressMap(), placeholderMap())
for ((depPackage, subst) in this.dependencies) {
cumulativeAddresses.extendWith(depPackage.addresses())
Expand Down
Loading

0 comments on commit 1b9fdfb

Please sign in to comment.