Permalink
Browse files

in parse-ns, don't include line information in the case of the

destination file not existing. In compile-file we now reset the
namespace for the file so that the user will get errors about names that
have changed under incremental recompilation.
  • Loading branch information...
1 parent d01222f commit 7153b297756a8cd36b249f5c023e29cd6ad78b6a @swannodette swannodette committed Sep 29, 2013
Showing with 21 additions and 16 deletions.
  1. +21 −16 src/clj/cljs/compiler.clj
View
@@ -874,14 +874,16 @@
(if (= (:op ast) :ns)
(let [ns-name (:name ast)
deps (merge (:uses ast) (:requires ast))]
- {:ns (or ns-name 'cljs.user)
- :provides [ns-name]
- :requires (if (= ns-name 'cljs.core)
- (set (vals deps))
- (conj (set (vals deps)) 'cljs.core))
- :file dest
- :source-file src
- :lines (-> dest io/reader line-seq count)})
+ (merge
+ {:ns (or ns-name 'cljs.user)
+ :provides [ns-name]
+ :requires (if (= ns-name 'cljs.core)
+ (set (vals deps))
+ (conj (set (vals deps)) 'cljs.core))
+ :file dest
+ :source-file src}
+ (when (.exists ^java.io.File dest)
+ {:lines (-> (io/reader dest) line-seq count)})))
(recur (rest forms))))))))]
(reset! ana/namespaces namespaces')
ret))
@@ -909,14 +911,17 @@
dest-file (io/file dest)]
(if (.exists src-file)
(try
- (if (or (requires-compilation? src-file dest-file) (:source-map opts))
- (do (mkdirs dest-file)
- (compile-file* src-file dest-file opts))
- (let [ns-info (parse-ns src-file dest-file opts)]
- (when-not (contains? @ana/namespaces (:ns ns-info))
- (with-core-cljs
- (ana/analyze-file src-file)))
- ns-info))
+ (let [{ns :ns :as ns-info} (parse-ns src-file dest-file opts)]
+ (if (or (requires-compilation? src-file dest-file) (:source-map opts))
+ (do (mkdirs dest-file)
+ (when (contains? @ana/namespaces ns)
+ (swap! ana/namespaces dissoc ns))
+ (compile-file* src-file dest-file opts))
+ (do
+ (when-not (contains? @ana/namespaces ns)
+ (with-core-cljs
+ (ana/analyze-file src-file)))
+ ns-info)))
(catch Exception e
(throw (ex-info (str "failed compiling file:" src) {:file src} e))))
(throw (java.io.FileNotFoundException. (str "The file " src " does not exist.")))))))

0 comments on commit 7153b29

Please sign in to comment.