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

Invalid ranges during formatting in Language: Clojure #544

Closed
puredanger opened this issue Oct 15, 2014 · 10 comments
Closed

Invalid ranges during formatting in Language: Clojure #544

puredanger opened this issue Oct 15, 2014 · 10 comments
Milestone

Comments

@puredanger
Copy link

Invalid ranges during formatting in Language: Clojure
java.lang.Throwable
    at com.intellij.diagnostic.LogMessageEx.error(LogMessageEx.java:134)
    at com.intellij.formatting.InitialInfoBuilder.assertInvalidRanges(InitialInfoBuilder.java:409)
    at com.intellij.formatting.InitialInfoBuilder.doProcessSimpleBlock(InitialInfoBuilder.java:306)
    at com.intellij.formatting.InitialInfoBuilder.processSimpleBlock(InitialInfoBuilder.java:273)
    at com.intellij.formatting.InitialInfoBuilder.buildFrom(InitialInfoBuilder.java:173)
    at com.intellij.formatting.InitialInfoBuilder.doIteration(InitialInfoBuilder.java:235)
    at com.intellij.formatting.InitialInfoBuilder.iteration(InitialInfoBuilder.java:109)
    at com.intellij.formatting.FormatProcessor$WrapBlocksState.doIteration(FormatProcessor.java:1313)
    at com.intellij.formatting.FormatProcessor$State.iteration(FormatProcessor.java:1246)
    at com.intellij.formatting.FormatProcessor.iteration(FormatProcessor.java:244)
    at com.intellij.formatting.FormatterImpl.buildProcessorAndWrapBlocks(FormatterImpl.java:434)
    at com.intellij.formatting.FormatterImpl.adjustLineIndent(FormatterImpl.java:371)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$5.doPerform(CodeStyleManagerImpl.java:358)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$5.doPerform(CodeStyleManagerImpl.java:355)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerRunnable.perform(CodeStyleManagerRunnable.java:112)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.doAdjustLineIndentByOffset(CodeStyleManagerImpl.java:355)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.access$500(CodeStyleManagerImpl.java:60)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$3.compute(CodeStyleManagerImpl.java:318)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$3.compute(CodeStyleManagerImpl.java:315)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:116)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.adjustLineIndent(CodeStyleManagerImpl.java:315)
    at com.intellij.codeInsight.editorActions.EnterHandler$DoEnterAction.run(EnterHandler.java:423)
    at com.intellij.codeInsight.editorActions.EnterHandler.executeWriteActionInner(EnterHandler.java:170)
    at com.intellij.codeInsight.editorActions.EnterHandler.access$000(EnterHandler.java:53)
    at com.intellij.codeInsight.editorActions.EnterHandler$1.run(EnterHandler.java:75)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect$2.compute(PostprocessReformattingAspect.java:107)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:116)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:104)
    at com.intellij.codeInsight.editorActions.EnterHandler.executeWriteAction(EnterHandler.java:72)
    at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:64)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
    at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.doExecute(EditorWriteActionHandler.java:47)
    at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:125)
    at com.intellij.codeInsight.template.impl.editorActions.EnterHandler.executeWriteAction(EnterHandler.java:54)
    at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:64)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
    at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.doExecute(EditorWriteActionHandler.java:47)
    at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:125)
    at cursive.repl.toolwindow.actions.REPLEnterAction.doExecute(REPLEnterAction.java:31)
    at com.intellij.openapi.editor.actionSystem.EditorActionHandler$1.perform(EditorActionHandler.java:120)
    at com.intellij.openapi.editor.impl.CaretModelImpl$3.run(CaretModelImpl.java:354)
    at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:425)
    at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:348)
    at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:117)
    at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:83)
    at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)
    at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:94)
    at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:68)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$3.performAction(IdeKeyEventDispatcher.java:564)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:611)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:463)
    at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:206)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:493)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)



Invalid formatting blocks:empty block
Start offset:1446 end offset:1446
Affected text fragment:[1426,1446] - 'nsducer-same-result)'
File text:(1446)
'(ns trtest.core-test
  (:require [clojure.test :refer :all]
            [clojure.test.check :as check]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]
            [clojure.test.check.clojure-test :as ctest]))


(def gen-action
  (gen/one-of
    [(gen/tuple (gen/return 'take) gen/pos-int)
     (gen/tuple (gen/return 'drop) gen/pos-int)]))

(def gen-actions
  (gen/vector gen-action))

(def gen-coll
  (gen/vector gen/int))

(defn apply-action
  [kind coll [action & params]]
  (apply (get-in actions [action kind]) params))

(defmacro apply-as-seq
  [coll actions]
  (if (seq actions)
     `(let [[action# & actions#] ~actions]
       (apply-as-seq (list ~@(first actions) ~coll)
       )
     `~coll))

  ;; actions: [[take 5] [drop 10] [map odd?]]
;; output with coll:
;;(map odd? (drop 10 (take 5 coll)))

(defn apply-as-xf
  [coll actions])

(defn seq-and-transducer-same-result
  [coll actions]
  (let [s (apply-as-seq coll actions)
        t (apply-as-xf coll actions)]
    (if (= s t)
      true
      (throw (ex-info "Applied actions to coll as seq and transducer and got different results."
                      {:coll coll
                       :actions actions
                       :s s
                       :t t})))))

(ctest/defspec seq-and-transducer
               5
               (prop/for-all* [gen-actions gen-coll])
               seq-and-transducer-same-result)'
model (class com.intellij.psi.formatter.FormattingDocumentModelImpl): com.intellij.psi.formatter.FormattingDocumentModelImpl@4ddc4eadPsi Tree:
Root ClojureFile(0,1446)
  ClNs(0,265)
    PsiElement(()('(')(0,1)
    ClSymbol(1,3)
      PsiElement(Symbol token)('ns')(1,3)
    PsiWhiteSpace(' ')(3,4)
    ClSymbol(4,20)
      PsiElement(Symbol token)('trtest.core-test')(4,20)
    PsiWhiteSpace('\n  ')(20,23)
    ClList(23,264)
      PsiElement(()('(')(23,24)
      ClKeyword(24,32)
        PsiElement(key)(':require')(24,32)
      PsiWhiteSpace(' ')(32,33)
      ClVector(33,59)
        PsiElement([)('[')(33,34)
        ClSymbol(34,46)
          PsiElement(Symbol token)('clojure.test')(34,46)
        PsiWhiteSpace(' ')(46,47)
        ClKeyword(47,53)
          PsiElement(key)(':refer')(47,53)
        PsiWhiteSpace(' ')(53,54)
        ClKeyword(54,58)
          PsiElement(key)(':all')(54,58)
        PsiElement(])(']')(58,59)
      PsiWhiteSpace('\n            ')(59,72)
      ClVector(72,102)
        PsiElement([)('[')(72,73)
        ClSymbol(73,91)
          PsiElement(Symbol token)('clojure.test.check')(73,91)
        PsiWhiteSpace(' ')(91,92)
        ClKeyword(92,95)
          PsiElement(key)(':as')(92,95)
        PsiWhiteSpace(' ')(95,96)
        ClSymbol(96,101)
          PsiElement(Symbol token)('check')(96,101)
        PsiElement(])(']')(101,102)
      PsiWhiteSpace('\n            ')(102,115)
      ClVector(115,154)
        PsiElement([)('[')(115,116)
        ClSymbol(116,145)
          PsiElement(Symbol token)('clojure.test.check.generators')(116,145)
        PsiWhiteSpace(' ')(145,146)
        ClKeyword(146,149)
          PsiElement(key)(':as')(146,149)
        PsiWhiteSpace(' ')(149,150)
        ClSymbol(150,153)
          PsiElement(Symbol token)('gen')(150,153)
        PsiElement(])(']')(153,154)
      PsiWhiteSpace('\n            ')(154,167)
      ClVector(167,207)
        PsiElement([)('[')(167,168)
        ClSymbol(168,197)
          PsiElement(Symbol token)('clojure.test.check.properties')(168,197)
        PsiWhiteSpace(' ')(197,198)
        ClKeyword(198,201)
          PsiElement(key)(':as')(198,201)
        PsiWhiteSpace(' ')(201,202)
        ClSymbol(202,206)
          PsiElement(Symbol token)('prop')(202,206)
        PsiElement(])(']')(206,207)
      PsiWhiteSpace('\n            ')(207,220)
      ClVector(220,263)
        PsiElement([)('[')(220,221)
        ClSymbol(221,252)
          PsiElement(Symbol token)('clojure.test.check.clojure-test')(221,252)
        PsiWhiteSpace(' ')(252,253)
        ClKeyword(253,256)
          PsiElement(key)(':as')(253,256)
        PsiWhiteSpace(' ')(256,257)
        ClSymbol(257,262)
          PsiElement(Symbol token)('ctest')(257,262)
        PsiElement(])(']')(262,263)
      PsiElement())(')')(263,264)
    PsiElement())(')')(264,265)
  PsiWhiteSpace('\n\n\n')(265,268)
  ClList(268,396)
    PsiElement(()('(')(268,269)
    ClSymbol(269,272)
      PsiElement(Symbol token)('def')(269,272)
    PsiWhiteSpace(' ')(272,273)
    ClSymbol(273,283)
      PsiElement(Symbol token)('gen-action')(273,283)
    PsiWhiteSpace('\n  ')(283,286)
    ClList(286,395)
      PsiElement(()('(')(286,287)
      ClSymbol(287,297)
        ClSymbol(287,290)
          PsiElement(Symbol token)('gen')(287,290)
        PsiElement(ns separator)('/')(290,291)
        PsiElement(Symbol token)('one-of')(291,297)
      PsiWhiteSpace('\n    ')(297,302)
      ClVector(302,394)
        PsiElement([)('[')(302,303)
        ClList(303,345)
          PsiElement(()('(')(303,304)
          ClSymbol(304,313)
            ClSymbol(304,307)
              PsiElement(Symbol token)('gen')(304,307)
            PsiElement(ns separator)('/')(307,308)
            PsiElement(Symbol token)('tuple')(308,313)
          PsiWhiteSpace(' ')(313,314)
          ClList(314,332)
            PsiElement(()('(')(314,315)
            ClSymbol(315,325)
              ClSymbol(315,318)
                PsiElement(Symbol token)('gen')(315,318)
              PsiElement(ns separator)('/')(318,319)
              PsiElement(Symbol token)('return')(319,325)
            PsiWhiteSpace(' ')(325,326)
            ClQuotedForm(326,331)
              PsiElement(')(''')(326,327)
              ClSymbol(327,331)
                PsiElement(Symbol token)('take')(327,331)
            PsiElement())(')')(331,332)
          PsiWhiteSpace(' ')(332,333)
          ClSymbol(333,344)
            ClSymbol(333,336)
              PsiElement(Symbol token)('gen')(333,336)
            PsiElement(ns separator)('/')(336,337)
            PsiElement(Symbol token)('pos-int')(337,344)
          PsiElement())(')')(344,345)
        PsiWhiteSpace('\n     ')(345,351)
        ClList(351,393)
          PsiElement(()('(')(351,352)
          ClSymbol(352,361)
            ClSymbol(352,355)
              PsiElement(Symbol token)('gen')(352,355)
            PsiElement(ns separator)('/')(355,356)
            PsiElement(Symbol token)('tuple')(356,361)
          PsiWhiteSpace(' ')(361,362)
          ClList(362,380)
            PsiElement(()('(')(362,363)
            ClSymbol(363,373)
              ClSymbol(363,366)
                PsiElement(Symbol token)('gen')(363,366)
              PsiElement(ns separator)('/')(366,367)
              PsiElement(Symbol token)('return')(367,373)
            PsiWhiteSpace(' ')(373,374)
            ClQuotedForm(374,379)
              PsiElement(')(''')(374,375)
              ClSymbol(375,379)
                PsiElement(Symbol token)('drop')(375,379)
            PsiElement())(')')(379,380)
          PsiWhiteSpace(' ')(380,381)
          ClSymbol(381,392)
            ClSymbol(381,384)
              PsiElement(Symbol token)('gen')(381,384)
            PsiElement(ns separator)('/')(384,385)
            PsiElement(Symbol token)('pos-int')(385,392)
          PsiElement())(')')(392,393)
        PsiElement(])(']')(393,394)
      PsiElement())(')')(394,395)
    PsiElement())(')')(395,396)
  PsiWhiteSpace('\n\n')(396,398)
  ClList(398,441)
    PsiElement(()('(')(398,399)
    ClSymbol(399,402)
      PsiElement(Symbol token)('def')(399,402)
    PsiWhiteSpace(' ')(402,403)
    ClSymbol(403,414)
      PsiElement(Symbol token)('gen-actions')(403,414)
    PsiWhiteSpace('\n  ')(414,417)
    ClList(417,440)
      PsiElement(()('(')(417,418)
      ClSymbol(418,428)
        ClSymbol(418,421)
          PsiElement(Symbol token)('gen')(418,421)
        PsiElement(ns separator)('/')(421,422)
        PsiElement(Symbol token)('vector')(422,428)
      PsiWhiteSpace(' ')(428,429)
      ClSymbol(429,439)
        PsiElement(Symbol token)('gen-action')(429,439)
      PsiElement())(')')(439,440)
    PsiElement())(')')(440,441)
  PsiWhiteSpace('\n\n')(441,443)
  ClList(443,480)
    PsiElement(()('(')(443,444)
    ClSymbol(444,447)
      PsiElement(Symbol token)('def')(444,447)
    PsiWhiteSpace(' ')(447,448)
    ClSymbol(448,456)
      PsiElement(Symbol token)('gen-coll')(448,456)
    PsiWhiteSpace('\n  ')(456,459)
    ClList(459,479)
      PsiElement(()('(')(459,460)
      ClSymbol(460,470)
        ClSymbol(460,463)
          PsiElement(Symbol token)('gen')(460,463)
        PsiElement(ns separator)('/')(463,464)
        PsiElement(Symbol token)('vector')(464,470)
      PsiWhiteSpace(' ')(470,471)
      ClSymbol(471,478)
        ClSymbol(471,474)
          PsiElement(Symbol token)('gen')(471,474)
        PsiElement(ns separator)('/')(474,475)
        PsiElement(Symbol token)('int')(475,478)
      PsiElement())(')')(478,479)
    PsiElement())(')')(479,480)
  PsiWhiteSpace('\n\n')(480,482)
  ClList(482,581)
    PsiElement(()('(')(482,483)
    ClSymbol(483,487)
      PsiElement(Symbol token)('defn')(483,487)
    PsiWhiteSpace(' ')(487,488)
    ClSymbol(488,500)
      PsiElement(Symbol token)('apply-action')(488,500)
    PsiWhiteSpace('\n  ')(500,503)
    ClVector(503,532)
      PsiElement([)('[')(503,504)
      ClSymbol(504,508)
        PsiElement(Symbol token)('kind')(504,508)
      PsiWhiteSpace(' ')(508,509)
      ClSymbol(509,513)
        PsiElement(Symbol token)('coll')(509,513)
      PsiWhiteSpace(' ')(513,514)
      ClVector(514,531)
        PsiElement([)('[')(514,515)
        ClSymbol(515,521)
          PsiElement(Symbol token)('action')(515,521)
        PsiWhiteSpace(' ')(521,522)
        ClSymbol(522,523)
          PsiElement(Symbol token)('&')(522,523)
        PsiWhiteSpace(' ')(523,524)
        ClSymbol(524,530)
          PsiElement(Symbol token)('params')(524,530)
        PsiElement(])(']')(530,531)
      PsiElement(])(']')(531,532)
    PsiWhiteSpace('\n  ')(532,535)
    ClList(535,580)
      PsiElement(()('(')(535,536)
      ClSymbol(536,541)
        PsiElement(Symbol token)('apply')(536,541)
      PsiWhiteSpace(' ')(541,542)
      ClList(542,572)
        PsiElement(()('(')(542,543)
        ClSymbol(543,549)
          PsiElement(Symbol token)('get-in')(543,549)
        PsiWhiteSpace(' ')(549,550)
        ClSymbol(550,557)
          PsiElement(Symbol token)('actions')(550,557)
        PsiWhiteSpace(' ')(557,558)
        ClVector(558,571)
          PsiElement([)('[')(558,559)
          ClSymbol(559,565)
            PsiElement(Symbol token)('action')(559,565)
          PsiWhiteSpace(' ')(565,566)
          ClSymbol(566,570)
            PsiElement(Symbol token)('kind')(566,570)
          PsiElement(])(']')(570,571)
        PsiElement())(')')(571,572)
      PsiWhiteSpace(' ')(572,573)
      ClSymbol(573,579)
        PsiElement(Symbol token)('params')(573,579)
      PsiElement())(')')(579,580)
    PsiElement())(')')(580,581)
  PsiWhiteSpace('\n\n')(581,583)
  ClList(583,1446)
    PsiElement(()('(')(583,584)
    ClSymbol(584,592)
      PsiElement(Symbol token)('defmacro')(584,592)
    PsiWhiteSpace(' ')(592,593)
    ClSymbol(593,605)
      PsiElement(Symbol token)('apply-as-seq')(593,605)
    PsiWhiteSpace('\n  ')(605,608)
    ClVector(608,622)
      PsiElement([)('[')(608,609)
      ClSymbol(609,613)
        PsiElement(Symbol token)('coll')(609,613)
      PsiWhiteSpace(' ')(613,614)
      ClSymbol(614,621)
        PsiElement(Symbol token)('actions')(614,621)
      PsiElement(])(']')(621,622)
    PsiWhiteSpace('\n  ')(622,625)
    ClList(625,760)
      PsiElement(()('(')(625,626)
      ClSymbol(626,628)
        PsiElement(Symbol token)('if')(626,628)
      PsiWhiteSpace(' ')(628,629)
      ClList(629,642)
        PsiElement(()('(')(629,630)
        ClSymbol(630,633)
          PsiElement(Symbol token)('seq')(630,633)
        PsiWhiteSpace(' ')(633,634)
        ClSymbol(634,641)
          PsiElement(Symbol token)('actions')(634,641)
        PsiElement())(')')(641,642)
      PsiWhiteSpace('\n     ')(642,648)
      ClBackQuotedExpression(backquoted expression)(648,759)
        PsiElement(`)('`')(648,649)
        ClList(649,759)
          PsiElement(()('(')(649,650)
          ClSymbol(650,653)
            PsiElement(Symbol token)('let')(650,653)
          PsiWhiteSpace(' ')(653,654)
          ClVector(654,685)
            PsiElement([)('[')(654,655)
            ClVector(655,675)
              PsiElement([)('[')(655,656)
              ClSymbol(656,663)
                PsiElement(Symbol token)('action#')(656,663)
              PsiWhiteSpace(' ')(663,664)
              ClSymbol(664,665)
                PsiElement(Symbol token)('&')(664,665)
              PsiWhiteSpace(' ')(665,666)
              ClSymbol(666,674)
                PsiElement(Symbol token)('actions#')(666,674)
              PsiElement(])(']')(674,675)
            PsiWhiteSpace(' ')(675,676)
            ClTilda(~expression)(676,684)
              PsiElement(~)('~')(676,677)
              ClSymbol(677,684)
                PsiElement(Symbol token)('actions')(677,684)
            PsiElement(])(']')(684,685)
          PsiWhiteSpace('\n       ')(685,693)
          ClList(693,746)
            PsiElement(()('(')(693,694)
            ClSymbol(694,706)
              PsiElement(Symbol token)('apply-as-seq')(694,706)
            PsiWhiteSpace(' ')(706,707)
            ClList(707,737)
              PsiElement(()('(')(707,708)
              ClSymbol(708,712)
                PsiElement(Symbol token)('list')(708,712)
              PsiWhiteSpace(' ')(712,713)
              ClTildaAt(~@expression)(713,730)
                PsiElement(~@)('~@')(713,715)
                ClList(715,730)
                  PsiElement(()('(')(715,716)
                  ClSymbol(716,721)
                    PsiElement(Symbol token)('first')(716,721)
                  PsiWhiteSpace(' ')(721,722)
                  ClSymbol(722,729)
                    PsiElement(Symbol token)('actions')(722,729)
                  PsiElement())(')')(729,730)
              PsiWhiteSpace(' ')(730,731)
              ClTilda(~expression)(731,736)
                PsiElement(~)('~')(731,732)
                ClSymbol(732,736)
                  PsiElement(Symbol token)('coll')(732,736)
              PsiElement())(')')(736,737)
            PsiWhiteSpace('\n       ')(737,745)
            PsiElement())(')')(745,746)
          PsiWhiteSpace('\n     ')(746,752)
          ClBackQuotedExpression(backquoted expression)(752,758)
            PsiElement(`)('`')(752,753)
            ClTilda(~expression)(753,758)
              PsiElement(~)('~')(753,754)
              ClSymbol(754,758)
                PsiElement(Symbol token)('coll')(754,758)
          PsiElement())(')')(758,759)
      PsiElement())(')')(759,760)
    PsiWhiteSpace('\n\n  ')(760,764)
    PsiComment(line comment)(';; actions: [[take 5] [drop 10] [map odd?]]')(764,807)
    PsiWhiteSpace('\n')(807,808)
    PsiComment(line comment)(';; output with coll:')(808,828)
    PsiWhiteSpace('\n')(828,829)
    PsiComment(line comment)(';;(map odd? (drop 10 (take 5 coll)))')(829,865)
    PsiWhiteSpace('\n\n')(865,867)
    ClList(867,902)
      PsiElement(()('(')(867,868)
      ClSymbol(868,872)
        PsiElement(Symbol token)('defn')(868,872)
      PsiWhiteSpace(' ')(872,873)
      ClSymbol(873,884)
        PsiElement(Symbol token)('apply-as-xf')(873,884)
      PsiWhiteSpace('\n  ')(884,887)
      ClVector(887,901)
        PsiElement([)('[')(887,888)
        ClSymbol(888,892)
          PsiElement(Symbol token)('coll')(888,892)
        PsiWhiteSpace(' ')(892,893)
        ClSymbol(893,900)
          PsiElement(Symbol token)('actions')(893,900)
        PsiElement(])(']')(900,901)
      PsiElement())(')')(901,902)
    PsiWhiteSpace('\n\n')(902,904)
    ClList(904,1293)
      PsiElement(()('(')(904,905)
      ClSymbol(905,909)
        PsiElement(Symbol token)('defn')(905,909)
      PsiWhiteSpace(' ')(909,910)
      ClSymbol(910,940)
        PsiElement(Symbol token)('seq-and-transducer-same-result')(910,940)
      PsiWhiteSpace('\n  ')(940,943)
      ClVector(943,957)
        PsiElement([)('[')(943,944)
        ClSymbol(944,948)
          PsiElement(Symbol token)('coll')(944,948)
        PsiWhiteSpace(' ')(948,949)
        ClSymbol(949,956)
          PsiElement(Symbol token)('actions')(949,956)
        PsiElement(])(']')(956,957)
      PsiWhiteSpace('\n  ')(957,960)
      ClList(960,1292)
        PsiElement(()('(')(960,961)
        ClSymbol(961,964)
          PsiElement(Symbol token)('let')(961,964)
        PsiWhiteSpace(' ')(964,965)
        ClVector(965,1033)
          PsiElement([)('[')(965,966)
          ClSymbol(966,967)
            PsiElement(Symbol token)('s')(966,967)
          PsiWhiteSpace(' ')(967,968)
          ClList(968,995)
            PsiElement(()('(')(968,969)
            ClSymbol(969,981)
              PsiElement(Symbol token)('apply-as-seq')(969,981)
            PsiWhiteSpace(' ')(981,982)
            ClSymbol(982,986)
              PsiElement(Symbol token)('coll')(982,986)
            PsiWhiteSpace(' ')(986,987)
            ClSymbol(987,994)
              PsiElement(Symbol token)('actions')(987,994)
            PsiElement())(')')(994,995)
          PsiWhiteSpace('\n        ')(995,1004)
          ClSymbol(1004,1005)
            PsiElement(Symbol token)('t')(1004,1005)
          PsiWhiteSpace(' ')(1005,1006)
          ClList(1006,1032)
            PsiElement(()('(')(1006,1007)
            ClSymbol(1007,1018)
              PsiElement(Symbol token)('apply-as-xf')(1007,1018)
            PsiWhiteSpace(' ')(1018,1019)
            ClSymbol(1019,1023)
              PsiElement(Symbol token)('coll')(1019,1023)
            PsiWhiteSpace(' ')(1023,1024)
            ClSymbol(1024,1031)
              PsiElement(Symbol token)('actions')(1024,1031)
            PsiElement())(')')(1031,1032)
          PsiElement(])(']')(1032,1033)
        PsiWhiteSpace('\n    ')(1033,1038)
        ClList(1038,1291)
          PsiElement(()('(')(1038,1039)
          ClSymbol(1039,1041)
            PsiElement(Symbol token)('if')(1039,1041)
          PsiWhiteSpace(' ')(1041,1042)
          ClList(1042,1049)
            PsiElement(()('(')(1042,1043)
            ClSymbol(1043,1044)
              PsiElement(Symbol token)('=')(1043,1044)
            PsiWhiteSpace(' ')(1044,1045)
            ClSymbol(1045,1046)
              PsiElement(Symbol token)('s')(1045,1046)
            PsiWhiteSpace(' ')(1046,1047)
            ClSymbol(1047,1048)
              PsiElement(Symbol token)('t')(1047,1048)
            PsiElement())(')')(1048,1049)
          PsiWhiteSpace('\n      ')(1049,1056)
          ClLiteral(1056,1060)
            PsiElement(true)('true')(1056,1060)
          PsiWhiteSpace('\n      ')(1060,1067)
          ClList(1067,1290)
            PsiElement(()('(')(1067,1068)
            ClSymbol(1068,1073)
              PsiElement(Symbol token)('throw')(1068,1073)
            PsiWhiteSpace(' ')(1073,1074)
            ClList(1074,1289)
              PsiElement(()('(')(1074,1075)
              ClSymbol(1075,1082)
                PsiElement(Symbol token)('ex-info')(1075,1082)
              PsiWhiteSpace(' ')(1082,1083)
              ClLiteral(1083,1157)
                PsiElement(string literal)('"Applied actions to coll as seq and transducer and got different results."')(1083,1157)
              PsiWhiteSpace('\n                      ')(1157,1180)
              ClMap(1180,1288)
                PsiElement({)('{')(1180,1181)
                ClKeyword(1181,1186)
                  PsiElement(key)(':coll')(1181,1186)
                PsiWhiteSpace(' ')(1186,1187)
                ClSymbol(1187,1191)
                  PsiElement(Symbol token)('coll')(1187,1191)
                PsiWhiteSpace('\n                       ')(1191,1215)
                ClKeyword(1215,1223)
                  PsiElement(key)(':actions')(1215,1223)
                PsiWhiteSpace(' ')(1223,1224)
                ClSymbol(1224,1231)
                  PsiElement(Symbol token)('actions')(1224,1231)
                PsiWhiteSpace('\n                       ')(1231,1255)
                ClKeyword(1255,1257)
                  PsiElement(key)(':s')(1255,1257)
                PsiWhiteSpace(' ')(1257,1258)
                ClSymbol(1258,1259)
                  PsiElement(Symbol token)('s')(1258,1259)
                PsiWhiteSpace('\n                       ')(1259,1283)
                ClKeyword(1283,1285)
                  PsiElement(key)(':t')(1283,1285)
                PsiWhiteSpace(' ')(1285,1286)
                ClSymbol(1286,1287)
                  PsiElement(Symbol token)('t')(1286,1287)
                PsiElement(})('}')(1287,1288)
              PsiElement())(')')(1288,1289)
            PsiElement())(')')(1289,1290)
          PsiElement())(')')(1290,1291)
        PsiElement())(')')(1291,1292)
      PsiElement())(')')(1292,1293)
    PsiWhiteSpace('\n\n')(1293,1295)
    ClList(1295,1446)
      PsiElement(()('(')(1295,1296)
      ClSymbol(1296,1309)
        ClSymbol(1296,1301)
          PsiElement(Symbol token)('ctest')(1296,1301)
        PsiElement(ns separator)('/')(1301,1302)
        PsiElement(Symbol token)('defspec')(1302,1309)
      PsiWhiteSpace(' ')(1309,1310)
      ClSymbol(1310,1328)
        PsiElement(Symbol token)('seq-and-transducer')(1310,1328)
      PsiWhiteSpace('\n               ')(1328,1344)
      ClLiteral(1344,1345)
        PsiElement(long literal)('5')(1344,1345)
      PsiWhiteSpace('\n               ')(1345,1361)
      ClList(1361,1399)
        PsiElement(()('(')(1361,1362)
        ClSymbol(1362,1375)
          ClSymbol(1362,1366)
            PsiElement(Symbol token)('prop')(1362,1366)
          PsiElement(ns separator)('/')(1366,1367)
          PsiElement(Symbol token)('for-all*')(1367,1375)
        PsiWhiteSpace(' ')(1375,1376)
        ClVector(1376,1398)
          PsiElement([)('[')(1376,1377)
          ClSymbol(1377,1388)
            PsiElement(Symbol token)('gen-actions')(1377,1388)
          PsiWhiteSpace(' ')(1388,1389)
          ClSymbol(1389,1397)
            PsiElement(Symbol token)('gen-coll')(1389,1397)
          PsiElement(])(']')(1397,1398)
        PsiElement())(')')(1398,1399)
      PsiWhiteSpace('\n               ')(1399,1415)
      ClSymbol(1415,1445)
        PsiElement(Symbol token)('seq-and-transducer-same-result')(1415,1445)
      PsiElement())(')')(1445,1446)
    ClojureErrorElement(Error: Expected ')')(1446,1446)
      <empty list>
@cursive-ide
Copy link
Owner

Wow, that's what I call an error report. I hope this never happens on clojure.core!

There are some problems with formatting right now, I'm trying to work around a bug in IntelliJ - see #517. I'm hoping to get this fixed for the next build.

@cursive-ide cursive-ide added this to the 0.1.40 milestone Oct 15, 2014
@puredanger
Copy link
Author

Sorry, I was going to come back and add a little context if I could reproduce. :) I managed to make it happen many more times unintentionally but in a practiced way.

I'm mostly switched over to Cursive now for my main editor. The key mappings helped a lot!

Thanks...

On Oct 15, 2014, at 5:38 PM, cursiveclojure notifications@github.com wrote:

Wow, that's what I call an error report. I hope this never happens on clojure.core!

There are some problems with formatting right now, I'm trying to work around a bug in IntelliJ - see #517. I'm hoping to get this fixed for the next build.


Reply to this email directly or view it on GitHub.

@cursive-ide
Copy link
Owner

Hehe, no, I was referring to the fact that the error message in the log has the entire file and the AST. I can't take credit for that though, that's IntelliJ.

It's odd that you see this so much and no-one else has reported it - formatting issues normally come out very quickly. But I should be able to reproduce with the AST from the error message, with any luck. Seriously, I had no idea formatting code was so hard.

Glad the key mappings helped, let me know if you're missing anything!

@puredanger
Copy link
Author

I started seeing that formatting error only after updating to the latest
version btw.

On Wed, Oct 15, 2014 at 6:37 PM, cursiveclojure notifications@github.com
wrote:

Hehe, no, I was referring to the fact that the error message in the log
has the entire file and the AST. I can't take credit for that though,
that's IntelliJ.

It's odd that you see this so much and no-one else has reported it -
formatting issues normally come out very quickly. But I should be able to
reproduce with the AST from the error message, with any luck. Seriously, I
had no idea formatting code was so hard.

Glad the key mappings helped, let me know if you're missing anything!


Reply to this email directly or view it on GitHub
#544 (comment)
.

@cursive-ide
Copy link
Owner

Thanks. Yeah, I've been fiddling with it recently to try to work around the platform bug.

@mbachrach
Copy link

I've been seeing this, too, although I don't have such a wonderful bug report:

2:21:51 PM Invalid ranges during formatting in Language: Clojure: Invalid ranges during formatting in Language: Clojure
2:21:56 PM Invalid ranges during formatting in Language: Clojure: Invalid ranges during formatting in Language: Clojure
screen shot 2014-10-16 at 8 36 10 pm

thanks for the hard work: cursive is excellent

@cursive-ide
Copy link
Owner

You're welcome! I'm glad you're enjoying it.

You can probably find an equivalently wonderful bug report in your log, Help->Show log in Finder/Explorer. Note that it does seem to include your whole source file, so mailing it to cursive@cursiveclojure.com might be a better idea than pasting it here if it's confidential or very long.

@blerou
Copy link

blerou commented Oct 17, 2014

I've been also experiencing the same formatting problem since 0.1.39 upgrade.

I'm using Idea CE 13.1.5 (IC-135.1289)

Invalid ranges during formatting in Language: Clojure
java.lang.Throwable
    at com.intellij.diagnostic.LogMessageEx.error(LogMessageEx.java:134)
    at com.intellij.formatting.InitialInfoBuilder.assertInvalidRanges(InitialInfoBuilder.java:409)
    at com.intellij.formatting.InitialInfoBuilder.doProcessSimpleBlock(InitialInfoBuilder.java:306)
    at com.intellij.formatting.InitialInfoBuilder.processSimpleBlock(InitialInfoBuilder.java:273)
    at com.intellij.formatting.InitialInfoBuilder.buildFrom(InitialInfoBuilder.java:173)
    at com.intellij.formatting.InitialInfoBuilder.doIteration(InitialInfoBuilder.java:235)
    at com.intellij.formatting.InitialInfoBuilder.iteration(InitialInfoBuilder.java:109)
    at com.intellij.formatting.FormatProcessor$WrapBlocksState.doIteration(FormatProcessor.java:1313)
    at com.intellij.formatting.FormatProcessor$State.iteration(FormatProcessor.java:1246)
    at com.intellij.formatting.FormatProcessor.iteration(FormatProcessor.java:244)
    at com.intellij.formatting.FormatterImpl.buildProcessorAndWrapBlocks(FormatterImpl.java:434)
    at com.intellij.formatting.FormatterImpl.adjustLineIndent(FormatterImpl.java:371)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$5.doPerform(CodeStyleManagerImpl.java:358)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$5.doPerform(CodeStyleManagerImpl.java:355)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerRunnable.perform(CodeStyleManagerRunnable.java:112)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.doAdjustLineIndentByOffset(CodeStyleManagerImpl.java:355)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.access$500(CodeStyleManagerImpl.java:60)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$3.compute(CodeStyleManagerImpl.java:318)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$3.compute(CodeStyleManagerImpl.java:315)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:116)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.adjustLineIndent(CodeStyleManagerImpl.java:315)
    at com.intellij.codeInsight.editorActions.TypedHandler$1$1.run(TypedHandler.java:626)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
    at com.intellij.codeInsight.editorActions.TypedHandler$1.perform(TypedHandler.java:615)
    at com.intellij.openapi.editor.impl.CaretModelImpl$3.run(CaretModelImpl.java:355)
    at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:426)
    at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:349)
    at com.intellij.codeInsight.editorActions.TypedHandler.indentBrace(TypedHandler.java:576)
    at com.intellij.codeInsight.editorActions.TypedHandler.indentOpenedParenth(TypedHandler.java:568)
    at com.intellij.codeInsight.editorActions.TypedHandler.execute(TypedHandler.java:236)
    at com.intellij.codeInsight.template.impl.editorActions.SpaceHandler.execute(SpaceHandler.java:48)
    at plugin.typing.ClojureTypedHandler.execute(typing.clj:384)
    at com.intellij.execution.impl.ConsoleViewImpl$MyTypedHandler.execute(ConsoleViewImpl.java:1229)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand$1.run(TypedAction.java:133)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:984)
    at com.intellij.openapi.editor.actionSystem.TypedAction$TypingCommand.run(TypedAction.java:127)
    at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:124)
    at com.intellij.openapi.editor.actionSystem.TypedAction.actionPerformed(TypedAction.java:107)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:1026)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:5189)
    at com.intellij.openapi.editor.impl.EditorImpl$11.keyTyped(EditorImpl.java:871)
    at java.awt.Component.processKeyEvent(Component.java:6471)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2828)
    at java.awt.Component.processEvent(Component.java:6293)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4872)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1887)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:899)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:727)
    at java.awt.Component.dispatchEventImpl(Component.java:4742)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:697)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:494)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:335)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

@cursive-ide
Copy link
Owner

This error was caused by the temporary error element inserted into the AST on a parse error (ClojureErrorElement in Alex's AST above), so it was caused by formatting a file with a syntax error in it. I've fixed this in the time-honoured tradition by rewriting the entire relevant module - in my defence, that's been on my to-do list for a long time now.

@mbachrach
Copy link

thanks!

On Oct 20, 2014, at 5:30 PM, cursiveclojure notifications@github.com wrote:

This error was caused by the temporary error element inserted into the AST on a parse error (ClojureErrorElement in Alex's AST above), so it was caused by formatting a file with a syntax error in it. I've fixed this in the time-honoured tradition by rewriting the entire relevant module - in my defence, that's been on my to-do list for a long time now.


Reply to this email directly or view it on GitHub #544 (comment).

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

4 participants