improved completion
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package dev.hgh.jai.settings
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
@@ -86,6 +87,49 @@ class JaiConfiguredRootTest : BasePlatformTestCase() {
|
||||
myFixture.checkResult("#load \"external.jai\";")
|
||||
}
|
||||
|
||||
fun testConfiguredRootSuppliesImportedSymbolCompletion() {
|
||||
configureRoot("Custom/module.jai" to "Helper :: () {}")
|
||||
myFixture.configureByText(
|
||||
"consumer.jai",
|
||||
"""
|
||||
#import "Custom";
|
||||
main :: () { Hel<caret>(); }
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
myFixture.completeBasic()
|
||||
myFixture.checkResult(
|
||||
"""
|
||||
#import "Custom";
|
||||
main :: () { Helper(); }
|
||||
""".trimIndent(),
|
||||
)
|
||||
}
|
||||
|
||||
fun testProbeStyleWorkspaceRootsSupplyLocalAndImportedCompletions() {
|
||||
val settings = JaiProjectSettings.getInstance(project)
|
||||
val jaiModules = Path.of(System.getProperty("user.home"), ".local", "jai", "modules")
|
||||
val probeModules = Path.of(System.getProperty("user.home"), "programming", "probe", "modules")
|
||||
settings.setRootPaths(listOf(jaiModules.toString(), probeModules.toString()))
|
||||
myFixture.configureByText(
|
||||
"main.jai",
|
||||
"""
|
||||
Foo :: struct { bar: int; }
|
||||
main :: () {
|
||||
foobazz := Foo.{};
|
||||
fo<caret>;
|
||||
}
|
||||
#import "Foo";
|
||||
#import "Basic";
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
myFixture.complete(CompletionType.BASIC, 1)
|
||||
val strings = myFixture.lookupElementStrings.orEmpty()
|
||||
assertTrue("local variable should be offered: $strings", "foobazz" in strings)
|
||||
assertTrue("Foo module symbol should be offered: $strings", "foo" in strings)
|
||||
}
|
||||
|
||||
fun testReferencesSearchIncludesProjectUsagesForConfiguredExternalDeclaration() {
|
||||
val module = configureRoot("Custom/module.jai" to "Helper :: () {}")
|
||||
val source =
|
||||
|
||||
Reference in New Issue
Block a user