diff --git a/src/main/grammars/MoveParser.bnf b/src/main/grammars/MoveParser.bnf index 108ff6a7..09079509 100644 --- a/src/main/grammars/MoveParser.bnf +++ b/src/main/grammars/MoveParser.bnf @@ -182,14 +182,13 @@ QualPathCodeFragmentElement ::= PathImpl Attr ::= '#' '[' <> ']' { pin = 1 } private Attr_first ::= '#' -AttrItem ::= IDENTIFIER (AttrItemList | AttrItemInitializer)? -{ - implements = [ - "org.move.lang.core.resolve.ref.MvReferenceElement" -// "org.move.lang.core.types.infer.MvInferenceContextOwner" - ] - mixin = "org.move.lang.core.psi.ext.MvAttrItemMixin" -} +AttrItem ::= PathImpl (AttrItemList | AttrItemInitializer)? +//{ +// implements = [ +// "org.move.lang.core.resolve.ref.MvReferenceElement" +// ] +// mixin = "org.move.lang.core.psi.ext.MvAttrItemMixin" +//} AttrItemList ::= '(' <>? ')' { pin = 1 } //AttrItemArgument ::= IDENTIFIER ('=' Expr)? //{ diff --git a/src/main/kotlin/org/move/ide/MvHighlighter.kt b/src/main/kotlin/org/move/ide/MvHighlighter.kt index 5ca9d01e..884b0da1 100644 --- a/src/main/kotlin/org/move/ide/MvHighlighter.kt +++ b/src/main/kotlin/org/move/ide/MvHighlighter.kt @@ -36,6 +36,8 @@ class MvHighlighter : SyntaxHighlighterBase() { BYTE_STRING_LITERAL, HEX_STRING_LITERAL -> MvColor.STRING INTEGER_LITERAL -> MvColor.NUMBER + QUOTE_IDENTIFIER -> MvColor.LABEL + in MOVE_KEYWORDS, BOOL_LITERAL -> MvColor.KEYWORD else -> null } diff --git a/src/main/kotlin/org/move/ide/annotator/HighlightingAnnotator.kt b/src/main/kotlin/org/move/ide/annotator/HighlightingAnnotator.kt index 8c4a1b3c..c1584ab0 100644 --- a/src/main/kotlin/org/move/ide/annotator/HighlightingAnnotator.kt +++ b/src/main/kotlin/org/move/ide/annotator/HighlightingAnnotator.kt @@ -2,12 +2,16 @@ package org.move.ide.annotator import com.intellij.lang.annotation.AnnotationHolder import com.intellij.psi.PsiElement +import com.intellij.psi.TokenType.WHITE_SPACE import com.intellij.psi.impl.source.tree.LeafPsiElement +import com.intellij.psi.tree.TokenSet import org.move.cli.settings.moveSettings import org.move.ide.colors.MvColor import org.move.lang.MvElementTypes.* +import org.move.lang.core.CONTEXTUAL_KEYWORDS import org.move.lang.core.psi.* import org.move.lang.core.psi.ext.* +import org.move.lang.core.tokenSetOf import org.move.lang.core.types.infer.inference import org.move.lang.core.types.ty.Ty import org.move.lang.core.types.ty.TyAdt @@ -31,6 +35,7 @@ val SPEC_BUILTIN_FUNCTIONS = setOf( class HighlightingAnnotator: MvAnnotatorBase() { override fun annotateInternal(element: PsiElement, holder: AnnotationHolder) { + if (element.elementType == WHITE_SPACE) return val color = when { element is LeafPsiElement -> highlightLeaf(element) element is MvLitExpr && element.text.startsWith("@") -> MvColor.ADDRESS @@ -51,9 +56,26 @@ class HighlightingAnnotator: MvAnnotatorBase() { leafType == QUOTE_IDENTIFIER -> MvColor.LABEL leafType == HEX_INTEGER_LITERAL -> MvColor.NUMBER parent is MvAssertMacroExpr -> MvColor.MACRO + parent is MvCopyExpr && element.text == "copy" -> MvColor.KEYWORD + + // covers `#, [, ]`, in #[test(my_signer = @0x1)] parent is MvAttr -> MvColor.ATTRIBUTE - parent is MvCopyExpr - && element.text == "copy" -> MvColor.KEYWORD + // covers `(, )`, in #[test(my_signer = @0x1)] + parent is MvAttrItemList -> MvColor.ATTRIBUTE + // covers `=` in #[test(my_signer = @0x1)] + parent is MvAttrItemInitializer -> MvColor.ATTRIBUTE + + leafType == COLON_COLON -> { + val firstParent = + element.findFirstParent(true) { it is MvAttrItemInitializer || it is MvAttrItem } + if (firstParent == null || firstParent is MvAttrItemInitializer) { + // belongs to the expression path, not highlighted + return null + } + // belongs to the attr item identifier + return MvColor.ATTRIBUTE + } + else -> null } } @@ -94,7 +116,7 @@ class HighlightingAnnotator: MvAnnotatorBase() { private fun highlightBindingPat(bindingPat: MvPatBinding): MvColor { val bindingOwner = bindingPat.parent - if (bindingPat.isReceiverStyleFunctionsEnabled && + if (bindingPat.isMethodsEnabled && bindingOwner is MvFunctionParameter && bindingOwner.isSelfParam ) { return MvColor.SELF_PARAMETER @@ -112,6 +134,9 @@ class HighlightingAnnotator: MvAnnotatorBase() { val identifierName = path.identifierName if (identifierName == "Self") return MvColor.KEYWORD + val rootPath = path.rootPath() + if (rootPath.parent is MvAttrItem) return MvColor.ATTRIBUTE + // any qual :: access is not highlighted if (path.qualifier != null) return null @@ -156,7 +181,7 @@ class HighlightingAnnotator: MvAnnotatorBase() { item is MvConst -> MvColor.CONSTANT else -> { val itemParent = item.parent - if (itemParent.isReceiverStyleFunctionsEnabled + if (itemParent.isMethodsEnabled && itemParent is MvFunctionParameter && itemParent.isSelfParam ) { MvColor.SELF_PARAMETER @@ -197,7 +222,16 @@ class HighlightingAnnotator: MvAnnotatorBase() { else -> MvColor.VARIABLE } - private val PsiElement.isReceiverStyleFunctionsEnabled + private val PsiElement.isMethodsEnabled get() = project.moveSettings.enableReceiverStyleFunctions + + companion object { + private val HIGHLIGHTED_ELEMENTS = TokenSet.orSet( + tokenSetOf( + IDENTIFIER, QUOTE_IDENTIFIER + ), + CONTEXTUAL_KEYWORDS + ) + } } diff --git a/src/main/kotlin/org/move/ide/inspections/MvUnusedTestSignerInspection.kt b/src/main/kotlin/org/move/ide/inspections/MvUnusedTestSignerInspection.kt index 868dcbc7..2e379623 100644 --- a/src/main/kotlin/org/move/ide/inspections/MvUnusedTestSignerInspection.kt +++ b/src/main/kotlin/org/move/ide/inspections/MvUnusedTestSignerInspection.kt @@ -21,7 +21,7 @@ class MvUnusedTestSignerInspection: MvLocalInspectionTool() { val innerAttrItems = attrItem.attrItemList?.attrItemList.orEmpty() for (innerAttrItem in innerAttrItems) { val refName = innerAttrItem.unqualifiedName ?: continue - if (innerAttrItem.unresolved) { + if (innerAttrItem.path.unresolved) { holder.registerProblem( innerAttrItem, "Unused test signer", diff --git a/src/main/kotlin/org/move/ide/inspections/MvUnusedVariableInspection.kt b/src/main/kotlin/org/move/ide/inspections/MvUnusedVariableInspection.kt index 86c65733..4b7efe01 100644 --- a/src/main/kotlin/org/move/ide/inspections/MvUnusedVariableInspection.kt +++ b/src/main/kotlin/org/move/ide/inspections/MvUnusedVariableInspection.kt @@ -34,8 +34,8 @@ class MvUnusedVariableInspection: MvLocalInspectionTool() { if (bindingName.startsWith("_")) return val references = binding.searchReferences() - // filter out #[test] attributes - .filter { it.element !is MvAttrItem } + // filter out `#[test(signer1, signer2)]` declarations + .filter { it.element.parent !is MvAttrItem } if (references.none()) { val fixes = when (binding.bindingTypeOwner) { is MvFunctionParameter -> arrayOf( diff --git a/src/main/kotlin/org/move/lang/MoveParserDefinition.kt b/src/main/kotlin/org/move/lang/MoveParserDefinition.kt index f664db00..a7a406e4 100644 --- a/src/main/kotlin/org/move/lang/MoveParserDefinition.kt +++ b/src/main/kotlin/org/move/lang/MoveParserDefinition.kt @@ -63,6 +63,6 @@ class MoveParserDefinition : ParserDefinition { /** * Should be increased after any change of parser rules */ - const val PARSER_VERSION: Int = LEXER_VERSION + 53 + const val PARSER_VERSION: Int = LEXER_VERSION + 54 } } diff --git a/src/main/kotlin/org/move/lang/core/MvTokenType.kt b/src/main/kotlin/org/move/lang/core/MvTokenType.kt index 5295ac51..1b1c33c5 100644 --- a/src/main/kotlin/org/move/lang/core/MvTokenType.kt +++ b/src/main/kotlin/org/move/lang/core/MvTokenType.kt @@ -12,16 +12,19 @@ class MvTokenType(debugName: String): IElementType(debugName, MoveLanguage) fun tokenSetOf(vararg tokens: IElementType) = TokenSet.create(*tokens) -val MOVE_KEYWORDS = tokenSetOf( - LET, MUT, ABORT, BREAK, CONTINUE, IF, ELSE, LOOP, RETURN, AS, WHILE, FOR, - SCRIPT_KW, ADDRESS, MODULE_KW, PUBLIC, FUN, STRUCT_KW, ACQUIRES, USE, HAS, PHANTOM, - MOVE, CONST_KW, NATIVE, FRIEND, ENTRY, INLINE, - ASSUME, ASSERT, REQUIRES, ENSURES, INVARIANT, MODIFIES, PRAGMA, INCLUDE, ABORTS_IF, WITH, UPDATE, DECREASES, - SPEC, SCHEMA_KW, GLOBAL, LOCAL, - EMITS, APPLY, TO, EXCEPT, INTERNAL, - FORALL, EXISTS, IN, WHERE, MATCH_KW, +val CONTEXTUAL_KEYWORDS = tokenSetOf(ENUM_KW, MATCH_KW) +val MOVE_KEYWORDS = TokenSet.orSet( + tokenSetOf( + LET, MUT, ABORT, BREAK, CONTINUE, IF, ELSE, LOOP, RETURN, AS, WHILE, FOR, + SCRIPT_KW, ADDRESS, MODULE_KW, PUBLIC, FUN, STRUCT_KW, ACQUIRES, USE, HAS, PHANTOM, + MOVE, CONST_KW, NATIVE, FRIEND, ENTRY, INLINE, + ASSUME, ASSERT, REQUIRES, ENSURES, INVARIANT, MODIFIES, PRAGMA, INCLUDE, ABORTS_IF, WITH, UPDATE, DECREASES, + SPEC, SCHEMA_KW, GLOBAL, LOCAL, + EMITS, APPLY, TO, EXCEPT, INTERNAL, + FORALL, EXISTS, IN, WHERE, ENUM_KW, MATCH_KW, + ), +// CONTEXTUAL_KEYWORDS ) -val CONTEXTUAL_KEYWORDS = tokenSetOf(MATCH_KW) val FUNCTION_MODIFIERS = tokenSetOf(VISIBILITY_MODIFIER, NATIVE, ENTRY, INLINE) val TYPES = tokenSetOf(PATH_TYPE, REF_TYPE, TUPLE_TYPE) diff --git a/src/main/kotlin/org/move/lang/core/psi/ext/MvAttrItem.kt b/src/main/kotlin/org/move/lang/core/psi/ext/MvAttrItem.kt index b72e8149..6e0a262b 100644 --- a/src/main/kotlin/org/move/lang/core/psi/ext/MvAttrItem.kt +++ b/src/main/kotlin/org/move/lang/core/psi/ext/MvAttrItem.kt @@ -1,41 +1,55 @@ package org.move.lang.core.psi.ext import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement import org.move.lang.core.psi.* import org.move.lang.core.psi.impl.MvNamedElementImpl +import org.move.lang.core.resolve.ref.MvPath2Reference import org.move.lang.core.resolve.ref.MvPolyVariantReference +import org.move.lang.core.resolve.ref.MvPolyVariantReferenceBase import org.move.lang.core.resolve.ref.MvPolyVariantReferenceCached - -val MvAttrItem.unqualifiedName: String get() = this.identifier.text +import org.move.lang.core.resolve2.PathKind +import org.move.lang.core.resolve2.pathKind + +val MvAttrItem.unqualifiedIdent: PsiElement? + get() { + val path = this.path + if (path.pathKind(false) !is PathKind.UnqualifiedPath) return null + return path.identifier + } +val MvAttrItem.unqualifiedName: String? get() = this.unqualifiedIdent?.text val MvAttrItem.attr: MvAttr? get() = this.parent as? MvAttr val MvAttrItem.innerAttrItems: List get() = this.attrItemList?.attrItemList.orEmpty() -val MvAttrItem.isAbortCode: Boolean get() = this.identifier.textMatches("abort_code") -val MvAttrItem.isTest: Boolean get() = this.identifier.textMatches("test") +val MvAttrItem.isAbortCode: Boolean get() = this.unqualifiedIdent?.textMatches("abort_code") == true +val MvAttrItem.isTest: Boolean get() = this.unqualifiedIdent?.textMatches("test") == true class AttrItemReferenceImpl( - element: MvAttrItem, + element: MvPath, val ownerFunction: MvFunction -) : MvPolyVariantReferenceCached(element) { +) : MvPolyVariantReferenceBase(element), MvPath2Reference { - override fun multiResolveInner(): List { + override fun multiResolve(): List { return ownerFunction.parameters .map { it.patBinding } .filter { it.name == element.referenceName } } + +// override fun multiResolveInner(): List { +// } } abstract class MvAttrItemMixin(node: ASTNode): MvNamedElementImpl(node), MvAttrItem { - override fun getReference(): MvPolyVariantReference? { - val attr = this.ancestorStrict() ?: return null - attr.attrItemList - .singleOrNull() - ?.takeIf { it.isTest } ?: return null - val ownerFunction = attr.attributeOwner as? MvFunction ?: return null - return AttrItemReferenceImpl(this, ownerFunction) - } +// override fun getReference(): MvPolyVariantReference? { +// val attr = this.ancestorStrict() ?: return null +// attr.attrItemList +// .singleOrNull() +// ?.takeIf { it.isTest } ?: return null +// val ownerFunction = attr.attributeOwner as? MvFunction ?: return null +// return AttrItemReferenceImpl(this, ownerFunction) +// } } diff --git a/src/main/kotlin/org/move/lang/core/psi/ext/MvPath.kt b/src/main/kotlin/org/move/lang/core/psi/ext/MvPath.kt index 70c4ce72..e47e59cd 100644 --- a/src/main/kotlin/org/move/lang/core/psi/ext/MvPath.kt +++ b/src/main/kotlin/org/move/lang/core/psi/ext/MvPath.kt @@ -124,7 +124,7 @@ fun MvPath.allowedNamespaces(isCompletion: Boolean = false): Set { // can be anything in completion parent is MvPathExpr -> if (isCompletion) ALL_NAMESPACES else NAMES -// } + parent is MvSchemaLit || parent is MvSchemaRef -> SCHEMAS parent is MvStructLitExpr @@ -137,6 +137,9 @@ fun MvPath.allowedNamespaces(isCompletion: Boolean = false): Set { parent is MvFriendDecl -> MODULES parent is MvModuleSpec -> MODULES + // should not be used for attr items + parent is MvAttrItem -> NONE + else -> debugErrorOrFallback( "Cannot build path namespaces: unhandled parent type ${parent?.elementType}", NAMES @@ -157,7 +160,19 @@ val MvPath.qualifier: MvPath? abstract class MvPathMixin(node: ASTNode): MvElementImpl(node), MvPath { - override fun getReference(): MvPath2Reference? = MvPath2ReferenceImpl(this) + override fun getReference(): MvPath2Reference? { + if (referenceName == null) return null + return when (val parent = parent) { + is MvAttrItem -> { + val attrItemList = (parent.parent as? MvAttrItemList) ?: return null + val parentAttrItem = (attrItemList.parent as? MvAttrItem)?.takeIf { it.isTest } ?: return null + val attr = parentAttrItem.attr ?: return null + val ownerFunction = attr.attributeOwner as? MvFunction ?: return null + AttrItemReferenceImpl(this, ownerFunction) + } + else -> MvPath2ReferenceImpl(this) + } + } } val MvPath.hasColonColon: Boolean get() = colonColon != null diff --git a/src/main/kotlin/org/move/lang/core/stubs/Stubs.kt b/src/main/kotlin/org/move/lang/core/stubs/Stubs.kt index 76e2a828..0869e4ba 100644 --- a/src/main/kotlin/org/move/lang/core/stubs/Stubs.kt +++ b/src/main/kotlin/org/move/lang/core/stubs/Stubs.kt @@ -38,10 +38,10 @@ interface MvAttributeOwnerStub { var verifyOnly = false for (attrItem in query.attrItems) { hasAttrs = true - if (attrItem.referenceName == "test_only") { + if (attrItem.unqualifiedName == "test_only") { testOnly = true } - if (attrItem.referenceName == "verify_only") { + if (attrItem.unqualifiedName == "verify_only") { verifyOnly = true } } diff --git a/src/test/kotlin/org/move/ide/annotator/AttrHighlightingAnnotatorTest.kt b/src/test/kotlin/org/move/ide/annotator/AttrHighlightingAnnotatorTest.kt new file mode 100644 index 00000000..ea1f242e --- /dev/null +++ b/src/test/kotlin/org/move/ide/annotator/AttrHighlightingAnnotatorTest.kt @@ -0,0 +1,32 @@ +package org.move.ide.annotator + +import org.move.ide.colors.MvColor +import org.move.utils.tests.annotation.AnnotatorTestCase + +class AttrHighlightingAnnotatorTest: AnnotatorTestCase(HighlightingAnnotator::class) { + override fun setUp() { + super.setUp() + annotationFixture.registerSeverities(MvColor.entries.map(MvColor::testSeverity)) + } + + fun `test highlight annotator identifier`() = checkHighlighting(""" + module 0x1::m { + #[view] + fun foo() {} + } + """) + + fun `test highlight annotator fq name`() = checkHighlighting(""" + module 0x1::m { + #[lint::view] + fun foo() {} + } + """) + + fun `test highlight annotator initializer`() = checkHighlighting(""" + module 0x1::m { + #[test(signer =
@0x1
)] + fun foo() {} + } + """) +} \ No newline at end of file diff --git a/src/test/kotlin/org/move/ide/annotator/HighlightingAnnotatorTest.kt b/src/test/kotlin/org/move/ide/annotator/HighlightingAnnotatorTest.kt index 61b7a798..703971cf 100644 --- a/src/test/kotlin/org/move/ide/annotator/HighlightingAnnotatorTest.kt +++ b/src/test/kotlin/org/move/ide/annotator/HighlightingAnnotatorTest.kt @@ -7,7 +7,7 @@ import org.move.utils.tests.annotation.AnnotatorTestCase class HighlightingAnnotatorTest: AnnotatorTestCase(HighlightingAnnotator::class) { override fun setUp() { super.setUp() - annotationFixture.registerSeverities(MvColor.values().map(MvColor::testSeverity)) + annotationFixture.registerSeverities(MvColor.entries.map(MvColor::testSeverity)) } fun `test block comment do not break the highlighting`() = checkHighlighting( @@ -355,13 +355,6 @@ class HighlightingAnnotatorTest: AnnotatorTestCase(HighlightingAnnotator::class) } """) - fun `test attribute highlighting`() = checkHighlighting(""" - module 0x1::m { - #[view] - fun foo() {} - } - """) - @MoveV2 fun `test enums and variants are highlighted`() = checkHighlighting(""" module 0x1::m { diff --git a/src/test/kotlin/org/move/ide/inspections/MvUnresolvedReferenceInspectionTest.kt b/src/test/kotlin/org/move/ide/inspections/MvUnresolvedReferenceInspectionTest.kt index 9afa0058..3a556630 100644 --- a/src/test/kotlin/org/move/ide/inspections/MvUnresolvedReferenceInspectionTest.kt +++ b/src/test/kotlin/org/move/ide/inspections/MvUnresolvedReferenceInspectionTest.kt @@ -562,4 +562,11 @@ module 0x1::m { } } """) + + fun `test no error for path in attr`() = checkByText(""" + module 0x1::m { + #[lint::my_lint] + fun main() {} + } + """) } diff --git a/src/test/kotlin/org/move/lang/resolve/ResolveVariablesTest.kt b/src/test/kotlin/org/move/lang/resolve/ResolveVariablesTest.kt index b38618c9..072fd07d 100644 --- a/src/test/kotlin/org/move/lang/resolve/ResolveVariablesTest.kt +++ b/src/test/kotlin/org/move/lang/resolve/ResolveVariablesTest.kt @@ -753,4 +753,13 @@ module 0x1::string_tests { } } """) + + fun `test no attr item signer reference for not direct children of test`() = checkByCode(""" + module 0x1::m { + #[test(unknown_attr(my_signer = @0x1))] + //^ unresolved + fun test_main(my_signer: signer) { + } + } + """) } diff --git a/src/test/resources/org/move/lang/parser/complete/attributes.move b/src/test/resources/org/move/lang/parser/complete/attributes.move index f47bbf9d..35e382ea 100644 --- a/src/test/resources/org/move/lang/parser/complete/attributes.move +++ b/src/test/resources/org/move/lang/parser/complete/attributes.move @@ -38,5 +38,6 @@ module 0x1::M { location = aptos_framework::ed25519, location = aptos_framework::ed25519::myfunction, )] + #[lint::allow_unsafe_randomness] fun abort_test_2() {} } diff --git a/src/test/resources/org/move/lang/parser/complete/attributes.txt b/src/test/resources/org/move/lang/parser/complete/attributes.txt index 32b7e227..77212aa8 100644 --- a/src/test/resources/org/move/lang/parser/complete/attributes.txt +++ b/src/test/resources/org/move/lang/parser/complete/attributes.txt @@ -4,7 +4,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test') PsiElement(])(']') PsiWhiteSpace('\n') PsiElement(module)('module') @@ -21,7 +22,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(use)('use') @@ -40,7 +42,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(const_kw)('const') @@ -64,7 +67,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(struct_kw)('struct') @@ -80,25 +84,29 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test') PsiElement(])(']') PsiWhiteSpace('\n ') MvAttrImpl(ATTR) PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('expected_failure') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('expected_failure') PsiElement(])(']') PsiWhiteSpace('\n ') MvAttrImpl(ATTR) PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test') PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('expected_failure') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('expected_failure') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -130,11 +138,13 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('attr1') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('attr1') PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('attr2') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('attr2') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(fun)('fun') @@ -153,11 +163,13 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('a') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -170,7 +182,8 @@ FILE PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('b') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('b') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -183,7 +196,8 @@ FILE PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('c') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('c') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -213,7 +227,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') PsiElement())(')') @@ -235,7 +250,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(native)('native') @@ -253,15 +269,18 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('show') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('show') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('book_orders_sdk') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('book_orders_sdk') PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('book_price_levels_sdk') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('book_price_levels_sdk') PsiElement())(')') PsiElement(])(']') PsiWhiteSpace('\n ') @@ -281,11 +300,13 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('expected_failure') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('expected_failure') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('abort_code') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('abort_code') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -302,7 +323,8 @@ FILE PsiElement(,)(',') PsiWhiteSpace(' ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('location') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('location') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') MvPathExprImpl(PATH_EXPR) @@ -331,15 +353,18 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('allow') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('allow') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('lint') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('lint') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('self_transfer') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('self_transfer') PsiElement())(')') PsiElement())(')') PsiElement(])(']') @@ -348,12 +373,14 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('expected_failure') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('expected_failure') MvAttrItemListImpl(ATTR_ITEM_LIST) PsiElement(()('(') PsiWhiteSpace('\n ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('abort_code') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('abort_code') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -367,7 +394,8 @@ FILE PsiElement(,)(',') PsiWhiteSpace('\n ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('location') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('location') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -381,7 +409,8 @@ FILE PsiElement(,)(',') PsiWhiteSpace('\n ') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('location') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('location') PsiWhiteSpace(' ') MvAttrItemInitializerImpl(ATTR_ITEM_INITIALIZER) PsiElement(=)('=') @@ -400,6 +429,17 @@ FILE PsiElement())(')') PsiElement(])(']') PsiWhiteSpace('\n ') + MvAttrImpl(ATTR) + PsiElement(#)('#') + PsiElement([)('[') + MvAttrItemImpl(ATTR_ITEM) + MvPathImpl(PATH) + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('lint') + PsiElement(::)('::') + PsiElement(IDENTIFIER)('allow_unsafe_randomness') + PsiElement(])(']') + PsiWhiteSpace('\n ') PsiElement(fun)('fun') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('abort_test_2') diff --git a/src/test/resources/org/move/lang/parser/complete/comments.txt b/src/test/resources/org/move/lang/parser/complete/comments.txt index 448457ca..815917f9 100644 --- a/src/test/resources/org/move/lang/parser/complete/comments.txt +++ b/src/test/resources/org/move/lang/parser/complete/comments.txt @@ -65,7 +65,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(fun)('fun') diff --git a/src/test/resources/org/move/lang/parser/complete/friend.txt b/src/test/resources/org/move/lang/parser/complete/friend.txt index 5bd4acef..311b8fc2 100644 --- a/src/test/resources/org/move/lang/parser/complete/friend.txt +++ b/src/test/resources/org/move/lang/parser/complete/friend.txt @@ -22,7 +22,8 @@ FILE PsiElement(#)('#') PsiElement([)('[') MvAttrItemImpl(ATTR_ITEM) - PsiElement(IDENTIFIER)('test_only') + MvPathImpl(PATH) + PsiElement(IDENTIFIER)('test_only') PsiElement(])(']') PsiWhiteSpace('\n ') PsiElement(friend_kw)('friend')