cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
575 stars 7 forks source link

ClassCastException on.CompletionProgressIndicator #104

Closed pmoriarty closed 10 years ago

pmoriarty commented 10 years ago

Getting this error in the logs when attempting completion on a namespace in a use or require clause in IDEA Ultimate 12.1.5 on Ubuntu with Cursive 0.1.05. Namespace completion is not working correctly. I'm seeing IntellijIdeaRulezzz in the list of possible completions and not all completions are showing up. Tried reinstalling the plugin and clearing the system folder but still having problems.

2013-11-12 14:07:19,421 [ 174898]  ERROR - on.CompletionProgressIndicator - clojure.lang.PersistentVector cannot be cast to org.jetbrains.plugins.clojure.psi.impl.ns.ClSyntheticNamespace 
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to org.jetbrains.plugins.clojure.psi.impl.ns.ClSyntheticNamespace
    at plugin.resolve.symbol$unqualified_variants$fn__7769.invoke(symbol.clj:187)
    at plugin.resolve.symbol$tree_walk.invoke(symbol.clj:42)
    at plugin.resolve.symbol$unqualified_variants.invoke(symbol.clj:182)
    at plugin.resolve.symbol$variants.invoke(symbol.clj:200)
    at clojure.lang.Var.invoke(Var.java:415)
    at org.jetbrains.plugins.clojure.psi.impl.symbols.ClSymbolImpl.getVariants(ClSymbolImpl.java:308)
    at org.jetbrains.plugins.clojure.psi.resolve.completion.ClojureCompletionContributor.fillCompletionVariants(ClojureCompletionContributor.java:31)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
    at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:115)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.a(CompletionProgressIndicator.java:775)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.access$900(CompletionProgressIndicator.java:86)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:757)
    at com.intellij.codeInsight.completion.AsyncCompletion$1$1$1.run(CompletionThreading.java:93)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:940)
    at com.intellij.codeInsight.completion.AsyncCompletion$1$1.run(CompletionThreading.java:88)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:185)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:226)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:175)
    at com.intellij.codeInsight.completion.AsyncCompletion$1.run(CompletionThreading.java:84)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:454)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:152)
cursive-ide commented 10 years ago

Hmm, that's very strange, I'm in the middle of an inter-city move but I'll try to look at this ASAP.

cursive-ide commented 10 years ago

I can't reproduce this. Could you send an example of an ns form where this happens, and what you were trying to complete?

pmoriarty commented 10 years ago

Here is a screenshot. As you can see the novate.util.metrics package has 5 namespaces. But completion isn't offering any of them.

image

However it works at the novate.util. level (though IntellijIdeaRulezzz is still offered)

image

pmoriarty commented 10 years ago

Here is a shot of the completion on 'novate.util.metrics.' to confirm the behaviour

image

cursive-ide commented 10 years ago

Hmm, I see - I can reproduce that now. It seems to depend on whether the cursor is before or after the interior dot. However what I'm not seeing is the exception - I only see the bad completion behaviour and the daft symbol.

KirinDave commented 10 years ago

I see this is long closed, but I'm still getting it. Pretty sure I followed the installation instructions to the letter on the site, did I accidentally pull a very old version?

It not only messes up all subsequent completion, but also seems to precipitate an error when my files were reporting saved but were not actually showing edits.

cursive-ide commented 10 years ago

Just to clarify, you're still seeing both the exception and the completion symbol problem?

You shouldn't be able to download an old version, but you can check in Settings->Plugins, the version of Cursive should be 0.1.15.

Which OS are you running? And is this project public somewhere I can try to reproduce the problem with?

cursive-ide commented 10 years ago

I just tried to reproduce this, but I can't. Are you able to share the ns form you were editing when this happened?

cursive-ide commented 10 years ago

Oh, and could you send a copy of your log? Help->Show log in Finder/Explorer/whatever.

gered commented 10 years ago

I just got a similar exception.

java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to cursive.psi.impl.ns.ClSyntheticNamespace
    at plugin.resolve.symbol$unqualified_variants$fn__3401.invoke(symbol.clj:223)
    at plugin.resolve.symbol$tree_walk.invoke(symbol.clj:44)
    at plugin.resolve.symbol$unqualified_variants.invoke(symbol.clj:218)
    at plugin.resolve.symbol$variants.invoke(symbol.clj:237)
    at clojure.lang.Var.invoke(Var.java:415)
    at cursive.psi.impl.symbols.ClSymbolImpl.getVariants(ClSymbolImpl.java:313)
    at cursive.psi.resolve.completion.ClojureCompletionContributor.fillCompletionVariants(ClojureCompletionContributor.java:35)
    at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:84)
    at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:115)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.a(CompletionProgressIndicator.java:769)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator.access$900(CompletionProgressIndicator.java:84)
    at com.intellij.codeInsight.completion.CompletionProgressIndicator$1CalculateItems.run(CompletionProgressIndicator.java:751)
    at com.intellij.codeInsight.completion.AsyncCompletion$1$1$1.run(CompletionThreading.java:93)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:908)
    at com.intellij.codeInsight.completion.AsyncCompletion$1$1.run(CompletionThreading.java:88)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at com.intellij.codeInsight.completion.AsyncCompletion$1.run(CompletionThreading.java:84)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:420)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:150)

I was re-writing the :require and :use bits in an (ns) in an existing namespace while upgrading a bunch of really old dependencies in an app of mine. I figure that the way in which I was rewriting all of this probably triggered the exception. I basically just put my cursor above the existing :use/:require, hit Enter a few times, and started writing a new :require while the old ones were still there. While writing out the new :require IntelliJ popped up with the error above.

For your reference, this is what my (ns) looked like when the error happened:

(ns myapp.views.layout
  (:require [selmer.parser :as parser
             [ring.util.response :refer [content-]]])    ; << cursor was on this line ... I was still typing it out

  (:use noir.request)
  (:require [selmer.parser :as parser]
            [noir.session :as session]
            [myapp.views.viewfilters]))

Again, this is probably kind of a weird way to write it, and obviously is a totally incorrect (ns) form which is what I figured caused the exception in my case. However, I was in the middle of rewriting/fixing it and was just keeping the old :use/:require around as a reference while doing so... so getting an error is still not something I would expect in any case... ideally Cursive would just silently fail.

Hope this helps you track this one down!

EDIT: lol, also noticed that there's a missing end square bracket in the first namespace listed in the new :require. However, that is exactly how I had written it when the exception occurred. Plenty of syntax oddities going on there, not surprised an exception was thrown, haha.

cursive-ide commented 10 years ago

Thanks - this one is caused by having one alias mapped to multiple ns'es - in your case you have it mapped twice even though it's to the same ns. This will be definitively fixed with some pretty large changes I'm making to how the indexing code works, hopefully in the next drop.