[Git][clojure-team/tools-namespace-clojure][upstream] New upstream version 1.3.0

Rob Browning (@rlb) gitlab at salsa.debian.org
Mon Dec 26 23:33:10 GMT 2022



Rob Browning pushed to branch upstream at Debian Clojure Maintainers / tools-namespace-clojure


Commits:
04ab1e51 by Rob Browning at 2022-12-26T13:18:05-06:00
New upstream version 1.3.0
- - - - -


20 changed files:

- .gitignore
- + CHANGES.md
- CONTRIBUTING.md
- + LICENSE
- README.md
- + deps.edn
- pom.xml
- src/main/clojure/clojure/tools/namespace.clj
- src/main/clojure/clojure/tools/namespace/dependency.clj → src/main/clojure/clojure/tools/namespace/dependency.cljc
- src/main/clojure/clojure/tools/namespace/dir.clj
- src/main/clojure/clojure/tools/namespace/file.clj
- src/main/clojure/clojure/tools/namespace/find.clj
- src/main/clojure/clojure/tools/namespace/parse.clj → src/main/clojure/clojure/tools/namespace/parse.cljc
- src/main/clojure/clojure/tools/namespace/repl.clj
- src/main/clojure/clojure/tools/namespace/track.clj → src/main/clojure/clojure/tools/namespace/track.cljc
- + src/test/clojure/clojure/tools/namespace/dir_test.clj
- + src/test/clojure/clojure/tools/namespace/find_test.clj
- src/test/clojure/clojure/tools/namespace/move_test.clj
- src/test/clojure/clojure/tools/namespace/parse_test.clj
- + src/test/clojure/clojure/tools/namespace/test_helpers.clj


Changes:

=====================================
.gitignore
=====================================
@@ -1 +1,4 @@
 target
+.cpcache
+.idea/
+*.iml


=====================================
CHANGES.md
=====================================
@@ -0,0 +1,290 @@
+# Change Log for tools.namespace
+
+## 1.x series
+
+## Version 1.3.0
+
+  * Fix [TNS-56](https://clojure.atlassian.net/browse/TNS-56): Don't consider :as-alias as a load dependency for namespaces
+
+## Version 1.2.0
+
+  * Fix [TNS-51](https://clojure.atlassian.net/browse/TNS-51): Support namespaces as strings in require statements for CLJS
+  * Fix [TNS-57](https://clojure.atlassian.net/browse/TNS-57): Support :require-macros for CLJS namespaces
+
+## Version 1.1.1
+ 
+  * [tools.reader] version 1.3.6
+
+### Version 1.1.0
+
+  * [tools.reader] version 1.3.4
+
+### Version 1.0.0
+
+  * No changes from previous
+
+## 0.3.x series
+
+### Version 0.3.1
+
+  * Fix [TNS-54](https://clojure.atlassian.net/browse/TNS-54): update
+    java.classpath dependency to fix issues on Java 9+
+
+  * [java.classpath] version 0.3.0
+
+  * [tools.reader] version 1.3.2
+
+### Version 0.3.0
+
+  * Released as non-alpha, still some known issues to fix in future.
+
+### Version 0.3.0-alpha4 on 25-Apr-2017
+
+  * Fix [TNS-47]: Always use canonical directory paths when searching
+    for files.
+
+### Version 0.3.0-alpha3 on 5-Jan-2016
+
+  * Ignore `:require-macros` and `:use-macros` when parsing namespace
+    dependencies. This is a change in behavior from previous 0.3
+    alphas and is a more robust fix for [TNS-38]. tools.namespace
+    currently only models one dependency graph at a time, so it treats
+    Clojure and ClojureScript as separate worlds and will not attempt
+    to analyze dependency relationships which cross that boundary.
+
+  * Fix [TNS-40]: do not catch exceptions in `c.t.n.file`. Instead,
+    catch and ignore only syntax exceptions (identified by `ex-data`
+    from [tools.reader]). This is a change in behavior from
+    0.3.0-alpha2 and 0.2. It should have minimal impact on users but
+    make some errors (such as an incompatible version of tools.reader)
+    more obvious.
+
+  * Known bugs not yet fixed: [TNS-42] When the same namespace is
+    defined in both `.clj` and `.cljc` files, dependencies may be read
+    from either, when it should prefer the `.clj` file.
+
+### Version 0.3.0-alpha2 on 13-Nov-2015
+
+  * Fix [TNS-38]: ignore circular dependency from `.cljs` file to
+    `.clj` file in `:require-macros`
+
+  * [tools.reader] version 0.10.0
+
+  * [java.classpath] version 0.2.3
+
+  * Add `clojure.tools.namespace.parse/name-from-ns-decl`
+
+### Version 0.3.0-alpha1 on 14-Aug-2015
+
+  * **Partial ClojureScript Support** [TNS-35]
+
+      * Platform-neutral namespaces were converted to conditional-read
+        (`.cljc`) files: c.t.n.dependency, c.t.n.track, and
+        c.t.n.parse. These namespaces can be used in ClojureScript
+        programs.
+
+      * Added support for finding, parsing, and analyzing
+        ClojureScript source files (`.cljs` and `.cljc`) in
+        c.t.n.file, c.t.n.parse, c.t.n.dir, and c.t.n.find with
+        optional "platform" arguments. These namespaces still only
+        **run** on the Clojure(JVM) platform.
+
+      * Reloading and interactive features remain Clojure(JVM) only
+        for now: c.t.n.move, c.t.n.reload, and c.t.n.repl
+
+      * Uses [tools.reader] for platform-independent parsing and
+        conditional-reader support.
+
+  * Minimum Clojure version is 1.7.0
+
+  * Breaking change: `c.t.n.parse/read-ns-decl` no longer returns
+    `nil` on syntax errors. Instead, exceptions are allowed to
+    propagate up from tools.reader. This change only affects code
+    which calls `read-ns-decl` directly. c.t.n.file and c.t.n.find
+    will catch and ignore reader exeptions when trying to read
+    namespace declarations.
+
+  * Enhancement [TNS-36]: Use java.classpath for better JVM classpath
+    resolution
+
+  * Possible breaking change: parse/read-ns-decl does not capture
+    reader errors
+
+  * Some definitions deprecated; see source code or Var metadata for
+    details.
+
+  * Adds dependency on [java.classpath]
+
+
+
+## 0.2.x series
+
+### Version 0.2.11 on 19-Jun-2015
+
+  * [TNS-34] Allow reader conditionals in parsed source files
+
+### Version 0.2.10 on 26-Feb-2015
+
+  * Widen existing functions to handle both clj and cljc files in
+    advance of reader conditional support in Clojure 1.7.
+
+### Version 0.2.9 on 31-Jan-2015
+
+  * Fix [TNS-20]: Undefined 'unload' order after namespaces are first
+    added to an new, empty tracker.
+
+  * Improvement [TNS-21]: Support `ns` clauses which use vectors
+    instead of lists for clauses, contrary to docs.
+
+  * Improvement [TNS-32]: Support `ns` clauses which use symbols as
+    clause heads instead of keywords, contrary to docs.
+
+### Version 0.2.8 on 19-Dec-2014
+
+  * Improvement [TNS-31]: Specific error message when `:after` symbol
+    passed to `refresh` cannot be resolved.
+
+  * Fix [TNS-26]: namespace alias recovery after failed reload did not
+    work due to local binding shadowing global Var
+
+### Version 0.2.7 on 19-Sept-2014
+
+  * [Revert bad commit](https://github.com/clojure/tools.namespace/commit/27194f2edfe3f5f9e1343f993beca4b43f0bafe8)
+    mistakenly included in 0.2.6 which could cause the tracker's
+    'unload' order to be incorrect. See discussion at [TNS-20].
+
+### **BROKEN** Version 0.2.6 on 7-Sept-2014 **DO NOT USE**
+
+  * `clojure.tools.namespace.parse/read-ns-decl` asserts that its
+    argument is a PushbackReader, instead of silently returning nil
+
+  * Fix [TNS-22]: broken `clojure.string/replace` with Windows path
+    separator
+
+### Version 0.2.5 on 15-Jul-2014
+
+  * New `clojure.tools.namespace.repl/clear` empties the state of the
+    REPL dependency tracker. This can help repair the dependency
+    tracker after a failed load or a circular dependency error.
+
+  * Enhancement [TNS-19]: `deps-from-ns-decl` should return an empty
+    set instead of nil. This may be a breaking change for some but
+    is consistent with the original docstring.
+
+  * Enhancement [TNS-18]: Compute transitive dependencies in linear time..
+
+  * Enhancement [TNS-17]: The `ns` form doesn't need to be the first
+    top-level form in a file.
+
+  * Fix [TNS-16]: Don't depend on specific hash ordering in tests.
+    Exposed by new hash functions in Clojure 1.6.0.
+
+  * Fix [TNS-15]: Handle spaces in classpath directories (old
+    `clojure.tools.namespace`)
+
+  * Fix [TNS-12]: Duplicate definition of `jar-file?`
+
+### Version 0.2.4 on 19-Jul-2013
+
+  * Fix [TNS-10]: Forbid circular dependency when a namespace depends
+    on itself
+
+  * Fix [TNS-9] and [TNS-11]: support other prefix-list forms
+
+  * Fix [TNS-8]: In `move-ns`, do not modify files whose contents does
+    not change
+
+### Version 0.2.3 on 01-Apr-2013
+
+  * New: Attempt recovery of aliases/refers in REPL after error
+
+### Version 0.2.2 on 14-Dec-2012
+
+  * New: Add `:after` option to `refresh`
+
+  * New: Add `clojure.tools.namespace.move`
+
+  * Fix [TNS-4], reflection warnings
+
+### Version 0.2.1 on 26-Oct-2012
+
+  * Fix: Restore deprecated 0.1.x APIs in `clojure.tools.namespace`
+
+  * Fix [TNS-3], actually use `refresh-dirs`
+
+### **BROKEN** Version 0.2.0 on 05-Oct-2012 **DO NOT USE**
+
+  * Not recommended for use: this release introduced breaking API
+    changes (renaming core namespaces and functions) without
+    backwards-compatibility. Applications with dependencies on both
+    the 0.2.x and 0.1.x APIs cannot use this version.
+
+  * New dependency tracking & reloading features
+
+  * Eliminate dependency on [java.classpath]
+
+
+
+## 0.1.x series
+
+### Version 0.1.3 on 24-Apr-2012
+
+  * Fix [TNS-1] Workaround for Clojure 1.2 reader bug
+
+### Version 0.1.2 on 10-Feb-2012
+
+  * Fix: Eliminate reflection warnings
+
+### Version 0.1.1 on 18-May-2011
+
+### Version 0.1.0 on 24-Apr-2011
+
+  * Source-compatible with clojure.contrib.find-namespaces in old
+    clojure-contrib 1.2.0
+
+
+[TNS-1]: http://dev.clojure.org/jira/browse/TNS-1
+[TNS-3]: http://dev.clojure.org/jira/browse/TNS-3
+[TNS-4]: http://dev.clojure.org/jira/browse/TNS-4
+[TNS-8]: http://dev.clojure.org/jira/browse/TNS-8
+[TNS-9]: http://dev.clojure.org/jira/browse/TNS-9
+[TNS-10]: http://dev.clojure.org/jira/browse/TNS-10
+[TNS-11]: http://dev.clojure.org/jira/browse/TNS-11
+[TNS-12]: http://dev.clojure.org/jira/browse/TNS-12
+[TNS-15]: http://dev.clojure.org/jira/browse/TNS-15
+[TNS-16]: http://dev.clojure.org/jira/browse/TNS-16
+[TNS-17]: http://dev.clojure.org/jira/browse/TNS-17
+[TNS-18]: http://dev.clojure.org/jira/browse/TNS-18
+[TNS-19]: http://dev.clojure.org/jira/browse/TNS-19
+[TNS-20]: http://dev.clojure.org/jira/browse/TNS-20
+[TNS-21]: http://dev.clojure.org/jira/browse/TNS-21
+[TNS-22]: http://dev.clojure.org/jira/browse/TNS-22
+[TNS-23]: http://dev.clojure.org/jira/browse/TNS-23
+[TNS-24]: http://dev.clojure.org/jira/browse/TNS-24
+[TNS-25]: http://dev.clojure.org/jira/browse/TNS-25
+[TNS-26]: http://dev.clojure.org/jira/browse/TNS-26
+[TNS-27]: http://dev.clojure.org/jira/browse/TNS-27
+[TNS-28]: http://dev.clojure.org/jira/browse/TNS-28
+[TNS-29]: http://dev.clojure.org/jira/browse/TNS-29
+[TNS-30]: http://dev.clojure.org/jira/browse/TNS-30
+[TNS-31]: http://dev.clojure.org/jira/browse/TNS-31
+[TNS-32]: http://dev.clojure.org/jira/browse/TNS-32
+[TNS-33]: http://dev.clojure.org/jira/browse/TNS-33
+[TNS-34]: http://dev.clojure.org/jira/browse/TNS-34
+[TNS-35]: http://dev.clojure.org/jira/browse/TNS-35
+[TNS-36]: http://dev.clojure.org/jira/browse/TNS-36
+[TNS-37]: http://dev.clojure.org/jira/browse/TNS-37
+[TNS-38]: http://dev.clojure.org/jira/browse/TNS-38
+[TNS-39]: http://dev.clojure.org/jira/browse/TNS-39
+[TNS-40]: http://dev.clojure.org/jira/browse/TNS-40
+[TNS-41]: http://dev.clojure.org/jira/browse/TNS-41
+[TNS-42]: http://dev.clojure.org/jira/browse/TNS-42
+[TNS-43]: http://dev.clojure.org/jira/browse/TNS-43
+[TNS-44]: http://dev.clojure.org/jira/browse/TNS-44
+[TNS-45]: http://dev.clojure.org/jira/browse/TNS-45
+[TNS-46]: http://dev.clojure.org/jira/browse/TNS-46
+[TNS-47]: http://dev.clojure.org/jira/browse/TNS-47
+
+[java.classpath]: https://github.com/clojure/java.classpath
+[tools.reader]: https://github.com/clojure/tools.reader
+[JEP 122]: http://openjdk.java.net/jeps/122


=====================================
CONTRIBUTING.md
=====================================
@@ -3,12 +3,10 @@ This is a [Clojure contrib] project.
 Under the Clojure contrib [guidelines], this project cannot accept
 pull requests. All patches must be submitted via [JIRA].
 
-See [Contributing] and the [FAQ] on the Clojure development [wiki] for
+See [Contributing] on the Clojure website for
 more information on how to contribute.
 
-[Clojure contrib]: http://dev.clojure.org/display/doc/Clojure+Contrib
-[Contributing]: http://dev.clojure.org/display/community/Contributing
-[FAQ]: http://dev.clojure.org/display/community/Contributing+FAQ
-[JIRA]: http://dev.clojure.org/jira/browse/TNS
-[guidelines]: http://dev.clojure.org/display/community/Guidelines+for+Clojure+Contrib+committers
-[wiki]: http://dev.clojure.org/
+[Clojure contrib]: https://clojure.org/community/contrib_libs
+[Contributing]: https://clojure.org/community/contributing
+[JIRA]: https://clojure.atlassian.net/browse/TNS
+[guidelines]: https://clojure.org/community/contrib_howto


=====================================
LICENSE
=====================================
@@ -0,0 +1,205 @@
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
+LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
+CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation
+   distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+    i) changes to the Program, and
+   ii) additions to the Program;
+
+   where such changes and/or additions to the Program originate from and are
+   distributed by that particular Contributor. A Contribution 'originates'
+   from a Contributor if it was added to the Program by such Contributor
+   itself or anyone acting on such Contributor's behalf. Contributions do not
+   include additions to the Program which: (i) are separate modules of
+   software distributed in conjunction with the Program under their own
+   license agreement, and (ii) are not derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are
+necessarily infringed by the use or sale of its Contribution alone or when
+combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this
+Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement,
+including all Contributors.
+
+2. GRANT OF RIGHTS
+  a) Subject to the terms of this Agreement, each Contributor hereby grants
+     Recipient a non-exclusive, worldwide, royalty-free copyright license to
+     reproduce, prepare derivative works of, publicly display, publicly
+     perform, distribute and sublicense the Contribution of such Contributor,
+     if any, and such derivative works, in source code and object code form.
+  b) Subject to the terms of this Agreement, each Contributor hereby grants
+     Recipient a non-exclusive, worldwide, royalty-free patent license under
+     Licensed Patents to make, use, sell, offer to sell, import and otherwise
+     transfer the Contribution of such Contributor, if any, in source code and
+     object code form. This patent license shall apply to the combination of
+     the Contribution and the Program if, at the time the Contribution is
+     added by the Contributor, such addition of the Contribution causes such
+     combination to be covered by the Licensed Patents. The patent license
+     shall not apply to any other combinations which include the Contribution.
+     No hardware per se is licensed hereunder.
+  c) Recipient understands that although each Contributor grants the licenses
+     to its Contributions set forth herein, no assurances are provided by any
+     Contributor that the Program does not infringe the patent or other
+     intellectual property rights of any other entity. Each Contributor
+     disclaims any liability to Recipient for claims brought by any other
+     entity based on infringement of intellectual property rights or
+     otherwise. As a condition to exercising the rights and licenses granted
+     hereunder, each Recipient hereby assumes sole responsibility to secure
+     any other intellectual property rights needed, if any. For example, if a
+     third party patent license is required to allow Recipient to distribute
+     the Program, it is Recipient's responsibility to acquire that license
+     before distributing the Program.
+  d) Each Contributor represents that to its knowledge it has sufficient
+     copyright rights in its Contribution, if any, to grant the copyright
+     license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under
+its own license agreement, provided that:
+
+  a) it complies with the terms and conditions of this Agreement; and
+  b) its license agreement:
+      i) effectively disclaims on behalf of all Contributors all warranties
+         and conditions, express and implied, including warranties or
+         conditions of title and non-infringement, and implied warranties or
+         conditions of merchantability and fitness for a particular purpose;
+     ii) effectively excludes on behalf of all Contributors all liability for
+         damages, including direct, indirect, special, incidental and
+         consequential damages, such as lost profits;
+    iii) states that any provisions which differ from this Agreement are
+         offered by that Contributor alone and not by any other party; and
+     iv) states that source code for the Program is available from such
+         Contributor, and informs licensees how to obtain it in a reasonable
+         manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+  a) it must be made available under this Agreement; and
+  b) a copy of this Agreement must be included with each copy of the Program.
+     Contributors may not remove or alter any copyright notices contained
+     within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution,
+if
+any, in a manner that reasonably allows subsequent Recipients to identify the
+originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with
+respect to end users, business partners and the like. While this license is
+intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner
+which does not create potential liability for other Contributors. Therefore,
+if a Contributor includes the Program in a commercial product offering, such
+Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any losses,
+damages and costs (collectively "Losses") arising from claims, lawsuits and
+other legal actions brought by a third party against the Indemnified
+Contributor to the extent caused by the acts or omissions of such Commercial
+Contributor in connection with its distribution of the Program in a commercial
+product offering. The obligations in this section do not apply to any claims
+or Losses relating to any actual or alleged intellectual property
+infringement. In order to qualify, an Indemnified Contributor must:
+a) promptly notify the Commercial Contributor in writing of such claim, and
+b) allow the Commercial Contributor to control, and cooperate with the
+Commercial Contributor in, the defense and any related settlement
+negotiations. The Indemnified Contributor may participate in any such claim at
+its own expense.
+
+For example, a Contributor might include the Program in a commercial product
+offering, Product X. That Contributor is then a Commercial Contributor. If
+that Commercial Contributor then makes performance claims, or offers
+warranties related to Product X, those performance claims and warranties are
+such Commercial Contributor's responsibility alone. Under this section, the
+Commercial Contributor would have to defend claims against the other
+Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
+IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
+Recipient is solely responsible for determining the appropriateness of using
+and distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to the
+risks and costs of program errors, compliance with applicable laws, damage to
+or loss of data, programs or equipment, and unavailability or interruption of
+operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
+CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
+LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
+EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of the
+remainder of the terms of this Agreement, and without further action by the
+parties hereto, such provision shall be reformed to the minimum extent
+necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Program itself
+(excluding combinations of the Program with other software or hardware)
+infringes such Recipient's patent(s), then such Recipient's rights granted
+under Section 2(b) shall terminate as of the date such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to
+comply with any of the material terms or conditions of this Agreement and does
+not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate,
+Recipient agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue
+and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in
+order to avoid inconsistency the Agreement is copyrighted and may only be
+modified in the following manner. The Agreement Steward reserves the right to
+publish new versions (including revisions) of this Agreement from time to
+time. No one other than the Agreement Steward has the right to modify this
+Agreement. The Eclipse Foundation is the initial Agreement Steward. The
+Eclipse Foundation may assign the responsibility to serve as the Agreement
+Steward to a suitable separate entity. Each new version of the Agreement will
+be given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version of the
+Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly
+stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
+licenses to the intellectual property of any Contributor under this Agreement,
+whether expressly, by implication, estoppel or otherwise. All rights in the
+Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the
+intellectual property laws of the United States of America. No party to this
+Agreement will bring a legal action under this Agreement more than one year
+after the cause of action arose. Each party waives its rights to a jury trial in
+any resulting litigation.
+
+


=====================================
README.md
=====================================
@@ -15,43 +15,53 @@ repositories.
 Releases and Dependency Information
 ----------------------------------------
 
-* [Latest stable release is 0.2.11](https://github.com/clojure/tools.namespace/tree/tools.namespace-0.2.11)
+This project follows the version scheme MAJOR.MINOR.PATCH where each component provides some relative indication of the size of the change, but does not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names).
 
-* [All Released Versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22tools.namespace%22)
+[Change Log](CHANGES.md)
 
-[Leiningen](http://leiningen.org/) dependency information:
+[All Released Versions](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22tools.namespace%22)
 
-    [org.clojure/tools.namespace "0.2.11"]
+### Stable Release ###
 
-[Maven](http://maven.apache.org/) dependency information:
+Latest stable release is [1.2.0](https://github.com/clojure/tools.namespace/tree/v1.2.0)
+
+[CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information:
+```clojure
+org.clojure/tools.namespace {:mvn/version "1.2.0"}
+```
+
+[Leiningen](https://leiningen.org/) stable dependency information:
+
+    [org.clojure/tools.namespace "1.2.0"]
+
+[Maven](https://maven.apache.org/) stable dependency information:
 
     <dependency>
       <groupId>org.clojure</groupId>
       <artifactId>tools.namespace</artifactId>
-      <version>0.2.11</version>
+      <version>1.2.0</version>
     </dependency>
 
-
 ### Development Snapshots ###
 
-* Git master branch is at **0.2.12-SNAPSHOT**
+Git master branch is at **1.2.1-SNAPSHOT**
 
-* [All Snapshot Versions](https://oss.sonatype.org/content/groups/public/org/clojure/tools.namespace/)
+[All Snapshot Versions](https://oss.sonatype.org/content/groups/public/org/clojure/tools.namespace/)
 
 Leiningen dependency information for development snapshots:
 
-    :dependencies [[org.clojure/tools.namespace "0.2.12-SNAPSHOT"]]
-    :repositories {"sonatype-oss-public"
-                   "https://oss.sonatype.org/content/groups/public/"}
+    :dependencies [[org.clojure/tools.namespace "1.2.1-SNAPSHOT"]]
+    :repositories [["sonatype-oss-public"
+                    "https://oss.sonatype.org/content/groups/public/"]]
 
-See also [Maven Settings and Repositories](http://dev.clojure.org/display/doc/Maven+Settings+and+Repositories) on dev.clojure.org.
+See also [Maven Settings and Repositories](https://clojure.org/releases/downloads#_using_clojure_snapshot_releases) on dev.clojure.org.
 
 
 
 Overview
 ----------------------------------------
 
-[API Documentation](http://clojure.github.com/tools.namespace/)
+[API Documentation](https://clojure.github.io/tools.namespace/)
 
 tools.namespace consists of several parts:
 
@@ -64,7 +74,7 @@ evaluate any code.
 
 **clojure.tools.namespace.find:** Utilities to search for Clojure
 namespaces on the filesystem, in directories or JAR files. Combined
-with [java.classpath](http://clojure.github.com/java.classpath/), it
+with [java.classpath](https://clojure.github.io/java.classpath/), it
 can search for namespaces on the Java classpath. This namespace
 contains most of the functions in clojure.tools.namespace version
 0.1.x.
@@ -88,6 +98,37 @@ your source files, so be careful.
 
 
 
+ClojureScript support
+-----------------------
+
+**New in version 0.3.0-alpha1**
+
+These namespaces are `.cljc` files usable from both Clojure(JVM) and
+ClojureScript:
+
+* c.t.n.dependency
+* c.t.n.track
+* c.t.n.parse
+
+These namespaces are usable on Clojure(JVM) only but can analyze both
+Clojure(JVM) and ClojureScript source files:
+
+* c.t.n.file
+* c.t.n.dir
+* c.t.n.find
+
+Most functions now take an optional "platform" argument, which is one
+of the constant values defined in c.t.n.find: `clj` or `cljs`. The
+default is `clj`.
+
+These namespaces are still Clojure(JVM) only: 
+
+* c.t.n.reload
+* c.t.n.repl
+* c.t.n.move.
+
+
+
 Reloading Code: Motivation
 ----------------------------
 
@@ -224,7 +265,7 @@ The "start" function should:
 The "stop" function should take the state returned by "start" as an
 argument and do the opposite:
 
-- Close or release stateful resourecs
+- Close or release stateful resources
 
 - Stop all background processes
 
@@ -353,11 +394,11 @@ definitions, especially references to things you created in the REPL.
 dependency tracker, do not store it in a namespace which gets
 reloaded.
 
-[AOT-compiled]: http://clojure.org/compilation
+[AOT-compiled]: https://clojure.org/reference/compilation
 [Ring]: https://github.com/ring-clojure/ring
 [ns-tracker]: https://github.com/weavejester/ns-tracker
-[ns]: http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/ns
-[require]: http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/require
+[ns]: https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/ns
+[require]: https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/require
 
 
 ### Warnings for Helper Functions
@@ -508,7 +549,7 @@ un/reloading those namespaces.
 
 Use this feature sparingly: it exists as a development-time
 convenience, not a work-around for code that is not reload-safe. Also,
-see the warnings about aliases, below. Aliases to reloaded namespaces
+see the [warnings about aliases](#warnings-for-aliases), below. Aliases to reloaded namespaces
 will break if the namespace *containing* the alias is not reloaded
 also.
 
@@ -521,181 +562,21 @@ mappings and aliases for namespaces with `disable-unload!` or
 Developer Information
 ----------------------------------------
 
+* [Change Log](CHANGES.md)
 * [GitHub project](https://github.com/clojure/tools.namespace)
-
-* [How to contribute](http://dev.clojure.org/display/community/Contributing)
-
-* [Bug Tracker](http://dev.clojure.org/jira/browse/TNS)
-
-* [Continuous Integration](http://build.clojure.org/job/tools.namespace/)
-
-* [Compatibility Test Matrix](http://build.clojure.org/job/tools.namespace-test-matrix/)
-
-
-
-Change Log
-----------------------------------------
-
-### Version 0.2.12-SNAPSHOT
-
-  * In development, current Git master branch
-
-### Version 0.2.11 on 19-Jun-2015
-
-  * [TNS-34] Allow reader conditionals in parsed source files
-
-### Version 0.2.10 on 26-Feb-2015
-
-  * Widen existing functions to handle both clj and cljc files in
-    advance of reader conditional support in Clojure 1.7.
-
-### Version 0.2.9 on 31-Jan-2015
-
-  * Fix [TNS-20]: Undefined 'unload' order after namespaces are first
-    added to an new, empty tracker.
-
-  * Improvement [TNS-21]: Support `ns` clauses which use vectors
-    instead of lists for clauses, contrary to docs.
-
-  * Improvement [TNS-32]: Support `ns` clauses which use symbols as
-    clause heads instead of keywords, contrary to docs.
-
-### Version 0.2.8 on 19-Dec-2014
-
-  * Improvement [TNS-31]: Specific error message when `:after` symbol
-    passed to `refresh` cannot be resolved.
-
-  * Fix [TNS-26]: namespace alias recovery after failed reload did not
-    work due to local binding shadowing global Var
-
-### Version 0.2.7 on 19-Sept-2014
-
-  * [Revert bad commit](https://github.com/clojure/tools.namespace/commit/27194f2edfe3f5f9e1343f993beca4b43f0bafe8)
-    mistakenly included in 0.2.6 which could cause the tracker's
-    'unload' order to be incorrect. See discussion at [TNS-20].
-
-### **BROKEN** Version 0.2.6 on 7-Sept-2014 **DO NOT USE**
-
-  * `clojure.tools.namespace.parse/read-ns-decl` asserts that its
-    argument is a PushbackReader, instead of silently returning nil
-
-  * Fix [TNS-22]: broken `clojure.string/replace` with Windows path
-    separator
-
-### Version 0.2.5 on 15-Jul-2014
-
-  * New `clojure.tools.namespace.repl/clear` empties the state of the
-    REPL dependency tracker. This can help repair the dependency
-    tracker after a failed load or a circular dependency error.
-
-  * Enhancement [TNS-19]: `deps-from-ns-decl` should return an empty
-    set instead of nil. This may be a breaking change for some but
-    is consistent with the original docstring.
-
-  * Enhancement [TNS-18]: Compute transitive dependencies in linear time..
-
-  * Enhancement [TNS-17]: The `ns` form doesn't need to be the first
-    top-level form in a file.
-
-  * Fix [TNS-16]: Don't depend on specific hash ordering in tests.
-    Exposed by new hash functions in Clojure 1.6.0.
-
-  * Fix [TNS-15]: Handle spaces in classpath directories (old
-    `clojure.tools.namespace`)
-
-  * Fix [TNS-12]: Duplicate definition of `jar-file?`
-
-### Version 0.2.4 on 19-Jul-2013
-
-  * Fix [TNS-10]: Forbid circular dependency when a namespace depends
-    on itself
-
-  * Fix [TNS-9] and [TNS-11]: support other prefix-list forms
-
-  * Fix [TNS-8]: In `move-ns`, do not modify files whose contents does
-    not change
-
-### Version 0.2.3 on 01-Apr-2013
-
-  * New: Attempt recovery of aliases/refers in REPL after error
-
-### Version 0.2.2 on 14-Dec-2012
-
-  * New: Add `:after` option to `refresh`
-
-  * New: Add `clojure.tools.namespace.move`
-
-  * Fix [TNS-4], reflection warnings
-
-### Version 0.2.1 on 26-Oct-2012
-
-  * Fix: Restore deprecated 0.1.x APIs in `clojure.tools.namespace`
-
-  * Fix [TNS-3], actually use `refresh-dirs`
-
-### Version 0.2.0 on 05-Oct-2012
-
-  * **Not recommended for use**: this release introduced breaking API
-    changes (renaming core namespaces and functions) without
-    backwards-compatibility. Applications with dependencies on both
-    the 0.2.x and 0.1.x APIs cannot use this version.
-
-  * New dependency tracking & reloading features
-
-  * Eliminate dependency on [java.classpath]
-
-### Version 0.1.3 on 24-Apr-2012
-
-  * Fix [TNS-1] Workaround for Clojure 1.2 reader bug
-
-### Version 0.1.2 on 10-Feb-2012
-
-  * Fix: Eliminate reflection warnings
-
-### Version 0.1.1 on 18-May-2011
-
-### Version 0.1.0 on 24-Apr-2011
-
-  * Source-compatible with clojure.contrib.find-namespaces in old
-    clojure-contrib 1.2.0
-
-[TNS-1]: http://dev.clojure.org/jira/browse/TNS-1
-[TNS-3]: http://dev.clojure.org/jira/browse/TNS-3
-[TNS-4]: http://dev.clojure.org/jira/browse/TNS-4
-[TNS-8]: http://dev.clojure.org/jira/browse/TNS-8
-[TNS-9]: http://dev.clojure.org/jira/browse/TNS-9
-[TNS-10]: http://dev.clojure.org/jira/browse/TNS-10
-[TNS-11]: http://dev.clojure.org/jira/browse/TNS-11
-[TNS-12]: http://dev.clojure.org/jira/browse/TNS-12
-[TNS-15]: http://dev.clojure.org/jira/browse/TNS-15
-[TNS-16]: http://dev.clojure.org/jira/browse/TNS-16
-[TNS-17]: http://dev.clojure.org/jira/browse/TNS-17
-[TNS-18]: http://dev.clojure.org/jira/browse/TNS-18
-[TNS-19]: http://dev.clojure.org/jira/browse/TNS-19
-[TNS-20]: http://dev.clojure.org/jira/browse/TNS-20
-[TNS-21]: http://dev.clojure.org/jira/browse/TNS-21
-[TNS-22]: http://dev.clojure.org/jira/browse/TNS-22
-[TNS-23]: http://dev.clojure.org/jira/browse/TNS-23
-[TNS-24]: http://dev.clojure.org/jira/browse/TNS-24
-[TNS-25]: http://dev.clojure.org/jira/browse/TNS-25
-[TNS-26]: http://dev.clojure.org/jira/browse/TNS-26
-[TNS-27]: http://dev.clojure.org/jira/browse/TNS-27
-[TNS-28]: http://dev.clojure.org/jira/browse/TNS-28
-[TNS-29]: http://dev.clojure.org/jira/browse/TNS-29
-[TNS-30]: http://dev.clojure.org/jira/browse/TNS-30
-[TNS-31]: http://dev.clojure.org/jira/browse/TNS-31
-[TNS-32]: http://dev.clojure.org/jira/browse/TNS-32
-[TNS-33]: http://dev.clojure.org/jira/browse/TNS-33
-[TNS-34]: http://dev.clojure.org/jira/browse/TNS-34
-[java.classpath]: https://github.com/clojure/java.classpath
-[JEP 122]: http://openjdk.java.net/jeps/122
+* [How to contribute](https://clojure.org/community/contributing)
+* [Bug Tracker](https://clojure.atlassian.net/browse/TNS)
+* [Continuous Integration](https://build.clojure.org/job/tools.namespace/)
+* [Compatibility Test Matrix](https://build.clojure.org/job/tools.namespace-test-matrix/)
 
 
 
 Copyright and License
 ----------------------------------------
 
-Copyright © 2012 Stuart Sierra All rights reserved. The use and
+Copyright © 2012-2021 Rich Hickey, Stuart Sierra, and contributors
+
+All rights reserved. The use and
 distribution terms for this software are covered by the
 [Eclipse Public License 1.0] which can be found in the file
 epl-v10.html at the root of this distribution. By using this software
@@ -703,4 +584,4 @@ in any fashion, you are agreeing to be bound by the terms of this
 license. You must not remove this notice, or any other, from this
 software.
 
-[Eclipse Public License 1.0]: http://opensource.org/licenses/eclipse-1.0.php
+[Eclipse Public License 1.0]: https://opensource.org/licenses/eclipse-1.0.php


=====================================
deps.edn
=====================================
@@ -0,0 +1,9 @@
+{:deps {org.clojure/tools.namespace {:local/root "." :deps/manifest :pom}}
+ :aliases
+ {:test
+  {:extra-paths ["src/test/clojure"]
+   :extra-deps {io.github.cognitect-labs/test-runner
+                {:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
+   ;; :main-opts ["-m" "cognitect.test-runner" "-d" "src/test/clojure"]
+   :exec-fn cognitect.test-runner.api/test
+   :exec-args {:dirs ["src/test/clojure"]}}}}


=====================================
pom.xml
=====================================
@@ -1,17 +1,37 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <artifactId>tools.namespace</artifactId>
-  <version>0.2.11</version>
-  <name>${artifactId}</name>
+  <version>1.3.0</version>
+  <name>tools.namespace</name>
 
   <parent>
     <groupId>org.clojure</groupId>
     <artifactId>pom.contrib</artifactId>
-    <version>0.1.2</version>
+    <version>1.1.0</version>
   </parent>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.clojure</groupId>
+      <artifactId>clojure</artifactId>
+      <version>${clojure.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.clojure</groupId>
+      <artifactId>java.classpath</artifactId>
+      <version>1.0.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.clojure</groupId>
+      <artifactId>tools.reader</artifactId>
+      <version>1.3.6</version>
+    </dependency>
+  </dependencies>
+
   <properties>
     <clojure.warnOnReflection>true</clojure.warnOnReflection>
+    <clojure.version>1.7.0</clojure.version>
   </properties>
 
   <developers>
@@ -24,6 +44,7 @@
     <connection>scm:git:git at github.com:clojure/tools.namespace.git</connection>
     <developerConnection>scm:git:git at github.com:clojure/tools.namespace.git</developerConnection>
     <url>git at github.com:clojure/tools.namespace.git</url>
-    <tag>tools.namespace-0.2.11</tag>
+    <tag>v1.3.0</tag>
   </scm>
+
 </project>


=====================================
src/main/clojure/clojure/tools/namespace.clj
=====================================
@@ -9,7 +9,9 @@
 (ns 
  ^{:author "Stuart Sierra",
    :doc "This namespace is DEPRECATED; most functions have been moved to
-  other namespaces"}
+  other namespaces"
+   :deprecated "0.2.1"
+   :added "0.1.0"}
  clojure.tools.namespace
  (:require [clojure.java.io :as io])
  (:import (java.io File FileReader BufferedReader PushbackReader
@@ -20,9 +22,11 @@
 ;;; Finding namespaces in a directory tree
 
 (defn clojure-source-file?
-  "DEPRECATED; trivial to implement locally
+  "DEPRECATED; moved to clojure.tools.namespace.file
 
   Returns true if file is a normal file with a .clj or .cljc extension."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^File file]
   (and (.isFile file)
        (or
@@ -34,6 +38,8 @@
 
   Searches recursively under dir for Clojure source files (.clj, .cljc).
   Returns a sequence of File objects, in breadth-first sort order."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^File dir]
   ;; Use sort by absolute path to get breadth-first search.
   (sort-by #(.getAbsolutePath ^File %)
@@ -43,6 +49,8 @@
   "DEPRECATED; moved to clojure.tools.namespace.parse
 
   Returns true if form is a (comment ...)"
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [form]
   (and (list? form) (= 'comment (first form))))
 
@@ -50,6 +58,8 @@
   "DEPRECATED; moved to clojure.tools.namespace.parse
 
   Returns true if form is a (ns ...) declaration."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [form]
   (and (list? form) (= 'ns (first form))))
 
@@ -60,6 +70,8 @@
   unevaluated form.  Returns nil if read fails or if a ns declaration
   cannot be found.  The ns declaration must be the first Clojure form
   in the file, except for (comment ...)  forms."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^PushbackReader rdr]
   (try
    (loop [] (let [form (doto (read rdr) str)]
@@ -75,6 +87,8 @@
   Attempts to read a (ns ...) declaration from file, and returns the
   unevaluated form.  Returns nil if read fails, or if the first form
   is not a ns declaration."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^File file]
   (with-open [rdr (PushbackReader. (BufferedReader. (FileReader. file)))]
     (read-ns-decl rdr)))
@@ -84,6 +98,8 @@
 
   Searches dir recursively for (ns ...) declarations in Clojure
   source files; returns the unevaluated ns declarations."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^File dir]
   (filter identity (map read-file-ns-decl (find-clojure-sources-in-dir dir))))
 
@@ -92,6 +108,8 @@
 
   Searches dir recursively for (ns ...) declarations in Clojure
   source files; returns the symbol names of the declared namespaces."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^File dir]
   (map second (find-ns-decls-in-dir dir)))
 
@@ -137,6 +155,8 @@
   "DEPRECATED; moved to clojure.tools.namespace.find
 
   Returns a sequence of filenames ending in .clj or .cljc found in the JAR file."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^JarFile jar-file]
   (filter #(or (.endsWith ^String % ".clj") (.endsWith ^String % ".cljc"))
           (filenames-in-jar jar-file)))
@@ -147,6 +167,8 @@
   Attempts to read a (ns ...) declaration from the named entry in the
   JAR file, and returns the unevaluated form.  Returns nil if the read
   fails, or if the first form is not a ns declaration."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^JarFile jarfile ^String entry-name]
   (with-open [rdr (PushbackReader.
                    (BufferedReader.
@@ -159,6 +181,8 @@
 
   Searches the JAR file for Clojure source files containing (ns ...)
   declarations; returns the unevaluated ns declarations."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^JarFile jarfile]
   (filter identity
           (map #(read-ns-decl-from-jarfile-entry jarfile %)
@@ -170,6 +194,8 @@
   Searches the JAR file for Clojure source files containing (ns ...)
   declarations.  Returns a sequence of the symbol names of the
   declared namespaces."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   [^JarFile jarfile]
   (map second (find-ns-decls-in-jarfile jarfile)))
 
@@ -182,7 +208,10 @@
 
   Searches CLASSPATH (both directories and JAR files) for Clojure
   source files containing (ns ...) declarations. Returns a sequence of
-  the unevaluated ns declaration forms." []
+  the unevaluated ns declaration forms."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
+  []
   (concat
    (mapcat find-ns-decls-in-dir (classpath-directories))
    (mapcat find-ns-decls-in-jarfile (classpath-jarfiles))))
@@ -195,5 +224,7 @@
   Searches CLASSPATH (both directories and JAR files) for Clojure
   source files containing (ns ...) declarations.  Returns a sequence
   of the symbol names of the declared namespaces."
+  {:deprecated "0.2.1"
+   :added "0.1.0"}
   []
   (map second (find-ns-decls-on-classpath)))


=====================================
src/main/clojure/clojure/tools/namespace/dependency.clj → src/main/clojure/clojure/tools/namespace/dependency.cljc
=====================================
@@ -86,8 +86,11 @@
   DependencyGraphUpdate
   (depend [graph node dep]
     (when (or (= node dep) (depends? graph dep node))
-      (throw (Exception. (str "Circular dependency between "
-                              (pr-str node) " and " (pr-str dep)))))
+      (throw (ex-info (str "Circular dependency between "
+                           (pr-str node) " and " (pr-str dep))
+                      {:reason ::circular-dependency
+                       :node node
+                       :dependency dep})))
     (MapDependencyGraph.
      (update-in dependencies [node] set-conj dep)
      (update-in dependents [dep] set-conj node)))
@@ -142,6 +145,10 @@
                (remove-node g' node)
                (clojure.set/union (set more) (set add)))))))
 
+(def ^:private max-number
+  #?(:clj Long/MAX_VALUE
+     :cljs js/Number.MAX_VALUE))
+
 (defn topo-comparator
   "Returns a comparator fn which produces a topological sort based on
   the dependencies in graph. Nodes not present in the graph will sort
@@ -149,6 +156,5 @@
   [graph]
   (let [pos (zipmap (topo-sort graph) (range))]
     (fn [a b]
-      (compare (get pos a Long/MAX_VALUE)
-               (get pos b Long/MAX_VALUE)))))
-
+      (compare (get pos a max-number)
+               (get pos b max-number)))))


=====================================
src/main/clojure/clojure/tools/namespace/dir.clj
=====================================
@@ -11,18 +11,20 @@
   file-modification timestamps"}
   clojure.tools.namespace.dir
   (:require [clojure.tools.namespace.file :as file]
+            [clojure.tools.namespace.find :as find]
             [clojure.tools.namespace.track :as track]
+            [clojure.java.classpath :refer [classpath-directories]]
             [clojure.java.io :as io]
             [clojure.set :as set]
             [clojure.string :as string])
   (:import (java.io File) (java.util.regex Pattern)))
 
-(defn- find-files [dirs]
+(defn- find-files [dirs platform]
   (->> dirs
        (map io/file)
+       (map #(.getCanonicalFile ^File %))
        (filter #(.exists ^File %))
-       (mapcat file-seq)
-       (filter file/clojure-file?)
+       (mapcat #(find/find-sources-in-dir % platform))
        (map #(.getCanonicalFile ^File %))))
 
 (defn- modified-files [tracker files]
@@ -31,43 +33,84 @@
 (defn- deleted-files [tracker files]
   (set/difference (::files tracker #{}) (set files)))
 
-(defn- update-files [tracker deleted modified]
+(defn- update-files [tracker deleted modified {:keys [read-opts]}]
   (let [now (System/currentTimeMillis)]
     (-> tracker
         (update-in [::files] #(if % (apply disj % deleted) #{}))
         (file/remove-files deleted)
         (update-in [::files] into modified)
-        (file/add-files modified)
+        (file/add-files modified read-opts)
         (assoc ::time now))))
 
-(defn- dirs-on-classpath []
-  (filter #(.isDirectory ^File %)
-          (map #(File. ^String %)
-               (string/split
-                (System/getProperty "java.class.path")
-                (Pattern/compile (Pattern/quote File/pathSeparator))))))
+(defn scan-files
+  "Scans files to find those which have changed since the last time
+  'scan-files' was run; updates the dependency tracker with
+  new/changed/deleted files.
 
-(defn scan
+  files is the collection of files to scan.
+
+  Optional third argument is map of options:
+
+    :platform  Either clj (default) or cljs, both defined in
+               clojure.tools.namespace.find, controls reader options for 
+               parsing files.
+
+    :add-all?  If true, assumes all extant files are modified regardless
+               of filesystem timestamps."
+  {:added "0.3.0"}
+  ([tracker files] (scan-files tracker files nil))
+  ([tracker files {:keys [platform add-all?]}]
+   (let [deleted (seq (deleted-files tracker files))
+         modified (if add-all?
+                    files
+                    (seq (modified-files tracker files)))]
+     (if (or deleted modified)
+       (update-files tracker deleted modified platform)
+       tracker))))
+
+(defn scan-dirs
   "Scans directories for files which have changed since the last time
-  'scan' was run; update the dependency tracker with
-  new/changed/deleted files.
+  'scan-dirs' or 'scan-files' was run; updates the dependency tracker
+  with new/changed/deleted files.
+
+  dirs is the collection of directories to scan, defaults to all
+  directories on Clojure's classpath.
+
+  Optional third argument is map of options:
+
+    :platform  Either clj (default) or cljs, both defined in 
+               clojure.tools.namespace.find, controls file extensions 
+               and reader options.
+
+    :add-all?  If true, assumes all extant files are modified regardless
+               of filesystem timestamps."
+  {:added "0.3.0"}
+  ([tracker] (scan-dirs tracker nil nil))
+  ([tracker dirs] (scan-dirs tracker dirs nil))
+  ([tracker dirs {:keys [platform add-all?] :as options}]
+   (let [ds (or (seq dirs) (classpath-directories))]
+     (scan-files tracker (find-files ds platform) options))))
+
+(defn scan
+  "DEPRECATED: replaced by scan-dirs.
+
+  Scans directories for Clojure (.clj, .cljc) source files which have
+  changed since the last time 'scan' was run; update the dependency
+  tracker with new/changed/deleted files.
 
   If no dirs given, defaults to all directories on the classpath."
+  {:added "0.2.0"
+   :deprecated "0.3.0"}
   [tracker & dirs]
-  (let [ds (or (seq dirs) (dirs-on-classpath))
-        files (find-files ds)
-        deleted (seq (deleted-files tracker files))
-        modified (seq (modified-files tracker files))]
-    (if (or deleted modified)
-      (update-files tracker deleted modified)
-      tracker)))
+  (scan-dirs tracker dirs {:platform find/clj}))
 
 (defn scan-all
-  "Scans directories for all Clojure source files and updates the
+  "DEPRECATED: replaced by scan-dirs.
+
+  Scans directories for all Clojure source files and updates the
   dependency tracker to reload files. If no dirs given, defaults to
   all directories on the classpath."
+  {:added "0.2.0"
+   :deprecated "0.3.0"}
   [tracker & dirs]
-  (let [ds (or (seq dirs) (dirs-on-classpath))
-        files (find-files ds)
-        deleted (seq (deleted-files tracker files))]
-    (update-files tracker deleted files)))
+  (scan-dirs tracker dirs {:platform find/clj :add-all? true}))


=====================================
src/main/clojure/clojure/tools/namespace/file.clj
=====================================
@@ -16,28 +16,53 @@
 
 (defn read-file-ns-decl
   "Attempts to read a (ns ...) declaration from file, and returns the
-  unevaluated form.  Returns nil if read fails, or if the first form
-  is not a ns declaration."
-  [file]
-  (with-open [rdr (PushbackReader. (io/reader file))]
-    (parse/read-ns-decl rdr)))
+  unevaluated form. Returns nil if ns declaration cannot be found.
+  read-opts is passed through to tools.reader/read."
+  ([file]
+   (read-file-ns-decl file nil))
+  ([file read-opts]
+   (with-open [rdr (PushbackReader. (io/reader file))]
+     (parse/read-ns-decl rdr read-opts))))
+
+(defn file-with-extension?
+  "Returns true if the java.io.File represents a file whose name ends
+  with one of the Strings in extensions."
+  {:added "0.3.0"}
+  [^java.io.File file extensions]
+  (and (.isFile file)
+       (let [name (.getName file)]
+         (some #(.endsWith name %) extensions))))
+
+(def ^{:added "0.3.0"}
+  clojure-extensions
+  "File extensions for Clojure (JVM) files."
+  (list ".clj" ".cljc"))
+
+(def ^{:added "0.3.0"}
+  clojurescript-extensions
+  "File extensions for ClojureScript files."
+  (list ".cljs" ".cljc"))
 
 (defn clojure-file?
-  "Returns true if the java.io.File represents a normal Clojure source
-  file."
+  "Returns true if the java.io.File represents a file which will be
+  read by the Clojure (JVM) compiler."
   [^java.io.File file]
-  (and (.isFile file)
-       (or
-         (.endsWith (.getName file) ".clj")
-         (.endsWith (.getName file) ".cljc"))))
+  (file-with-extension? file clojure-extensions))
+
+(defn clojurescript-file?
+  "Returns true if the java.io.File represents a file which will be
+  read by the ClojureScript compiler."
+  {:added "0.3.0"}
+  [^java.io.File file]
+  (file-with-extension? file clojurescript-extensions))
 
 ;;; Dependency tracker
 
-(defn- files-and-deps [files]
+(defn- files-and-deps [files read-opts]
   (reduce (fn [m file]
-            (if-let [decl (read-file-ns-decl file)]
+            (if-let [decl (read-file-ns-decl file read-opts)]
               (let [deps (parse/deps-from-ns-decl decl)
-                    name (second decl)]
+                    name (parse/name-from-ns-decl decl)]
                 (-> m
                     (assoc-in [:depmap name] deps)
                     (assoc-in [:filemap file] name)))
@@ -48,12 +73,15 @@
 
 (defn add-files
   "Reads ns declarations from files; returns an updated dependency
-  tracker with those files added."
-  [tracker files]
-  (let [{:keys [depmap filemap]} (files-and-deps files)]
-    (-> tracker
-        (track/add depmap)
-        (update-in [::filemap] merge-map filemap))))
+  tracker with those files added. read-opts is passed through to
+  tools.reader."
+  ([tracker files]
+   (add-files tracker files nil))
+  ([tracker files read-opts]
+   (let [{:keys [depmap filemap]} (files-and-deps files read-opts)]
+     (-> tracker
+         (track/add depmap)
+         (update-in [::filemap] merge-map filemap)))))
 
 (defn remove-files
   "Returns an updated dependency tracker with files removed. The files


=====================================
src/main/clojure/clojure/tools/namespace/find.clj
=====================================
@@ -10,7 +10,8 @@
   ^{:author "Stuart Sierra",
      :doc "Search for namespace declarations in directories and JAR files."} 
   clojure.tools.namespace.find
-  (:require [clojure.java.io :as io]
+  (:require [clojure.java.classpath :as classpath]
+            [clojure.java.io :as io]
             [clojure.set :as set]
             [clojure.tools.namespace.file :as file]
             [clojure.tools.namespace.parse :as parse])
@@ -18,104 +19,187 @@
                     InputStreamReader)
            (java.util.jar JarFile JarEntry)))
 
-;;; JAR-file utilities, adapted from clojure.java.classpath
+(def ^{:added "0.3.0"}
+  clj
+  "Platform definition of file extensions and reader options for
+  Clojure (.clj and .cljc) source files."
+  {:read-opts parse/clj-read-opts
+   :extensions file/clojure-extensions})
+
+(def ^{:added "0.3.0"}
+  cljs
+  "Platform definition of file extensions and reader options for
+  ClojureScript (.cljs and .cljc) source files."
+  {:read-opts parse/cljs-read-opts
+   :extensions file/clojurescript-extensions})
+
+(defmacro ^:private ignore-reader-exception
+  "If body throws an exception caused by a syntax error (from
+  tools.reader), returns nil. Rethrows other exceptions."
+  [& body]
+  `(try ~@body
+        (catch Exception e#
+          (if (= :reader-exception (:type (ex-data e#)))
+            nil
+            (throw e#)))))
 
-(defn- jar-file?
-  "Returns true if file is a normal file with a .jar or .JAR extension."
-  [f]
-  (let [file (io/file f)]
-    (and (.isFile file)
-         (or (.endsWith (.getName file) ".jar")
-             (.endsWith (.getName file) ".JAR")))))
+;;; Finding namespaces in a directory tree
 
-(defn- jar-files
-  "Given a sequence of File objects, filters it for JAR files, returns
-  a sequence of java.util.jar.JarFile objects."
+(defn- sort-files-breadth-first
   [files]
-  (map #(JarFile. ^File %) (filter jar-file? files)))
-
-(defn- filenames-in-jar
-  "Returns a sequence of Strings naming the non-directory entries in
-  the JAR file."
-  [^JarFile jar-file]
-  (map #(.getName ^JarEntry %)
-       (filter #(not (.isDirectory ^JarEntry %))
-               (enumeration-seq (.entries jar-file)))))
-
-;;; Finding namespaces in a directory tree
+  (sort-by #(.getAbsolutePath ^File %) files))
+
+(defn find-sources-in-dir
+  "Searches recursively under dir for source files. Returns a sequence
+  of File objects, in breadth-first sort order.
+
+  Optional second argument is either clj (default) or cljs, both
+  defined in clojure.tools.namespace.find."
+  {:added "0.3.0"}
+  ([dir]
+   (find-sources-in-dir dir nil))
+  ([^File dir platform]
+   (let [{:keys [extensions]} (or platform clj)]
+     (->> (file-seq dir)
+          (filter #(file/file-with-extension? % extensions))
+          sort-files-breadth-first))))
 
 (defn find-clojure-sources-in-dir
-  "Searches recursively under dir for Clojure source files (.clj, .cljc)..
+  "DEPRECATED: replaced by find-sources-in-dir
+
+  Searches recursively under dir for Clojure source files (.clj, .cljc).
   Returns a sequence of File objects, in breadth-first sort order."
+  {:added "0.2.0"
+   :deprecated "0.3.0"}
   [^File dir]
-  ;; Use sort by absolute path to get breadth-first search.
-  (sort-by #(.getAbsolutePath ^File %)
-           (filter file/clojure-file? (file-seq dir))))
+  (find-sources-in-dir dir clj))
 
 (defn find-ns-decls-in-dir
   "Searches dir recursively for (ns ...) declarations in Clojure
-  source files; returns the unevaluated ns declarations."
-  [^File dir]
-  (keep file/read-file-ns-decl (find-clojure-sources-in-dir dir)))
+  source files; returns the unevaluated ns declarations.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  {:added "0.2.0"}
+  ([dir] (find-ns-decls-in-dir dir nil))
+  ([dir platform]
+   (keep #(ignore-reader-exception
+           (file/read-file-ns-decl % (:read-opts platform)))
+         (find-sources-in-dir dir platform))))
 
 (defn find-namespaces-in-dir
   "Searches dir recursively for (ns ...) declarations in Clojure
-  source files; returns the symbol names of the declared namespaces."
-  [^File dir]
-  (map second (find-ns-decls-in-dir dir)))
+  source files; returns the symbol names of the declared namespaces.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  {:added "0.3.0"}
+  ([dir] (find-namespaces-in-dir dir nil))
+  ([dir platform]
+   (map parse/name-from-ns-decl (find-ns-decls-in-dir dir platform))))
 
 ;;; Finding namespaces in JAR files
 
+(defn- ends-with-extension
+  [^String filename extensions]
+  (some #(.endsWith filename %) extensions))
+
+(defn sources-in-jar
+  "Returns a sequence of source file names found in the JAR file.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  {:added "0.3.0"}
+  ([jar-file]
+   (sources-in-jar jar-file nil))
+  ([^JarFile jar-file platform]
+   (let [{:keys [extensions]} (or platform clj)]
+     (filter #(ends-with-extension % extensions)
+             (classpath/filenames-in-jar jar-file)))))
+
 (defn clojure-sources-in-jar
-  "Returns a sequence of filenames ending in .clj or .cljc found in the JAR file."
-  [^JarFile jar-file]
-  (filter #(or (.endsWith ^String % ".clj") (.endsWith ^String % ".cljc"))
-          (filenames-in-jar jar-file)))
+  "DEPRECATED: replaced by sources-in-jar
+
+  Returns a sequence of filenames ending in .clj or .cljc found in the
+  JAR file."
+  {:added "0.2.0"
+   :deprecated "0.3.0"}
+  [jar-file]
+  (sources-in-jar jar-file clj))
 
 (defn read-ns-decl-from-jarfile-entry
   "Attempts to read a (ns ...) declaration from the named entry in the
-  JAR file, and returns the unevaluated form.  Returns nil if the read
-  fails, or if the first form is not a ns declaration."
-  [^JarFile jarfile ^String entry-name]
-  (with-open [rdr (PushbackReader.
-                   (io/reader
-                    (.getInputStream jarfile (.getEntry jarfile entry-name))))]
-    (parse/read-ns-decl rdr)))
+  JAR file, and returns the unevaluated form. Returns nil if read
+  fails due to invalid syntax or if a ns declaration cannot be found.
+
+  Optional third argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  ([jarfile entry-name]
+   (read-ns-decl-from-jarfile-entry jarfile entry-name nil))
+  ([^JarFile jarfile ^String entry-name platform]
+   (let [{:keys [read-opts]} (or platform clj)]
+     (with-open [rdr (PushbackReader.
+                      (io/reader
+                       (.getInputStream jarfile (.getEntry jarfile entry-name))))]
+       (ignore-reader-exception
+        (parse/read-ns-decl rdr read-opts))))))
 
 (defn find-ns-decls-in-jarfile
-  "Searches the JAR file for Clojure source files containing (ns ...)
-  declarations; returns the unevaluated ns declarations."
-  [^JarFile jarfile]
-  (filter identity
-          (map #(read-ns-decl-from-jarfile-entry jarfile %)
-               (clojure-sources-in-jar jarfile))))
+  "Searches the JAR file for source files containing (ns ...)
+  declarations; returns the unevaluated ns declarations.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  ([jarfile]
+   (find-ns-decls-in-jarfile jarfile nil))
+  ([^JarFile jarfile platform]
+   (keep #(read-ns-decl-from-jarfile-entry jarfile % platform)
+         (sources-in-jar jarfile platform))))
 
 (defn find-namespaces-in-jarfile
-  "Searches the JAR file for Clojure source files containing (ns ...)
+  "Searches the JAR file for platform source files containing (ns ...)
   declarations.  Returns a sequence of the symbol names of the
-  declared namespaces."
-  [^JarFile jarfile]
-  (map second (find-ns-decls-in-jarfile jarfile)))
+  declared namespaces.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  ([jarfile]
+   (find-namespaces-in-jarfile jarfile nil))
+  ([^JarFile jarfile platform]
+   (map parse/name-from-ns-decl (find-ns-decls-in-jarfile jarfile platform))))
 
 
 ;;; Finding namespaces
 
 (defn find-ns-decls
   "Searches a sequence of java.io.File objects (both directories and
-  JAR files) for .clj or .cljc source files containing (ns...) declarations.
-  Returns a sequence of the unevaluated ns declaration forms. Use with
-  clojure.java.classpath to search Clojure's classpath."
-  [files]
-  (concat
-   (mapcat find-ns-decls-in-dir (filter #(.isDirectory ^File %) files))
-   (mapcat find-ns-decls-in-jarfile (jar-files files))))
+  JAR files) for platform source files containing (ns...)
+  declarations. Returns a sequence of the unevaluated ns declaration
+  forms. Use with clojure.java.classpath to search Clojure's
+  classpath.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  ([files]
+   (find-ns-decls files nil))
+  ([files platform]
+   (concat
+    (mapcat #(find-ns-decls-in-dir % platform)
+            (filter #(.isDirectory ^File %) files))
+    (mapcat #(find-ns-decls-in-jarfile % platform)
+            (map #(JarFile. (io/file %))
+                 (filter classpath/jar-file? files))))))
 
 (defn find-namespaces
   "Searches a sequence of java.io.File objects (both directories and
-  JAR files) for .clj or .cljc source files containing (ns...) declarations.
-  Returns a sequence of the symbol names of the declared
+  JAR files) for platform source files containing (ns...)
+  declarations. Returns a sequence of the symbol names of the declared
   namespaces. Use with clojure.java.classpath to search Clojure's
-  classpath."
-  [files]
-  (map second (find-ns-decls files)))
-
+  classpath.
+
+  Optional second argument platform is either clj (default) or cljs,
+  both defined in clojure.tools.namespace.find."
+  ([files]
+   (find-namespaces files nil))
+  ([files platform]
+   (map parse/name-from-ns-decl (find-ns-decls files platform))))


=====================================
src/main/clojure/clojure/tools/namespace/parse.clj → src/main/clojure/clojure/tools/namespace/parse.cljc
=====================================
@@ -10,15 +10,9 @@
       :doc "Parse Clojure namespace (ns) declarations and extract
   dependencies."}
   clojure.tools.namespace.parse
-  (:require [clojure.set :as set]))
-
-(defn- read-clj
-  "Calls clojure.core/read. If reader conditionals are
-  supported (Clojure 1.7) then adds options {:read-cond :allow}."
-  [rdr]
-  (if (resolve 'clojure.core/reader-conditional?)
-    (read {:read-cond :allow} rdr)
-    (read rdr)))
+  (:require #?(:clj [clojure.tools.reader :as reader]
+               :cljs [cljs.tools.reader :as reader])
+            [clojure.set :as set]))
 
 (defn comment?
   "Returns true if form is a (comment ...)"
@@ -30,22 +24,39 @@
   [form]
   (and (list? form) (= 'ns (first form))))
 
+(def clj-read-opts
+  "Map of options for tools.reader/read allowing reader conditionals
+  with the :clj feature enabled."
+  {:read-cond :allow
+   :features #{:clj}})
+
+(def cljs-read-opts
+  "Map of options for tools.reader/read allowing reader conditionals
+  with the :cljs feature enabled."
+  {:read-cond :allow
+   :features #{:cljs}})
+
 (defn read-ns-decl
-  "Attempts to read a (ns ...) declaration from a
-  java.io.PushbackReader, and returns the unevaluated form. Returns
-  the first top-level ns form found. Returns nil if read fails or if a
-  ns declaration cannot be found. Note that read can execute code
-  (controlled by *read-eval*), and as such should be used only with
-  trusted sources."
-  [rdr]
-  {:pre [(instance? java.io.PushbackReader rdr)]}
-  (try
-   (loop []
-     (let [form (doto (read-clj rdr) str)] ; str forces errors, see TNS-1
-       (if (ns-decl? form)
-         form
-         (recur))))
-   (catch Exception e nil)))
+  "Attempts to read a (ns ...) declaration from a reader, and returns
+  the unevaluated form. Returns the first top-level ns form found.
+  Returns nil if ns declaration cannot be found. Throws exception on
+  invalid syntax.
+
+  Note that read can execute code (controlled by
+  tools.reader/*read-eval*), and as such should be used only with
+  trusted sources. read-opts is passed through to tools.reader/read,
+  defaults to clj-read-opts"
+  ([rdr]
+   (read-ns-decl rdr nil))
+  ([rdr read-opts]
+   (let [opts (assoc (or read-opts clj-read-opts)
+                     :eof ::eof)]
+     (loop []
+       (let [form (reader/read opts rdr)]
+         (cond
+           (ns-decl? form) form
+           (= ::eof form) nil
+           :else (recur)))))))
 
 ;;; Parsing dependencies
 
@@ -64,7 +75,8 @@
   [namespace :refer (x y)] or just [namespace]"
   [form]
   (and (sequential? form)  ; should be a vector, but often is not
-       (symbol? (first form))
+       (or (symbol? (first form))
+           (string? (first form)))
        (or (keyword? (second form))  ; vector like [foo :as f]
            (= 1 (count form)))))  ; bare vector like [foo]
 
@@ -76,20 +88,42 @@
                            f))
                   (rest form))
 	(option-spec? form)
-          (deps-from-libspec prefix (first form))
+          (when-not (= :as-alias (second form))
+            (deps-from-libspec prefix (first form)))
 	(symbol? form)
           (list (symbol (str (when prefix (str prefix ".")) form)))
 	(keyword? form)  ; Some people write (:require ... :reload-all)
           nil
-	:else
-          (throw (IllegalArgumentException.
-                  (pr-str "Unparsable namespace form:" form)))))
+        (string? form) ; NPM dep, ignore
+          nil
+        :else
+          (throw (ex-info "Unparsable namespace form"
+                          {:reason ::unparsable-ns-form
+                           :form form}))))
+
+(def ^:private ns-clause-head-names
+  "Set of symbol/keyword names which can appear as the head of a
+  clause in the ns form."
+  #{"use" "require" "require-macros"})
+
+(def ^:private ns-clause-heads
+  "Set of all symbols and keywords which can appear at the head of a
+  dependency clause in the ns form."
+  (set (mapcat (fn [name] (list (keyword name)
+                                (symbol name)))
+               ns-clause-head-names)))
 
 (defn- deps-from-ns-form [form]
   (when (and (sequential? form)  ; should be list but sometimes is not
-	     (contains? #{:use :require 'use 'require} (first form)))
+	     (contains? ns-clause-heads (first form)))
     (mapcat #(deps-from-libspec nil %) (rest form))))
 
+(defn name-from-ns-decl
+  "Given an (ns...) declaration form (unevaluated), returns the name
+  of the namespace as a symbol."
+  [decl]
+  (second decl))
+
 (defn deps-from-ns-decl
   "Given an (ns...) declaration form (unevaluated), returns a set of
   symbols naming the dependencies of that namespace.  Handles :use and


=====================================
src/main/clojure/clojure/tools/namespace/repl.clj
=====================================
@@ -11,11 +11,12 @@
   clojure.tools.namespace.repl
   (:require [clojure.tools.namespace.track :as track]
             [clojure.tools.namespace.dir :as dir]
+            [clojure.tools.namespace.find :as find]
             [clojure.tools.namespace.reload :as reload]))
 
-(defonce ^:private refresh-tracker (track/tracker))
+(defonce refresh-tracker (track/tracker))
 
-(defonce ^:private refresh-dirs [])
+(defonce refresh-dirs [])
 
 (defn- print-and-return [tracker]
   (if-let [e (::reload/error tracker)]
@@ -79,7 +80,7 @@
     (when (find-ns ns-name)
       (alias alias-sym ns-name))))
 
-(defn- do-refresh [scan-fn after-sym]
+(defn- do-refresh [scan-opts after-sym]
   (when after-sym
     (assert (symbol? after-sym) ":after value must be a symbol")
     (assert (namespace after-sym)
@@ -87,8 +88,7 @@
   (let [current-ns-name (ns-name *ns*)
         current-ns-refers (referred *ns*)
         current-ns-aliases (aliased *ns*)]
-    (alter-var-root #'refresh-tracker
-                    #(apply scan-fn % refresh-dirs))
+    (alter-var-root #'refresh-tracker dir/scan-dirs refresh-dirs scan-opts)
     (alter-var-root #'refresh-tracker remove-disabled)
     (print-pending-reloads refresh-tracker)
     (alter-var-root #'refresh-tracker reload/track-reload)
@@ -142,7 +142,7 @@
                been reloaded."
   [& options]
   (let [{:keys [after]} options]
-    (do-refresh dir/scan after)))
+    (do-refresh {:platform find/clj} after)))
 
 (defn refresh-all
   "Scans source code directories for all Clojure source files and
@@ -159,7 +159,7 @@
                been reloaded."
   [& options]
   (let [{:keys [after]} options]
-    (do-refresh dir/scan-all after)))
+    (do-refresh {:platform find/clj :add-all? true} after)))
 
 (defn set-refresh-dirs
   "Sets the directories which are scanned by 'refresh'. Supports the


=====================================
src/main/clojure/clojure/tools/namespace/track.clj → src/main/clojure/clojure/tools/namespace/track.cljc
=====================================
@@ -114,7 +114,8 @@
   {})
 
 (comment
-  ;; Structure of the namespace tracker map
+  ;; Structure of the namespace tracker map. Documented for reference
+  ;; only: This is not a public API.
 
   {;; Dependency graph of namespace names (symbols) as defined in
    ;; clojure.tools.namespace.dependency/graph


=====================================
src/test/clojure/clojure/tools/namespace/dir_test.clj
=====================================
@@ -0,0 +1,38 @@
+(ns clojure.tools.namespace.dir-test
+  (:require [clojure.test :refer [deftest is]]
+            [clojure.tools.namespace.test-helpers :as help]
+            [clojure.tools.namespace.dir :as dir])
+  (:import
+   (java.io File)))
+
+(defn- make-symbolic-link
+  "Reflectively calls java.nio.file.Files/createSymbolicLink on two
+  java.io.File arguments, to avoid a compile-time dependency on
+  java.nio.file.Files. Returns a java.io.File."
+  [^File link ^File target]
+  (let [path-class (Class/forName "java.nio.file.Path")
+        attr-class (Class/forName "java.nio.file.attribute.FileAttribute")
+        attr-array (make-array attr-class 0)
+        attr-array-class (.getClass attr-array)
+        to-path (.getMethod java.io.File "toPath" (into-array Class []))
+        to-file (.getMethod path-class "toFile" (into-array Class []))
+        create-link (.getMethod (Class/forName "java.nio.file.Files")
+                                "createSymbolicLink"
+                                (into-array Class [path-class path-class attr-array-class]))
+        link-path (.invoke to-path link (object-array 0))
+        target-path (.invoke to-path target (object-array 0))
+        link (.invoke create-link path-class (object-array [link-path target-path attr-array]))]
+    (.invoke to-file link (object-array 0))))
+
+;; Only run this test on Java 1.7+, where java.nio.file.Files is available.
+(when (try (Class/forName "java.nio.file.Files")
+           (catch ClassNotFoundException _ false))
+  (deftest t-scan-by-canonical-path
+    (let [dir (help/create-temp-dir "t-scan-by-canonical-path")
+          main-clj (help/create-source dir 'example.main :clj '[example.one])
+          one-cljc (help/create-source dir 'example.one :clj)
+          other-dir (help/create-temp-dir "t-scan-by-canonical-path-other")
+          link (File. other-dir "link")]
+      (make-symbolic-link link dir)
+      (is (= (::dir/files (dir/scan-dirs {} [dir]))
+             (::dir/files (dir/scan-dirs {} [link])))))))


=====================================
src/test/clojure/clojure/tools/namespace/find_test.clj
=====================================
@@ -0,0 +1,29 @@
+(ns clojure.tools.namespace.find-test
+  (:require [clojure.test :refer [deftest is]]
+            [clojure.tools.namespace.test-helpers :as help]
+            [clojure.tools.namespace.find :as find])
+  (:import (java.io File)))
+
+(deftest t-find-clj-and-cljc-files
+  "main.clj depends on one.cljc which depends on two.clj.
+  two.cljs also exists but should not be returned"
+  (let [dir (help/create-temp-dir "t-find-clj-and-cljc-files")
+        main-clj (help/create-source dir 'example.main :clj '[example.one])
+        one-cljc (help/create-source dir 'example.one :cljc '[example.two])
+        two-clj (help/create-source dir 'example.two :clj)
+        two-cljs (help/create-source dir 'example.two :cljs)]
+    (is (help/same-files?
+         [main-clj one-cljc two-clj]
+         (find/find-sources-in-dir dir)))))
+
+(deftest t-find-cljs-and-cljc-files
+  "main.cljs depends on one.cljc which depends on two.cljs.
+  two.clj also exists but should not be returned"
+  (let [dir (help/create-temp-dir "t-find-cljs-and-cljc-files")
+        main-cljs (help/create-source dir 'example.main :cljs '[example.one])
+        one-cljc (help/create-source dir 'example.one :cljc '[example.two])
+        two-clj (help/create-source dir 'example.two :clj)
+        two-cljs (help/create-source dir 'example.two :cljs)]
+    (is (help/same-files?
+         [main-cljs one-cljc two-cljs]
+         (find/find-sources-in-dir dir find/cljs)))))


=====================================
src/test/clojure/clojure/tools/namespace/move_test.clj
=====================================
@@ -1,62 +1,42 @@
 (ns clojure.tools.namespace.move-test
-  (:use [clojure.java.io :as io]
-        [clojure.test :only (deftest is)]
-        [clojure.tools.namespace.move :only (move-ns)])
+  (:require [clojure.java.io :as io]
+            [clojure.test :refer [deftest is]]
+            [clojure.tools.namespace.move :refer [move-ns]]
+            [clojure.tools.namespace.test-helpers :as help])
   (:import (java.io File)))
 
-(defn- create-temp-dir
-  "Creates and returns a new temporary directory java.io.File."
-  [name]
-  (let [temp-file (File/createTempFile name nil)]
-    (.delete temp-file)
-    (.mkdirs temp-file)
-    temp-file))
+(defn- create-file-one [dir]
+  (help/create-source dir 'example.one :clj
+                      '[example.two example.three]
+                      '[(defn foo []
+                           (example.a.four/foo))]))
 
-(def ^:private file-one-contents "
- (ns com.example.one
-   (:require [com.example.two :as two]
-             [com.example.three :as three]))
+(defn- create-file-two [dir]
+  (help/create-source dir 'example.two :clj
+                    '[example.three example.a.four]))
 
- (defn foo []
-   (com.example.a.four/foo))
-")
+(defn- create-file-three [dir]
+  (help/create-source dir 'example.three :clj
+                    '[example.five]))
 
-(def ^:private file-two-contents "
- (ns com.example.two
-   (:require [com.example.three :as three]
-             [com.example.a.four :as four]))
-")
-
-(def ^:private file-three-contents "
- (ns com.example.three
-   (:use com.example.five))
-")
-
-(def ^:private file-four-contents "
- (ns com.example.a.four)
- (defn foo [] \"foo\")
-")
+(defn- create-file-four [dir]
+  (help/create-source dir 'example.a.four :clj))
 
 (deftest t-move-ns
-  (let [temp-dir (create-temp-dir "tools-namespace-t-move-ns")
+  (let [temp-dir (help/create-temp-dir "tools-namespace-t-move-ns")
         src-dir (io/file temp-dir "src")
-        example-dir (io/file temp-dir "src" "com" "example")
-        file-one (io/file example-dir "one.clj")
-        file-two (io/file example-dir "two.clj")
-        file-three (io/file example-dir "three.clj")
-        old-file-four (io/file example-dir "a" "four.clj")
+        example-dir (io/file temp-dir "src" "example")
+        file-one (create-file-one src-dir)
+        file-two (create-file-two src-dir)
+        file-three (create-file-three src-dir)
+        old-file-four (create-file-four src-dir)
         new-file-four (io/file example-dir "b" "four.clj")]
 
-    (.mkdirs (io/file example-dir "a"))
-    (spit file-one file-one-contents)
-    (spit file-two file-two-contents)
-    (spit file-three file-three-contents)
-    (spit old-file-four file-four-contents)
-    (Thread/sleep 1500) ;; ensure file timestamps are different
-
     (let [file-three-last-modified (.lastModified file-three)]
 
-      (move-ns 'com.example.a.four 'com.example.b.four src-dir [src-dir])
+      (Thread/sleep 1500) ;; ensure file timestamps are different
+
+      (move-ns 'example.a.four 'example.b.four src-dir [src-dir])
 
       (is (.exists new-file-four)
           "new file should exist")
@@ -66,7 +46,7 @@
           "old empty directory should not exist")
       (is (= file-three-last-modified (.lastModified file-three))
           "unaffected file should not have been modified")
-      (is (not-any? #(.contains (slurp %) "com.example.a.four")
+      (is (not-any? #(.contains (slurp %) "example.a.four")
                     [file-one file-two file-three new-file-four]))
-      (is (every? #(.contains (slurp %) "com.example.b.four")
+      (is (every? #(.contains (slurp %) "example.b.four")
                   [file-one file-two new-file-four])))))


=====================================
src/test/clojure/clojure/tools/namespace/parse_test.clj
=====================================
@@ -25,7 +25,8 @@
                 [four :refer (a b)]]
                [com.example.sub
                 [five :as five]
-                six])
+                six
+                [eleven :as-alias eleven]])
      (:use [com.example
             seven
             [eight :as eight]
@@ -171,11 +172,35 @@
   (:require #?(:clj clojure.string
                :cljs goog.string)))")
 
+(defn str->ns-decl [^String s]
+  (-> s
+      java.io.StringReader.
+      java.io.PushbackReader.
+      read-ns-decl))
+
 (deftest t-reader-conditionals
   (when (resolve 'clojure.core/reader-conditional?)
     (let [actual (-> reader-conditionals-string
-                     java.io.StringReader.
-                     java.io.PushbackReader.
-                     read-ns-decl
+                     str->ns-decl
                      deps-from-ns-decl)]
       (is (= #{'clojure.string} actual)))))
+
+(def cljs-ns-with-npm-dependency
+  "(ns com.examples.one
+    (:require [\"foobar\"] [baz]))")
+
+(deftest cljs-string-dependency
+  (let [actual (-> cljs-ns-with-npm-dependency
+                   str->ns-decl
+                   deps-from-ns-decl)]
+    (is (= #{'baz} actual))))
+
+(def cljs-ns-with-require-macros
+  "(ns com.examples.one
+    (:require-macros [org.macros :refer [my-macro]]))")
+
+(deftest cljs-require-macros
+  (let [actual (-> cljs-ns-with-require-macros
+                   str->ns-decl
+                   deps-from-ns-decl)]
+    (is (= #{'org.macros} actual))))


=====================================
src/test/clojure/clojure/tools/namespace/test_helpers.clj
=====================================
@@ -0,0 +1,82 @@
+(ns clojure.tools.namespace.test-helpers
+  "Utilities to help with testing files and namespaces."
+  (:require [clojure.java.io :as io]
+            [clojure.string :as string])
+  (:import (java.io Closeable File Writer PrintWriter)))
+
+(defn create-temp-dir
+  "Creates and returns a new temporary directory java.io.File."
+  [name]
+  (let [temp-file (File/createTempFile name nil)]
+    (.delete temp-file)
+    (.mkdirs temp-file)
+    (println "Temporary directory" (.getAbsolutePath temp-file))
+    temp-file))
+
+(defn- write-contents
+  "Writes contents into writer. Strings are written as-is via println,
+  other types written as by prn."
+  [^Writer writer contents]
+  {:pre [(sequential? contents)]}
+  (binding [*out* (PrintWriter. writer)]
+    (doseq [content contents]
+      (if (string? content)
+        (println content)
+        (prn content))
+      (newline))))
+
+(defn create-file
+  "Creates a file from a vector of path elements. Writes contents into
+  the file. Elements of contents may be data, written via prn, or
+  strings, written directly."
+  [path contents]
+  {:pre [(vector? path)]}
+  (let [^File file (apply io/file path)]
+    (when-let [parent (.getParentFile file)]
+      (.mkdirs parent))
+    (with-open [wtr (io/writer file)]
+      (write-contents wtr contents))
+    file))
+
+(defn- sym->path
+  "Converts a symbol name into a vector of path parts, not including
+  file extension."
+  [symbol]
+  {:pre [(symbol? symbol)]
+   :post [(vector? %)]}
+  (-> (name symbol)
+      (string/replace \- \_)
+      (string/split #"\.")))
+
+(defn- source-path
+  "Returns a vector of path components for namespace named sym,
+  with given file extension (keyword)."
+  [sym extension]
+  (let [path (sym->path sym)
+        basename (peek path)
+        filename (str basename \. (name extension))]
+    (conj (pop path) filename)))
+
+(defn create-source
+  "Creates a file at the correct path under base-dir for a namespace
+  named sym, with file extension (keyword), containing a ns
+  declaration which :require's the dependencies (symbols). Optional
+  contents written after the ns declaration as by write-contents."
+  ([base-dir sym extension]
+   (create-source base-dir sym extension nil nil))
+  ([base-dir sym extension dependencies]
+   (create-source base-dir sym extension dependencies nil))  
+  ([base-dir sym extension dependencies contents]
+   (let [full-path (into [base-dir] (source-path sym extension))
+         ns-decl (if (seq dependencies)
+                   (list 'ns sym (list* :require dependencies))
+                   (list 'ns sym))]
+     (create-file full-path (into [ns-decl] contents)))))
+
+(defn same-files?
+  "True if files-a and files-b contain the same canonical File's,
+  regardless of order."
+  [files-a files-b]
+  (= (sort (map #(.getCanonicalPath ^File %) files-a))
+     (sort (map #(.getCanonicalPath ^File %) files-b))))
+



View it on GitLab: https://salsa.debian.org/clojure-team/tools-namespace-clojure/-/commit/04ab1e5186b64250ac9dd39ee3f4fcb02bf2f871

-- 
View it on GitLab: https://salsa.debian.org/clojure-team/tools-namespace-clojure/-/commit/04ab1e5186b64250ac9dd39ee3f4fcb02bf2f871
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221226/f29733ed/attachment.htm>


More information about the pkg-java-commits mailing list