Skip to content

Commit

Permalink
Remove correct expression testing in REPL, because user input can to …
Browse files Browse the repository at this point in the history
…contain any symbols
  • Loading branch information
alhimik45 committed Dec 8, 2013
1 parent 84620da commit 9b9c3f8
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/clooj/repl/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@
(swap! (:items repl-history) replace-first
(utils/get-text-str (app :repl-in-text-area))))

(defn correct-expression? [cmd]
(let [rdr (-> cmd StringReader. PushbackReader.)]
(try (while (read rdr nil nil))
true
(catch IllegalArgumentException e true) ;explicitly show duplicate keys etc.
(catch Exception e false))))

(defn read-string-at [source-text start-line]
`(let [sr# (java.io.StringReader. (str (apply str (repeat ~start-line "\n"))
~source-text))
Expand Down Expand Up @@ -145,7 +138,7 @@
(let [ta (app :doc-text-area)
region (selected-region ta)
txt (:text region)]
(if-not (and txt (correct-expression? txt))
(if-not txt
(.setText (app :arglist-label) "Malformed expression")
(let [line (.getLineOfOffset ta (:start region))]
(send-to-repl app txt (relative-file app) line false)))))
Expand Down Expand Up @@ -241,10 +234,8 @@
txt
caret-pos)))))
submit #(when-let [txt (.getText ta-in)]
(if (correct-expression? txt)
(do (send-to-repl app txt false)
(.setText ta-in ""))
(.setText (app :arglist-label) "Malformed expression")))
(do (send-to-repl app txt false)
(.setText ta-in "")))
at-top #(zero? (.getLineOfOffset ta-in (get-caret-pos)))
at-bottom #(= (.getLineOfOffset ta-in (get-caret-pos))
(.getLineOfOffset ta-in (.. ta-in getText length)))
Expand Down

0 comments on commit 9b9c3f8

Please sign in to comment.