I have the weirdest problem in IDEA (have had for ...
# intellij
l
I have the weirdest problem in IDEA (have had for about a year maybe?) I'm always running the latest EAP, and I run it on three different machines: One Qubes OS (where IDEA is running in a Fedora template), one plain Fedora machine and one Windows 11 machine. Now, the type-matching completion works on one of these machines (the Qubes OS machine) and one the two others, I always get "no suggestions". I sync the config between these machines, and all other settings seems to work fine. It's not the keymap, since the same thing happens even if I go to
Code→Code Completion→Type Matching
. I've even tried to wipe the entire config directory on the Fedora machine and re-synced settings with no luck. One doesn't need this completion mode as often in Kotlin as in Java, which is why I've survived for this long. When I need it it's really annoying though. I thought the functionality had stopped working in IDEA altogether, but then I noticed it worked on one of my machines (same version of IDEA installed).
a
Have you tried the same place in code where you have suggestions in one case but not in another, right? Could you please share your idea.log for the case where there are no suggestions?
l
I have, and on the machine where it worked, it worked all the time. I'm now in front of the Fedora machine and I can press Control-Shift-Space anywhere and no matter where I do it, it says "no suggestions".
@Anna Kozlova would you be able to tell me what debug option to use to enable more logging? Right now nothing is written to the log when I try to expand. I'd be happy to share the entire file if that would help.
a
and no exceptions in log at all? I was suspecting some indexing problem.
l
Oh I'm sure I have exceptions all right. Let me find them.
(sorry, that was an old exception)
@Anna Kozlova OK, here's one at the end that is at least a little relevant:
Copy code
2024-09-23 22:13:37,317 [5171413] SEVERE - #c.i.p.i.PsiClassImplUtil - Element: class org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightConstructor #kotlin  because: File language:Language: JAVA != Provider base language:Language: kotlin
invalidated at: no info [Plugin: org.jetbrains.kotlin]
com.intellij.diagnostic.PluginException: Element: class org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightConstructor #kotlin  because: File language:Language: JAVA != Provider base language:Language: kotlin
invalidated at: no info [Plugin: org.jetbrains.kotlin]
        at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
        at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:100)
        at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:510)
        at com.intellij.psi.impl.PsiClassImplUtil.skipInvalid(PsiClassImplUtil.java:408)
        at com.intellij.psi.impl.PsiClassImplUtil.access$200(PsiClassImplUtil.java:45)
        at com.intellij.psi.impl.PsiClassImplUtil$MemberCache.lambda$new$2(PsiClassImplUtil.java:368)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
        at one.util.streamex.AbstractStreamEx.forEach(AbstractStreamEx.java:352)
        at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
        at one.util.streamex.StreamEx.toArray(StreamEx.java:871)
        at com.intellij.psi.impl.PsiClassImplUtil$MemberCache.lambda$new$3(PsiClassImplUtil.java:368)
        at com.intellij.util.containers.ConcurrentFactoryMap$2.create(ConcurrentFactoryMap.java:174)
        at com.intellij.util.containers.ConcurrentFactoryMap.get(ConcurrentFactoryMap.java:40)
        at com.intellij.psi.impl.PsiClassImplUtil$MemberCache.getAllMembers(PsiClassImplUtil.java:402)
        at com.intellij.psi.impl.PsiClassImplUtil.getAllByMap(PsiClassImplUtil.java:167)
        at com.intellij.psi.impl.PsiClassImplUtil.getAllMethods(PsiClassImplUtil.java:56)
        at org.jetbrains.kotlin.light.classes.symbol.classes.SymbolLightClassBase.getAllMethods(SymbolLightClassBase.kt:59)
        at com.intellij.execution.junit.JUnitUtil.hasTestOrSuiteMethods(JUnitUtil.java:216)
        at com.intellij.execution.junit.JUnitUtil.lambda$isTestClass$0(JUnitUtil.java:212)
        at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:173)
        at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.kt:40)
        at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:236)
        at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:43)
        at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:236)
        at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
        at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:27)
        at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:66)
        at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:237)
        at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.kt:34)
        at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:83)
        at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:170)
        at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:136)
        at com.intellij.execution.junit.JUnitUtil.isTestClass(JUnitUtil.java:211)
        at com.intellij.execution.junit2.inspection.JUnitEntryPoint.isEntryPoint(JUnitEntryPoint.java:45)
        at com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase.isStrictEntryPoint(UnusedDeclarationInspectionBase.java:291)
        at com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase.isEntryPoint(UnusedDeclarationInspectionBase.java:260)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedSymbolUtil.isEntryPoint(KotlinUnusedSymbolUtil.kt:779)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedSymbolUtil.getPsiToReportProblem(KotlinUnusedSymbolUtil.kt:137)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedHighlightingVisitor.handleDeclaration(KotlinUnusedHighlightingVisitor.kt:171)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedHighlightingVisitor.access$handleDeclaration(KotlinUnusedHighlightingVisitor.kt:38)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedHighlightingVisitor$collectAndHighlightNamedElements$1.invoke(KotlinUnusedHighlightingVisitor.kt:142)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedHighlightingVisitor$collectAndHighlightNamedElements$1.invoke(KotlinUnusedHighlightingVisitor.kt:140)
        at org.jetbrains.kotlin.idea.highlighting.KotlinUnusedHighlightingVisitor.collectAndHighlightNamedElements$lambda$2(KotlinUnusedHighlightingVisitor.kt:140)
        at com.intellij.concurrency.ApplierCompleter.processArrayItem(ApplierCompleter.java:116)
        at com.intellij.concurrency.ApplierCompleter.processArray(ApplierCompleter.java:196)
        at com.intellij.concurrency.ApplierCompleter.helpOthers(ApplierCompleter.java:215)
        at com.intellij.concurrency.ApplierCompleter.helpAll(ApplierCompleter.java:176)
        at com.intellij.concurrency.ApplierCompleter.lambda$exec$0(ApplierCompleter.java:106)
        at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:291)
        at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
        at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$2(ApplierCompleter.java:148)
        at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
        at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
        at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
        at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:159)
        at com.intellij.concurrency.ApplierCompleter.lambda$wrapAndRun$1(ApplierCompleter.java:140)
        at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.executeByImpatientReader(AnyThreadWriteThreadingSupport.kt:486)
        at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
        at com.intellij.concurrency.ApplierCompleter.wrapAndRun(ApplierCompleter.java:140)
        at com.intellij.concurrency.ApplierCompleter.exec(ApplierCompleter.java:108)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: com.intellij.psi.PsiInvalidElementAccessException: Element: class org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightConstructor #kotlin  because: File language:Language: JAVA != Provider base language:Language: kotlin
invalidated at: no info
        ... 72 more
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - IntelliJ IDEA 2024.2.2  Build #IU-242.22855.74
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - JDK: 21.0.3; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - OS: Linux
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - Plugin to blame: Kotlin version: <tel:242.22855.74|242.22855.74>-IJ
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - Last Action: EditorEnter
I'll be happy to upload the entire file. I don't see any secrets in it.
a
let's try? Exceptions are rather unrelated (
l
Oh, and I've reset the caches, reindexed and I've even completely deleted every sincle cache and config file and started completely fresh, and the problem remains.
a
sorry to hear that! Let's try with the file text?
l
Here's the file.
You can see quite a few severe errors in the log.
a
I see suspicious
Copy code
2024-09-23 22:08:11,861 [4845957]   WARN - #c.i.o.v.i.l.LocalFileSystemBase - /home/elias/prog/array/mpbignum/build/classes/kotlin/jvm/main/|buf ← ffi:allocBytes 100 
            |buf ffi:copyInto ("testfoo"-@\0),0
            |lib ← ffi:loadLibrary "libc.so.6"
            |fn ← lib ffi:findFunction ("puts" ; :int ; :ptr)
            |result ← fn ffi:callFunction buf
            |ffi:free buf
l
The text is raw text from one of my test cases.
a
Copy code
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:171)
	at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
	at java.base/java.nio.file.Files.readAttributes(Files.java:1853)
	at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.readAttributes(LocalFileSystemImpl.java:374)
It means that IDE tried to load file attributes but failed. It might end in all kinds of problems, including indexes and thus completion and e.g. find usages
I'd check what jdk you run on and what is the OS you use, very likely IDEA doesn't support well one of it (as you already assumed yourself)
l
I mean, it's as standard as it gets:
Copy code
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - IntelliJ IDEA 2024.2.2  Build #IU-242.22855.74
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - JDK: 21.0.3; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2024-09-23 22:13:37,319 [5171415] SEVERE - #c.i.p.i.PsiClassImplUtil - OS: Linux
Also, I get the same issue on Windows 11. Again with the JetBrains-delivered JDK.
a
Does it help switching back to K1 mode?
l
OK, the last thing I can think of to try. I created a new project. Exited IDEA, deleted the old log file and then loaded the hello world project. Problem remained, but now there is only one error in the log:
Copy code
2024-09-24 21:58:28,686 [   2552]   WARN - #c.i.w.i.i.WorkspaceModelCacheSerializer - Workspace model cache was not serialized
com.intellij.platform.workspace.storage.metadata.exceptions.MissingTypeMetadataException: Metadata for the com.intellij.platform.workspace.jps.entities.LibraryEntity was not collected. Please run the generator for the class com.intellij.platform.workspace.jps.entities.LibraryEntity
        at com.intellij.platform.workspace.storage.metadata.MetadataStorage.getMetadataByTypeFqn(apiCode.kt:32)
You mean in the idea properties file? I can try.
a
It's in
Settings | Languages & Frameworks | Kotlin
l
Woah!
I changed it to
-Didea.kotlin.plugin.use.k2=false
and now it works!
Let me try in my main project.
Indeed. It works now. Amazing.
@Anna Kozlova thank you very much!
I wonder if I changed this setting on my Qubes laptop at some point and forgot about it.
a
it's far from amazing 😕 If you can try to install IDEA 2024.3 EAP and check there, it would be a great help. I'll check the K2 exceptions meanwhile, I think, that we fixed them but can't be 100% sure
l
Downloading it now.
🙌 1
a
I'll try your project locally, let's see
l
Sadly, problem came back even in EAP.
The problem definitely happens during indexation, because before it was done indexing, Control-Shift-Space gave me some things (like do/for/when/if, etc). Then once indexation was done, it says "no suggestions"
Turning K2 off again makes it work.
a
oh, I am stupid. I am so sorry. We haven't implemented smart type completion yet
l
Oops. If that was mentioned in the release notes, I am sorry for not noticing that.
I always try to read all the release notes when I update.
I do note that "when guards" don't seem to work without K2? I get errors where I'm using it (yes, I tend to use all new Kotlin features pretty much immediately and I just now found a great use case for it)
a
K2 doesn't have all features which K1 had but has some new ones
yes, new kotlin language features would be supported in K2 mode only (it's impossible to support them in K1) but there are some other new features as well. It's a complicated situation for us and we are very thankful to get feedback!
l
I did note that K2 has a lot better flow analysis. I have some bogus warnings now that are clearly wrong.
a
please please please, report them: here, on YT or whatever. We are working with the feedback!
l
Even for K1?
a
K1-only issues become less priority, sorry
l
That's fine. I'll monitor the issue you shared, and switch to K2 once completion works.
thank you color 1