(defn parse-externs [^SourceFile source-file]
(let [^CompilerOptions compiler-options (CompilerOptions.)
closure-compiler
(doto
(let [compiler (com.google.javascript.jscomp.Compiler.)]
(com.google.javascript.jscomp.Compiler/setLoggingLevel Level/WARNING)
compiler)
(.init (list source-file) '() compiler-options))
js-ast (JsAst. source-file)
^Node root (.getAstRoot js-ast closure-compiler)]
(loop [nodes (.children root)
externs []]
(if (empty? nodes)
externs
(let [node (first nodes)
new-extern (parse-extern-node node)]
(recur (rest nodes) (concat externs new-extern)))))))