Skip to content

Commit 6057da8

Browse files
committed
add :file
1 parent 26d3384 commit 6057da8

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/main/clojure/cljs/externs.clj

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
[com.google.javascript.rhino
1919
Node Token JSTypeExpression]))
2020

21+
(def ^:dynamic *source-file* nil)
22+
2123
;; ------------------------------------------------------------------------------
2224
;; Externs Parsing
2325

@@ -51,7 +53,8 @@
5153
{:tag 'Function
5254
:ret-tag (get-type* (.getReturnType info))
5355
:arglists (list (into [] (map symbol (.getParameterNames info))))})))
54-
{:line (.getLineno node)}
56+
{:file *source-file*
57+
:line (.getLineno node)}
5558
(when-let [doc (.getOriginalCommentString info)]
5659
{:doc doc}))))))
5760

@@ -114,25 +117,26 @@
114117
(defmethod parse-extern-node :default [node])
115118

116119
(defn parse-externs [^SourceFile source-file]
117-
(let [^CompilerOptions compiler-options
118-
(doto (CompilerOptions.)
119-
(.setParseJsDocDocumentation
120-
Config$JsDocParsing/INCLUDE_DESCRIPTIONS_WITH_WHITESPACE))
121-
closure-compiler
122-
(doto
123-
(let [compiler (com.google.javascript.jscomp.Compiler.)]
124-
(com.google.javascript.jscomp.Compiler/setLoggingLevel Level/WARNING)
125-
compiler)
126-
(.init (list source-file) '() compiler-options))
127-
js-ast (JsAst. source-file)
128-
^Node root (.getAstRoot js-ast closure-compiler)]
129-
(loop [nodes (.children root)
130-
externs []]
131-
(if (empty? nodes)
132-
externs
133-
(let [node (first nodes)
134-
new-extern (parse-extern-node node)]
135-
(recur (rest nodes) (concat externs new-extern)))))))
120+
(binding [*source-file* (.getName source-file)]
121+
(let [^CompilerOptions compiler-options
122+
(doto (CompilerOptions.)
123+
(.setParseJsDocDocumentation
124+
Config$JsDocParsing/INCLUDE_DESCRIPTIONS_WITH_WHITESPACE))
125+
closure-compiler
126+
(doto
127+
(let [compiler (com.google.javascript.jscomp.Compiler.)]
128+
(com.google.javascript.jscomp.Compiler/setLoggingLevel Level/WARNING)
129+
compiler)
130+
(.init (list source-file) '() compiler-options))
131+
js-ast (JsAst. source-file)
132+
^Node root (.getAstRoot js-ast closure-compiler)]
133+
(loop [nodes (.children root)
134+
externs []]
135+
(if (empty? nodes)
136+
externs
137+
(let [node (first nodes)
138+
new-extern (parse-extern-node node)]
139+
(recur (rest nodes) (concat externs new-extern))))))))
136140

137141
(defn index-externs [externs]
138142
(reduce

0 commit comments

Comments
 (0)