Skip to content

Commit

Permalink
proper lookup element for named tuple field completion
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov committed Nov 11, 2024
1 parent 554aa4f commit b074841
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/main/kotlin/org/move/ide/MoveIcons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ object MoveIcons {
val MODULE = load("/icons/module.svg")

val STRUCT = load("/icons/struct.svg")
val STRUCT_FIELD = AllIcons.Nodes.Field
val SCHEMA = AllIcons.Nodes.Static

val FIELD = load("/icons/nodes/field.svg")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
import org.move.ide.presentation.text
import org.move.lang.core.psi.*
import org.move.lang.core.psi.ext.MvMethodOrField
import org.move.lang.core.psi.ext.addressRef
import org.move.lang.core.psi.ext.joinToSignature
import org.move.lang.core.psi.ext.outerFileName
import org.move.lang.core.psi.ext.*
import org.move.lang.core.resolve.ScopeEntry
import org.move.lang.core.types.infer.*
import org.move.lang.core.types.ty.TyUnknown
Expand Down Expand Up @@ -66,7 +63,7 @@ fun MvNamedElement.getLookupElementBuilder2(
.withTypeText(this.containingFile?.name)
}

is MvNamedFieldDecl -> {
is MvFieldDecl -> {
val fieldTy = this.type?.loweredType(msl)?.substitute(subst) ?: TyUnknown
base
.withTypeText(fieldTy.text(false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ val MvNamedFieldDecl.fieldOwner: MvFieldsOwner get() = blockFields?.parent as Mv
abstract class MvNamedFieldDeclMixin(node: ASTNode) : MvMandatoryNameIdentifierOwnerImpl(node),
MvNamedFieldDecl {

override fun getIcon(flags: Int): Icon = MoveIcons.STRUCT_FIELD
override fun getIcon(flags: Int): Icon = MoveIcons.FIELD
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ class LookupElementTest: MvTestBase() {
}
""", tailText = "(&mut self)", typeText = "u8"
)

fun `test named tuple field lookup`() = checkMethodOrFieldProvider(
"""
module 0x1::m {
struct S(u8, u8);
fun main(s: S) {
s.0;
//^
}
}
""", typeText = "u8"
)
//
// fun `test import module lookup`() = checkNamedItem("""
// module 0x1::m {
Expand Down

0 comments on commit b074841

Please sign in to comment.