-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #268 from pontem-network/add-fields-completion-to-…
…struct-lit a number of fixes for struct field completion and completion priority
- Loading branch information
Showing
18 changed files
with
205 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/test/kotlin/org/move/lang/completion/CompletionAutoPopupTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.move.lang.completion | ||
|
||
import com.intellij.testFramework.fixtures.CompletionAutoPopupTester | ||
import com.intellij.util.ThrowableRunnable | ||
import org.intellij.lang.annotations.Language | ||
import org.move.utils.tests.NamedAddress | ||
import org.move.utils.tests.completion.CompletionTestCase | ||
|
||
class CompletionAutoPopupTest: CompletionTestCase() { | ||
private lateinit var tester: CompletionAutoPopupTester | ||
|
||
fun `test popup is not shown when typing variable name`() = checkPopupIsNotShownAfterTyping( | ||
""" | ||
module 0x1::m { | ||
struct MyStruct { val: u8 } | ||
fun main() { | ||
let tr/*caret*/ | ||
} | ||
} | ||
""", "u" | ||
) | ||
|
||
fun `test popup is shown when typing name starting with upper case`() = checkPopupIsShownAfterTyping( | ||
""" | ||
module 0x1::m { | ||
struct MyStruct { val: u8 } | ||
fun main() { | ||
let Str/*caret*/ | ||
} | ||
} | ||
""", "u" | ||
) | ||
|
||
fun `test popup is shown for struct pat fields`() = checkPopupIsShownAfterTyping( | ||
""" | ||
module 0x1::m { | ||
struct MyStruct { val: u8 } | ||
fun main() { | ||
let MyStruct { v/*caret*/ }; | ||
} | ||
} | ||
""", "a" | ||
) | ||
|
||
override fun setUp() { | ||
super.setUp() | ||
tester = CompletionAutoPopupTester(myFixture) | ||
} | ||
|
||
override fun runTestRunnable(testRunnable: ThrowableRunnable<Throwable>) { | ||
tester.runWithAutoPopupEnabled(testRunnable) | ||
} | ||
|
||
override fun runInDispatchThread(): Boolean = false | ||
|
||
private fun checkPopupIsShownAfterTyping(@Language("Move") code: String, toType: String) { | ||
configureAndType(code, toType) | ||
assertNotNull(tester.lookup) | ||
} | ||
|
||
private fun checkPopupIsNotShownAfterTyping(@Language("Move") code: String, toType: String) { | ||
configureAndType(code, toType) | ||
assertNull(tester.lookup) | ||
} | ||
|
||
private fun configureAndType(code: String, toType: String) { | ||
InlineFile(code).withCaret() | ||
tester.typeWithPauses(toType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.