|
18 | 18 | [com.google.javascript.rhino
|
19 | 19 | Node Token JSTypeExpression]))
|
20 | 20 |
|
| 21 | +(def ^:dynamic *source-file* nil) |
| 22 | + |
21 | 23 | ;; ------------------------------------------------------------------------------
|
22 | 24 | ;; Externs Parsing
|
23 | 25 |
|
|
51 | 53 | {:tag 'Function
|
52 | 54 | :ret-tag (get-type* (.getReturnType info))
|
53 | 55 | :arglists (list (into [] (map symbol (.getParameterNames info))))})))
|
54 |
| - {:line (.getLineno node)} |
| 56 | + {:file *source-file* |
| 57 | + :line (.getLineno node)} |
55 | 58 | (when-let [doc (.getOriginalCommentString info)]
|
56 | 59 | {:doc doc}))))))
|
57 | 60 |
|
|
114 | 117 | (defmethod parse-extern-node :default [node])
|
115 | 118 |
|
116 | 119 | (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)))))))) |
136 | 140 |
|
137 | 141 | (defn index-externs [externs]
|
138 | 142 | (reduce
|
|
0 commit comments