()
13 | class Present(val value: P) : Value
()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/lang/core/types/ty/TyInfer.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.core.types.ty
2 |
3 | import org.sui.ide.presentation.tyToString
4 | import org.sui.lang.core.types.infer.HAS_TY_INFER_MASK
5 | import org.sui.lang.core.types.infer.Node
6 | import org.sui.lang.core.types.infer.NodeOrValue
7 | import org.sui.lang.core.types.infer.VarValue
8 |
9 | sealed class TyInfer : Ty(HAS_TY_INFER_MASK) {
10 | // Note these classes must NOT be `data` classes and must provide equality by identity
11 | class TyVar(
12 | val origin: TyTypeParameter? = null,
13 | override var parent: NodeOrValue = VarValue(null, 0)
14 | ) : TyInfer(), Node {
15 |
16 | override fun abilities(): Set = origin?.abilities() ?: Ability.none()
17 | }
18 |
19 | class IntVar(
20 | override var parent: NodeOrValue = VarValue(null, 0)
21 | ) : TyInfer(), Node {
22 |
23 | override fun abilities(): Set = Ability.all()
24 | }
25 |
26 | override fun toString(): String = tyToString(this)
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/lang/core/types/ty/TyRange.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.core.types.ty
2 |
3 | import org.sui.ide.presentation.tyToString
4 |
5 | data class TyRange(val item: Ty) : Ty() {
6 | override fun abilities(): Set = Ability.all()
7 | override fun toString(): String = tyToString(this)
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/lang/core/types/ty/TySchema.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.core.types.ty
2 |
3 | import org.sui.lang.core.psi.MvSchema
4 | import org.sui.lang.core.types.infer.Substitution
5 | import org.sui.lang.core.types.infer.TypeFolder
6 | import org.sui.lang.core.types.infer.mergeFlags
7 |
8 | data class TySchema(
9 | override val item: MvSchema,
10 | override val substitution: Substitution,
11 | val typeArguments: List
12 | ) : GenericTy(item, substitution, mergeFlags(typeArguments)) {
13 |
14 | override fun abilities(): Set = Ability.all()
15 |
16 | override fun innerFoldWith(folder: TypeFolder): Ty {
17 | return TySchema(
18 | item,
19 | substitution.foldValues(folder),
20 | typeArguments.map { it.foldWith(folder) }
21 | )
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/lang/core/types/ty/TyTuple.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.lang.core.types.ty
7 |
8 | import org.sui.ide.presentation.tyToString
9 |
10 | import org.sui.lang.core.types.infer.TypeFolder
11 | import org.sui.lang.core.types.infer.TypeVisitor
12 | import org.sui.lang.core.types.infer.mergeFlags
13 |
14 | data class TyTuple(val types: List) : Ty(mergeFlags(types)) {
15 | override fun abilities() = Ability.all()
16 |
17 | override fun innerFoldWith(folder: TypeFolder): Ty =
18 | TyTuple(types.map { it.foldWith(folder) })
19 |
20 | override fun innerVisitWith(visitor: TypeVisitor): Boolean =
21 | types.any(visitor)
22 |
23 | override fun toString(): String = tyToString(this)
24 |
25 | companion object {
26 | fun unknown(arity: Int): TyTuple = TyTuple(generateSequence { TyUnknown }.take(arity).toList())
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/lang/core/types/ty/TyUnknown.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.lang.core.types.ty
7 |
8 | import org.sui.ide.presentation.tyToString
9 | import org.sui.lang.core.types.infer.HAS_TY_UNKNOWN_MASK
10 |
11 | object TyUnknown : Ty(HAS_TY_UNKNOWN_MASK) {
12 | override fun abilities() = Ability.all()
13 | override fun toString(): String = tyToString(this)
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/Component.kt:
--------------------------------------------------------------------------------
1 | package org.sui.openapiext
2 |
3 | import com.intellij.ide.DataManager
4 | import com.intellij.openapi.actionSystem.CommonDataKeys
5 | import com.intellij.openapi.project.Project
6 | import java.awt.Component
7 |
8 | val Component.project: Project? get() {
9 | val context = DataManager.getInstance().getDataContext(this)
10 | return CommonDataKeys.PROJECT.getData(context)
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/Editor.kt:
--------------------------------------------------------------------------------
1 | package org.sui.openapiext
2 |
3 | import com.intellij.openapi.editor.Editor
4 | import com.intellij.openapi.editor.ex.EditorEx
5 | import com.intellij.openapi.editor.highlighter.HighlighterIterator
6 |
7 |
8 | fun isValidOffset(offset: Int, text: CharSequence): Boolean =
9 | 0 <= offset && offset <= text.length
10 |
11 |
12 | fun Editor.createLexer(offset: Int): HighlighterIterator? {
13 | if (!isValidOffset(offset, document.charsSequence)) return null
14 | val lexer = (this as EditorEx).highlighter.createIterator(offset)
15 | if (lexer.atEnd()) return null
16 | return lexer
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/Logger.kt:
--------------------------------------------------------------------------------
1 | package org.sui.openapiext
2 |
3 | import com.intellij.openapi.diagnostic.LogLevel
4 | import com.intellij.openapi.diagnostic.LogLevel.*
5 | import com.intellij.openapi.diagnostic.Logger
6 | import org.sui.openapiext.common.isUnitTestMode
7 |
8 | fun Logger.debugInProduction(message: String) {
9 | if (isUnitTestMode) {
10 | this.warn(message)
11 | } else {
12 | this.debug(message)
13 | }
14 | }
15 |
16 | fun Logger.log(content: String, level: LogLevel) {
17 | when (level) {
18 | ERROR -> this.error(content)
19 | WARNING -> this.warn(content)
20 | INFO -> this.info(content)
21 | DEBUG -> this.debug(content)
22 | TRACE -> this.trace(content)
23 | OFF, ALL -> {}
24 | }
25 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/PluginPathManager.kt:
--------------------------------------------------------------------------------
1 | package org.sui.openapiext
2 |
3 | import com.intellij.openapi.util.SystemInfo
4 | import java.nio.file.Path
5 |
6 | object PluginPathManager {
7 | private fun pluginDir(): Path = plugin().pluginPath
8 |
9 | fun getCurrentOS(): String {
10 | return when {
11 | SystemInfo.isMac -> "macos"
12 | SystemInfo.isWindows -> "windows"
13 | SystemInfo.isLinux -> "ubuntu"
14 | else -> "ubuntu"
15 | }
16 | }
17 |
18 | val bundledSuiCli: String?
19 | get() {
20 | return null
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/TaskResult.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.openapiext
7 |
8 | sealed class TaskResult {
9 | class Ok(val value: T) : TaskResult()
10 | class Err(val reason: String, val message: String? = null) : TaskResult()
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/openapiext/paths.kt:
--------------------------------------------------------------------------------
1 | package org.sui.openapiext
2 |
3 | import com.intellij.openapi.vfs.VirtualFile
4 | import com.intellij.openapi.vfs.VirtualFileManager
5 | import org.sui.stdext.exists
6 | import java.nio.file.Path
7 | import java.nio.file.Paths
8 |
9 | fun Path.resolveExisting(other: String): Path? {
10 | val path = resolve(other)
11 | return if (path.exists()) path else null
12 | }
13 |
14 | fun Path.resolveAbsPath(other: String): Path? {
15 | val rawPath = Paths.get(other)
16 | if (rawPath.isAbsolute && rawPath.exists()) return rawPath
17 |
18 | val joined = this.resolve(other)
19 | if (!joined.exists()) {
20 | return null
21 | } else {
22 | return joined.toRealPath()
23 | }
24 | }
25 |
26 | fun Path.toVirtualFile(): VirtualFile? =
27 | VirtualFileManager.getInstance().findFileByNioPath(this)
28 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/MoveTomlLocalPathReferenceProvider.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml
2 |
3 | import com.intellij.psi.PsiElement
4 | import com.intellij.psi.PsiReferenceProvider
5 | import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference
6 | import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet
7 | import com.intellij.util.ProcessingContext
8 | import org.toml.lang.psi.TomlLiteral
9 | import org.toml.lang.psi.ext.TomlLiteralKind
10 | import org.toml.lang.psi.ext.kind
11 |
12 | class MoveTomlLocalPathReferenceProvider : PsiReferenceProvider() {
13 | override fun getReferencesByElement(
14 | element: PsiElement,
15 | context: ProcessingContext
16 | ): Array {
17 | val kind = (element as? TomlLiteral)?.kind ?: return emptyArray()
18 | if (kind !is TomlLiteralKind.String) return emptyArray()
19 |
20 | return FileReferenceSet(element).allReferences
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/MoveTomlReferenceContributor.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml
2 |
3 | import com.intellij.psi.PsiReferenceContributor
4 | import com.intellij.psi.PsiReferenceRegistrar
5 |
6 | class MoveTomlReferenceContributor : PsiReferenceContributor() {
7 | override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
8 | registrar.registerReferenceProvider(
9 | MoveTomlPsiPatterns.dependencyLocal(), MoveTomlLocalPathReferenceProvider()
10 | )
11 | registrar.registerReferenceProvider(
12 | MoveTomlPsiPatterns.dependencyGitUrl(), MoveTomlUrlReferenceProvider()
13 | )
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/MoveTomlUrlReferenceProvider.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml
2 |
3 | import com.intellij.openapi.paths.WebReference
4 | import com.intellij.psi.PsiElement
5 | import com.intellij.psi.PsiReference
6 | import com.intellij.psi.PsiReferenceProvider
7 | import com.intellij.util.ProcessingContext
8 | import org.toml.lang.psi.TomlLiteral
9 | import org.toml.lang.psi.ext.TomlLiteralKind
10 | import org.toml.lang.psi.ext.kind
11 |
12 | class MoveTomlUrlReferenceProvider : PsiReferenceProvider() {
13 | override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array {
14 | val literal = element as? TomlLiteral ?: return emptyArray()
15 | val kind = (literal.kind as? TomlLiteralKind.String) ?: return emptyArray()
16 | val value = kind.value ?: return emptyArray()
17 |
18 | if (value.startsWith("http://") || value.startsWith("https://")) {
19 | return arrayOf(WebReference(element, value))
20 | }
21 | return emptyArray()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/NamedAddressReferenceContributor.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml
2 |
3 | import com.intellij.psi.*
4 | import com.intellij.util.ProcessingContext
5 | import org.sui.lang.core.MvPsiPattern
6 | import org.sui.lang.core.psi.MvNamedAddress
7 | import org.sui.lang.core.resolve.ref.NamedAddressReference
8 |
9 | class NamedAddressReferenceProvider : PsiReferenceProvider() {
10 | override fun getReferencesByElement(
11 | element: PsiElement,
12 | context: ProcessingContext
13 | ): Array {
14 | if (element !is MvNamedAddress) return emptyArray()
15 | return arrayOf(NamedAddressReference(element))
16 | }
17 | }
18 |
19 | class NamedAddressReferenceContributor : PsiReferenceContributor() {
20 | override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
21 | registrar.registerReferenceProvider(
22 | MvPsiPattern.namedAddress(), NamedAddressReferenceProvider()
23 | )
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/completion/MoveTomlCompletionContributor.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml.completion
2 |
3 | import com.intellij.codeInsight.completion.CompletionContributor
4 | import com.intellij.codeInsight.completion.CompletionType
5 | import org.sui.toml.MoveTomlPsiPatterns.inKey
6 |
7 | class MoveTomlCompletionContributor : CompletionContributor() {
8 | init {
9 | extend(CompletionType.BASIC, inKey, MoveTomlKeysCompletionProvider())
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/toml/utils.kt:
--------------------------------------------------------------------------------
1 | package org.sui.toml
2 |
3 | import org.toml.lang.psi.TomlKeySegment
4 | import org.toml.lang.psi.TomlTableHeader
5 |
6 | val TomlKeySegment.isDependencyKey: Boolean
7 | get() {
8 | val name = name
9 | return name == "dependencies" || name == "dev-dependencies"
10 | }
11 |
12 | val TomlTableHeader.isDependencyListHeader: Boolean
13 | get() = key?.segments?.lastOrNull()?.isDependencyKey == true
14 |
15 | val TomlKeySegment.isAddressesKey: Boolean
16 | get() {
17 | val name = name
18 | return name == "addresses" || name == "dev-addresses"
19 | }
20 |
21 | val TomlTableHeader.isAddressesListHeader: Boolean
22 | get() = key?.segments?.lastOrNull()?.isDependencyKey == true
23 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/PlatformUtils.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils
2 |
3 | import com.intellij.openapi.util.Computable
4 | import com.intellij.openapi.util.RecursionManager
5 |
6 | fun recursionGuard(key: Any, block: Computable, memoize: Boolean = false): T? =
7 | RecursionManager.doPreventingRecursion(key, memoize, block)
8 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/SignatureUtils.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils
2 |
3 | import org.sui.stdext.joinToWithBuffer
4 |
5 | object SignatureUtils {
6 | fun joinParameters(params: List>): String =
7 | buildString {
8 | append("(")
9 | params.joinToWithBuffer(this, separator = ", ") { sb ->
10 | val (name, type) = this
11 | sb.append(name)
12 | if (type != null) {
13 | sb.append(": ")
14 | sb.append(type)
15 | }
16 | }
17 | append(")")
18 | }
19 | }
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/paths.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils
2 |
3 | import com.intellij.openapi.components.service
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.vfs.VirtualFile
6 | import com.intellij.openapi.vfs.VirtualFileManager
7 | import java.nio.file.Path
8 | import java.nio.file.Paths
9 |
10 | interface SuiProjectRootService {
11 | val path: Path?
12 |
13 | val pathFile: VirtualFile?
14 | get() = path?.let { VirtualFileManager.getInstance().findFileByNioPath(it) }
15 | }
16 |
17 | class SuiProjectRootServiceImpl(private val project: Project) : SuiProjectRootService {
18 | override val path: Path?
19 | get() = project.basePath?.let { Paths.get(it) }
20 | }
21 |
22 | class TestSuiProjectRootServiceImpl(private val project: Project) : SuiProjectRootService {
23 | private var _path: Path = Paths.get("")
24 |
25 | override val path: Path
26 | get() = _path
27 |
28 | fun modifyPath(path: Path) {
29 | _path = path
30 | }
31 | }
32 |
33 | val Project.rootService: SuiProjectRootService get() = service()
34 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/refactor.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils
2 |
3 | import com.intellij.psi.PsiElement
4 | import org.sui.ide.refactoring.isValidMoveVariableIdentifier
5 | import org.sui.lang.MvElementTypes
6 | import org.sui.lang.core.psi.MvPsiFactory
7 | import org.sui.lang.core.psi.ext.elementType
8 |
9 | fun doRenameIdentifier(identifier: PsiElement, newName: String) {
10 | val factory = MvPsiFactory(identifier.project)
11 | val newIdentifier = when (identifier.elementType) {
12 | MvElementTypes.IDENTIFIER -> {
13 | if (!isValidMoveVariableIdentifier(newName)) return
14 | factory.identifier(newName)
15 | }
16 | else -> error("Unsupported identifier type for `$newName` (${identifier.elementType})")
17 | }
18 | identifier.replace(newIdentifier)
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/ui/CompletionTextField.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.ui
2 |
3 | import com.intellij.openapi.project.Project
4 | import com.intellij.ui.TextFieldWithAutoCompletion
5 |
6 | class CompletionTextField(
7 | project: Project,
8 | initialValue: String,
9 | variants: Collection,
10 | ) :
11 | TextFieldWithAutoCompletion(
12 | project,
13 | StringsCompletionProvider(variants, null),
14 | false,
15 | initialValue
16 | )
17 |
--------------------------------------------------------------------------------
/src/main/kotlin/org/sui/utils/ui/compat.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.ui
2 |
3 | import com.intellij.openapi.project.DumbService
4 | import com.intellij.openapi.project.Project
5 | import com.intellij.openapi.ui.popup.JBPopup
6 |
7 | object NavigationUtilCompat {
8 | fun hidePopupIfDumbModeStarts(popup: JBPopup, project: Project) {
9 | if (!DumbService.isDumb(project)) {
10 | project.messageBus.connect(popup)
11 | .subscribe(DumbService.DUMB_MODE, object: DumbService.DumbModeListener {
12 | override fun enteredDumbMode() {
13 | popup.cancel()
14 | }
15 | })
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Move File.move.ft:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/src/main/resources/fileTemplates/internal/Move File.move.ft
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Move Module.move.ft:
--------------------------------------------------------------------------------
1 | module ${ADDRESS}::${NAME} {
2 | }
3 |
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Move Test Module.move.ft:
--------------------------------------------------------------------------------
1 | #[test_only]
2 | module ${ADDRESS}::${NAME} {
3 | }
4 |
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Sui Move File.move.ft:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/src/main/resources/fileTemplates/internal/Sui Move File.move.ft
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Sui Move Module.move.ft:
--------------------------------------------------------------------------------
1 | module ${ADDRESS}::${NAME} {
2 | }
3 |
--------------------------------------------------------------------------------
/src/main/resources/fileTemplates/internal/Sui Move Test Module.move.ft:
--------------------------------------------------------------------------------
1 | #[test_only]
2 | module ${ADDRESS}::${NAME} {
3 | }
4 |
--------------------------------------------------------------------------------
/src/main/resources/icons/annotationtype.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/src/main/resources/icons/annotationtype.png
--------------------------------------------------------------------------------
/src/main/resources/icons/annotationtype@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/src/main/resources/icons/annotationtype@2x.png
--------------------------------------------------------------------------------
/src/main/resources/icons/enum.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/icons/enumVariant.svg:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/icons/module.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/icons/mv.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/AddressByValueImport.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects imports that valid by address value, but invalid by address name.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/FieldInitShorthand.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Reports cases where field initialization shorthand can be used.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/InvalidModuleDeclaration.html:
--------------------------------------------------------------------------------
1 | Invalid module declaration. The module does not have a specified address / address block.
2 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvAbilityCheck.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Check abilities. WIP: emits false-positives in some cases.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvConstNaming.html:
--------------------------------------------------------------------------------
1 | Checks if constant names follow the Mv naming convention.
2 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvExternalLinter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This inspection runs external linter to check for aptos-cli compiler errors.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvFunctionNaming.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Checks function naming.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvLocalBindingNaming.html:
--------------------------------------------------------------------------------
1 | Checks if local variable names follow the Mv naming convention.
2 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvMissingAcquires.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Missing acquires
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvStructNaming.html:
--------------------------------------------------------------------------------
1 | Checks if struct names follow the Mv naming convention.
2 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvTypeCheck.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Type checking
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvUnresolvedReference.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Reports unresolved references. This inspection can report false positives.
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvUnusedAcquiresType.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Unused acquires type
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvUnusedImport.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects unused import.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/MvUnusedVariable.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects unused variables and function parameters.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/PhantomTypeParameter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Checks whether a type parameter could be declared phantom.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/RedundantQualifiedPath.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Marks redundant qualified path.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/RedundantTypeCast.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects redundant cast expressions.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/ReplaceWithIndexExpr.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects built-in global storage calls which can be replaced with the index notation.
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/ReplaceWithMethodCall.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects ability to use receiver-style function (Compiler V2 only).
4 |
5 |
--------------------------------------------------------------------------------
/src/main/resources/inspectionDescriptions/UnusedTestSigner.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detects unused #[test] attribute signer variable.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/ChopAttrArgumentListIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Put attr arguments on separate lines.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/ChopParameterListIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Put parameter on separate lines.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/ChopStructLiteralIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Chop struct literal.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/ChopStructPatIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Chop struct pat intention.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/ChopValueArgumentListIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Put arguments on separate lines.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/InlineAddressBlockIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Inline address block.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/intentionDescriptions/RemoveCurlyBracesIntention/description.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Removes enclosing curly braces from use item.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/messages/MvBundle.properties:
--------------------------------------------------------------------------------
1 | advanced.setting.aptos.group=Aptos
2 | advanced.setting.org.move.aptos.test.tool.window=Show test results in Test Tool Window
3 | advanced.setting.org.move.aptos.test.tool.window.description=The feature implementation is incomplete, test error messages are skipped
4 | advanced.setting.sui.group=Aptos
5 | advanced.setting.org.move.sui.test.tool.window=Show test results in Test Tool Window
6 | advanced.setting.org.move.sui.test.tool.window.description=The feature implementation is incomplete, test error messages are skipped
7 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/cli/externalSystem/ImportTreeProjectTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.cli.externalSystem
2 |
3 | import org.sui.utils.tests.MvProjectTestBase
4 |
5 | class ImportTreeProjectTest : MvProjectTestBase() {
6 | fun `test import project with circular dependencies no stackoverflow`() {
7 | testProject {
8 | moveToml(
9 | """
10 | [package]
11 | name = "MyPackage"
12 |
13 | [dependencies]
14 | MyLocal = { local = "." }
15 | """
16 | )
17 | sources { main("/*caret*/") }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/FoldingBuilderTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide
2 |
3 | import org.sui.utils.tests.MvTestBase
4 |
5 | class FoldingBuilderTest : MvTestBase() {
6 | override val dataPath = "org.sui.ide/folding.fixtures"
7 |
8 | fun `test script`() = doTest()
9 | fun `test module`() = doTest()
10 | fun `test script with parameters`() = doTest()
11 |
12 | private fun doTest() {
13 | myFixture.testFolding("$testDataPath/$fileName")
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/MvBreadcrumbsProviderTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide
2 |
3 | import com.intellij.testFramework.UsefulTestCase
4 | import org.intellij.lang.annotations.Language
5 | import org.sui.utils.tests.MvTestBase
6 |
7 | class MvBreadcrumbsProviderTest : MvTestBase() {
8 | fun `test breadcrumbs`() = doTextTest(
9 | """
10 | module 0x1::M {
11 | fun main() {
12 | while (true) if (true) /*caret*/;
13 | }
14 | }
15 | """, """
16 | 0x1::M
17 | main()
18 | {...}
19 | while (true)
20 | if (true)
21 | """
22 | )
23 |
24 | private fun doTextTest(@Language("Sui Move") content: String, info: String) {
25 | InlineFile(content.trimIndent())
26 | val crumbs = myFixture.breadcrumbsAtCaret.joinToString(separator = "\n") { it.text }
27 | UsefulTestCase.assertSameLines(info.trimIndent(), crumbs)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/annotator/errors/BuiltInFunctionNameErrorTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.annotator.errors
2 |
3 | import org.sui.ide.annotator.MvErrorAnnotator
4 | import org.sui.utils.tests.annotation.AnnotatorTestCase
5 |
6 | class BuiltInFunctionNameErrorTest : AnnotatorTestCase(MvErrorAnnotator::class) {
7 | fun `test function`() = checkErrors(
8 | """
9 | module 0x1::M {
10 | fun move_to() {}
11 | }
12 | """
13 | )
14 |
15 | fun `test native function`() = checkErrors(
16 | """
17 | module 0x1::M {
18 | native fun move_to();
19 | }
20 | """
21 | )
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/annotator/syntaxErrors/NativeStructNotSupportedTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.annotator.syntaxErrors
2 |
3 | import org.sui.ide.annotator.MvSyntaxErrorAnnotator
4 | import org.sui.utils.tests.annotation.AnnotatorTestCase
5 |
6 | class NativeStructNotSupportedTest : AnnotatorTestCase(MvSyntaxErrorAnnotator::class) {
7 | fun `test native struct is not supported by the vm`() = checkWarnings(
8 | """
9 | module 0x1::m {
10 | native struct S;
11 | }
12 | """
13 | )
14 | }
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/annotator/syntaxErrors/SpecFunRequiresReturnValueTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.annotator.syntaxErrors
2 |
3 | import org.sui.ide.annotator.MvSyntaxErrorAnnotator
4 | import org.sui.utils.tests.annotation.AnnotatorTestCase
5 |
6 | class SpecFunRequiresReturnValueTest : AnnotatorTestCase(MvSyntaxErrorAnnotator::class) {
7 | fun `test spec fun with explicit return value`() = checkWarnings(
8 | """
9 | module 0x1::m {
10 | spec fun value(): u8 { 1 }
11 | spec fun vec(): vector { vector[1] }
12 | }
13 | """
14 | )
15 |
16 | fun `test spec fun requires return value`() = checkWarnings(
17 | """
18 | module 0x1::m {
19 | spec fun value() {}
20 | spec fun vec() {}
21 | }
22 | """
23 | )
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/docs/MoveNamedAddressDocumentationTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.docs
2 |
3 | import org.sui.utils.tests.MvDocumentationProviderProjectTestCase
4 |
5 | class MvNamedModulePathDocumentationTest : MvDocumentationProviderProjectTestCase() {
6 | fun `test value of named address accessible from documentation`() = doTestByFileTree(
7 | {
8 | moveToml(
9 | """
10 | [package]
11 | name = "UserInfo"
12 | version = "0.1.0"
13 |
14 | [addresses]
15 | Std = "0x42"
16 | """
17 | )
18 | sources {
19 | move(
20 | "main.move", """
21 | module Std::Module {}
22 | //^
23 | """
24 | )
25 | }
26 | },
27 | "Std = \"0x42\"", block = MvDocumentationProvider::generateDoc
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/formatter/FormatterTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.formatter
2 |
3 | import org.sui.utils.tests.MvFormatterTestBase
4 |
5 | class FormatterTest : MvFormatterTestBase() {
6 | fun `test blank lines`() = doTest()
7 | fun `test comments`() = doTest()
8 | fun `test address block`() = doTest()
9 | fun `test operators`() = doTest()
10 | fun `test functions`() = doTest()
11 | fun `test function parameters`() = doTest()
12 | fun `test specs`() = doTest()
13 | fun `test structs`() = doTest()
14 | fun `test inner block`() = doTest()
15 | fun `test expressions`() = doTest()
16 | fun `test chop wraps`() = doTest()
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/inspections/InvalidModuleDeclarationInspectionTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.inspections
2 |
3 | import org.sui.utils.tests.annotation.InspectionTestBase
4 |
5 | class InvalidModuleDeclarationInspectionTest : InspectionTestBase(InvalidModuleDeclarationInspection::class) {
6 | fun `test module in address block - no error`() = checkByText(
7 | """
8 | address 0x1 { module M {} }
9 | """
10 | )
11 |
12 | fun `test module with inline address - no error`() = checkByText(
13 | """
14 | module 0x1::M {}
15 | """
16 | )
17 |
18 | fun `test error if no address block or address specified`() = checkByText(
19 | """
20 | module M {}
21 | """
22 | )
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/intentions/ChopAttrArgumentListIntentionTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.intentions
2 |
3 | import org.sui.utils.tests.MvIntentionTestCase
4 |
5 | class ChopAttrArgumentListIntentionTest : MvIntentionTestCase(ChopAttrArgumentListIntention::class) {
6 | fun `test separate lines for test attributes`() = doAvailableTest(
7 | """
8 | module 0x1::M {
9 | #[test(/*caret*/signer1 = @0x1, signer2 = @0x2, signer3 = @0x3)]
10 | fun test_my_function() {
11 |
12 | }
13 | }
14 | """, """
15 | module 0x1::M {
16 | #[test(
17 | signer1 = @0x1,
18 | signer2 = @0x2,
19 | signer3 = @0x3
20 | )]
21 | fun test_my_function() {
22 |
23 | }
24 | }
25 | """
26 | )
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/intentions/ChopStructLiteralIntentionTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.intentions
2 |
3 | import org.sui.utils.tests.MvIntentionTestCase
4 |
5 | class ChopStructLiteralIntentionTest : MvIntentionTestCase(ChopStructLiteralIntention::class) {
6 | fun `test separate lines for test attributes`() = doAvailableTest(
7 | """
8 | module 0x1::M {
9 | struct S { val1: u8, val2: u8 }
10 | fun test_my_function() {
11 | S { /*caret*/val1: u8, val2: u8 };
12 | }
13 | }
14 | """, """
15 | module 0x1::M {
16 | struct S { val1: u8, val2: u8 }
17 | fun test_my_function() {
18 | S {
19 | val1: u8,
20 | val2: u8
21 | };
22 | }
23 | }
24 | """
25 | )
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/intentions/ChopValueArgumentListIntentionTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.intentions
2 |
3 | import org.sui.utils.tests.MvIntentionTestCase
4 |
5 | class ChopValueArgumentListIntentionTest : MvIntentionTestCase(ChopValueArgumentListIntention::class) {
6 | fun `test separate arguments in call expr`() = doAvailableTest(
7 | """
8 | module 0x1::main {
9 | fun call(foo: u8, bar: u8, baz: u8) {}
10 | fun main() {
11 | call(/*caret*/1, 2, 3);
12 | }
13 | }
14 | """, """
15 | module 0x1::main {
16 | fun call(foo: u8, bar: u8, baz: u8) {}
17 | fun main() {
18 | call(
19 | 1,
20 | 2,
21 | 3
22 | );
23 | }
24 | }
25 | """
26 | )
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/lineMarkers/ItemSpecsLineMarkerProviderTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.lineMarkers
2 |
3 | import org.sui.utils.tests.lineMarkers.LineMarkerProviderTestBase
4 |
5 | class ItemSpecsLineMarkerProviderTest : LineMarkerProviderTestBase() {
6 | fun `test no specifications`() = doTestByText(
7 | """
8 | module 0x1::m {
9 | fun call() {}
10 | }
11 | module 0x1::m2 {}
12 | module 0x1::m3 {}
13 | """
14 | )
15 |
16 | fun `test item specifications`() = doTestByText(
17 | """
18 | module 0x1::m { // - Has specifications
19 | fun call() {} // - Has specifications
20 |
21 | }
22 | spec 0x1::m {
23 | spec call {}
24 | }
25 | """
26 | )
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/refactoring/optimizeImports/OptimizeImportsTestBase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.refactoring.optimizeImports
2 |
3 | import org.intellij.lang.annotations.Language
4 | import org.sui.ide.inspections.MvUnusedImportInspection
5 | import org.sui.utils.tests.MvTestBase
6 | import org.sui.utils.tests.WithEnabledInspections
7 |
8 | @WithEnabledInspections(MvUnusedImportInspection::class)
9 | abstract class OptimizeImportsTestBase : MvTestBase() {
10 |
11 | protected fun doTest(@Language("Sui Move") before: String, @Language("Sui Move") after: String) =
12 | checkEditorAction(before, after, "OptimizeImports")
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/structureView/HidePrivateFunctionsFilterTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.structureView
2 |
3 | class HidePrivateFunctionsFilterTest : StructureViewToggleableActionTestBase() {
4 | fun `test hide private functions filter`() = doTest(
5 | """
6 | module 0x1::m {
7 | public fun public_main() {}
8 | fun private_main() {}
9 | }
10 | """, """
11 | -main.move
12 | -m
13 | public_main()
14 | private_main()
15 | """, """
16 | -main.move
17 | -m
18 | public_main()
19 | """
20 | )
21 |
22 | override val actionId: String get() = HidePrivateFunctionsFilter.ID
23 | }
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/structureView/HideTestFunctionsFilterTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.structureView
2 |
3 | class HideTestFunctionsFilterTest : StructureViewToggleableActionTestBase() {
4 | fun `test hide test functions filter`() = doTest(
5 | """
6 | module 0x1::m {
7 | fun main() {}
8 | #[test]
9 | fun test_main() {}
10 | }
11 | """, """
12 | -main.move
13 | -m
14 | main()
15 | test_main()
16 | """, """
17 | -main.move
18 | -m
19 | main()
20 | """
21 | )
22 |
23 | override val actionId: String get() = HideTestFunctionsFilter.ID
24 | }
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/structureView/HideTestOnlyItemsFilterTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.structureView
2 |
3 | class HideTestOnlyItemsFilterTest : StructureViewToggleableActionTestBase() {
4 | fun `test hide test only items filter`() = doTest(
5 | """
6 | module 0x1::m {
7 | struct S {}
8 | #[test_only]
9 | struct ST {}
10 |
11 | fun main() {}
12 | #[test_only]
13 | fun main_t() {}
14 | }
15 | """, """
16 | -main.move
17 | -m
18 | S
19 | ST
20 | main()
21 | main_t()
22 | """, """
23 | -main.move
24 | -m
25 | S
26 | main()
27 | """
28 | )
29 |
30 | override val actionId: String get() = HideTestOnlyItemsFilter.ID
31 | }
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/structureView/StructureViewToggleableActionTestBase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.ide.structureView
7 |
8 | import org.intellij.lang.annotations.Language
9 |
10 | abstract class StructureViewToggleableActionTestBase : StructureViewTestBase() {
11 | protected abstract val actionId: String
12 |
13 | protected fun doTest(@Language("Sui Move") code: String, disabled: String, enabled: String) =
14 | doTestStructureView(code) {
15 | setActionActive(actionId, false)
16 | assertTreeEqual(tree, disabled.trimMargin())
17 | setActionActive(actionId, true)
18 | assertTreeEqual(tree, enabled.trimMargin())
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/ide/typing/EnterInLineCommentHandlerTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.ide.typing
2 |
3 | import org.sui.utils.tests.MvTypingTestCase
4 |
5 | class EnterInLineCommentHandlerTest: MvTypingTestCase() {
6 | override val dataPath = "org.sui.ide/typing/lineComment.fixtures"
7 |
8 | fun `test in outer doc comment`() = doTestByText("""
9 | /// multiply by two
10 | module 0x1::M {}
11 | """, """
12 | /// multi
13 | /// ply by two
14 | module 0x1::M {}
15 | """)
16 |
17 | fun `test after outer doc comment`() = doTest()
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/lang/lexer/LexerTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.lexer
2 |
3 | import org.sui.utils.tests.MvLexerTestBase
4 |
5 | class LexerTest : MvLexerTestBase() {
6 | fun `test block comments`() = doTest()
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/lang/parser/PartialParsingTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.parser
2 |
3 | import org.sui.utils.tests.parser.MvParsingTestCase
4 |
5 | class PartialParsingTest : MvParsingTestCase("partial") {
6 | // top level items recovery
7 | fun `test top level items`() = doTest(true)
8 | fun `test module const`() = doTest(true)
9 | // fun `test module uses`() = doTest(true)
10 |
11 | fun `test spec`() = doTest(true)
12 |
13 | // functions
14 | fun `test function signatures`() = doTest(true)
15 | fun `test function calls`() = doTest(true)
16 |
17 | // structs
18 | fun `test struct decls`() = doTest(true)
19 | fun `test struct fields`() = doTest(true)
20 |
21 | // expressions
22 | fun `test expressions`() = doTest(true)
23 | fun `test assignments`() = doTest(true)
24 | fun `test dot exprs`() = doTest(true)
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/lang/parser/SpecsParsingTest.kt:
--------------------------------------------------------------------------------
1 | package org.sui.lang.parser
2 |
3 | import org.sui.utils.tests.parser.MvParsingTestCase
4 |
5 | class SpecsParsingTest : MvParsingTestCase("specs") {
6 | fun `test scopes`() = doTest()
7 | fun `test conditions`() = doTest()
8 | fun `test forall exists`() = doTest()
9 | fun `test pragma`() = doTest()
10 |
11 | fun `test apply`() = doTest()
12 | fun `test spec statements`() = doTest(true, false)
13 | fun `test spec file`() = doTest()
14 | fun `test spec properties`() = doTest()
15 | fun `test spec variables`() = doTest()
16 |
17 | fun doTest() {
18 | super.doTest(true, true)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/InlineFile.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.utils.tests
7 |
8 | import com.intellij.testFramework.fixtures.CodeInsightTestFixture
9 |
10 | class InlineFile(fixture: CodeInsightTestFixture, private val code: String, val name: String) {
11 | private val hasCaretMarker = "/*caret*/" in code || "" in code
12 |
13 | init {
14 | fixture.configureByText(name, replaceCaretMarker(code))
15 | }
16 |
17 | fun withCaret() {
18 | check(hasCaretMarker) {
19 | "Please, add `/*caret*/` or `` marker to\n$code"
20 | }
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/MvFormatterTestBase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests
2 |
3 | import com.intellij.psi.formatter.FormatterTestCase
4 | import org.intellij.lang.annotations.Language
5 | import org.sui.utils.tests.base.TestCase
6 |
7 | abstract class MvFormatterTestBase : FormatterTestCase() {
8 | override fun getTestDataPath() = "src/test/resources"
9 | override fun getBasePath(): String = "org/move/ide/formatter.fixtures"
10 | override fun getFileExtension() = "move"
11 |
12 | override fun getTestName(lowercaseFirstLetter: Boolean): String {
13 | val camelCase = super.getTestName(lowercaseFirstLetter)
14 | return TestCase.camelOrWordsToSnake(camelCase)
15 | }
16 |
17 | override fun doTextTest(@Language("Move") text: String, @Language("Move") textAfter: String) {
18 | check(text.trimIndent() != textAfter.trimIndent()) {
19 | "Formatter before and after should be different"
20 | }
21 | super.doTextTest(text.trimIndent(), textAfter.trimIndent())
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/MvLightTestBase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests
2 |
3 | import com.intellij.testFramework.fixtures.BasePlatformTestCase
4 |
5 | abstract class MvLightTestBase : BasePlatformTestCase() {
6 | override fun setUp() {
7 | super.setUp()
8 |
9 | val isDebugMode = this.findAnnotationInstance()?.enabled ?: true
10 | setRegistryKey("org.move.debug.enabled", isDebugMode)
11 |
12 | this.handleCompilerV2Annotations(project)
13 | this.handleNamedAddressAnnotations(project)
14 | }
15 | }
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/MvTypingTestCase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests
2 |
3 | import org.intellij.lang.annotations.Language
4 | import org.sui.lang.MoveFileType
5 |
6 | abstract class MvTypingTestCase : MvTestBase() {
7 | protected fun doTest(c: Char = '\n') = checkByFile {
8 | myFixture.type(c)
9 | }
10 |
11 | protected fun doTest(@Language("Move") before: String, type: Char, @Language("Move") after: String) {
12 | val beforeText = replaceCaretMarker(before)
13 | val afterText = replaceCaretMarker(after)
14 |
15 | myFixture.configureByText(MoveFileType, beforeText)
16 | myFixture.type(type)
17 | myFixture.checkResult(afterText)
18 | }
19 |
20 | protected fun doTestByText(
21 | @Language("Move") before: String,
22 | @Language("Move") after: String,
23 | c: Char = '\n'
24 | ) =
25 | checkByText(before.trimIndent(), after.trimIndent()) {
26 | myFixture.type(c)
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/Settings.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests
2 |
3 | import junit.framework.TestCase
4 |
5 | /** Tries to find the specified annotation on the current test method and then on the current class */
6 | inline fun TestCase.findAnnotationInstance(): T? =
7 | javaClass.getMethod(name).getAnnotation(T::class.java) ?: javaClass.getAnnotation(T::class.java)
8 |
9 | /** Tries to find the specified annotation on the current test method and then on the current class */
10 | inline fun TestCase.findAnnotationInstances(): Array =
11 | javaClass.getMethod(name).getAnnotationsByType(T::class.java) ?: javaClass.getAnnotationsByType(T::class.java)
12 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/annotation/AnnotatorTestCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Use of this source code is governed by the MIT license that can be
3 | * found in the LICENSE file.
4 | */
5 |
6 | package org.sui.utils.tests.annotation
7 |
8 | import org.intellij.lang.annotations.Language
9 | import org.sui.ide.annotator.MvAnnotatorBase
10 | import kotlin.reflect.KClass
11 |
12 | abstract class AnnotatorTestCase(
13 | private val annotatorClass: KClass
14 | ) : MvAnnotationTestCase() {
15 |
16 | override fun createAnnotationFixture(): MvAnnotationTestFixture =
17 | MvAnnotationTestFixture(this, myFixture, annotatorClasses = listOf(annotatorClass))
18 |
19 | protected fun checkFixByText(
20 | fixName: String,
21 | @Language("Move") before: String,
22 | @Language("Move") after: String,
23 | checkWarn: Boolean = true,
24 | checkInfo: Boolean = false,
25 | checkWeakWarn: Boolean = false,
26 | ) =
27 | annotationFixture.checkFixByText(fixName, before, after, checkWarn, checkInfo, checkWeakWarn)
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/base/TestCase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests.base
2 |
3 | import java.nio.file.Path
4 | import java.nio.file.Paths
5 |
6 | interface TestCase {
7 | val testFileExtension: String
8 | fun getTestDataPath(): String
9 | fun getTestName(lowercaseFirstLetter: Boolean): String
10 |
11 | companion object {
12 | const val testResourcesPath = "src/test/resources"
13 |
14 | @JvmStatic
15 | fun camelOrWordsToSnake(name: String): String {
16 | if (' ' in name)
17 | return name.trim().replace(" ", "_")
18 | return name.split("(?=[A-Z])".toRegex()).joinToString("_", transform = String::lowercase)
19 | }
20 | }
21 | }
22 |
23 | fun TestCase.pathToSourceTestFile(): Path =
24 | Paths.get("${TestCase.testResourcesPath}/${getTestDataPath()}/${getTestName(true)}.$testFileExtension")
25 |
26 | fun TestCase.pathToGoldTestFile(): Path =
27 | Paths.get("${TestCase.testResourcesPath}/${getTestDataPath()}/${getTestName(true)}.txt")
28 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/common.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests
2 |
3 | import org.jetbrains.annotations.TestOnly
4 | import org.sui.cli.MoveProject
5 | import org.sui.cli.MoveProjectsService
6 |
7 | @TestOnly
8 | fun MoveProjectsService.singleProject(): MoveProject {
9 | return when (allProjects.size) {
10 | 0 -> error("No cargo projects found")
11 | 1 -> allProjects.single()
12 | else -> error("Expected single cargo project, found multiple: $allProjects")
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/kotlin/org/sui/utils/tests/lineMarkers/LineMarkerProviderTestBase.kt:
--------------------------------------------------------------------------------
1 | package org.sui.utils.tests.lineMarkers
2 |
3 | import org.intellij.lang.annotations.Language
4 | import org.sui.utils.tests.MvTestBase
5 |
6 | abstract class LineMarkerProviderTestBase : MvTestBase() {
7 |
8 | protected lateinit var lineMarkerTestHelper: LineMarkerTestHelper
9 |
10 | override fun setUp() {
11 | super.setUp()
12 | lineMarkerTestHelper = LineMarkerTestHelper(myFixture)
13 | }
14 |
15 | protected fun doTestByText(@Language("Move") source: String) {
16 | lineMarkerTestHelper.doTestByText("main.move", source)
17 | }
18 |
19 | // protected fun doTestByFileTree(filePath: String, builder: FileTreeBuilder.() -> Unit) {
20 | // val fileTree = fileTree(builder)
21 | // val testProject = fileTree(builder).toTestProject(project, )
22 | // lineMarkerTestHelper.doTestFromFile(testProject.file(filePath))
23 | // }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/resources/META-INF/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 | org.sui.lang
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test/resources/move_toml_project/.aptos/config.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | profiles:
3 | default:
4 | private_key: "0x1f9abf8196bd6b34731fdf99da384180ee43002befac0e55f39aceed9869e321"
5 | public_key: "0x21dae149d5c16ec825558eb86c6434a2aa4bd1a54b66430dfdea983f3f5faaec"
6 | account: 2ec4190dd6eec80913e02da22de89700a9b5e13e27b51750191b7ceb3eee1a2f
7 | rest_url: "https://fullnode.testnet.aptoslabs.com"
8 | emergency:
9 | private_key: "0x3976a9fa9196a4e0240e64d1837fec879d65229194aef942fb81a7b41ff62912"
10 | public_key: "0xb1af70c600661e19d631296d89b8fd51aecafd2e7da76d27a9f462046647e17e"
11 | account: c5f39b983cf06b9e26dc149b3a8c0d7fcb27733954fa86eff7f3c70427644b1f
12 | rest_url: "https://fullnode.testnet.aptoslabs.com"
13 |
--------------------------------------------------------------------------------
/src/test/resources/move_toml_project/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "move_toml"
3 | version = "0.1.0"
4 |
5 | [addresses]
6 | Std = "0x1"
7 | DiemFramework = "0xB1E55ED"
8 |
9 | [dependencies]
10 | Debug = { local = "./stdlib/Debug.move" }
11 |
--------------------------------------------------------------------------------
/src/test/resources/move_toml_project/stdlib/debug.move:
--------------------------------------------------------------------------------
1 | address 0x1 {
2 |
3 | module Debug {
4 | native public fun print(x: &T);
5 | native public fun print_stack_trace();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/function_call/run_command_for_entry_function_call_with_no_arguments.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/function_call/run_command_for_entry_function_call_with_one_argument.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/function_call/view_command_for_view_function_call_with_no_arguments.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/function_call/view_command_for_view_function_call_with_one_argument.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_file_with_multiple_module_single_test_module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_file_with_one_module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_function_if_inside_non_test_only_module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_module_with_test_function.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_move_package_from_root.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_move_package_from_tests_directory.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/run_tests_for_move_toml_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_compiler_v2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_compiler_v2_without_cli_flag.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_function.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_function_dumping_state_on_test_failure.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_function_skipping_fetch_git_deps.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/cli/producers.fixtures/test/test_run_for_module_with_test_functions_inside_sources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/folding.fixtures/module.move:
--------------------------------------------------------------------------------
1 | /// my docstring
2 | /// my other docstring
3 | module 0x1::M {
4 | const MY_CONST: u64 = 1;
5 | const MY_CONST_2: u64 = 1;
6 |
7 | /// my docstring
8 | /// my other docstring
9 | fun main() acquires A, B, C {
10 | let a = 1;
11 | }
12 |
13 | spec main {
14 | assert true;
15 | }
16 |
17 | spec fun spec_fun {
18 | assert true;
19 | }
20 |
21 | spec module {}
22 |
23 | /// my docstring
24 | /// my other docstring
25 | struct R { val: u8 }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/folding.fixtures/script.move:
--------------------------------------------------------------------------------
1 | script {
2 | use use 0x1::Main;
3 | use 0x1::Main2;
4 | fun main() {
5 | let a = 1;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/folding.fixtures/script_with_parameters.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main(s: &signer, a: u8) {
3 | let a = 1;
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/address_block.move:
--------------------------------------------------------------------------------
1 | address 0x0{
2 | // comment
3 | // second comment
4 | module M{
5 | use 0x0::Transaction;
6 | struct MyStruct{}
7 | fun main(){}
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/address_block_after.move:
--------------------------------------------------------------------------------
1 | address 0x0 {
2 | // comment
3 | // second comment
4 | module M {
5 | use 0x0::Transaction;
6 |
7 | struct MyStruct {}
8 |
9 | fun main() {}
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/blank_lines.move:
--------------------------------------------------------------------------------
1 | script {
2 | use 0x0::Transaction;
3 | use 0x0::Account;
4 | // use 0x0::Signer;
5 | use 0x0::XFI;
6 |
7 | fun main() {}
8 |
9 |
10 | }
11 |
12 | script {
13 | fun main() {
14 | let a = 1; let b = 2;
15 |
16 | let c = 3; // comment
17 | }
18 |
19 |
20 |
21 | }
22 |
23 | module MM {
24 | use 0x0::Transaction;
25 | use 0x0::Account;
26 | // use 0x0::Signer;
27 | use 0x0::XFI;
28 | }
29 |
30 | address 0x0 {
31 |
32 |
33 | module M {
34 |
35 | }
36 | module M2 {
37 | use 0x0::Transaction;
38 | use 0x0::Account;
39 |
40 | fun main() {}
41 |
42 | struct MyStruct {}
43 | }
44 | }
45 |
46 | address 0x1 {
47 |
48 | module M2 {
49 |
50 | struct T {}
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/blank_lines_after.move:
--------------------------------------------------------------------------------
1 | script {
2 | use 0x0::Transaction;
3 | use 0x0::Account;
4 | // use 0x0::Signer;
5 | use 0x0::XFI;
6 |
7 | fun main() {}
8 | }
9 |
10 | script {
11 | fun main() {
12 | let a = 1;
13 | let b = 2;
14 |
15 | let c = 3; // comment
16 | }
17 | }
18 |
19 | module MM {
20 | use 0x0::Transaction;
21 | use 0x0::Account;
22 | // use 0x0::Signer;
23 | use 0x0::XFI;
24 | }
25 |
26 | address 0x0 {
27 |
28 | module M {}
29 |
30 | module M2 {
31 | use 0x0::Transaction;
32 | use 0x0::Account;
33 |
34 | fun main() {}
35 |
36 | struct MyStruct {}
37 | }
38 | }
39 |
40 | address 0x1 {
41 |
42 | module M2 {
43 |
44 | struct T {}
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/chop_wraps.move:
--------------------------------------------------------------------------------
1 | module 0x1::chop_wraps {
2 | use 0x1::m::{long_function_1, long_function_2};
3 | use 0x1::m::{long_function_1, long_function_2, long_function_3, long_function_4, long_function_5, long_function_6, long_function_7};
4 |
5 | fun long_arguments(addr1: address, addr1: address, addr1: address, addr1: address, addr1: address, addr1: address) {}
6 |
7 | struct EventsStore has key { storage_registered_handle: event::EventHandle>, coin_deposited_handle: event::EventHandle>, coin_withdrawn_handle: event::EventHandle>,
8 | }
9 |
10 | #[test(account = @my_address, account = @my_address, account = @my_address, account = @my_address, account = @my_address, account = @my_address)]
11 | fun main() {
12 | call(1 + 2 + 3 + 4 + 5, 1 + 2 + 3 + 4 + 5, 1 + 2 + 3 + 4 + 5, 1 + 2 + 3 + 4 + 5, 1 + 2 + 3 + 4 + 5, 1 + 2 + 3 + 4 + 5)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/comments.move:
--------------------------------------------------------------------------------
1 | /// hello
2 | /// world
3 | /// my comment
4 | module 0x1::Comments {
5 | use 0x1::M;
6 | // other comment
7 | /// other docstring
8 |
9 | /// hello
10 | /// world
11 | /// my comment
12 | const MY_CONST: u64 = 1;
13 |
14 | /// hello
15 | /// world
16 | /// my comment
17 | struct M {}
18 |
19 | /// hello
20 | /// world
21 | /// my comment
22 | fun main() {}
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/comments_after.move:
--------------------------------------------------------------------------------
1 | /// hello
2 | /// world
3 | /// my comment
4 | module 0x1::Comments {
5 | use 0x1::M;
6 |
7 | // other comment
8 | /// other docstring
9 |
10 | /// hello
11 | /// world
12 | /// my comment
13 | const MY_CONST: u64 = 1;
14 |
15 | /// hello
16 | /// world
17 | /// my comment
18 | struct M {}
19 |
20 | /// hello
21 | /// world
22 | /// my comment
23 | fun main() {}
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/expressions.move:
--------------------------------------------------------------------------------
1 | module 0x1::expressions {
2 | fun main(): bool {
3 | if (true
4 | && false
5 | ) {};
6 |
7 | if (
8 | true
9 | && false
10 | )
11 | true
12 | else
13 | false;
14 |
15 | vector[
16 | 1,
17 | 1,
18 | ];
19 |
20 | while (true)
21 | 1 + 1;
22 |
23 | return 1 == 2
24 | && (1 == 3
25 | && 1 == 4);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/expressions_after.move:
--------------------------------------------------------------------------------
1 | module 0x1::expressions {
2 | fun main(): bool {
3 | if (true
4 | && false
5 | ) {};
6 |
7 | if (
8 | true
9 | && false
10 | )
11 | true
12 | else
13 | false;
14 |
15 | vector[
16 | 1,
17 | 1,
18 | ];
19 |
20 | while (true)
21 | 1 + 1;
22 |
23 | return 1 == 2
24 | && (1 == 3
25 | && 1 == 4);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/function_parameters.move:
--------------------------------------------------------------------------------
1 | module 0x1::function_parameters {
2 | fun prologue(
3 | a: u8,
4 | b: u8,
5 | c: u8,
6 | ): u8 {}
7 |
8 | spec prologue(
9 | a: u8,
10 | b: u8,
11 | c: u8,
12 | ): u8 {}
13 |
14 | spec fun prologue(
15 | a: u8,
16 | b: u8,
17 | c: u8,
18 | ): u8 {}
19 |
20 | spec module {
21 | fun prologue(
22 | a: u8,
23 | b: u8,
24 | c: u8,
25 | ): u8 {}
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/function_parameters_after.move:
--------------------------------------------------------------------------------
1 | module 0x1::function_parameters {
2 | fun prologue(
3 | a: u8,
4 | b: u8,
5 | c: u8,
6 | ): u8 {}
7 |
8 | spec prologue(
9 | a: u8,
10 | b: u8,
11 | c: u8,
12 | ): u8 {}
13 |
14 | spec fun prologue(
15 | a: u8,
16 | b: u8,
17 | c: u8,
18 | ): u8 {}
19 |
20 | spec module {
21 | fun prologue(
22 | a: u8,
23 | b: u8,
24 | c: u8,
25 | ): u8 {}
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/functions.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main( ) {}
3 | fun main2 (a:u8, b : u8,c :u8 ) :u8 {}
4 | fun main3 < T , U > () {}
5 | fun main_signer(mysigner: &signer) {}
6 | fun main_signer2(mysigner: &mut signer) {}
7 |
8 | public fun public_main()acquires S {}
9 |
10 | public ( script ) fun public_script_main() {}
11 |
12 | public ( friend ) fun public_friend_main() {}
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/functions_after.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main() {}
3 |
4 | fun main2(a: u8, b: u8, c: u8): u8 {}
5 |
6 | fun main3() {}
7 |
8 | fun main_signer(mysigner: &signer) {}
9 |
10 | fun main_signer2(mysigner: &mut signer) {}
11 |
12 | public fun public_main() acquires S {}
13 |
14 | public(script) fun public_script_main() {}
15 |
16 | public(friend) fun public_friend_main() {}
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/inner_block.move:
--------------------------------------------------------------------------------
1 | module 0x1::inner_block {
2 | fun call() {
3 | {
4 | let a = 1;
5 | };
6 | spec {
7 | let a = 1;
8 | };
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/inner_block_after.move:
--------------------------------------------------------------------------------
1 | module 0x1::inner_block {
2 | fun call() {
3 | {
4 | let a = 1;
5 | };
6 | spec {
7 | let a = 1;
8 | };
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/operators.move:
--------------------------------------------------------------------------------
1 | script {
2 | const A: u64 =
3 | 1;
4 | fun main() {
5 | let a=1;
6 | let b = 1+2+3+4;
7 | let c=a==b;
8 | let d =
9 | 4;
10 | e =
11 | 5;
12 |
13 | *b;
14 | *&b;
15 | *&*&*&b;
16 |
17 | 1 != 0;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/operators_after.move:
--------------------------------------------------------------------------------
1 | script {
2 | const A: u64 =
3 | 1;
4 |
5 | fun main() {
6 | let a = 1;
7 | let b = 1 + 2 + 3 + 4;
8 | let c = a == b;
9 | let d =
10 | 4;
11 | e =
12 | 5;
13 |
14 | *b;
15 | *&b;
16 | *&*&*&b;
17 |
18 | 1 != 0;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/specs.move:
--------------------------------------------------------------------------------
1 | module M {
2 | spec initialize {
3 | assert true;
4 |
5 | pragma hello = world,
6 | hello2 = world2;
7 | include
8 | MySchema;
9 |
10 | /// After genesis, time progresses monotonically.
11 | invariant update
12 | old(is_operating()) ==> old(spec_now_microseconds()) <= spec_now_microseconds();
13 |
14 | /// Conditions we only check for the implementation, but do not pass to the caller.
15 | aborts_if [concrete]
16 | (if (proposer == @vm_reserved) {
17 | now != timestamp
18 | } else {
19 | now >= timestamp
20 | })
21 | with error::INVALID_ARGUMENT;
22 | }
23 |
24 | spec MyStruct {
25 | assert true;
26 | }
27 |
28 | spec schema MySchema {
29 | assert true;
30 | }
31 |
32 | spec module {
33 | fun is_currency(): bool {
34 | true
35 | }
36 | }
37 |
38 | spec fun spec_is_lbr(): bool {
39 | type() == type();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/structs.move:
--------------------------------------------------------------------------------
1 | module M {
2 | struct MyStruct {
3 | a: u8,
4 | b: u8,
5 | c: u8,
6 | }
7 |
8 | resource struct MyStruct {
9 | a: u8,
10 | b: u8,
11 | c: u8,
12 | }
13 | }
14 |
15 | module M2 {
16 | struct MyStruct {
17 | a:u8,
18 | b : u8 , c:u8,
19 | }
20 |
21 | fun main() {
22 | call(MyStruct {
23 | a: val, b: anotherval
24 | });
25 |
26 | call(
27 | a,
28 | MyStruct {
29 | a: val, b: anotherval
30 | }
31 | );
32 |
33 | let a = MyStruct{val};
34 | let a = MyStruct{val:myval};
35 | let a = MyStruct{val:myval};
36 |
37 | let MyStruct{val} = get_struct();
38 | let MyStruct{val:myval} = get_struct();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/formatter.fixtures/structs_after.move:
--------------------------------------------------------------------------------
1 | module M {
2 | struct MyStruct {
3 | a: u8,
4 | b: u8,
5 | c: u8,
6 | }
7 |
8 | resource struct MyStruct {
9 | a: u8,
10 | b: u8,
11 | c: u8,
12 | }
13 | }
14 |
15 | module M2 {
16 | struct MyStruct {
17 | a: u8,
18 | b: u8,
19 | c: u8,
20 | }
21 |
22 | fun main() {
23 | call(MyStruct {
24 | a: val, b: anotherval
25 | });
26 |
27 | call(
28 | a,
29 | MyStruct {
30 | a: val, b: anotherval
31 | }
32 | );
33 |
34 | let a = MyStruct { val };
35 | let a = MyStruct { val: myval };
36 | let a = MyStruct { val: myval };
37 |
38 | let MyStruct { val } = get_struct();
39 | let MyStruct { val: myval } = get_struct();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/typing/lineComment.fixtures/after_outer_doc_comment.move:
--------------------------------------------------------------------------------
1 | /// multiply by two
2 | module 0x1::M {}
3 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/ide/typing/lineComment.fixtures/after_outer_doc_comment_after.move:
--------------------------------------------------------------------------------
1 | /// multiply by two
2 | ///
3 | module 0x1::M {}
4 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/lexer/block_comments.move:
--------------------------------------------------------------------------------
1 | /* module M */
2 | module M1 {}
3 |
4 | /* /* */ */
5 | module M2 {}
6 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/lexer/block_comments.txt:
--------------------------------------------------------------------------------
1 | BLOCK_COMMENT ('/* module M */')
2 | WHITE_SPACE ('\n')
3 | module ('module')
4 | WHITE_SPACE (' ')
5 | IDENTIFIER ('M1')
6 | WHITE_SPACE (' ')
7 | { ('{')
8 | } ('}')
9 | WHITE_SPACE ('\n\n')
10 | BLOCK_COMMENT ('/* /* */ */')
11 | WHITE_SPACE ('\n')
12 | module ('module')
13 | WHITE_SPACE (' ')
14 | IDENTIFIER ('M2')
15 | WHITE_SPACE (' ')
16 | { ('{')
17 | } ('}')
18 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/access_control.move:
--------------------------------------------------------------------------------
1 | module 0x1::access_control {
2 | fun f1(): u8 acquires S {}
3 |
4 | fun f2(): u8 reads S {}
5 |
6 | fun f3(): u8 writes S {}
7 |
8 | fun f4() acquires S(*) {}
9 |
10 | fun f_multiple() acquires R reads R writes T, S reads G {}
11 |
12 | fun f5() acquires 0x42::*::* {}
13 |
14 | fun f6() acquires 0x42::m::* {}
15 |
16 | fun f7() acquires *(*) {}
17 |
18 | fun f8() acquires *(0x42) {}
19 |
20 | fun f9(a: address) acquires *(a) {}
21 |
22 | fun f10(param: u64) acquires *(make_up_address(param)) {}
23 |
24 | fun make_up_address(x: u64): address {
25 | @0x42
26 | }
27 |
28 | fun f11() !reads *(0x42), *(0x43) {}
29 |
30 | fun f12() pure {}
31 |
32 | fun ok2(s: &signer): bool reads R(signer::address_of(s)) {}
33 |
34 | fun ok2(s: &signer): bool reads R(address_of(s)) {}
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/addresses.move:
--------------------------------------------------------------------------------
1 | address named = 0x1;
2 | address alice = {{alice}};
3 |
4 | /* my module */
5 | module 0x1::M {
6 | fun main() {
7 | @0;
8 | @01;
9 | @0x0;
10 | @0x0000;
11 | @0x00001111;
12 | @wallet1pxqfjvnu0utauj8fctw2s7j4mfyvrsjd59c2u8;
13 | @5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty;
14 | @Std;
15 | @{{alice}};
16 | @DiemFramework;
17 |
18 | @0x89b9f9d1fadc027cf9532d6f9904152222331122;
19 | @0x89b9f9d1fadc027cf9532d6f9904152289b9f9d1fadc027cf9532d6f99041522;
20 | }
21 | }
22 |
23 | address 0x111 {
24 | module M {}
25 | }
26 |
27 | address wallet1pxqfjvnu0utauj8fctw2s7j4mfyvrsjd59c2u8 {
28 | module M {}
29 | }
30 |
31 | address 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty {
32 | module M {}
33 | }
34 |
35 | address DiemFramework {
36 | module M1 {
37 |
38 | }
39 | }
40 |
41 | module 0x111::M2 {}
42 | module DiemFramework::M2 {}
43 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/annotated_literals.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | (0x1: u128);
4 | (0x1u128: u128);
5 | (000001: u128);
6 | (0: u64);
7 | (10000: u64);
8 | (true: bool);
9 | (false: bool);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/assignments.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | *a = 3;
4 | record.val = 1;
5 | record.val = vector>>;
6 | (record.val = 1);
7 |
8 | call().operator = 11;
9 | call().operator.main = 11;
10 |
11 | Coin { value: val } = 1;
12 | Coin { value: _ } = 1;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/comments.move:
--------------------------------------------------------------------------------
1 | // line comment
2 | script {
3 | /* block comment */
4 | /**
5 | multiline comment
6 | */
7 | /**
8 | * One can have /* nested */
9 | * // block comments
10 | */
11 | fun main() {}
12 | // /* unclosed block comment inside line comment
13 | // /* block comment inside line comment */
14 | }
15 |
16 | /// doc comment
17 | /// another doc comment
18 | module 0x1::M {
19 | /// function doc comment
20 | fun m() {}
21 | /// doc comment with outer attribute
22 | #[test_only]
23 | fun main() {
24 | let _ = /*caret*/1;
25 | }
26 |
27 | /// docs
28 | native fun native_m();
29 |
30 | /// docs
31 | native struct NatS;
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/contextual_token_operators.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | 1 < 2;
4 | 1 > 2;
5 | 1 << 2;
6 | 1 >> 2;
7 | 1 && 2;
8 | 1 || 2;
9 | 1 <= 2;
10 | 1 >= 2;
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/dot_expressions.move:
--------------------------------------------------------------------------------
1 | module 0x1::dot_expressions {
2 | fun dot() {
3 | bin.field1.field2;
4 | bin.field < 1;
5 | bin.receiver_func();
6 | bin.field.call();
7 |
8 | bin.call::();
9 | bin.call::();
10 | vector[1].length::();
11 | }
12 | spec dot {
13 | bin.field[1];
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/expressions.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main() {
3 | 1; 1u8; 1u16; 1u32; 1u64; 1u128;
4 |
5 | 0b11; // invalid
6 | 0xFF;
7 | 0x;
8 | 0011;
9 | 0xRR; // invalid
10 | 0xFFFu128;
11 |
12 | 0x1111_1111;
13 | 1_000;
14 |
15 | (1 + 1) * (1 + 1);
16 | (!!true + !!true) * !!false;
17 | 1 % 2;
18 | 1 ^ 2;
19 |
20 | (a * b as u64);
21 |
22 | *a = 1 + 2 * (3 + 5) * 4;
23 |
24 | a < b && b > 2;
25 |
26 | v1[1+1];
27 | v2[i + 1..len(v2)];
28 |
29 | has;
30 | schema;
31 | include;
32 | assume;
33 | assert;
34 | invariant;
35 |
36 | return
37 | }
38 | fun m() {
39 | return 1
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/expressions_angle_brackets.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | a < b && b > 2;
4 | a <= b && b > 2;
5 |
6 | a <= b < 1 >= 2 > 3;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/expressions_assignments.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | let a = 1 + 1;
4 | let b = (a = 1);
5 |
6 | *&a = 1;
7 | &a.b = 1;
8 | *a = *1 + *1;
9 | *a = *1 * *1;
10 | *a = *!1 + *!2;
11 | }
12 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/expressions_if_else_as.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | if (true) *!1 else *!2;
4 | (if (true) 1 else 2) as u8;
5 | (2) as u8;
6 | (a = 2) as u8;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/expressions_specs.move:
--------------------------------------------------------------------------------
1 | module M {
2 | spec module {
3 | a ==> b;
4 | a <==> b;
5 | a < x && y ==> x;
6 | a <= x && y <==> x;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/friend.move:
--------------------------------------------------------------------------------
1 | module M1 {
2 | friend 0x1::M2;
3 |
4 | #[test_only]
5 | friend 0x2::M2;
6 |
7 | public(friend) fun f_of_m1() {}
8 | public ( friend ) fun f_of_m2() {}
9 | }
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/function_calls.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | call();
4 | call(1, 2);
5 | call(b"", b"");
6 | call(b"", x"");
7 | call(x"", b"");
8 | call(x"", x"");
9 | call(1, 2,);
10 | call(0, 0u8, 0u64, 1u8, 1u64,);
11 | call(a, a.b, &a, &mut a, copy a, move a);
12 |
13 | call();
14 | call<0x1::Mod::S>();
15 | call();
16 | call();
17 | call>();
18 | call>(Transaction::new>());
19 |
20 | Transaction::call>();
21 |
22 | assert(true, 1);
23 | assert!(true, 1);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/generics.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | let a = vector;
4 | let b = map;
5 | let c = vector>;
6 | let c = map>;
7 |
8 | vector == vector;
9 | vector >= vector;
10 | }
11 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/let_patterns.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | let a = 1;
4 | let (a, b) = (1, 2);
5 | let R { a, b } = get_record();
6 | let R { a: _, b: _ } = get_record();
7 |
8 | let R { a: alias_a, b: alias_b } = get_record();
9 | let R { a: T { c, d }} = get_record();
10 | let R { a: T { c: alias_c, d: _ }} = get_record();
11 |
12 | let (R { a, b }, M { a: _, b: _ }) = get_record_tuple();
13 |
14 | let Generic {} = g;
15 | let Generic { g } = g;
16 | let Generic { g: R { f: f3 } } = g;
17 |
18 | let a: (u8) = 1;
19 | let a: (((u8))) = 1;
20 | let b: ((u8, u8)) = (1, 1);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/loops.move:
--------------------------------------------------------------------------------
1 | module 0x1::loops {
2 | fun main() {
3 | while (true) {
4 | 1;
5 | break;
6 | continue;
7 | };
8 | loop {
9 | 1;
10 | break;
11 | continue;
12 | };
13 |
14 | let for;
15 | for (i in 0..10) {
16 | 1;
17 | break;
18 | continue;
19 | };
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/macros.move:
--------------------------------------------------------------------------------
1 | module 0x1::macros {
2 | public inline fun map(
3 | v: vector,
4 | f: |Element|NewElement,
5 | ): vector {
6 | foreach(v, |elem| push_back(&mut result, f(elem)));
7 | }
8 |
9 | inline fun filter(
10 | p: |&Element|
11 | ) {
12 | foreach(v, |elem| {
13 | if (p(&elem)) push_back(&mut result, elem);
14 | });
15 | }
16 |
17 | inline fun fold(a: (Element),
18 | f: (|Element| Element),
19 | g: |Element, (|Element| Element)| Element): Element {
20 | f(a, g)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/public_package.move:
--------------------------------------------------------------------------------
1 | module 0x1::public_package {
2 |
3 | public(package) fun package(package: u8): u8 {
4 | let package = package + 1;
5 | package
6 | }
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/strings.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | b"(false: bool);";
4 | x"0101";
5 | x"";
6 | b"\t\n\r\0";
7 | b"\\";
8 | b"\"";
9 | b"\x01";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/struct_declarations.move:
--------------------------------------------------------------------------------
1 | module 0x1::M {
2 | struct Coin {}
3 |
4 | struct ValidatorConfig has store, drop {
5 | val1: u8,
6 | val2: vector,
7 | }
8 |
9 | struct ResourceValidatorConfig {
10 | val1: u8,
11 | val2: vector,
12 | operator_account: Option,
13 | operator_account2: Option<&signer>,
14 | }
15 |
16 | native struct NativeStruct;
17 |
18 | native struct NativeStructParams;
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/struct_literals.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main() {
3 | let a = Struct { a: val, b: 1 + 1 };
4 | let a = Struct { a: val, b: Struct2 { val, anotherval: 1 + 1 } };
5 | }
6 |
7 | fun return_empty_struct() {
8 | return Struct {};
9 | }
10 |
11 | fun return_empty_struct_as_expression() {
12 | Struct {}
13 | }
14 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/use.move:
--------------------------------------------------------------------------------
1 | script {
2 | use 0x1::Transaction;
3 | use 0x1::Transaction::Instance;
4 | use 0x1::Transaction::{};
5 | use 0x1::Transaction::{Self, EventHandle};
6 | use 0x1::Transaction::foo as bar;
7 | use 0x1::Transaction::{foo, foo as bar};
8 |
9 | fun main() {
10 | use 0x1::Transaction;
11 |
12 | let x = {
13 | use 0x1::Transaction;
14 | 0
15 | };
16 |
17 | {{{{
18 | use 0x2::Mango;
19 | }}}};
20 |
21 | while (true) {
22 | use 0x1::Transaction;
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/vectors.move:
--------------------------------------------------------------------------------
1 | module 0x1::vectors {
2 | use std::vector;
3 |
4 | fun main(a: vector) {
5 | vector[];
6 | vector[1, 1];
7 | vector[
8 | type_info,
9 | type_info,
10 | ];
11 | vector[1, 2, 3];
12 | vector::add();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/complete/while_loop_inline_assignment.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | while (v < 10) v = v + 1;
4 | while (v < 10) { v = v + 1 };
5 | while (v < 10) ( v = v + 1 );
6 | while (v < 10) ( v: u8 );
7 | while (v < 10) ( (v = v + 1): u8 );
8 | }
9 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/assignments.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | let a = ;
4 | let a: = 1;
5 | let a: u8 1;
6 |
7 | call()
8 | let (a, b) = ;
9 | let (a +++ ) = 1;
10 |
11 | *a = ;
12 |
13 | let R { a = ;
14 | let R { a;
15 | let R { a, b } = ;
16 |
17 | record.val = ;
18 | (record.val = );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/dot_exprs.move:
--------------------------------------------------------------------------------
1 | module 0x1::dot_exprs {
2 | fun m() {
3 | bin. assert!(true, 1);
4 |
5 | bin. S { field: 1 };
6 |
7 | bin. vector[];
8 |
9 | bin.field bin.field
10 |
11 | bin. aptos_token::get_token();
12 |
13 | bin. b"
14 | bin. x"
15 | bin. return
16 | }
17 |
18 | fun receiver() {
19 | bin.no_type_args_without_colon_colon();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/empty_script.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun
3 | }
4 |
5 | script {
6 | fun main();
7 | }
8 |
9 | script {
10 | fun main
11 | fun main
12 | }
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/expressions.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun m() {
3 | bin.;
4 | x";
5 | b"
6 | }
7 | fun main() {
8 | RMRK
9 | RMRK::
10 | 0x1:: ;
11 | 0x1::RMRK:: ;
12 | Sender::RMRK:: ;
13 | Sender::RMRK::
14 |
15 | while (true) {}
16 | return
17 | 0hello
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/function_calls.move:
--------------------------------------------------------------------------------
1 | script {
2 | fun main() {
3 | call(1;
4 | call(1 +);
5 | call(1, 2 +);
6 | call(1, 2,,);
7 | call(1, 2,,4);
8 | assert()
9 |
10 | foo4(1,;
11 | foo5(;
12 |
13 | foo6(1,
14 | let _ = 0;
15 |
16 | foo7(1, assert;
17 |
18 | let a = call(,);
19 | call(& );
20 | call(&mut );
21 |
22 | call10(,,,);
23 |
24 | assert!(s.val +);
25 | assert!(s.val !=);
26 | assert!(s.val ==);
27 |
28 | spec {
29 | call(a,
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/function_signatures.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main(a,) {}
3 | fun main(a: u8, b) {}
4 | fun main(a: u8, b:) {}
5 |
6 | pub
7 | public
8 | public(friend)
9 | public(script)
10 | public fun
11 |
12 | native
13 | native fun
14 | native public
15 | native public(friend)
16 | native public(script)
17 | native public fun
18 |
19 | fun main_01(a b: u8) {}
20 | fun main_02(, b: u8) {}
21 | fun main_03(a: &, b: u8) {}
22 |
23 | fun main_1(): (u8 {}
24 | fun main_2(): (u8, {}
25 | fun main_3(): (u8, u8 {}
26 | fun main_5() acq
27 | fun main_6() acquires {}
28 | fun main_7() acquires U,,{}
29 | fun main_8() acquires U V{}
30 |
31 | fun main_11<() {}
32 | fun main_12() {}
35 | fun main_15() {}
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/module_const.move:
--------------------------------------------------------------------------------
1 | module M {
2 | const MY_CONST
3 |
4 | const MY_CONST:
5 |
6 | const MY_CONST: u8
7 |
8 | const MY_CONST: u8 =
9 |
10 | const MY_CONST: u8 = 1
11 |
12 | const CONST_NO_TYPE = 1;
13 |
14 | const CONST_NO_TYPE_WITH_COMMA: = 1;
15 |
16 | fun main() {}
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/module_uses.move:
--------------------------------------------------------------------------------
1 | module 0x1::M {
2 | use
3 | use 0x0
4 | use Std
5 | use Std::
6 | use 0x0::
7 | use 0x0::Transaction
8 | use 0x0::Transaction::
9 | use 0x0::Transaction::;
10 | use 0x0::Transaction::create
11 | use 0x0::Transaction::{
12 | use 0x0::Transaction::{;
13 | use 0x0::Transaction::{create,
14 | use 0x0::Transaction::{create,;
15 | use 0x0::Transaction::{create, modify,,}
16 | use 0x0::Transaction::{create as , update};
17 |
18 | fun main() {}
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/spec.move:
--------------------------------------------------------------------------------
1 | module 0x1::M {
2 | spec
3 | spec my_function
4 | spec MyStruct
5 | spec module
6 | spec fun
7 | spec fun myfun
8 | spec schema
9 | spec schema MySchema
10 |
11 | fun m() {
12 | assume;
13 | let a = exists;
14 | 1 ==> 2;
15 | }
16 | spec module {
17 | include Schema
18 |
19 | assert;
20 | assume;
21 | assume exists 1;
22 |
23 | ensures result ==> 1;
24 | ensures true
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/struct_decls.move:
--------------------------------------------------------------------------------
1 | module 0x1::M {
2 | struct
3 | native struct
4 | struct S
5 | struct {}
6 | native struct S1
7 | struct S
8 | struct S
9 | }
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/struct_fields.move:
--------------------------------------------------------------------------------
1 | module M {
2 | struct T {
3 | : u8,
4 | my_field: u8
5 | }
6 | struct T {
7 | my_field: ,
8 | my_field: u8
9 | }
10 | struct T {
11 | my_field: u8
12 | my_field: u8
13 | }
14 |
15 | struct NoTypesFields {
16 | field1,
17 | field2:,
18 | field3
19 | }
20 |
21 | fun main() {
22 | let T { my: } = 1;
23 | let T { my: , my_field } = 1;
24 | let T { my: , my_field: , my_field2: _ } = 1;
25 | let T { my myfield } = 1;
26 | let T { my myfield: _ } = 1;
27 | }
28 | }
29 |
30 | module M {
31 | fun main() {
32 | T { my: };
33 | T { my: , my_field: , my_field2: 2 };
34 | T { my myfield: 1 };
35 | T { my myfield };
36 | T { my myfield: _ };
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/partial/top_level_items.move:
--------------------------------------------------------------------------------
1 | module
2 | module Std::
3 |
4 | script {
5 | fun
6 | }
7 |
8 | script {
9 | fun main()
10 | }
11 |
12 | script {
13 | use
14 | fun main() {}
15 | }
16 |
17 | script {
18 | use 0x0::
19 | }
20 |
21 | script {
22 | use 0x0::
23 |
24 | fun main() {
25 | use 0x0::
26 | }
27 | }
28 |
29 | script {
30 | use 0x0::Transaction::
31 |
32 | fun main() {}
33 | }
34 |
35 | script {
36 | use 0x0::Transaction::create
37 |
38 | fun main() {}
39 | }
40 |
41 | script {
42 | use 0x0::Transaction::;
43 |
44 | fun main() {}
45 | }
46 |
47 | script {
48 | use 0x0::Transaction::create
49 | use 0x0::Transaction::modify;
50 |
51 | fun main() {}
52 | }
53 |
54 | /*
55 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/apply.move:
--------------------------------------------------------------------------------
1 | module M {
2 | spec module {
3 | apply Foo to *foo;
4 | apply ExactlyOne to * except initialize;
5 | apply ModuleInvariant to *foo*;
6 | apply EnsuresHasKeyRotationCap { account: new_account } to make_account;
7 | apply ModuleInvariant to *foo*, bar except public *, internal baz;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/forall_exists.move:
--------------------------------------------------------------------------------
1 | module 0x1::M {
2 | spec fun spec_call() {
3 | exists i in 1..100: i == 3
4 | }
5 | spec module {
6 | invariant
7 | forall addr1: address where old(exists(addr1)): true;
8 |
9 | invariant
10 | forall x: num, y: num, z: num
11 | : x == y && y == z ==> x == z;
12 | invariant
13 | forall x: num
14 | : exists y: num
15 | : y >= x;
16 |
17 | invariant
18 | forall x: num where true:
19 | forall y: num where false:
20 | x >= y;
21 |
22 | invariant exists x in 1..10, y in 8..12 : x == y;
23 | invariant exists x in 1..10, y in 8..12 : x == y;
24 |
25 | ensures result ==> (forall j in 0..100: true);
26 | ensures exists x in 1..10 : x == 1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/pragma.move:
--------------------------------------------------------------------------------
1 | module M {
2 | spec module {
3 | pragma verify;
4 | pragma verify = true;
5 | pragma verify = true, timeout;
6 | pragma verify = true, timeout = 60;
7 | pragma friend = gg;
8 | pragma friend = 0x1::m::gg;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/scopes.move:
--------------------------------------------------------------------------------
1 | module M {
2 | fun main() {
3 | spec {};
4 | spec {}
5 | }
6 |
7 | spec module {
8 | fun all(): bool {}
9 | fun uninterpreted(addr: address);
10 |
11 | // Native function which is defined in the prover's prelude.
12 | native fun serialize(v: &MvValue): vector;
13 | }
14 |
15 | spec MyStruct {}
16 | spec fun spec_is_valid(addr: address) {}
17 | spec fun spec_uninterpreted(addr: address);
18 | spec native fun spec_is_valid_native(addr: address);
19 |
20 | fun unpack() {}
21 |
22 | spec unpack {}
23 | spec unpack() {}
24 | spec unpack() {}
25 | spec unpack(a: u8, b: u8) {}
26 | spec unpack(): u8 {}
27 |
28 | spec schema ModuleInvariant {
29 | supply: num;
30 | local ensures: num;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/spec_file.move:
--------------------------------------------------------------------------------
1 | spec sender::my_module {
2 | spec create_address {
3 | pragma opaque;
4 | }
5 |
6 | spec fun spec_now_microseconds(): u64 {
7 | global(@aptos_framework).microseconds
8 | }
9 |
10 | /// Helper schema to specify that a function aborts if not in genesis.
11 | spec schema AbortsIfNotGenesis {
12 | aborts_if !is_genesis() with error::INVALID_STATE;
13 | }
14 |
15 | spec write_to_event_store() {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/spec_properties.move:
--------------------------------------------------------------------------------
1 | module 0x1::spec_properties {
2 | spec module {
3 | invariant [] true;
4 | invariant [seed = 1] true;
5 | invariant [abstract, concrete, verify = true] 1 == 1;
6 | invariant [seed] true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/test/resources/org/sui/lang/parser/specs/spec_variables.move:
--------------------------------------------------------------------------------
1 | module 0x1::m {
2 | spec module {
3 | local two: u8;
4 | local two_with_params: u8;
5 | global three: u8;
6 | global four: u8 = 1;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ui-tests/src/main/kotlin/org/move/ui/utils/StepsLogger.kt:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 |
3 | package org.sui.ui.utils
4 |
5 | import com.intellij.remoterobot.stepsProcessing.StepLogger
6 | import com.intellij.remoterobot.stepsProcessing.StepWorker
7 |
8 | object StepsLogger {
9 | private var initializaed = false
10 |
11 | @JvmStatic
12 | fun init() {
13 | if (initializaed.not()) {
14 | StepWorker.registerProcessor(StepLogger())
15 | initializaed = true
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/ui-tests/src/test/resources/example-packages/aptos_package/Move.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "MyAptosPackage"
3 | version = "1.0.0"
4 | authors = []
5 |
6 | [addresses]
7 |
8 | [dev-addresses]
9 |
10 | [dependencies.AptosFramework]
11 | git = "https://github.com/aptos-labs/aptos-core.git"
12 | rev = "mainnet"
13 | subdir = "aptos-move/framework/aptos-framework"
14 |
15 | [dev-dependencies]
16 |
--------------------------------------------------------------------------------
/ui-tests/src/test/resources/example-packages/aptos_package/sources/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/ui-tests/src/test/resources/example-packages/aptos_package/sources/.gitkeep
--------------------------------------------------------------------------------
/ui-tests/src/test/resources/example-packages/empty_move_package/main.move:
--------------------------------------------------------------------------------
1 | module 0x1::main {
2 | fun main() {}
3 | }
4 |
--------------------------------------------------------------------------------
/ui-tests/src/test/resources/example-packages/sui_package/sources/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoh-zone/intellij-move/48845e020b80432b1cf58c2eb9192e5759b8a2c0/ui-tests/src/test/resources/example-packages/sui_package/sources/.gitkeep
--------------------------------------------------------------------------------