Skip to content

Commit

Permalink
Merge pull request #108 from pontem-network/1.30.0
Browse files Browse the repository at this point in the history
1.30.0
  • Loading branch information
mkurnikov authored Jul 17, 2023
2 parents 44f3e0e + 9c98b9c commit facd1bc
Show file tree
Hide file tree
Showing 55 changed files with 1,514 additions and 179 deletions.
29 changes: 11 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,26 @@ fun prop(name: String): String =
?: error("Property `$name` is not defined in gradle.properties for environment `$platformVersion`")

val pluginJarName = "intellij-move-$platformVersion"
val pluginVersion = "1.29.0"
val pluginVersion = "1.30.0"
val pluginGroup = "org.move"
val javaVersion = JavaVersion.VERSION_17
val kotlinJvmTarget = "17"
val kotlinStdlibVersion = "1.8.21"
val kotlinStdlibVersion = "1.9.0"

group = pluginGroup
version = pluginVersion

plugins {
id("java")
kotlin("jvm") version "1.8.21"
id("org.jetbrains.intellij") version "1.13.3"
kotlin("jvm") version "1.9.0"
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.grammarkit") version "2022.3.1"
id("net.saliman.properties") version "1.5.2"
}

dependencies {
// kotlin stdlib source code
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinStdlibVersion")
implementation("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinStdlibVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinStdlibVersion")

implementation("io.sentry:sentry:5.5.2") {
implementation("io.sentry:sentry:6.25.0") {
exclude("org.slf4j")
}
implementation("com.github.ajalt.clikt:clikt:3.5.2")
Expand Down Expand Up @@ -80,9 +76,6 @@ allprojects {
main {
kotlin.srcDirs("src/$platformVersion/main/kotlin")
}
// test {
// kotlin.srcDirs("src/$platformVersion/test/kotlin")
// }
}
}

Expand All @@ -103,11 +96,11 @@ allprojects {

tasks {
// workaround for gradle not seeing tests in 2021.3+
val test by getting(Test::class) {
setScanForTestClasses(false)
// Only run tests from classes that end with "Test"
include("**/*Test.class")
}
// val test by getting(Test::class) {
// isScanForTestClasses = false
// // Only run tests from classes that end with "Test"
// include("**/*Test.class")
// }

patchPluginXml {
version.set("$pluginVersion.$platformVersion")
Expand Down Expand Up @@ -148,7 +141,7 @@ allprojects {
generateMoveLexer, generateMoveParser
)
kotlinOptions {
jvmTarget = kotlinJvmTarget
jvmTarget = "17"
languageVersion = "1.8"
apiVersion = "1.6"
freeCompilerArgs = listOf("-Xjvm-default=all")
Expand Down
23 changes: 23 additions & 0 deletions changelog/1.30.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# INTELLIJ MOVE CHANGELOG: 1.30.0

17 Jul 2023

## Features

* Add "Download Aptos" button to the Move settings.

* Address validation in the `Move.toml` file.

* Function naming inspection.

* Highlight resources and mutable references in the code.

* Support underscores in integer and hex literals ([#107](https://github.com/pontem-network/intellij-move/issues/107)).

## Fixes

* More fixes for dot expr type inference.

## Internal

* Add `[dependencies]` and library path to the Sentry diagnostics. It will hopefully allow to fix issues with the dependency paths.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/grammars/MoveLexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ BECH32_ADDRESS=wallet1[A-Z0-9a-z&&[^boi1]]{6,83}
POLKADOT_ADDRESS=[1-9A-HJ-NP-Za-km-z]{40}[1-9A-HJ-NP-Za-km-z]*

BOOL_LITERAL=(true)|(false)
INTEGER_LITERAL=[0-9]+[a-zA-Z0-9]*
HEX_INTEGER_LITERAL=0x[0-9a-zA-Z]*
INTEGER_LITERAL=[0-9]+[a-zA-Z0-9_]*
HEX_INTEGER_LITERAL=0x[0-9a-zA-Z_]*
HEX_STRING_LITERAL=x\" ( [0-9a-zA-Z]* ) (\")?
BYTE_STRING_LITERAL=b\" ( [^\\\"\n] | \\[^] )* (\")?
//BYTE_STRING_LITERAL=b\" ( [^\"\n] | (\\\")] )* (\")?
Expand Down
5 changes: 3 additions & 2 deletions src/main/grammars/MoveParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,14 @@ private ExprStmt_expr ::= ItemSpecBlockExpr
private ExprStmt_recover ::= !(';' | '}' | <<mslOnly SpecExpr_first>> | Expr_first)
private Expr_first ::= let | if | while | loop | continue | break | return | spec
| copy | move | abort
// | (<<VECTOR_IDENTIFIER>> ('<' | '['))
| IDENTIFIER
| '*' | '&' | '!' | '|' | '{' | '('
| AnyLitToken_first
| (AddressRef '::')
private SpecExpr_first ::= include | apply | pragma | emits | assume | assert | ensures
| axiom | modifies | aborts_if | aborts_with | requires
| invariant | choose
| invariant | choose | decreases | update

///////////////////////////////////////////////////////////////////////////////////////////////////
// Blocks
Expand Down Expand Up @@ -1050,7 +1051,7 @@ private DotExpr_field ::= '.' (!'.') StructDotField {
pin = 2
consumeTokenMethod = "consumeTokenFast"
}
StructDotField ::= IDENTIFIER
StructDotField ::= !(<<VECTOR_IDENTIFIER>> ('[' | '<')) IDENTIFIER !('(' | '::' | '!' | '{')
{
implements = ["org.move.lang.core.resolve.ref.MvStructFieldReferenceElement"]
mixin = "org.move.lang.core.psi.ext.MvStructDotMixin"
Expand Down
46 changes: 15 additions & 31 deletions src/main/kotlin/org/move/cli/MoveProjectsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,56 +161,40 @@ class MoveProjectsService(val project: Project) : Disposable {
private fun modifyProjects(
updater: (List<MoveProject>) -> CompletableFuture<List<MoveProject>>
): CompletableFuture<List<MoveProject>> {
val refreshStatusPublisher =
project.messageBus.syncPublisher(MOVE_PROJECTS_REFRESH_TOPIC)

val wrappedUpdater = { projects: List<MoveProject> ->
refreshStatusPublisher.onRefreshStarted()
updater(projects)
}

return projects.updateAsync(wrappedUpdater)
.thenApply { projects ->
buildWatcher.updateProjects(projects)
resetIDEState(projects)
projects
}
}

private fun resetIDEState(projects: Collection<MoveProject>) {
invokeAndWaitIfNeeded {
runWriteAction {
projectsIndex.resetIndex()

PsiManager.getInstance(project).dropPsiCaches()
project.movePsiManager.incStructureModificationCount()

// In unit tests roots change is done by the test framework in most cases
runOnlyInNonLightProject(project) {
ProjectRootManagerEx.getInstanceEx(project)
.makeRootsChange(EmptyRunnable.getInstance(), false, true)
invokeAndWaitIfNeeded {
runWriteAction {
projectsIndex.resetIndex()

// In unit tests roots change is done by the test framework in most cases
runOnlyInNonLightProject(project) {
ProjectRootManagerEx.getInstanceEx(project)
.makeRootsChange(EmptyRunnable.getInstance(), false, true)
}
// increments structure modification counter in the subscriber
project.messageBus
.syncPublisher(MOVE_PROJECTS_TOPIC).moveProjectsUpdated(this, projects)
}
}
project.messageBus
.syncPublisher(MOVE_PROJECTS_TOPIC)
.moveProjectsUpdated(this, projects)
projects
}
}
}

override fun dispose() {}

companion object {
private val LOG = logger<MoveProjectsService>()

val MOVE_PROJECTS_TOPIC: Topic<MoveProjectsListener> = Topic(
val MOVE_PROJECTS_TOPIC: Topic<MoveProjectsListener> = Topic.create(
"move projects changes",
MoveProjectsListener::class.java
)

val MOVE_PROJECTS_REFRESH_TOPIC: Topic<MoveProjectsRefreshListener> = Topic(
"Move refresh",
MoveProjectsRefreshListener::class.java
)
}

fun interface MoveProjectsListener {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/move/cli/manifest/MoveToml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class MoveToml(
projectRoot: Path
): Pair<TomlDependency.Local, RawAddressMap>? {
val localPathValue = depTable["local"]?.stringValue() ?: return null
val localPath =
val normalizedLocalPath =
projectRoot.resolve(localPathValue).toAbsolutePath().normalize()
val subst = parseAddrSubst(depTable)
return Pair(TomlDependency.Local(depName, localPath), subst)
return Pair(TomlDependency.Local(depName, normalizedLocalPath), subst)
}

private fun parseGitDependency(
Expand Down
35 changes: 21 additions & 14 deletions src/main/kotlin/org/move/cli/module/BuildLibraryRootsProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,27 @@ class MoveLibrary(
override fun getPresentableText(): String = if (version != null) "$name $version" else name
}

private val MoveProject.ideaLibraries: Collection<MoveLibrary>
class BuildLibraryRootsProvider : AdditionalLibraryRootsProvider() {
override fun getAdditionalProjectLibraries(project: Project): Collection<SyntheticLibrary> {
return project.moveProjects
.allProjects
.smartFlatMap { it.ideaLibraries }
.toMutableSet()
}

override fun getRootsToWatch(project: Project): List<VirtualFile> {
return getAdditionalProjectLibraries(project).flatMap { it.sourceRoots }
}
}

private fun <U, V> Collection<U>.smartFlatMap(transform: (U) -> Collection<V>): Collection<V> =
when (size) {
0 -> emptyList()
1 -> transform(first())
else -> this.flatMap(transform)
}

private val MoveProject.ideaLibraries: Collection<SyntheticLibrary>
get() {
return this.dependencies
.map { it.first }
Expand All @@ -50,16 +70,3 @@ private val MoveProject.ideaLibraries: Collection<MoveLibrary>
}

}

class BuildLibraryRootsProvider : AdditionalLibraryRootsProvider() {
override fun getAdditionalProjectLibraries(project: Project): MutableSet<SyntheticLibrary> {
return project.moveProjects
.allProjects
.flatMap { it.ideaLibraries }
.toMutableSet()
}

override fun getRootsToWatch(project: Project): List<VirtualFile> {
return getAdditionalProjectLibraries(project).flatMap { it.sourceRoots }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.move.cli.sentryReporter

import io.sentry.Sentry
import org.move.cli.MoveProject
import org.move.cli.MoveProjectsService
import org.move.cli.MoveProjectsService.MoveProjectsListener
import org.move.cli.manifest.TomlDependency
import org.move.openapiext.getTable
import org.move.openapiext.getTablesByFirstSegment
import org.move.openapiext.syntheticLibraries

@Suppress("PropertyName")
private data class MoveTomlContext(
val name: String,
val dependencies_parsed: List<TomlDependency>,
val dependencies_raw: List<String>,
)

private data class SyntheticLibraryContext(val roots: List<String>)

private data class MoveProjectContext(
val moveToml: MoveTomlContext,
val syntheticLibraries: List<SyntheticLibraryContext>
)

class SentryContextsProjectsListener : MoveProjectsListener {
override fun moveProjectsUpdated(service: MoveProjectsService, projects: Collection<MoveProject>) {
Sentry.configureScope {
it.setContexts(
"projects",
projects.mapNotNull { moveProject -> getMoveProjectContext(moveProject) }
)
}
}

private fun getMoveProjectContext(moveProject: MoveProject): MoveProjectContext? {
val tomlFile = moveProject.currentPackage.moveToml.tomlFile ?: return null

val rawDeps = mutableListOf<String>()
val depsTable = tomlFile.getTable("dependencies")
if (depsTable != null) {
rawDeps.add(depsTable.text)
}
for (depInlineTable in tomlFile.getTablesByFirstSegment("dependencies")) {
rawDeps.add(depInlineTable.text)
}

val moveTomt = MoveTomlContext(
name = moveProject.currentPackage.packageName,
dependencies_raw = rawDeps,
dependencies_parsed = moveProject.currentPackage.moveToml.deps.map { it.first },
)
val syntheticLibraries =
moveProject.project.syntheticLibraries
.map { SyntheticLibraryContext(it.allRoots.map { it.path }) }
return MoveProjectContext(moveTomt, syntheticLibraries)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.move.cli
package org.move.cli.sentryReporter

import com.intellij.diagnostic.DiagnosticBundle
import com.intellij.diagnostic.IdeErrorsDialog
Expand All @@ -20,17 +20,16 @@ import io.sentry.UserFeedback
import io.sentry.protocol.Message
import io.sentry.protocol.SentryId
import org.move.cli.settings.moveSettings
import org.move.cli.settings.pluginDebugMode
import org.move.openapiext.project
import org.move.stdext.asMap
import java.awt.Component


class PontemSentryErrorReporter : ErrorReportSubmitter() {
class SentryErrorReporter : ErrorReportSubmitter() {
init {
Sentry.init { options ->
options.dsn = "https://a3153f348f8d43f189c4228db47cfc0d@sentry.pontem.network/6"
options.enableUncaughtExceptionHandler = false
options.isEnableUncaughtExceptionHandler = false
}
}

Expand Down Expand Up @@ -85,10 +84,8 @@ class PontemSentryErrorReporter : ErrorReportSubmitter() {
settings.remove("aptosPath")
sentryEvent.contexts["Settings"] = settings
}
sentryEvent.contexts["Stacktrace"] =
mapOf(
"Value" to event.throwableText
)
// IdeaLoggingEvent only provides text stacktrace
sentryEvent.contexts["Stacktrace"] = mapOf("Value" to event.throwableText)

val sentryMessage = Message()
sentryMessage.formatted = event.errorMessage
Expand Down
Loading

0 comments on commit facd1bc

Please sign in to comment.