Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClojureScript indentation goes wrong when you have Javascript interop #519

Closed
wilkerlucio opened this issue Sep 28, 2014 · 7 comments
Closed
Milestone

Comments

@wilkerlucio
Copy link

Hi

I was noticing some weirdness on my indentation while working here, and I could isolate the issue, and it seems to happen every time I have code that interop with Javascript variables.

First I wanna point a working example (no issue here):

(consider the ^ to be the cursor place):

(let [a b^])

Pressing return from that, gives me:

(let [a b
      ^])

But, now try to press return on this:

(let [a (.-body js/document)^])

And you will get:

(let [a (.-body js/document)
^])

By that tiny example, I realized that once I put any JS interop into a block, all that top level indentation get's screwed (the return goes to wrong places).

Please let me know if you need any more information.

@cursive-ide cursive-ide added this to the 0.1.37 milestone Sep 29, 2014
@cursive-ide
Copy link
Owner

I'm not seeing this, I get:

(let [a (.-body js/document)
      ])

As I would expect. Can you check your log for exceptions after reproducing this?

@wilkerlucio
Copy link
Author

Humm

First, when I just open this project I'm getting this:

java.lang.NullPointerException: null keys not supported
    at gnu.trove.THashMap.put(THashMap.java:162)
    at com.intellij.util.indexing.ValueContainerImpl.a(ValueContainerImpl.java:72)
    at com.intellij.util.indexing.ValueContainerImpl.addValue(ValueContainerImpl.java:55)
    at com.intellij.util.indexing.ValueContainerMap$ValueContainerExternalizer.read(ValueContainerMap.java:130)
    at com.intellij.util.indexing.ValueContainerMap$ValueContainerExternalizer.read(ValueContainerMap.java:80)
    at com.intellij.util.io.PersistentHashMap.doGet(PersistentHashMap.java:427)
    at com.intellij.util.io.PersistentHashMap.get(PersistentHashMap.java:398)
    at com.intellij.util.indexing.MapIndexStorage$2$1.compute(MapIndexStorage.java:121)
    at com.intellij.util.indexing.MapIndexStorage$2$1.compute(MapIndexStorage.java:109)
    at com.intellij.util.indexing.ChangeTrackingValueContainer.a(ChangeTrackingValueContainer.java:121)
    at com.intellij.util.indexing.ChangeTrackingValueContainer.getValueIterator(ChangeTrackingValueContainer.java:78)
    at com.intellij.util.indexing.FileBasedIndexImpl$15.convert(FileBasedIndexImpl.java:986)
    at com.intellij.util.indexing.FileBasedIndexImpl$15.convert(FileBasedIndexImpl.java:961)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:934)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:1007)
    at com.intellij.util.indexing.FileBasedIndexImpl.processValues(FileBasedIndexImpl.java:915)
    at com.intellij.util.indexing.FileBasedIndexImpl.processValues(FileBasedIndexImpl.java:905)
    at plugin.index.js$root_object_map_by_name.invoke(js.clj:218)
    at plugin.index.js$all_properties$fn__2192.invoke(js.clj:254)
    at clojure.core$map$fn__4207.invoke(core.clj:2487)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.Cons.next(Cons.java:39)
    at clojure.lang.RT.next(RT.java:598)
    at clojure.core$next.invoke(core.clj:64)
    at clojure.core.protocols$fn__6034.invoke(protocols.clj:146)
    at clojure.core.protocols$fn__6005$G__6000__6014.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__6026.invoke(protocols.clj:54)
    at clojure.core.protocols$fn__5979$G__5974__5992.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6177)
    at plugin.index.js$all_properties.invoke(js.clj:255)
    at plugin.resolve.symbol.editor.cljs$all_properties$fn__3813.invoke(cljs.clj:96)
    at plugin.psi$cached_value$reify__7610.compute(psi.clj:379)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:199)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:81)
    at plugin.psi$cached_value.doInvoke(psi.clj:383)
    at clojure.lang.RestFn.invoke(RestFn.java:525)
    at plugin.resolve.symbol.editor.cljs$all_properties.invoke(cljs.clj:99)
    at plugin.resolve.symbol.editor.cljs$resolve_js_element.invoke(cljs.clj:156)
    at plugin.resolve.symbol.editor.cljs$editor_resolver$reify__3946.resolve_unqualified(cljs.clj:317)
    at plugin.resolve.symbol$resolve_normal_symbol.invoke(symbol.clj:96)
    at plugin.resolve.symbol$resolve_symbol.invoke(symbol.clj:120)
    at clojure.lang.Var.invoke(Var.java:419)
    at cursive.psi.impl.symbols.SymbolReference$MyResolver.resolve(SymbolReference.java:67)
    at cursive.psi.impl.symbols.SymbolReference$MyResolver.resolve(SymbolReference.java:64)
    at com.intellij.psi.impl.source.resolve.ResolveCache.a(ResolveCache.java:103)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:131)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:123)
    at cursive.psi.impl.symbols.SymbolReference.multiResolve(SymbolReference.java:58)
    at plugin.resolve$resolve.invoke(resolve.clj:52)
    at plugin.resolve$resolve_keys.invoke(resolve.clj:185)
    at plugin.resolve$list_resolve_symbols$fn__8312.invoke(resolve.clj:203)
    at plugin.psi$cached_value$reify__7610.compute(psi.clj:379)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:199)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:81)
    at plugin.psi$cached_value.doInvoke(psi.clj:383)
    at clojure.lang.RestFn.invoke(RestFn.java:494)
    at plugin.resolve$list_resolve_symbols.invoke(resolve.clj:200)
    at plugin.intellij.gutter$line_marker_info$fn__7208$fn__7214.invoke(gutter.clj:53)
    at plugin.intellij.gutter$line_marker_info$fn__7208.invoke(gutter.clj:52)
    at clojure.core$some.invoke(core.clj:2443)
    at plugin.intellij.gutter$line_marker_info.invoke(gutter.clj:54)
    at plugin.intellij.gutter$initialise$reify__7237.getLineMarkerInfo(gutter.clj:96)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.addLineMarkers(LineMarkersPass.java:182)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:121)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:62)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:371)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:368)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:344)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask.exec(JobLauncherImpl.java:193)
    at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858)
    at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687)
    at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642)
    at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:109)



java.lang.NullPointerException: null keys not supported
    at gnu.trove.THashMap.put(THashMap.java:162)
    at com.intellij.util.indexing.ValueContainerImpl.a(ValueContainerImpl.java:72)
    at com.intellij.util.indexing.ValueContainerImpl.addValue(ValueContainerImpl.java:55)
    at com.intellij.util.indexing.ValueContainerMap$ValueContainerExternalizer.read(ValueContainerMap.java:130)
    at com.intellij.util.indexing.ValueContainerMap$ValueContainerExternalizer.read(ValueContainerMap.java:80)
    at com.intellij.util.io.PersistentHashMap.doGet(PersistentHashMap.java:427)
    at com.intellij.util.io.PersistentHashMap.get(PersistentHashMap.java:398)
    at com.intellij.util.indexing.MapIndexStorage$2$1.compute(MapIndexStorage.java:121)
    at com.intellij.util.indexing.MapIndexStorage$2$1.compute(MapIndexStorage.java:109)
    at com.intellij.util.indexing.ChangeTrackingValueContainer.a(ChangeTrackingValueContainer.java:121)
    at com.intellij.util.indexing.ChangeTrackingValueContainer.getValueIterator(ChangeTrackingValueContainer.java:78)
    at com.intellij.util.indexing.FileBasedIndexImpl$15.convert(FileBasedIndexImpl.java:986)
    at com.intellij.util.indexing.FileBasedIndexImpl$15.convert(FileBasedIndexImpl.java:961)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:934)
    at com.intellij.util.indexing.FileBasedIndexImpl.a(FileBasedIndexImpl.java:1007)
    at com.intellij.util.indexing.FileBasedIndexImpl.processValues(FileBasedIndexImpl.java:915)
    at com.intellij.util.indexing.FileBasedIndexImpl.processValues(FileBasedIndexImpl.java:905)
    at plugin.index.js$root_object_map_by_name.invoke(js.clj:218)
    at plugin.index.js$all_properties$fn__2192.invoke(js.clj:254)
    at clojure.core$map$fn__4207.invoke(core.clj:2487)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.Cons.next(Cons.java:39)
    at clojure.lang.RT.next(RT.java:598)
    at clojure.core$next.invoke(core.clj:64)
    at clojure.core.protocols$fn__6034.invoke(protocols.clj:146)
    at clojure.core.protocols$fn__6005$G__6000__6014.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__6026.invoke(protocols.clj:54)
    at clojure.core.protocols$fn__5979$G__5974__5992.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6177)
    at plugin.index.js$all_properties.invoke(js.clj:255)
    at plugin.resolve.symbol.editor.cljs$all_properties$fn__3813.invoke(cljs.clj:96)
    at plugin.psi$cached_value$reify__7610.compute(psi.clj:379)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:199)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:81)
    at plugin.psi$cached_value.doInvoke(psi.clj:383)
    at clojure.lang.RestFn.invoke(RestFn.java:525)
    at plugin.resolve.symbol.editor.cljs$all_properties.invoke(cljs.clj:99)
    at plugin.resolve.symbol.editor.cljs$resolve_js_element.invoke(cljs.clj:156)
    at plugin.resolve.symbol.editor.cljs$editor_resolver$reify__3946.resolve_unqualified(cljs.clj:317)
    at plugin.resolve.symbol$resolve_normal_symbol.invoke(symbol.clj:96)
    at plugin.resolve.symbol$resolve_symbol.invoke(symbol.clj:120)
    at clojure.lang.Var.invoke(Var.java:419)
    at cursive.psi.impl.symbols.SymbolReference$MyResolver.resolve(SymbolReference.java:67)
    at cursive.psi.impl.symbols.SymbolReference$MyResolver.resolve(SymbolReference.java:64)
    at com.intellij.psi.impl.source.resolve.ResolveCache.a(ResolveCache.java:103)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:131)
    at com.intellij.psi.impl.source.resolve.ResolveCache.resolveWithCaching(ResolveCache.java:123)
    at cursive.psi.impl.symbols.SymbolReference.multiResolve(SymbolReference.java:58)
    at plugin.resolve$resolve.invoke(resolve.clj:52)
    at plugin.resolve$resolve_keys.invoke(resolve.clj:185)
    at plugin.resolve$list_resolve_symbols$fn__8312.invoke(resolve.clj:203)
    at plugin.psi$cached_value$reify__7610.compute(psi.clj:379)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:199)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:81)
    at plugin.psi$cached_value.doInvoke(psi.clj:383)
    at clojure.lang.RestFn.invoke(RestFn.java:494)
    at plugin.resolve$list_resolve_symbols.invoke(resolve.clj:200)
    at plugin.intellij.gutter$line_marker_info$fn__7208$fn__7214.invoke(gutter.clj:53)
    at plugin.intellij.gutter$line_marker_info$fn__7208.invoke(gutter.clj:52)
    at clojure.core$some.invoke(core.clj:2443)
    at plugin.intellij.gutter$line_marker_info.invoke(gutter.clj:54)
    at plugin.intellij.gutter$initialise$reify__7237.getLineMarkerInfo(gutter.clj:96)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.addLineMarkers(LineMarkersPass.java:182)
    at com.intellij.codeInsight.daemon.impl.LineMarkersPass.doCollectInformation(LineMarkersPass.java:121)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:62)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1$1.run(PassExecutorService.java:380)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass$1.run(PassExecutorService.java:371)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:368)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:344)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask.exec(JobLauncherImpl.java:193)
    at jsr166e.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at jsr166e.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:858)
    at jsr166e.ForkJoinPool.scan(ForkJoinPool.java:1687)
    at jsr166e.ForkJoinPool.runWorker(ForkJoinPool.java:1642)
    at jsr166e.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:109)

And actually this error keep repeating all the time...

I tried create a new project (lein new ...), and just added the clojurescript dependency:

[org.clojure/clojurescript "0.0-2322"]

Then ran a REPL with Piggieback, for this I have on my profiles.clj:

:plugins [[com.cemerick/austin "0.1.5"]]
(cemerick.piggieback/cljs-repl :repl-env (cemerick.austin/exec-env))

I think I reported this same exception before, I'm noticing this error is getting very frequent on every ClojureScript project that I have here (and I'm working in about 3 of then currently).

Since those instabilities on ClojureScript are hitting me so often, I would like to ask if there may be any local cache that can be triggering it? Maybe something that I can cleanup to see if it gets better?

@wilkerlucio
Copy link
Author

I wasn't able to reproduce the indentation problem on a new project, so, here is my project.clj of the project where it's failing:

(defproject captioneer-editor "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0-alpha2"]
                 [org.clojure/clojurescript "0.0-2322"]
                 [org.clojure/core.async "0.1.338.0-5c5012-alpha"]]

  :plugins [[lein-cljsbuild "1.0.3"]]

  :source-paths ["src/clj" "src/cljs"]

  :cljsbuild {
   :builds {
             :dev {
                    :source-paths ["src/cljs"]
                    :compiler {
                                :output-dir "resources/out"
                                :output-to "resources/compiled/main.js"
                                :optimizations :whitespace}}}})

@cursive-ide
Copy link
Owner

Ok, I'll take a look at this, thanks. Is this project open source? Can I reproduce this locally?

@wilkerlucio
Copy link
Author

The project is not open source, but I sent it to you by email so you can try it.

Using the same zip folder that I sent to you, these are the steps that I did to reproduce it here:

1 - drag the extracted project folder into IntelliJ
2 - open the src/cljs/captioneer/editor/core.cljs
3 - Run a task to build the CLJS javascript

To do the step 3, I have an external tool for leiningen cljs build configured here, you can find the configuration for that in the following screenshot: https://www.dropbox.com/s/u3lw9hu7bpmc0ky/Screenshot%202014-09-29%2019.58.23.png?dl=0

With that, an IDE error prompts here, and I get the same stack I posted here before.

Hope with that you can reproduce it.

Thanks.

@cursive-ide
Copy link
Owner

That's great, thanks Wilker!

@wilkerlucio
Copy link
Author

Another thing, using the zip I was also able to reproduce the initial described let issue while editing (try at the end of file src/cljs/captioneer/editor/core.cljs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants