diff options
author | Aaron Bedra and Stuart Halloway <pair@clojure.com> | 2010-07-23 09:37:49 -0400 |
---|---|---|
committer | Aaron Bedra and Stuart Halloway <pair@clojure.com> | 2010-07-23 09:37:49 -0400 |
commit | b8d2743d3a89e13fc9deb2844ca2167b34aaa9b6 (patch) | |
tree | b32f67ec7fb475de6f100a481726144d56bf0b6a | |
parent | fc08a89cbaa785a55e5fc6a22367a1511deec508 (diff) |
use the 1.2 metadata reader macro ^ instead of #^
89 files changed, 616 insertions, 616 deletions
diff --git a/src/main/clojure/clojure/contrib/accumulators.clj b/src/main/clojure/clojure/contrib/accumulators.clj index dcd03dd1..55073e33 100644 --- a/src/main/clojure/clojure/contrib/accumulators.clj +++ b/src/main/clojure/clojure/contrib/accumulators.clj @@ -19,7 +19,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "A generic accumulator interface and implementations of various accumulators."} clojure.contrib.accumulators diff --git a/src/main/clojure/clojure/contrib/agent_utils.clj b/src/main/clojure/clojure/contrib/agent_utils.clj index 0ab845d5..1b7b2107 100644 --- a/src/main/clojure/clojure/contrib/agent_utils.clj +++ b/src/main/clojure/clojure/contrib/agent_utils.clj @@ -13,7 +13,7 @@ ;; note to other contrib members: feel free to add to this lib (ns - #^{:author "Christophe Grande", + ^{:author "Christophe Grande", :doc "Miscellaneous agent utilities (note to other contrib members: feel free to add to this lib)", } diff --git a/src/main/clojure/clojure/contrib/base64.clj b/src/main/clojure/clojure/contrib/base64.clj index 5e1e3310..2556487c 100644 --- a/src/main/clojure/clojure/contrib/base64.clj +++ b/src/main/clojure/clojure/contrib/base64.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:doc "Base-64 encoding and (maybe later) decoding. +(ns ^{:doc "Base-64 encoding and (maybe later) decoding. This is mainly here as an example. It is much slower than the Apache Commons Codec implementation or sun.misc.BASE64Encoder." @@ -29,7 +29,7 @@ is a 65-character String containing the 64 characters to use in the encoding; the 65th character is the pad character. line-length is the maximum number of characters per line, nil for no line breaks." - [#^InputStream input #^Writer output #^String alphabet line-length] + [^InputStream input ^Writer output ^String alphabet line-length] (let [buffer (make-array Byte/TYPE 3)] (loop [line 0] (let [len (.read input buffer)] @@ -80,7 +80,7 @@ "Encodes String in base 64; returns a String. If not specified, encoding is UTF-8 and line-length is nil." ([s] (encode-str s "UTF-8" nil)) - ([#^String s #^String encoding line-length] + ([^String s ^String encoding line-length] (let [output (StringWriter.)] (encode (ByteArrayInputStream. (.getBytes s encoding)) output *base64-alphabet* line-length) diff --git a/src/main/clojure/clojure/contrib/classpath.clj b/src/main/clojure/clojure/contrib/classpath.clj index a5a1a6d3..232860f0 100644 --- a/src/main/clojure/clojure/contrib/classpath.clj +++ b/src/main/clojure/clojure/contrib/classpath.clj @@ -13,7 +13,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Utilities for dealing with the JVM's classpath"} clojure.contrib.classpath (:require [clojure.contrib.jar :as jar]) diff --git a/src/main/clojure/clojure/contrib/combinatorics.clj b/src/main/clojure/clojure/contrib/combinatorics.clj index ca8c8ba2..1be12aa4 100644 --- a/src/main/clojure/clojure/contrib/combinatorics.clj +++ b/src/main/clojure/clojure/contrib/combinatorics.clj @@ -62,7 +62,7 @@ On my own computer, I use versions of all these algorithms that return sequences (ns
- #^{:author "Mark Engelberg",
+ ^{:author "Mark Engelberg",
:doc "Efficient, functional algorithms for generating lazy
sequences for common combinatorial functions. (See the source code
for a longer description.)"}
diff --git a/src/main/clojure/clojure/contrib/command_line.clj b/src/main/clojure/clojure/contrib/command_line.clj index 907b009f..47ee7849 100644 --- a/src/main/clojure/clojure/contrib/command_line.clj +++ b/src/main/clojure/clojure/contrib/command_line.clj @@ -9,7 +9,7 @@ ; Process command-line arguments according to a given cmdspec (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "Process command-line arguments according to a given cmdspec"} clojure.contrib.command-line (:use (clojure.contrib [string :only (join)]))) @@ -60,7 +60,7 @@ (defn- rmv-q "Remove ?" - [#^String s] + [^String s] (if (.endsWith s "?") (.substring s 0 (dec (count s))) s)) diff --git a/src/main/clojure/clojure/contrib/complex_numbers.clj b/src/main/clojure/clojure/contrib/complex_numbers.clj index 01f90b9c..cf9aafd9 100644 --- a/src/main/clojure/clojure/contrib/complex_numbers.clj +++ b/src/main/clojure/clojure/contrib/complex_numbers.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Complex numbers NOTE: This library is in evolution. Most math functions are not implemented yet."} diff --git a/src/main/clojure/clojure/contrib/cond.clj b/src/main/clojure/clojure/contrib/cond.clj index 0ae8ca06..d3a5338e 100644 --- a/src/main/clojure/clojure/contrib/cond.clj +++ b/src/main/clojure/clojure/contrib/cond.clj @@ -11,7 +11,7 @@ ;; scgilardi (gmail) ;; 2 October 2008 -(ns #^{:author "Stephen C. Gilardi" +(ns ^{:author "Stephen C. Gilardi" :doc "Extensions to the basic cond function."} clojure.contrib.cond) diff --git a/src/main/clojure/clojure/contrib/condition.clj b/src/main/clojure/clojure/contrib/condition.clj index 32397a84..57525bfe 100644 --- a/src/main/clojure/clojure/contrib/condition.clj +++ b/src/main/clojure/clojure/contrib/condition.clj @@ -11,7 +11,7 @@ ;; scgilardi (gmail) ;; Created 09 June 2009 -(ns #^{:author "Stephen C. Gilardi" +(ns ^{:author "Stephen C. Gilardi" :doc "Flexible raising and handling of conditions: Functions: diff --git a/src/main/clojure/clojure/contrib/core.clj b/src/main/clojure/clojure/contrib/core.clj index c696ed12..e7239717 100644 --- a/src/main/clojure/clojure/contrib/core.clj +++ b/src/main/clojure/clojure/contrib/core.clj @@ -13,7 +13,7 @@ ;; note to other contrib members: feel free to add to this lib (ns - #^{:author "Laurent Petit (and others)" + ^{:author "Laurent Petit (and others)" :doc "Functions/macros variants of the ones that can be found in clojure.core (note to other contrib members: feel free to add to this lib)"} clojure.contrib.core diff --git a/src/main/clojure/clojure/contrib/dataflow.clj b/src/main/clojure/clojure/contrib/dataflow.clj index 95ffc59f..d326d0d6 100644 --- a/src/main/clojure/clojure/contrib/dataflow.clj +++ b/src/main/clojure/clojure/contrib/dataflow.clj @@ -15,7 +15,7 @@ (ns - #^{:author "Jeffrey Straszheim", + ^{:author "Jeffrey Straszheim", :doc "A library to support a dataflow model of state"} clojure.contrib.dataflow (:use [clojure.set :only (union intersection difference)]) @@ -363,7 +363,7 @@ (list 'cell :validator (:display cell))) (defmethod print-method ::dataflow-cell - [f #^Writer w] + [f ^Writer w] (binding [*out* w] (pr (display-cell f)))) diff --git a/src/main/clojure/clojure/contrib/datalog.clj b/src/main/clojure/clojure/contrib/datalog.clj index 93e132de..77d9d3a9 100644 --- a/src/main/clojure/clojure/contrib/datalog.clj +++ b/src/main/clojure/clojure/contrib/datalog.clj @@ -18,7 +18,7 @@ (ns - #^{:author "Jeffrey Straszheim", + ^{:author "Jeffrey Straszheim", :doc "A Clojure implementation of Datalog"} clojure.contrib.datalog (:use clojure.contrib.datalog.rules diff --git a/src/main/clojure/clojure/contrib/datalog/database.clj b/src/main/clojure/clojure/contrib/datalog/database.clj index 931011e9..27f84484 100644 --- a/src/main/clojure/clojure/contrib/datalog/database.clj +++ b/src/main/clojure/clojure/contrib/datalog/database.clj @@ -31,7 +31,7 @@ ;;; DDL (defmethod print-method ::datalog-database - [db #^Writer writer] + [db ^Writer writer] (binding [*out* writer] (do (println "(datalog-database") @@ -49,7 +49,7 @@ (def empty-database (datalog-database {})) (defmethod print-method ::datalog-relation - [rel #^Writer writer] + [rel ^Writer writer] (binding [*out* writer] (do (println "(datalog-relation") diff --git a/src/main/clojure/clojure/contrib/datalog/rules.clj b/src/main/clojure/clojure/contrib/datalog/rules.clj index e0ca338f..9cb667e5 100644 --- a/src/main/clojure/clojure/contrib/datalog/rules.clj +++ b/src/main/clojure/clojure/contrib/datalog/rules.clj @@ -74,7 +74,7 @@ `(is-safe? (build-rule ~head [~@body])))) (defmethod print-method ::datalog-rule - [rule #^Writer writer] + [rule ^Writer writer] (print-method (display-rule rule) writer)) (defn return-rule-data @@ -89,7 +89,7 @@ `(with-meta ~qq {:type ::datalog-query}))) (defmethod print-method ::datalog-query - [query #^Writer writer] + [query ^Writer writer] (print-method (display-query query) writer)) @@ -139,7 +139,7 @@ (reduce conj empty-rules-set rules)) (defmethod print-method ::datalog-rules-set - [rules #^Writer writer] + [rules ^Writer writer] (binding [*out* writer] (do (print "(rules-set") diff --git a/src/main/clojure/clojure/contrib/def.clj b/src/main/clojure/clojure/contrib/def.clj index 08274cec..c3cd2c42 100644 --- a/src/main/clojure/clojure/contrib/def.clj +++ b/src/main/clojure/clojure/contrib/def.clj @@ -15,7 +15,7 @@ ;; 17 May 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "def.clj provides variants of def that make including doc strings and making private definitions more succinct."} clojure.contrib.def) diff --git a/src/main/clojure/clojure/contrib/duck_streams.clj b/src/main/clojure/clojure/contrib/duck_streams.clj index 5af717cb..c2a60dbc 100644 --- a/src/main/clojure/clojure/contrib/duck_streams.clj +++ b/src/main/clojure/clojure/contrib/duck_streams.clj @@ -46,7 +46,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "This file defines \"duck-typed\" I/O utility functions for Clojure. The 'reader' and 'writer' functions will open and return an instance of java.io.BufferedReader and java.io.PrintWriter, @@ -69,27 +69,27 @@ (def - #^{:doc "Name of the default encoding to use when reading & writing. + ^{:doc "Name of the default encoding to use when reading & writing. Default is UTF-8." :tag "java.lang.String"} *default-encoding* "UTF-8") (def - #^{:doc "Size, in bytes or characters, of the buffer used when + ^{:doc "Size, in bytes or characters, of the buffer used when copying streams."} *buffer-size* 1024) (def - #^{:doc "Type object for a Java primitive byte array."} + ^{:doc "Type object for a Java primitive byte array."} *byte-array-type* (class (make-array Byte/TYPE 0))) -(defn #^File file-str +(defn ^File file-str "Concatenates args as strings and returns a java.io.File. Replaces all / and \\ with File/separatorChar. Replaces ~ at the start of the path with the user.home system property." [& args] - (let [#^String s (apply str args) + (let [^String s (apply str args) s (.replaceAll (re-matcher #"[/\\]" s) File/separator) s (if (.startsWith s "~") (str (System/getProperty "user.home") @@ -98,7 +98,7 @@ (File. s))) -(defmulti #^{:tag BufferedReader +(defmulti ^{:tag BufferedReader :doc "Attempts to coerce its argument into an open java.io.BufferedReader. Argument may be an instance of Reader, BufferedReader, InputStream, File, URI, URL, Socket, or String. @@ -115,27 +115,27 @@ (defmethod reader Reader [x] (BufferedReader. x)) -(defmethod reader InputStream [#^InputStream x] +(defmethod reader InputStream [^InputStream x] (BufferedReader. (InputStreamReader. x *default-encoding*))) -(defmethod reader File [#^File x] +(defmethod reader File [^File x] (reader (FileInputStream. x))) -(defmethod reader URL [#^URL x] +(defmethod reader URL [^URL x] (reader (if (= "file" (.getProtocol x)) (FileInputStream. (.getPath x)) (.openStream x)))) -(defmethod reader URI [#^URI x] +(defmethod reader URI [^URI x] (reader (.toURL x))) -(defmethod reader String [#^String x] +(defmethod reader String [^String x] (try (let [url (URL. x)] (reader url)) (catch MalformedURLException e (reader (File. x))))) -(defmethod reader Socket [#^Socket x] +(defmethod reader Socket [^Socket x] (reader (.getInputStream x))) (defmethod reader :default [x] @@ -143,13 +143,13 @@ (def - #^{:doc "If true, writer and spit will open files in append mode. + ^{:doc "If true, writer and spit will open files in append mode. Defaults to false. Use append-writer or append-spit." :tag "java.lang.Boolean"} *append-to-writer* false) -(defmulti #^{:tag PrintWriter +(defmulti ^{:tag PrintWriter :doc "Attempts to coerce its argument into an open java.io.PrintWriter wrapped around a java.io.BufferedWriter. Argument may be an instance of Writer, PrintWriter, BufferedWriter, OutputStream, File, @@ -172,7 +172,7 @@ (assert-not-appending) x) -(defmethod writer BufferedWriter [#^BufferedWriter x] +(defmethod writer BufferedWriter [^BufferedWriter x] (assert-not-appending) (PrintWriter. x)) @@ -181,32 +181,32 @@ ;; Writer includes sub-classes such as FileWriter (PrintWriter. (BufferedWriter. x))) -(defmethod writer OutputStream [#^OutputStream x] +(defmethod writer OutputStream [^OutputStream x] (assert-not-appending) (PrintWriter. (BufferedWriter. (OutputStreamWriter. x *default-encoding*)))) -(defmethod writer File [#^File x] +(defmethod writer File [^File x] (let [stream (FileOutputStream. x *append-to-writer*)] (binding [*append-to-writer* false] (writer stream)))) -(defmethod writer URL [#^URL x] +(defmethod writer URL [^URL x] (if (= "file" (.getProtocol x)) (writer (File. (.getPath x))) (throw (Exception. (str "Cannot write to non-file URL <" x ">"))))) -(defmethod writer URI [#^URI x] +(defmethod writer URI [^URI x] (writer (.toURL x))) -(defmethod writer String [#^String x] +(defmethod writer String [^String x] (try (let [url (URL. x)] (writer url)) (catch MalformedURLException err (writer (File. x))))) -(defmethod writer Socket [#^Socket x] +(defmethod writer Socket [^Socket x] (writer (.getOutputStream x))) (defmethod writer :default [x] @@ -225,7 +225,7 @@ "Writes lines (a seq) to f, separated by newlines. f is opened with writer, and automatically closed at the end of the sequence." [f lines] - (with-open [#^PrintWriter writer (writer f)] + (with-open [^PrintWriter writer (writer f)] (loop [lines lines] (when-let [line (first lines)] (.write writer (str line)) @@ -236,17 +236,17 @@ "Like clojure.core/line-seq but opens f with reader. Automatically closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE." [f] - (let [read-line (fn this [#^BufferedReader rdr] + (let [read-line (fn this [^BufferedReader rdr] (lazy-seq (if-let [line (.readLine rdr)] (cons line (this rdr)) (.close rdr))))] (read-line (reader f)))) -(defn #^String slurp* +(defn ^String slurp* "Like clojure.core/slurp but opens f with reader." [f] - (with-open [#^BufferedReader r (reader f)] + (with-open [^BufferedReader r (reader f)] (let [sb (StringBuilder.)] (loop [c (.read r)] (if (neg? c) @@ -258,13 +258,13 @@ "Opposite of slurp. Opens f with writer, writes content, then closes f." [f content] - (with-open [#^PrintWriter w (writer f)] + (with-open [^PrintWriter w (writer f)] (.print w content))) (defn append-spit "Like spit but appends to file." [f content] - (with-open [#^PrintWriter w (append-writer f)] + (with-open [^PrintWriter w (append-writer f)] (.print w content))) (defn pwd @@ -298,7 +298,7 @@ ~@body))) (defmulti - #^{:doc "Copies input to output. Returns nil. + ^{:doc "Copies input to output. Returns nil. Input may be an InputStream, Reader, File, byte[], or String. Output may be an OutputStream, Writer, or File. @@ -310,7 +310,7 @@ copy (fn [input output] [(type input) (type output)])) -(defmethod copy [InputStream OutputStream] [#^InputStream input #^OutputStream output] +(defmethod copy [InputStream OutputStream] [^InputStream input ^OutputStream output] (let [buffer (make-array Byte/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] @@ -318,8 +318,8 @@ (do (.write output buffer 0 size) (recur))))))) -(defmethod copy [InputStream Writer] [#^InputStream input #^Writer output] - (let [#^"[B" buffer (make-array Byte/TYPE *buffer-size*)] +(defmethod copy [InputStream Writer] [^InputStream input ^Writer output] + (let [^"[B" buffer (make-array Byte/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) @@ -327,12 +327,12 @@ (do (.write output chars) (recur)))))))) -(defmethod copy [InputStream File] [#^InputStream input #^File output] +(defmethod copy [InputStream File] [^InputStream input ^File output] (with-open [out (FileOutputStream. output)] (copy input out))) -(defmethod copy [Reader OutputStream] [#^Reader input #^OutputStream output] - (let [#^"[C" buffer (make-array Character/TYPE *buffer-size*)] +(defmethod copy [Reader OutputStream] [^Reader input ^OutputStream output] + (let [^"[C" buffer (make-array Character/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) @@ -340,57 +340,57 @@ (do (.write output bytes) (recur)))))))) -(defmethod copy [Reader Writer] [#^Reader input #^Writer output] - (let [#^"[C" buffer (make-array Character/TYPE *buffer-size*)] +(defmethod copy [Reader Writer] [^Reader input ^Writer output] + (let [^"[C" buffer (make-array Character/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) (do (.write output buffer 0 size) (recur))))))) -(defmethod copy [Reader File] [#^Reader input #^File output] +(defmethod copy [Reader File] [^Reader input ^File output] (with-open [out (FileOutputStream. output)] (copy input out))) -(defmethod copy [File OutputStream] [#^File input #^OutputStream output] +(defmethod copy [File OutputStream] [^File input ^OutputStream output] (with-open [in (FileInputStream. input)] (copy in output))) -(defmethod copy [File Writer] [#^File input #^Writer output] +(defmethod copy [File Writer] [^File input ^Writer output] (with-open [in (FileInputStream. input)] (copy in output))) -(defmethod copy [File File] [#^File input #^File output] +(defmethod copy [File File] [^File input ^File output] (with-open [in (FileInputStream. input) out (FileOutputStream. output)] (copy in out))) -(defmethod copy [String OutputStream] [#^String input #^OutputStream output] +(defmethod copy [String OutputStream] [^String input ^OutputStream output] (copy (StringReader. input) output)) -(defmethod copy [String Writer] [#^String input #^Writer output] +(defmethod copy [String Writer] [^String input ^Writer output] (copy (StringReader. input) output)) -(defmethod copy [String File] [#^String input #^File output] +(defmethod copy [String File] [^String input ^File output] (copy (StringReader. input) output)) -(defmethod copy [*byte-array-type* OutputStream] [#^"[B" input #^OutputStream output] +(defmethod copy [*byte-array-type* OutputStream] [^"[B" input ^OutputStream output] (copy (ByteArrayInputStream. input) output)) -(defmethod copy [*byte-array-type* Writer] [#^"[B" input #^Writer output] +(defmethod copy [*byte-array-type* Writer] [^"[B" input ^Writer output] (copy (ByteArrayInputStream. input) output)) -(defmethod copy [*byte-array-type* File] [#^"[B" input #^Writer output] +(defmethod copy [*byte-array-type* File] [^"[B" input ^Writer output] (copy (ByteArrayInputStream. input) output)) (defn make-parents "Creates all parent directories of file." - [#^File file] + [^File file] (.mkdirs (.getParentFile file))) (defmulti - #^{:doc "Converts argument into a Java byte array. Argument may be + ^{:doc "Converts argument into a Java byte array. Argument may be a String, File, InputStream, or Reader. If the argument is already a byte array, returns it." :arglists '([arg])} @@ -398,20 +398,20 @@ (defmethod to-byte-array *byte-array-type* [x] x) -(defmethod to-byte-array String [#^String x] +(defmethod to-byte-array String [^String x] (.getBytes x *default-encoding*)) -(defmethod to-byte-array File [#^File x] +(defmethod to-byte-array File [^File x] (with-open [input (FileInputStream. x) buffer (ByteArrayOutputStream.)] (copy input buffer) (.toByteArray buffer))) -(defmethod to-byte-array InputStream [#^InputStream x] +(defmethod to-byte-array InputStream [^InputStream x] (let [buffer (ByteArrayOutputStream.)] (copy x buffer) (.toByteArray buffer))) -(defmethod to-byte-array Reader [#^Reader x] +(defmethod to-byte-array Reader [^Reader x] (.getBytes (slurp* x) *default-encoding*)) diff --git a/src/main/clojure/clojure/contrib/error_kit.clj b/src/main/clojure/clojure/contrib/error_kit.clj index 93ebddd4..6cffd859 100644 --- a/src/main/clojure/clojure/contrib/error_kit.clj +++ b/src/main/clojure/clojure/contrib/error_kit.clj @@ -12,7 +12,7 @@ ; or API adjustments. (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "EXPERIMENTAL System for defining and using custom errors Please contact Chouser if you have any suggestions for better names @@ -135,7 +135,7 @@ or API adjustments."} `[::continue '~continue-name [~@args]]) -(def #^{:doc "Special form to be used inside a 'with-handler'. When +(def ^{:doc "Special form to be used inside a 'with-handler'. When any error is 'raised' from withing the dynamic scope of 'body' that is of error-name's type or a derived type, the args will be bound and the body executed. If no 'error-name' is given, the body will @@ -147,7 +147,7 @@ or API adjustments."} [error-name? args-destruct-map-args & body])} handle) -(def #^{:doc "Special form to be used inside a 'with-handler'. +(def ^{:doc "Special form to be used inside a 'with-handler'. Control can be passed to this 'continue' form from a 'raise' enclosed in this with-handler's dynamic scope, when this 'continue-name' is given to a 'continue' form." diff --git a/src/main/clojure/clojure/contrib/except.clj b/src/main/clojure/clojure/contrib/except.clj index 93153342..720fcaf7 100644 --- a/src/main/clojure/clojure/contrib/except.clj +++ b/src/main/clojure/clojure/contrib/except.clj @@ -16,7 +16,7 @@ ;; Created 07 July 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "Provides functions that make it easy to specify the class, cause, and message when throwing an Exception or Error. The optional message is formatted using clojure.core/format."} diff --git a/src/main/clojure/clojure/contrib/fcase.clj b/src/main/clojure/clojure/contrib/fcase.clj index 62a49da0..4d0fc184 100644 --- a/src/main/clojure/clojure/contrib/fcase.clj +++ b/src/main/clojure/clojure/contrib/fcase.clj @@ -23,7 +23,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "This file defines a generic \"case\" macro called \"fcase\" which takes the equality-testing function as an argument. It also defines a traditional \"case\" macro that tests using \"=\" and variants that diff --git a/src/main/clojure/clojure/contrib/find_namespaces.clj b/src/main/clojure/clojure/contrib/find_namespaces.clj index 174820d4..928499c7 100644 --- a/src/main/clojure/clojure/contrib/find_namespaces.clj +++ b/src/main/clojure/clojure/contrib/find_namespaces.clj @@ -13,7 +13,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Search for ns declarations in dirs, JARs, or CLASSPATH"} clojure.contrib.find-namespaces (:require [clojure.contrib.classpath :as cp] @@ -27,14 +27,14 @@ (defn clojure-source-file? "Returns true if file is a normal file with a .clj extension." - [#^File file] + [^File file] (and (.isFile file) (.endsWith (.getName file) ".clj"))) (defn find-clojure-sources-in-dir "Searches recursively under dir for Clojure source files (.clj). Returns a sequence of File objects, in breadth-first sort order." - [#^File dir] + [^File dir] ;; Use sort by absolute path to get breadth-first search. (sort-by #(.getAbsolutePath %) (filter clojure-source-file? (file-seq dir)))) @@ -54,7 +54,7 @@ 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." - [#^PushbackReader rdr] + [^PushbackReader rdr] (try (let [form (read rdr)] (cond (ns-decl? form) form @@ -66,20 +66,20 @@ "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 file] + [^File file] (with-open [rdr (PushbackReader. (BufferedReader. (FileReader. file)))] (read-ns-decl rdr))) (defn find-ns-decls-in-dir "Searches dir recursively for (ns ...) declarations in Clojure source files; returns the unevaluated ns declarations." - [#^File dir] + [^File dir] (filter identity (map read-file-ns-decl (find-clojure-sources-in-dir dir)))) (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] + [^File dir] (map second (find-ns-decls-in-dir dir))) @@ -87,14 +87,14 @@ (defn clojure-sources-in-jar "Returns a sequence of filenames ending in .clj found in the JAR file." - [#^JarFile jar-file] + [^JarFile jar-file] (filter #(.endsWith % ".clj") (jar/filenames-in-jar jar-file))) (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] + [^JarFile jarfile ^String entry-name] (with-open [rdr (PushbackReader. (BufferedReader. (InputStreamReader. @@ -104,7 +104,7 @@ (defn find-ns-decls-in-jarfile "Searches the JAR file for Clojure source files containing (ns ...) declarations; returns the unevaluated ns declarations." - [#^JarFile jarfile] + [^JarFile jarfile] (filter identity (map #(read-ns-decl-from-jarfile-entry jarfile %) (clojure-sources-in-jar jarfile)))) @@ -113,7 +113,7 @@ "Searches the JAR file for Clojure source files containing (ns ...) declarations. Returns a sequence of the symbol names of the declared namespaces." - [#^JarFile jarfile] + [^JarFile jarfile] (map second (find-ns-decls-in-jarfile jarfile))) diff --git a/src/main/clojure/clojure/contrib/fnmap.clj b/src/main/clojure/clojure/contrib/fnmap.clj index f9cfc7c5..cc9824c5 100644 --- a/src/main/clojure/clojure/contrib/fnmap.clj +++ b/src/main/clojure/clojure/contrib/fnmap.clj @@ -9,7 +9,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Sierra" +(ns ^{:author "Stuart Sierra" :doc "Maps that dispatch get/assoc to user-defined functions. Note: requires AOT-compilation"} diff --git a/src/main/clojure/clojure/contrib/gen_html_docs.clj b/src/main/clojure/clojure/contrib/gen_html_docs.clj index 5a96b911..73166510 100644 --- a/src/main/clojure/clojure/contrib/gen_html_docs.clj +++ b/src/main/clojure/clojure/contrib/gen_html_docs.clj @@ -42,7 +42,7 @@ ;; * Remove the whojure dependency (ns - #^{:author "Craig Andera", + ^{:author "Craig Andera", :doc "Generates a single HTML page that contains the documentation for one or more Clojure libraries."} clojure.contrib.gen-html-docs diff --git a/src/main/clojure/clojure/contrib/generic.clj b/src/main/clojure/clojure/contrib/generic.clj index dc4ef572..44cc6db7 100644 --- a/src/main/clojure/clojure/contrib/generic.clj +++ b/src/main/clojure/clojure/contrib/generic.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :skip-wiki true :doc "Generic interfaces This library provides generic interfaces in the form of diff --git a/src/main/clojure/clojure/contrib/generic/arithmetic.clj b/src/main/clojure/clojure/contrib/generic/arithmetic.clj index 90b6e659..04f2c318 100644 --- a/src/main/clojure/clojure/contrib/generic/arithmetic.clj +++ b/src/main/clojure/clojure/contrib/generic/arithmetic.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Generic arithmetic interface This library defines generic versions of + - * / as multimethods that can be defined for any type. The minimal required diff --git a/src/main/clojure/clojure/contrib/generic/collection.clj b/src/main/clojure/clojure/contrib/generic/collection.clj index c708050b..cdca97fb 100644 --- a/src/main/clojure/clojure/contrib/generic/collection.clj +++ b/src/main/clojure/clojure/contrib/generic/collection.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Generic arithmetic interface This library defines generic versions of common collection-related functions as multimethods that can be diff --git a/src/main/clojure/clojure/contrib/generic/comparison.clj b/src/main/clojure/clojure/contrib/generic/comparison.clj index 47210cbf..e41b0792 100644 --- a/src/main/clojure/clojure/contrib/generic/comparison.clj +++ b/src/main/clojure/clojure/contrib/generic/comparison.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Generic comparison interface This library defines generic versions of = < > <= >= zero? as multimethods that can be defined for any type. Of the diff --git a/src/main/clojure/clojure/contrib/generic/functor.clj b/src/main/clojure/clojure/contrib/generic/functor.clj index 9faf4603..4728eaab 100644 --- a/src/main/clojure/clojure/contrib/generic/functor.clj +++ b/src/main/clojure/clojure/contrib/generic/functor.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Generic functor interface (fmap)"} clojure.contrib.generic.functor) diff --git a/src/main/clojure/clojure/contrib/generic/math_functions.clj b/src/main/clojure/clojure/contrib/generic/math_functions.clj index a0fb3609..c0918840 100644 --- a/src/main/clojure/clojure/contrib/generic/math_functions.clj +++ b/src/main/clojure/clojure/contrib/generic/math_functions.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Generic math function interface This library defines generic versions of common mathematical functions such as sqrt or sin as multimethods that can be diff --git a/src/main/clojure/clojure/contrib/graph.clj b/src/main/clojure/clojure/contrib/graph.clj index 0be6420c..226908fc 100644 --- a/src/main/clojure/clojure/contrib/graph.clj +++ b/src/main/clojure/clojure/contrib/graph.clj @@ -15,7 +15,7 @@ (ns - #^{:author "Jeffrey Straszheim", + ^{:author "Jeffrey Straszheim", :doc "Basic graph theory algorithms"} clojure.contrib.graph (use [clojure.set :only (union)])) diff --git a/src/main/clojure/clojure/contrib/greatest_least.clj b/src/main/clojure/clojure/contrib/greatest_least.clj index 79e41813..6fce1c0c 100644 --- a/src/main/clojure/clojure/contrib/greatest_least.clj +++ b/src/main/clojure/clojure/contrib/greatest_least.clj @@ -1,5 +1,5 @@ (ns - #^{:author "Vincent Foley", + ^{:author "Vincent Foley", :doc "Various functions for finding greatest and least values in a collection"} clojure.contrib.greatest-least) diff --git a/src/main/clojure/clojure/contrib/http/agent.clj b/src/main/clojure/clojure/contrib/http/agent.clj index cd257bb7..9582f803 100644 --- a/src/main/clojure/clojure/contrib/http/agent.clj +++ b/src/main/clojure/clojure/contrib/http/agent.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:doc "Agent-based asynchronous HTTP client. +(ns ^{:doc "Agent-based asynchronous HTTP client. This is a HTTP client library based on Java's HttpURLConnection class and Clojure's Agent system. It allows you to make multiple @@ -78,7 +78,7 @@ (defn- setup-http-connection "Sets the instance method, redirect behavior, and request headers of the HttpURLConnection." - [#^HttpURLConnection conn options] + [^HttpURLConnection conn options] (when-let [t (:connect-timeout options)] (.setConnectTimeout conn t)) (when-let [t (:read-timeout options)] @@ -96,7 +96,7 @@ (c/start-http-connection conn (:body options)) (assoc state ::state ::started))) -(defn- connection-success? [#^HttpURLConnection conn] +(defn- connection-success? [^HttpURLConnection conn] "Returns true if the HttpURLConnection response code is in the 2xx range." (= 2 (quot (.getResponseCode conn) 100))) @@ -105,7 +105,7 @@ "Agent action that opens the response body stream on the HTTP request; this will block until the response stream is available." ; [state options] - (let [#^HttpURLConnection conn (::connection state)] + (let [^HttpURLConnection conn (::connection state)] (assoc state ::response-stream (if (connection-success? conn) (.getInputStream conn) @@ -127,8 +127,8 @@ the HttpURLConnection." [state options] (when (::response-stream state) - (.close #^InputStream (::response-stream state))) - (.disconnect #^HttpURLConnection (::connection state)) + (.close ^InputStream (::response-stream state))) + (.disconnect ^HttpURLConnection (::connection state)) (assoc state ::response-stream nil ::state ::disconnected)) @@ -138,10 +138,10 @@ digit, an Integer." [digit http-agnt] (= digit (quot (.getResponseCode - #^HttpURLConnection (::connection @http-agnt)) + ^HttpURLConnection (::connection @http-agnt)) 100))) -(defn- #^ByteArrayOutputStream get-byte-buffer [http-agnt] +(defn- ^ByteArrayOutputStream get-byte-buffer [http-agnt] (let [buffer (result http-agnt)] (if (instance? ByteArrayOutputStream buffer) buffer @@ -270,9 +270,9 @@ ([http-agnt] (await http-agnt) ;; have to wait for Content-Encoding (string http-agnt (or (.getContentEncoding - #^HttpURLConnection (::connection @http-agnt)) + ^HttpURLConnection (::connection @http-agnt)) duck/*default-encoding*))) - ([http-agnt #^String encoding] + ([http-agnt ^String encoding] (.toString (get-byte-buffer http-agnt) encoding))) @@ -316,32 +316,32 @@ received." [http-agnt] (when (done? http-agnt) - (.getResponseCode #^HttpURLConnection (::connection @http-agnt)))) + (.getResponseCode ^HttpURLConnection (::connection @http-agnt)))) (defn message "Returns the HTTP response message (e.g. 'Not Found'), for this request, or nil if the response has not yet been received." [http-agnt] (when (done? http-agnt) - (.getResponseMessage #^HttpURLConnection (::connection @http-agnt)))) + (.getResponseMessage ^HttpURLConnection (::connection @http-agnt)))) (defn headers "Returns a map of HTTP response headers. Header names are converted to keywords in all lower-case Header values are strings. If a header appears more than once, only the last value is returned." [http-agnt] - (reduce (fn [m [#^String k v]] + (reduce (fn [m [^String k v]] (assoc m (when k (keyword (.toLowerCase k))) (last v))) {} (.getHeaderFields - #^HttpURLConnection (::connection @http-agnt)))) + ^HttpURLConnection (::connection @http-agnt)))) (defn headers-seq "Returns the HTTP response headers in order as a sequence of [String,String] pairs. The first 'header' name may be null for the HTTP status line." [http-agnt] - (let [#^HttpURLConnection conn (::connection @http-agnt) - f (fn thisfn [#^Integer i] + (let [^HttpURLConnection conn (::connection @http-agnt) + f (fn thisfn [^Integer i] ;; Get value first because first key may be nil. (when-let [value (.getHeaderField conn i)] (cons [(.getHeaderFieldKey conn i) value] diff --git a/src/main/clojure/clojure/contrib/http/connection.clj b/src/main/clojure/clojure/contrib/http/connection.clj index 0afc0cd9..1186f109 100644 --- a/src/main/clojure/clojure/contrib/http/connection.clj +++ b/src/main/clojure/clojure/contrib/http/connection.clj @@ -11,7 +11,7 @@ ;; agreeing to be bound by the terms of this license. You must not ;; remove this notice, or any other, from this software. -(ns #^{:doc "Low-level HTTP client API around HttpURLConnection"} +(ns ^{:doc "Low-level HTTP client API around HttpURLConnection"} clojure.contrib.http.connection (:require [clojure.contrib.io :as duck]) (:import (java.net URI URL HttpURLConnection) @@ -23,35 +23,35 @@ (.openConnection (duck/as-url url))) (defmulti - #^{:doc "Transmits a request entity body."} + ^{:doc "Transmits a request entity body."} send-request-entity (fn [conn entity] (type entity))) -(defmethod send-request-entity duck/*byte-array-type* [#^HttpURLConnection conn entity] +(defmethod send-request-entity duck/*byte-array-type* [^HttpURLConnection conn entity] (.setFixedLengthStreamingMode conn (count entity)) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity String [conn #^String entity] +(defmethod send-request-entity String [conn ^String entity] (send-request-entity conn (.getBytes entity duck/*default-encoding*))) -(defmethod send-request-entity File [#^HttpURLConnection conn #^File entity] +(defmethod send-request-entity File [^HttpURLConnection conn ^File entity] (.setFixedLengthStreamingMode conn (.length entity)) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity InputStream [#^HttpURLConnection conn entity] +(defmethod send-request-entity InputStream [^HttpURLConnection conn entity] (.setChunkedStreamingMode conn -1) (.connect conn) (duck/copy entity (.getOutputStream conn))) -(defmethod send-request-entity Reader [#^HttpURLConnection conn entity] +(defmethod send-request-entity Reader [^HttpURLConnection conn entity] (.setChunkedStreamingMode conn -1) (.connect conn) (duck/copy entity (.getOutputStream conn))) (defn start-http-connection - ([#^HttpURLConnection conn] (.connect conn)) - ([#^HttpURLConnection conn request-entity-body] + ([^HttpURLConnection conn] (.connect conn)) + ([^HttpURLConnection conn request-entity-body] (if request-entity-body (do (.setDoOutput conn true) (send-request-entity conn request-entity-body)) diff --git a/src/main/clojure/clojure/contrib/import_static.clj b/src/main/clojure/clojure/contrib/import_static.clj index 94d827a5..c15bac52 100644 --- a/src/main/clojure/clojure/contrib/import_static.clj +++ b/src/main/clojure/clojure/contrib/import_static.clj @@ -14,7 +14,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Import static Java methods/fields into Clojure"} clojure.contrib.import-static (:use clojure.set)) diff --git a/src/main/clojure/clojure/contrib/io.clj b/src/main/clojure/clojure/contrib/io.clj index b849300c..99325078 100644 --- a/src/main/clojure/clojure/contrib/io.clj +++ b/src/main/clojure/clojure/contrib/io.clj @@ -46,7 +46,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "This file defines polymorphic I/O utility functions for Clojure. The Streams protocol defines reader, writer, input-stream and @@ -68,31 +68,31 @@ (def - #^{:doc "Name of the default encoding to use when reading & writing. + ^{:doc "Name of the default encoding to use when reading & writing. Default is UTF-8." :tag "java.lang.String"} *default-encoding* "UTF-8") (def - #^{:doc "Size, in bytes or characters, of the buffer used when + ^{:doc "Size, in bytes or characters, of the buffer used when copying streams."} *buffer-size* 1024) (def - #^{:doc "Type object for a Java primitive byte array."} + ^{:doc "Type object for a Java primitive byte array."} *byte-array-type* (class (make-array Byte/TYPE 0))) (def - #^{:doc "Type object for a Java primitive char array."} + ^{:doc "Type object for a Java primitive char array."} *char-array-type* (class (make-array Character/TYPE 0))) -(defn #^File file-str +(defn ^File file-str "Concatenates args as strings and returns a java.io.File. Replaces all / and \\ with File/separatorChar. Replaces ~ at the start of the path with the user.home system property." [& args] - (let [#^String s (apply str args) + (let [^String s (apply str args) s (.replace s \\ File/separatorChar) s (.replace s \/ File/separatorChar) s (if (.startsWith s "~") @@ -102,7 +102,7 @@ (File. s))) (def - #^{:doc "If true, writer, output-stream and spit will open files in append mode. + ^{:doc "If true, writer, output-stream and spit will open files in append mode. Defaults to false. Instead of binding this var directly, use append-writer, append-output-stream or append-spit." :tag "java.lang.Boolean"} @@ -186,42 +186,42 @@ (extend File Streams (assoc default-streams-impl - :input-stream #(input-stream (FileInputStream. #^File %)) - :output-stream #(let [stream (FileOutputStream. #^File % *append*)] + :input-stream #(input-stream (FileInputStream. ^File %)) + :output-stream #(let [stream (FileOutputStream. ^File % *append*)] (binding [*append* false] (output-stream stream))))) (extend URL Streams (assoc default-streams-impl - :input-stream (fn [#^URL x] + :input-stream (fn [^URL x] (input-stream (if (= "file" (.getProtocol x)) (FileInputStream. (.getPath x)) (.openStream x)))) - :output-stream (fn [#^URL x] + :output-stream (fn [^URL x] (if (= "file" (.getProtocol x)) (output-stream (File. (.getPath x))) (throw (Exception. (str "Can not write to non-file URL <" x ">"))))))) (extend URI Streams (assoc default-streams-impl - :input-stream #(input-stream (.toURL #^URI %)) - :output-stream #(output-stream (.toURL #^URI %)))) + :input-stream #(input-stream (.toURL ^URI %)) + :output-stream #(output-stream (.toURL ^URI %)))) (extend String Streams (assoc default-streams-impl :input-stream #(try (input-stream (URL. %)) (catch MalformedURLException e - (input-stream (File. #^String %)))) + (input-stream (File. ^String %)))) :output-stream #(try (output-stream (URL. %)) (catch MalformedURLException err - (output-stream (File. #^String %)))))) + (output-stream (File. ^String %)))))) (extend Socket Streams (assoc default-streams-impl - :input-stream #(.getInputStream #^Socket %) - :output-stream #(output-stream (.getOutputStream #^Socket %)))) + :input-stream #(.getInputStream ^Socket %) + :output-stream #(output-stream (.getOutputStream ^Socket %)))) (extend *byte-array-type* Streams (assoc default-streams-impl :input-stream #(input-stream (ByteArrayInputStream. %)))) @@ -239,7 +239,7 @@ Streams (assoc default-streams-impl :reader identity)) (defn- inputstream->reader - [#^InputStream is] + [^InputStream is] (reader (InputStreamReader. is *default-encoding*))) (extend InputStream Streams @@ -259,7 +259,7 @@ Streams (assoc default-streams-impl :writer #(do (assert-not-appending) %))) (defn- outputstream->writer - [#^OutputStream os] + [^OutputStream os] (assert-not-appending) (writer (OutputStreamWriter. os *default-encoding*))) (extend OutputStream @@ -292,7 +292,7 @@ "Writes lines (a seq) to f, separated by newlines. f is opened with writer, and automatically closed at the end of the sequence." [f lines] - (with-open [#^BufferedWriter writer (writer f)] + (with-open [^BufferedWriter writer (writer f)] (loop [lines lines] (when-let [line (first lines)] (.write writer (str line)) @@ -303,17 +303,17 @@ "Like clojure.core/line-seq but opens f with reader. Automatically closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE." [f] - (let [read-line (fn this [#^BufferedReader rdr] + (let [read-line (fn this [^BufferedReader rdr] (lazy-seq (if-let [line (.readLine rdr)] (cons line (this rdr)) (.close rdr))))] (read-line (reader f)))) -(defn #^String slurp* +(defn ^String slurp* "Like clojure.core/slurp but opens f with reader." [f] - (with-open [#^BufferedReader r (reader f)] + (with-open [^BufferedReader r (reader f)] (let [sb (StringBuilder.)] (loop [c (.read r)] (if (neg? c) @@ -325,13 +325,13 @@ "Opposite of slurp. Opens f with writer, writes content, then closes f." [f content] - (with-open [#^Writer w (writer f)] + (with-open [^Writer w (writer f)] (.write w content))) (defn append-spit "Like spit but appends to file." [f content] - (with-open [#^Writer w (append-writer f)] + (with-open [^Writer w (append-writer f)] (.write w content))) (defn pwd @@ -365,7 +365,7 @@ ~@body))) (defmulti - #^{:doc "Copies input to output. Returns nil. + ^{:doc "Copies input to output. Returns nil. Input may be an InputStream, Reader, File, byte[], or String. Output may be an OutputStream, Writer, or File. @@ -377,7 +377,7 @@ copy (fn [input output] [(type input) (type output)])) -(defmethod copy [InputStream OutputStream] [#^InputStream input #^OutputStream output] +(defmethod copy [InputStream OutputStream] [^InputStream input ^OutputStream output] (let [buffer (make-array Byte/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] @@ -385,8 +385,8 @@ (do (.write output buffer 0 size) (recur))))))) -(defmethod copy [InputStream Writer] [#^InputStream input #^Writer output] - (let [#^"[B" buffer (make-array Byte/TYPE *buffer-size*)] +(defmethod copy [InputStream Writer] [^InputStream input ^Writer output] + (let [^"[B" buffer (make-array Byte/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) @@ -394,12 +394,12 @@ (do (.write output chars) (recur)))))))) -(defmethod copy [InputStream File] [#^InputStream input #^File output] +(defmethod copy [InputStream File] [^InputStream input ^File output] (with-open [out (FileOutputStream. output)] (copy input out))) -(defmethod copy [Reader OutputStream] [#^Reader input #^OutputStream output] - (let [#^"[C" buffer (make-array Character/TYPE *buffer-size*)] +(defmethod copy [Reader OutputStream] [^Reader input ^OutputStream output] + (let [^"[C" buffer (make-array Character/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) @@ -407,66 +407,66 @@ (do (.write output bytes) (recur)))))))) -(defmethod copy [Reader Writer] [#^Reader input #^Writer output] - (let [#^"[C" buffer (make-array Character/TYPE *buffer-size*)] +(defmethod copy [Reader Writer] [^Reader input ^Writer output] + (let [^"[C" buffer (make-array Character/TYPE *buffer-size*)] (loop [] (let [size (.read input buffer)] (when (pos? size) (do (.write output buffer 0 size) (recur))))))) -(defmethod copy [Reader File] [#^Reader input #^File output] +(defmethod copy [Reader File] [^Reader input ^File output] (with-open [out (FileOutputStream. output)] (copy input out))) -(defmethod copy [File OutputStream] [#^File input #^OutputStream output] +(defmethod copy [File OutputStream] [^File input ^OutputStream output] (with-open [in (FileInputStream. input)] (copy in output))) -(defmethod copy [File Writer] [#^File input #^Writer output] +(defmethod copy [File Writer] [^File input ^Writer output] (with-open [in (FileInputStream. input)] (copy in output))) -(defmethod copy [File File] [#^File input #^File output] +(defmethod copy [File File] [^File input ^File output] (with-open [in (FileInputStream. input) out (FileOutputStream. output)] (copy in out))) -(defmethod copy [String OutputStream] [#^String input #^OutputStream output] +(defmethod copy [String OutputStream] [^String input ^OutputStream output] (copy (StringReader. input) output)) -(defmethod copy [String Writer] [#^String input #^Writer output] +(defmethod copy [String Writer] [^String input ^Writer output] (copy (StringReader. input) output)) -(defmethod copy [String File] [#^String input #^File output] +(defmethod copy [String File] [^String input ^File output] (copy (StringReader. input) output)) -(defmethod copy [*char-array-type* OutputStream] [input #^OutputStream output] +(defmethod copy [*char-array-type* OutputStream] [input ^OutputStream output] (copy (CharArrayReader. input) output)) -(defmethod copy [*char-array-type* Writer] [input #^Writer output] +(defmethod copy [*char-array-type* Writer] [input ^Writer output] (copy (CharArrayReader. input) output)) -(defmethod copy [*char-array-type* File] [input #^File output] +(defmethod copy [*char-array-type* File] [input ^File output] (copy (CharArrayReader. input) output)) -(defmethod copy [*byte-array-type* OutputStream] [#^"[B" input #^OutputStream output] +(defmethod copy [*byte-array-type* OutputStream] [^"[B" input ^OutputStream output] (copy (ByteArrayInputStream. input) output)) -(defmethod copy [*byte-array-type* Writer] [#^"[B" input #^Writer output] +(defmethod copy [*byte-array-type* Writer] [^"[B" input ^Writer output] (copy (ByteArrayInputStream. input) output)) -(defmethod copy [*byte-array-type* File] [#^"[B" input #^Writer output] +(defmethod copy [*byte-array-type* File] [^"[B" input ^Writer output] (copy (ByteArrayInputStream. input) output)) (defn make-parents "Creates all parent directories of file." - [#^File file] + [^File file] (.mkdirs (.getParentFile file))) (defmulti - #^{:doc "Converts argument into a Java byte array. Argument may be + ^{:doc "Converts argument into a Java byte array. Argument may be a String, File, InputStream, or Reader. If the argument is already a byte array, returns it." :arglists '([arg])} @@ -474,21 +474,21 @@ (defmethod to-byte-array *byte-array-type* [x] x) -(defmethod to-byte-array String [#^String x] +(defmethod to-byte-array String [^String x] (.getBytes x *default-encoding*)) -(defmethod to-byte-array File [#^File x] +(defmethod to-byte-array File [^File x] (with-open [input (FileInputStream. x) buffer (ByteArrayOutputStream.)] (copy input buffer) (.toByteArray buffer))) -(defmethod to-byte-array InputStream [#^InputStream x] +(defmethod to-byte-array InputStream [^InputStream x] (let [buffer (ByteArrayOutputStream.)] (copy x buffer) (.toByteArray buffer))) -(defmethod to-byte-array Reader [#^Reader x] +(defmethod to-byte-array Reader [^Reader x] (.getBytes (slurp* x) *default-encoding*)) (defmulti relative-path-string @@ -496,28 +496,28 @@ Building block for clojure.contrib.java/file." class) -(defmethod relative-path-string String [#^String s] +(defmethod relative-path-string String [^String s] (relative-path-string (File. s))) -(defmethod relative-path-string File [#^File f] +(defmethod relative-path-string File [^File f] (if (.isAbsolute f) (throw (IllegalArgumentException. (str f " is not a relative path"))) (.getPath f))) -(defmulti #^File as-file +(defmulti ^File as-file "Interpret a String or a java.io.File as a File. Building block for clojure.contrib.java/file, which you should prefer in most cases." class) -(defmethod as-file String [#^String s] (File. s)) +(defmethod as-file String [^String s] (File. s)) (defmethod as-file File [f] f) -(defn #^File file +(defn ^File file "Returns a java.io.File from string or file args." ([arg] (as-file arg)) ([parent child] - (File. #^File (as-file parent) #^String (relative-path-string child))) + (File. ^File (as-file parent) ^String (relative-path-string child))) ([parent child & more] (reduce file (file parent child) more))) @@ -539,14 +539,14 @@ Raise an exception if any deletion fails unless silently is true." (delete-file f silently))) (defmulti - #^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." + ^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." :arglists '([arg])} as-url type) (defmethod as-url URL [x] x) -(defmethod as-url URI [#^URI x] (.toURL x)) +(defmethod as-url URI [^URI x] (.toURL x)) -(defmethod as-url String [#^String x] (URL. x)) +(defmethod as-url String [^String x] (URL. x)) -(defmethod as-url File [#^File x] (.toURL x)) +(defmethod as-url File [^File x] (.toURL x)) diff --git a/src/main/clojure/clojure/contrib/jar.clj b/src/main/clojure/clojure/contrib/jar.clj index de979bba..df471f27 100644 --- a/src/main/clojure/clojure/contrib/jar.clj +++ b/src/main/clojure/clojure/contrib/jar.clj @@ -13,7 +13,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Utilities for working with Java JAR files"} clojure.contrib.jar (:import (java.io File) @@ -21,7 +21,7 @@ (defn jar-file? "Returns true if file is a normal file with a .jar or .JAR extension." - [#^File file] + [^File file] (and (.isFile file) (or (.endsWith (.getName file) ".jar") (.endsWith (.getName file) ".JAR")))) @@ -29,7 +29,7 @@ (defn filenames-in-jar "Returns a sequence of Strings naming the non-directory entries in the JAR file." - [#^JarFile jar-file] + [^JarFile jar-file] (map #(.getName %) (filter #(not (.isDirectory %)) (enumeration-seq (.entries jar-file))))) diff --git a/src/main/clojure/clojure/contrib/java_utils.clj b/src/main/clojure/clojure/contrib/java_utils.clj index e8d93782..70a31f8b 100644 --- a/src/main/clojure/clojure/contrib/java_utils.clj +++ b/src/main/clojure/clojure/contrib/java_utils.clj @@ -33,7 +33,7 @@ ; Stuart Sierra (ns - #^{:author "Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard, Stuart Sierra", + ^{:author "Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard, Stuart Sierra", :doc "A set of utilties for dealing with Java stuff like files and properties. Design goals: @@ -64,28 +64,28 @@ Building block for clojure.contrib.java-utils/file." class) -(defmethod relative-path-string String [#^String s] +(defmethod relative-path-string String [^String s] (relative-path-string (File. s))) -(defmethod relative-path-string File [#^File f] +(defmethod relative-path-string File [^File f] (if (.isAbsolute f) (throw (IllegalArgumentException. (str f " is not a relative path"))) (.getPath f))) -(defmulti #^File as-file +(defmulti ^File as-file "Interpret a String or a java.io.File as a File. Building block for clojure.contrib.java-utils/file, which you should prefer in most cases." class) -(defmethod as-file String [#^String s] (File. s)) +(defmethod as-file String [^String s] (File. s)) (defmethod as-file File [f] f) -(defn #^File file +(defn ^File file "Returns a java.io.File from string or file args." ([arg] (as-file arg)) ([parent child] - (File. #^File (as-file parent) #^String (relative-path-string child))) + (File. ^File (as-file parent) ^String (relative-path-string child))) ([parent child & more] (reduce file (file parent child) more))) @@ -108,11 +108,11 @@ (name x) (str x))) ([x & ys] - ((fn [#^StringBuilder sb more] + ((fn [^StringBuilder sb more] (if more (recur (. sb (append (as-str (first more)))) (next more)) (str sb))) - (new StringBuilder #^String (as-str x)) ys))) + (new StringBuilder ^String (as-str x)) ys))) (defn get-system-property "Get a system property." @@ -149,7 +149,7 @@ ; Not there is no corresponding props->map. Just destructure! -(defn #^Properties as-properties +(defn ^Properties as-properties "Convert any seq of pairs to a java.utils.Properties instance. Uses as-str to convert both keys and values into strings." {:tag Properties} @@ -171,9 +171,9 @@ {:tag Properties} ([m file-able] (write-properties m file-able nil)) ([m file-able comments] - (with-open [#^FileOutputStream f (FileOutputStream. (file file-able))] + (with-open [^FileOutputStream f (FileOutputStream. (file file-able))] (doto (as-properties m) - (.store f #^String comments))))) + (.store f ^String comments))))) (defn delete-file "Delete file f. Raise an exception if it fails unless silently is true." @@ -193,17 +193,17 @@ Raise an exception if any deletion fails unless silently is true." (delete-file f silently))) (defmulti - #^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." + ^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." :arglists '([arg])} as-url type) (defmethod as-url URL [x] x) -(defmethod as-url URI [#^URI x] (.toURL x)) +(defmethod as-url URI [^URI x] (.toURL x)) -(defmethod as-url String [#^String x] (URL. x)) +(defmethod as-url String [^String x] (URL. x)) -(defmethod as-url File [#^File x] (.toURL x)) +(defmethod as-url File [^File x] (.toURL x)) (defn wall-hack-method "Calls a private or protected method. diff --git a/src/main/clojure/clojure/contrib/javadoc/browse.clj b/src/main/clojure/clojure/contrib/javadoc/browse.clj index b6d99e4d..af61772d 100644 --- a/src/main/clojure/clojure/contrib/javadoc/browse.clj +++ b/src/main/clojure/clojure/contrib/javadoc/browse.clj @@ -10,7 +10,7 @@ ; You must not remove this notice, or any other, from this software. (ns - #^{:author "Christophe Grand", + ^{:author "Christophe Grand", :doc "Start a web browser from Clojure"} clojure.contrib.javadoc.browse (:require [clojure.contrib.shell :as sh]) diff --git a/src/main/clojure/clojure/contrib/javadoc/browse_ui.clj b/src/main/clojure/clojure/contrib/javadoc/browse_ui.clj index c76d39dd..4bda1ff9 100644 --- a/src/main/clojure/clojure/contrib/javadoc/browse_ui.clj +++ b/src/main/clojure/clojure/contrib/javadoc/browse_ui.clj @@ -18,7 +18,7 @@ (.setEditable htmlpane false) (.addHyperlinkListener htmlpane (proxy [javax.swing.event.HyperlinkListener] [] - (hyperlinkUpdate [#^javax.swing.event.HyperlinkEvent e] + (hyperlinkUpdate [^javax.swing.event.HyperlinkEvent e] (when (= (.getEventType e) (. javax.swing.event.HyperlinkEvent$EventType ACTIVATED)) (if (instance? javax.swing.text.html.HTMLFrameHyperlinkEvent e) (-> htmlpane .getDocument (.processHTMLFrameHyperlinkEvent e)) diff --git a/src/main/clojure/clojure/contrib/jmx.clj b/src/main/clojure/clojure/contrib/jmx.clj index 978baa83..ca0232ed 100644 --- a/src/main/clojure/clojure/contrib/jmx.clj +++ b/src/main/clojure/clojure/contrib/jmx.clj @@ -7,7 +7,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Halloway" +(ns ^{:author "Stuart Halloway" :doc "JMX support for Clojure Requires post-Clojure 1.0 git edge for clojure.test, clojure.backtrace. diff --git a/src/main/clojure/clojure/contrib/json.clj b/src/main/clojure/clojure/contrib/json.clj index 0a3e7b33..69f6cc9d 100644 --- a/src/main/clojure/clojure/contrib/json.clj +++ b/src/main/clojure/clojure/contrib/json.clj @@ -11,7 +11,7 @@ ;; agreeing to be bound by the terms of this license. You must not ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Sierra" +(ns ^{:author "Stuart Sierra" :doc "JavaScript Object Notation (JSON) parser/writer. See http://www.json.org/ To write JSON, use json-str, write-json, or write-json. @@ -26,7 +26,7 @@ (declare read-json-reader) -(defn- read-json-array [#^PushbackReader stream keywordize?] +(defn- read-json-array [^PushbackReader stream keywordize?] ;; Expects to be called with the head of the stream AFTER the ;; opening bracket. (loop [i (.read stream), result (transient [])] @@ -40,7 +40,7 @@ (let [element (read-json-reader stream keywordize? true nil)] (recur (.read stream) (conj! result element)))))))) -(defn- read-json-object [#^PushbackReader stream keywordize?] +(defn- read-json-object [^PushbackReader stream keywordize?] ;; Expects to be called with the head of the stream AFTER the ;; opening bracket. (loop [i (.read stream), key nil, result (transient {})] @@ -68,7 +68,7 @@ (assoc! result (if keywordize? (keyword key) key) element))))))))) -(defn- read-json-hex-character [#^PushbackReader stream] +(defn- read-json-hex-character [^PushbackReader stream] ;; Expects to be called with the head of the stream AFTER the ;; initial "\u". Reads the next four characters from the stream. (let [digits [(.read stream) @@ -83,7 +83,7 @@ (throw (Exception. "JSON error (invalid hex character in Unicode character escape)"))) (char (Integer/parseInt (apply str chars) 16))))) -(defn- read-json-escaped-character [#^PushbackReader stream] +(defn- read-json-escaped-character [^PushbackReader stream] ;; Expects to be called with the head of the stream AFTER the ;; initial backslash. (let [c (char (.read stream))] @@ -96,7 +96,7 @@ (= c \t) \tab (= c \u) (read-json-hex-character stream)))) -(defn- read-json-quoted-string [#^PushbackReader stream] +(defn- read-json-quoted-string [^PushbackReader stream] ;; Expects to be called with the head of the stream AFTER the ;; opening quotation mark. (let [buffer (StringBuilder.)] @@ -111,7 +111,7 @@ (recur (.read stream)))))))) (defn- read-json-reader - ([#^PushbackReader stream keywordize? eof-error? eof-value] + ([^PushbackReader stream keywordize? eof-error? eof-value] (loop [i (.read stream)] (let [c (char i)] (cond @@ -205,8 +205,8 @@ (write-json [object out] "Print object to PrintWriter out as JSON")) -(defn- write-json-string [#^CharSequence s #^PrintWriter out] - (let [sb (StringBuilder. #^Integer (count s))] +(defn- write-json-string [^CharSequence s ^PrintWriter out] + (let [sb (StringBuilder. ^Integer (count s))] (.append sb \") (dotimes [i (count s)] (let [cp (Character/codePointAt s i)] @@ -228,7 +228,7 @@ (.append sb \") (.print out (str sb)))) -(defn- write-json-object [m #^PrintWriter out] +(defn- write-json-object [m ^PrintWriter out] (.print out \{) (loop [x m] (when (seq m) @@ -246,7 +246,7 @@ (recur nxt))))) (.print out \})) -(defn- write-json-array [s #^PrintWriter out] +(defn- write-json-array [s ^PrintWriter out] (.print out \[) (loop [x s] (when (seq x) @@ -258,16 +258,16 @@ (recur nxt))))) (.print out \])) -(defn- write-json-bignum [x #^PrintWriter out] +(defn- write-json-bignum [x ^PrintWriter out] (.print out (str x))) -(defn- write-json-plain [x #^PrintWriter out] +(defn- write-json-plain [x ^PrintWriter out] (.print out x)) -(defn- write-json-null [x #^PrintWriter out] +(defn- write-json-null [x ^PrintWriter out] (.print out "null")) -(defn- write-json-named [x #^PrintWriter out] +(defn- write-json-named [x ^PrintWriter out] (write-json-string (name x) out)) (defn- write-json-generic [x out] diff --git a/src/main/clojure/clojure/contrib/lazy_seqs.clj b/src/main/clojure/clojure/contrib/lazy_seqs.clj index 6b42d0a6..2a0c0a6c 100644 --- a/src/main/clojure/clojure/contrib/lazy_seqs.clj +++ b/src/main/clojure/clojure/contrib/lazy_seqs.clj @@ -33,7 +33,7 @@ ;; Created 07 June 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc " ==== Lazy sequences ==== diff --git a/src/main/clojure/clojure/contrib/lazy_xml.clj b/src/main/clojure/clojure/contrib/lazy_xml.clj index 07f775a4..5b4ce124 100644 --- a/src/main/clojure/clojure/contrib/lazy_xml.clj +++ b/src/main/clojure/clojure/contrib/lazy_xml.clj @@ -9,7 +9,7 @@ ; Functions to parse xml lazily and emit back to text. (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "Functions to parse xml lazily and emit back to text."} clojure.contrib.lazy-xml (:use [clojure.xml :as xml :only []] @@ -53,7 +53,7 @@ (let [s (if (instance? Reader s) (InputSource. s) s) f (fn filler-func [fill] (startparse s (proxy [DefaultHandler] [] - (startElement [uri local-name q-name #^Attributes atts] + (startElement [uri local-name q-name ^Attributes atts] ;(prn :start-element q-name)(flush) (let [attrs (into {} (for [i (range (.getLength atts))] [(keyword (.getQName atts i)) @@ -118,16 +118,16 @@ (getLocalName [_ i] (name (key (v i)))) (getQName [_ i] (name (key (v i)))) (getValue [_ uri name] (get (:attrs e) name)) - (#^String getValue [_ #^int i] (val (v i))) - (#^String getType [_ #^int i] "CDATA")))) + (^String getValue [_ ^int i] (val (v i))) + (^String getType [_ ^int i] "CDATA")))) (defn- emit-element "Recursively prints as XML text the element struct e. To have it print extra whitespace like clojure.xml/emit, use the :pad true option." - [e #^org.xml.sax.ContentHandler ch] + [e ^org.xml.sax.ContentHandler ch] (if (instance? String e) - (.characters ch (.toCharArray #^String e) 0 (count e)) + (.characters ch (.toCharArray ^String e) 0 (count e)) (let [nspace (namespace (:tag e)) qname (name (:tag e))] (.startElement ch (or nspace "") qname qname (attributes e)) @@ -163,7 +163,7 @@ (setFeature [_ name value]) (setProperty [_ name value]) (setContentHandler [_ ch] (reset! content-handler ch)) - (#^void parse [_ #^org.xml.sax.InputSource _] + (^void parse [_ ^org.xml.sax.InputSource _] (when @content-handler (.startDocument @content-handler) (emit-element e @content-handler) diff --git a/src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj b/src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj index 06181569..761456e1 100644 --- a/src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj +++ b/src/main/clojure/clojure/contrib/lazy_xml/with_pull.clj @@ -46,7 +46,7 @@ (pull-step xpp))))))] (lazy-seq (step xpp)))) -(def #^{:private true} factory +(def ^{:private true} factory (doto (XmlPullParserFactory/newInstance) (.setNamespaceAware true))) diff --git a/src/main/clojure/clojure/contrib/logging.clj b/src/main/clojure/clojure/contrib/logging.clj index 58c40ac4..30141e7b 100644 --- a/src/main/clojure/clojure/contrib/logging.clj +++ b/src/main/clojure/clojure/contrib/logging.clj @@ -11,7 +11,7 @@ ;; agreeing to be bound by the terms of this license. You must not ;; remove this notice, or any other, from this software. (ns - #^{:author "Alex Taggart, Timothy Pratley", + ^{:author "Alex Taggart, Timothy Pratley", :doc "Logging macros which delegate to a specific logging implementation. At runtime a specific implementation is selected from, in order, Apache @@ -54,14 +54,14 @@ (defmacro def-impl-name {:private true} [& body] `(def - #^{:doc "The name of the logging implementation used."} + ^{:doc "The name of the logging implementation used."} *impl-name* ~@body)) (defmacro def-impl-get-log {:private true} [& body] `(def - #^{:doc + ^{:doc "Returns an implementation-specific log by string namespace. End-users should not need to call this." :arglist '([~'log-ns])} @@ -71,7 +71,7 @@ (defmacro def-impl-enabled? {:private true} [& body] `(def - #^{:doc + ^{:doc "Implementation-specific check if a particular level is enabled. End-users should not need to call this." :arglist '([~'log ~'level])} @@ -81,7 +81,7 @@ (defmacro def-impl-write! {:private true} [& body] `(def - #^{:doc + ^{:doc "Implementation-specific write of a log message. End-users should not need to call this." :arglist '([~'log ~'level ~'message ~'throwable])} @@ -99,9 +99,9 @@ (def-impl-name "org.apache.commons.logging") (def-impl-get-log (fn [log-ns#] - (org.apache.commons.logging.LogFactory/getLog #^String log-ns#))) + (org.apache.commons.logging.LogFactory/getLog ^String log-ns#))) (def-impl-enabled? - (fn [#^org.apache.commons.logging.Log log# level#] + (fn [^org.apache.commons.logging.Log log# level#] (condp = level# :trace (.isTraceEnabled log#) :debug (.isDebugEnabled log#) @@ -110,7 +110,7 @@ :error (.isErrorEnabled log#) :fatal (.isFatalEnabled log#)))) (def-impl-write! - (fn [#^org.apache.commons.logging.Log log# level# msg# e#] + (fn [^org.apache.commons.logging.Log log# level# msg# e#] (condp = level# :trace (.trace log# msg# e#) :debug (.debug log# msg# e#) @@ -133,7 +133,7 @@ (def-impl-name "org.apache.log4j") (def-impl-get-log (fn [log-ns#] - (org.apache.log4j.Logger/getLogger #^String log-ns#))) + (org.apache.log4j.Logger/getLogger ^String log-ns#))) (let [levels# {:trace org.apache.log4j.Level/TRACE :debug org.apache.log4j.Level/DEBUG :info org.apache.log4j.Level/INFO @@ -141,10 +141,10 @@ :error org.apache.log4j.Level/ERROR :fatal org.apache.log4j.Level/FATAL}] (def-impl-enabled? - (fn [#^org.apache.log4j.Logger log# level#] + (fn [^org.apache.log4j.Logger log# level#] (.isEnabledFor log# (levels# level#)))) (def-impl-write! - (fn [#^org.apache.log4j.Logger log# level# msg# e#] + (fn [^org.apache.log4j.Logger log# level# msg# e#] (if-not e# (.log log# (levels# level#) msg#) (.log log# (levels# level#) msg# e#))))) @@ -171,15 +171,15 @@ :error java.util.logging.Level/SEVERE :fatal java.util.logging.Level/SEVERE}] (def-impl-enabled? - (fn [#^java.util.logging.Logger log# level#] + (fn [^java.util.logging.Logger log# level#] (.isLoggable log# (levels# level#)))) (def-impl-write! - (fn [#^java.util.logging.Logger log# level# msg# e#] + (fn [^java.util.logging.Logger log# level# msg# e#] (if-not e# - (.log log# #^java.util.logging.Level (levels# level#) - #^String (str msg#)) - (.log log# #^java.util.logging.Level (levels# level#) - #^String (str msg#) #^Throwable e#))))) + (.log log# ^java.util.logging.Level (levels# level#) + ^String (str msg#)) + (.log log# ^java.util.logging.Level (levels# level#) + ^String (str msg#) ^Throwable e#))))) true)) (catch Exception e nil))) @@ -193,13 +193,13 @@ "Valid logging implementation could not be found."))) -(def #^{:doc +(def ^{:doc "The default agent used for performing logging durng a transaction or when direct logging is disabled."} *logging-agent* (agent nil)) -(def #^{:doc +(def ^{:doc "A boolean indicating whether direct logging (as opposed to via an agent) is allowed when not operating from within a transaction. Defaults to true."} *allow-direct-logging* (atom true)) @@ -248,14 +248,14 @@ (proxy [java.io.ByteArrayOutputStream] [] (flush [] (proxy-super flush) - (let [s (.trim (.toString #^java.io.ByteArrayOutputStream this))] + (let [s (.trim (.toString ^java.io.ByteArrayOutputStream this))] (proxy-super reset) (if (> (.length s) 0) (log level s nil log-ns))))) true)) -(def #^{:doc +(def ^{:doc "A ref used by log-capture! to maintain a reference to the original System.out and System.err streams." :private true} diff --git a/src/main/clojure/clojure/contrib/macro_utils.clj b/src/main/clojure/clojure/contrib/macro_utils.clj index 37ab3b88..e101f712 100644 --- a/src/main/clojure/clojure/contrib/macro_utils.clj +++ b/src/main/clojure/clojure/contrib/macro_utils.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Local macros and symbol macros Local macros are defined by a macrolet form. They are usable only diff --git a/src/main/clojure/clojure/contrib/macros.clj b/src/main/clojure/clojure/contrib/macros.clj index ffb67183..ce6b3237 100644 --- a/src/main/clojure/clojure/contrib/macros.clj +++ b/src/main/clojure/clojure/contrib/macros.clj @@ -10,7 +10,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Various small macros"} clojure.contrib.macros) diff --git a/src/main/clojure/clojure/contrib/map_utils.clj b/src/main/clojure/clojure/contrib/map_utils.clj index 4adf3068..886c2529 100644 --- a/src/main/clojure/clojure/contrib/map_utils.clj +++ b/src/main/clojure/clojure/contrib/map_utils.clj @@ -14,7 +14,7 @@ ;; Created 25 Feb 2009 (ns - #^{:author "Jason Wolfe, Chris Houser", + ^{:author "Jason Wolfe, Chris Houser", :doc "Utilities for operating on Clojure maps."} clojure.contrib.map-utils) diff --git a/src/main/clojure/clojure/contrib/math.clj b/src/main/clojure/clojure/contrib/math.clj index 56007c71..d4519de9 100644 --- a/src/main/clojure/clojure/contrib/math.clj +++ b/src/main/clojure/clojure/contrib/math.clj @@ -44,7 +44,7 @@ ;; returns the floor of the square root and the "remainder".
(ns
- #^{:author "Mark Engelberg",
+ ^{:author "Mark Engelberg",
:doc "Math functions that deal intelligently with the various
types in Clojure's numeric tower, as well as math functions
commonly found in Scheme implementations.
@@ -98,7 +98,7 @@ exact-integer-sqrt - Implements a math function from the R6RS Scheme (derive java.lang.Double ::inexact)
(derive java.lang.Float ::inexact)
-(defmulti #^{:arglists '([base pow])
+(defmulti ^{:arglists '([base pow])
:doc "(expt base pow) is base to the pow power.
Returns an exact number if the base is an exact number and the power is an integer, otherwise returns a double."}
expt (fn [x y] [(class x) (class y)]))
@@ -126,7 +126,7 @@ Returns an exact number if the base is an exact number and the power is an integ (neg? n) (- n)
:else n))
-(defmulti #^{:arglists '([n])
+(defmulti ^{:arglists '([n])
:doc "(floor n) returns the greatest integer less than or equal to n.
If n is an exact number, floor returns an integer, otherwise a double."}
floor class)
@@ -138,7 +138,7 @@ If n is an exact number, floor returns an integer, otherwise a double."} (defmethod floor :default [n]
(Math/floor n))
-(defmulti #^{:arglists '([n])
+(defmulti ^{:arglists '([n])
:doc "(ceil n) returns the least integer greater than or equal to n.
If n is an exact number, ceil returns an integer, otherwise a double."}
ceil class)
@@ -150,7 +150,7 @@ If n is an exact number, ceil returns an integer, otherwise a double."} (defmethod ceil :default [n]
(Math/ceil n))
-(defmulti #^{:arglists '([n])
+(defmulti ^{:arglists '([n])
:doc "(round n) rounds to the nearest integer.
round always returns an integer. Rounds up for values exactly in between two integers."}
round class)
@@ -176,7 +176,7 @@ round always returns an integer. Rounds up for values exactly in between two in :else (abs (* b (quot a (gcd a b))))))
; Length of integer in binary, used as helper function for sqrt.
-(defmulti #^{:private true} integer-length class)
+(defmulti ^{:private true} integer-length class)
(defmethod integer-length java.lang.Integer [n]
(count (Integer/toBinaryString n)))
(defmethod integer-length java.lang.Long [n]
@@ -212,7 +212,7 @@ For example, (exact-integer-sqrt 15) is [3 6] because 15 = 3^2+6." error (- n (* isqrt isqrt))]
[isqrt error])))
-(defmulti #^{:arglists '([n])
+(defmulti ^{:arglists '([n])
:doc "Square root, but returns exact number if possible."}
sqrt class)
(defmethod sqrt ::integer [n]
diff --git a/src/main/clojure/clojure/contrib/miglayout.clj b/src/main/clojure/clojure/contrib/miglayout.clj index 67aced84..f9c03a13 100644 --- a/src/main/clojure/clojure/contrib/miglayout.clj +++ b/src/main/clojure/clojure/contrib/miglayout.clj @@ -20,7 +20,7 @@ ;; Created 5 October 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "Clojure support for the MiGLayout layout manager http://www.miglayout.com/ @@ -66,7 +66,7 @@ Example: Any items marked with an \"id\" constraint will be included in a map from id to component attached to the container. The map can be retrieved using clojure.contrib.miglayout/components." - [#^JComponent container & args] + [^JComponent container & args] (let [item-constraints (apply parse-item-constraints args) {:keys [keywords components]} item-constraints {:keys [layout column row]} keywords] @@ -75,5 +75,5 @@ Example: (defn components "Returns a map from id (a keyword) to component for all components with an id constraint set" - [#^JComponent container] + [^JComponent container] (get-components container)) diff --git a/src/main/clojure/clojure/contrib/miglayout/internal.clj b/src/main/clojure/clojure/contrib/miglayout/internal.clj index 3f9877fe..f6e6431f 100644 --- a/src/main/clojure/clojure/contrib/miglayout/internal.clj +++ b/src/main/clojure/clojure/contrib/miglayout/internal.clj @@ -93,8 +93,8 @@ (defn add-components "Adds components with constraints to a container" - [#^JComponent container components] - (loop [[[#^Component component constraint] & components] components + [^JComponent container components] + (loop [[[^Component component constraint] & components] components id-map nil] (if component (let [cc (parse-component-constraint constraint)] @@ -108,13 +108,13 @@ (defn get-components "Returns a map from id to component for all components with an id" - [#^JComponent container] + [^JComponent container] (.getClientProperty container ::components)) (defn do-layout "Attaches a MigLayout layout manager to container and adds components with constraints" - [#^JComponent container layout column row components] + [^JComponent container layout column row components] (doto container (.setLayout (new-by-name MigLayout layout column row)) (add-components components))) diff --git a/src/main/clojure/clojure/contrib/mmap.clj b/src/main/clojure/clojure/contrib/mmap.clj index 341c27e3..0adbf38f 100644 --- a/src/main/clojure/clojure/contrib/mmap.clj +++ b/src/main/clojure/clojure/contrib/mmap.clj @@ -10,7 +10,7 @@ ; mmaped file for "normal" activies -- slurp, load-file, etc. (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "Functions for memory-mapping files, plus some functions that use a mmaped file for \"normal\" activies -- slurp, load-file, etc."} clojure.contrib.mmap @@ -21,7 +21,7 @@ mmaped file for \"normal\" activies -- slurp, load-file, etc."} ;(set! *warn-on-reflection* true) -(def READ_ONLY #^{:private true} +(def READ_ONLY ^{:private true} (java.nio.channels.FileChannel$MapMode/READ_ONLY)) (defn mmap @@ -32,13 +32,13 @@ mmaped file for \"normal\" activies -- slurp, load-file, etc."} (defn slurp "Reads the file named by f and returns it as a string." - [#^String f] + [^String f] (.. java.nio.charset.Charset (forName "UTF-8") (newDecoder) (decode (mmap f)))) (defn buffer-stream "Returns an InputStream for a ByteBuffer, such as returned by mmap." - [#^ByteBuffer buf] + [^ByteBuffer buf] (proxy [InputStream] [] (available [] (.remaining buf)) (read diff --git a/src/main/clojure/clojure/contrib/mock.clj b/src/main/clojure/clojure/contrib/mock.clj index e66d1fd1..aaa36a8c 100644 --- a/src/main/clojure/clojure/contrib/mock.clj +++ b/src/main/clojure/clojure/contrib/mock.clj @@ -51,7 +51,7 @@ ) ;; end comment
(ns clojure.contrib.mock
- #^{:author "Matt Clark",
+ ^{:author "Matt Clark",
:doc "function mocking/expectations for Clojure" }
(:use [clojure.contrib.seq :only (positions)]
[clojure.contrib.def :only (defmacro-)]))
@@ -177,7 +177,7 @@ increases count, returns return value. count checker for each dependency."
[mock-data] (doseq [[mfn i checker fn-name] mock-data] (checker fn-name @i)))
-(defn #^{:private true} make-bindings [expect-bindings mock-data-sym]
+(defn ^{:private true} make-bindings [expect-bindings mock-data-sym]
`[~@(interleave (map #(first %) (partition 2 expect-bindings))
(map (fn [i] `(nth (nth ~mock-data-sym ~i) 0))
(range (quot (count expect-bindings) 2))))])
diff --git a/src/main/clojure/clojure/contrib/monadic_io_streams.clj b/src/main/clojure/clojure/contrib/monadic_io_streams.clj index 6109ef92..7919ef3e 100644 --- a/src/main/clojure/clojure/contrib/monadic_io_streams.clj +++ b/src/main/clojure/clojure/contrib/monadic_io_streams.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Monadic I/O with Java input/output streams Defines monadic I/O statements to be used in a state monad with an input or output stream as the state. The macro @@ -56,7 +56,7 @@ (defn write "Write text (a string)" - [#^String text] + [^String text] (fn [s] [(.write (unlock s) text) s])) (defn flush diff --git a/src/main/clojure/clojure/contrib/monads.clj b/src/main/clojure/clojure/contrib/monads.clj index 8f90c01b..3cb1bd16 100644 --- a/src/main/clojure/clojure/contrib/monads.clj +++ b/src/main/clojure/clojure/contrib/monads.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :see-also [["http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/" "Monad tutorial part 1"] ["http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/" "Monad tutorial part 2"] ["http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/" "Monad tutorial part 3"] diff --git a/src/main/clojure/clojure/contrib/ns_utils.clj b/src/main/clojure/clojure/contrib/ns_utils.clj index d77b3217..ba8c43ce 100644 --- a/src/main/clojure/clojure/contrib/ns_utils.clj +++ b/src/main/clojure/clojure/contrib/ns_utils.clj @@ -40,7 +40,7 @@ ;; 23 April 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "Namespace utilities"} clojure.contrib.ns-utils (:use clojure.contrib.except)) diff --git a/src/main/clojure/clojure/contrib/pprint.clj b/src/main/clojure/clojure/contrib/pprint.clj index e738792d..2289e920 100644 --- a/src/main/clojure/clojure/contrib/pprint.clj +++ b/src/main/clojure/clojure/contrib/pprint.clj @@ -12,7 +12,7 @@ ;; You must not remove this notice, or any other, from this software. (ns - #^{:author "Tom Faulhaber", + ^{:author "Tom Faulhaber", :doc "This module comprises two elements: 1) A pretty printer for Clojure data structures, implemented in the function \"pprint\" diff --git a/src/main/clojure/clojure/contrib/pprint/cl_format.clj b/src/main/clojure/clojure/contrib/pprint/cl_format.clj index b93d535a..85f29b13 100644 --- a/src/main/clojure/clojure/contrib/pprint/cl_format.clj +++ b/src/main/clojure/clojure/contrib/pprint/cl_format.clj @@ -61,7 +61,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm navigator (init-navigator args)] (execute-format writer compiled-format navigator))) -(def #^{:private true} *format-str* nil) +(def ^{:private true} *format-str* nil) (defn- format-error [message offset] (let [full-message (str message \newline *format-str* \newline @@ -74,7 +74,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm ;;; (possibly going forwards and backwards as it does so) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defstruct #^{:private true} +(defstruct ^{:private true} arg-navigator :seq :rest :pos ) (defn init-navigator @@ -118,7 +118,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm (absolute-reposition navigator newpos) (struct arg-navigator (:seq navigator) (drop position (:rest navigator)) newpos)))) -(defstruct #^{:private true} +(defstruct ^{:private true} compiled-directive :func :def :params :offset) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -160,7 +160,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm (declare opt-base-str) -(def #^{:private true} +(def ^{:private true} special-radix-markers {2 "#b" 8 "#o", 16 "#x"}) (defn- format-simple-number [n] @@ -179,7 +179,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm (defn- format-ascii [print-func params arg-navigator offsets] (let [ [arg arg-navigator] (next-arg arg-navigator) - #^String base-output (or (format-simple-number arg) (print-func arg)) + ^String base-output (or (format-simple-number arg) (print-func arg)) base-width (.length base-output) min-width (+ base-width (:minpad params)) width (if (>= min-width (:mincol params)) @@ -207,7 +207,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm (integer? x) true (decimal? x) (>= (.ulp (.stripTrailingZeros (bigdec 0))) 1) ; true iff no fractional part (float? x) (= x (Math/floor x)) - (ratio? x) (let [#^clojure.lang.Ratio r x] + (ratio? x) (let [^clojure.lang.Ratio r x] (= 0 (rem (.numerator r) (.denominator r)))) :else false)) @@ -229,7 +229,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm "0" (let [xlated-val (cond (float? val) (bigdec val) - (ratio? val) (let [#^clojure.lang.Ratio r val] + (ratio? val) (let [^clojure.lang.Ratio r val] (/ (.numerator r) (.denominator r))) :else val)] (apply str @@ -237,7 +237,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm #(if (< % 10) (char (+ (int \0) %)) (char (+ (int \a) (- % 10)))) (remainders base val)))))) -(def #^{:private true} +(def ^{:private true} java-base-formats {8 "%o", 10 "%d", 16 "%x"}) (defn- opt-base-str @@ -265,7 +265,7 @@ for improved performance" commas (repeat (count groups) (:commachar params))] (apply str (next (interleave commas groups)))) raw-str) - #^String signed-str (cond + ^String signed-str (cond neg (str "-" group-str) (:at params) (str "+" group-str) true group-str) @@ -284,23 +284,23 @@ for improved performance" ;;; Support for english formats (~R and ~:R) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def #^{:private true} +(def ^{:private true} english-cardinal-units ["zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten" "eleven" "twelve" "thirteen" "fourteen" "fifteen" "sixteen" "seventeen" "eighteen" "nineteen"]) -(def #^{:private true} +(def ^{:private true} english-ordinal-units ["zeroth" "first" "second" "third" "fourth" "fifth" "sixth" "seventh" "eighth" "ninth" "tenth" "eleventh" "twelfth" "thirteenth" "fourteenth" "fifteenth" "sixteenth" "seventeenth" "eighteenth" "nineteenth"]) -(def #^{:private true} +(def ^{:private true} english-cardinal-tens ["" "" "twenty" "thirty" "forty" "fifty" "sixty" "seventy" "eighty" "ninety"]) -(def #^{:private true} +(def ^{:private true} english-ordinal-tens ["" "" "twentieth" "thirtieth" "fortieth" "fiftieth" "sixtieth" "seventieth" "eightieth" "ninetieth"]) @@ -309,7 +309,7 @@ for improved performance" ;; Number names from http://www.jimloy.com/math/billion.htm ;; We follow the rules for writing numbers from the Blue Book ;; (http://www.grammarbook.com/numbers/numbers.asp) -(def #^{:private true} +(def ^{:private true} english-scale-numbers ["" "thousand" "million" "billion" "trillion" "quadrillion" "quintillion" "sextillion" "septillion" "octillion" "nonillion" "decillion" @@ -434,14 +434,14 @@ Note this should only be used for the last one in the sequence" ;;; Support for roman numeral formats (~@R and ~@:R) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def #^{:private true} +(def ^{:private true} old-roman-table [[ "I" "II" "III" "IIII" "V" "VI" "VII" "VIII" "VIIII"] [ "X" "XX" "XXX" "XXXX" "L" "LX" "LXX" "LXXX" "LXXXX"] [ "C" "CC" "CCC" "CCCC" "D" "DC" "DCC" "DCCC" "DCCCC"] [ "M" "MM" "MMM"]]) -(def #^{:private true} +(def ^{:private true} new-roman-table [[ "I" "II" "III" "IV" "V" "VI" "VII" "VIII" "IX"] [ "X" "XX" "XXX" "XL" "L" "LX" "LXX" "LXXX" "XC"] @@ -482,7 +482,7 @@ Note this should only be used for the last one in the sequence" ;;; Support for character formats (~C) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def #^{:private true} +(def ^{:private true} special-chars { 8 "Backspace", 9 "Tab", 10 "Newline", 13 "Return", 32 "Space"}) (defn- pretty-character [params navigator offsets] @@ -539,8 +539,8 @@ Note this should only be used for the last one in the sequence" ;; TODO - return exponent as int to eliminate double conversion (defn- float-parts-base "Produce string parts for the mantissa (normalized 1-9) and exponent" - [#^Object f] - (let [#^String s (.toLowerCase (.toString f)) + [^Object f] + (let [^String s (.toLowerCase (.toString f)) exploc (.indexOf s (int \e))] (if (neg? exploc) (let [dotloc (.indexOf s (int \.))] @@ -553,11 +553,11 @@ Note this should only be used for the last one in the sequence" (defn- float-parts "Take care of leading and trailing zeros in decomposed floats" [f] - (let [[m #^String e] (float-parts-base f) + (let [[m ^String e] (float-parts-base f) m1 (rtrim m \0) m2 (ltrim m1 \0) delta (- (count m1) (count m2)) - #^String e (if (and (pos? (count e)) (= (nth e 0) \+)) (subs e 1) e)] + ^String e (if (and (pos? (count e)) (= (nth e 0) \+)) (subs e 1) e)] (if (empty? m2) ["0" 0] [m2 (- (Integer/valueOf e) delta)]))) @@ -578,7 +578,7 @@ Note this should only be used for the last one in the sequence" ["0" 0 false] (if (> len round-pos) (let [round-char (nth m1 round-pos) - #^String result (subs m1 0 round-pos)] + ^String result (subs m1 0 round-pos)] (if (>= (int round-char) (int \5)) (let [result-val (Integer/valueOf result) leading-zeros (subs result 0 (min (prefix-count result \0) (- round-pos 1))) @@ -670,7 +670,7 @@ Note this should only be used for the last one in the sequence" expchar (or (:exponentchar params) \E) add-sign (or (:at params) (neg? arg)) prepend-zero (<= k 0) - #^Integer scaled-exp (- exp (dec k)) + ^Integer scaled-exp (- exp (dec k)) scaled-exp-str (str (Math/abs scaled-exp)) scaled-exp-str (str expchar (if (neg? scaled-exp) \- \+) (if e (apply str @@ -756,14 +756,14 @@ Note this should only be used for the last one in the sequence" ;; the function to render ~$ directives ;; TODO: support rationals. Back off to ~D/~A is the appropriate cases (defn- dollar-float [params navigator offsets] - (let [[#^Double arg navigator] (next-arg navigator) + (let [[^Double arg navigator] (next-arg navigator) [mantissa exp] (float-parts (Math/abs arg)) d (:d params) ; digits after the decimal n (:n params) ; minimum digits before the decimal w (:w params) ; minimum field width add-sign (or (:at params) (neg? arg)) [rounded-mantissa scaled-exp expanded] (round-str mantissa exp d nil) - #^String fixed-repr (get-fixed rounded-mantissa (if expanded (inc scaled-exp) scaled-exp) d) + ^String fixed-repr (get-fixed rounded-mantissa (if expanded (inc scaled-exp) scaled-exp) d) full-repr (str (apply str (repeat (- n (.indexOf fixed-repr (int \.))) \0)) fixed-repr) full-len (+ (count full-repr) (if add-sign 1 0))] (print (str @@ -1012,45 +1012,45 @@ Note this should only be used for the last one in the sequence" (defn- downcase-writer "Returns a proxy that wraps writer, converting all characters to lower case" - [#^java.io.Writer writer] + [^java.io.Writer writer] (proxy [java.io.Writer] [] (close [] (.close writer)) (flush [] (.flush writer)) - (write ([#^chars cbuf #^Integer off #^Integer len] + (write ([^chars cbuf ^Integer off ^Integer len] (.write writer cbuf off len)) ([x] (condp = (class x) String - (let [s #^String x] + (let [s ^String x] (.write writer (.toLowerCase s))) Integer - (let [c #^Character x] + (let [c ^Character x] (.write writer (int (Character/toLowerCase (char c)))))))))) (defn- upcase-writer "Returns a proxy that wraps writer, converting all characters to upper case" - [#^java.io.Writer writer] + [^java.io.Writer writer] (proxy [java.io.Writer] [] (close [] (.close writer)) (flush [] (.flush writer)) - (write ([#^chars cbuf #^Integer off #^Integer len] + (write ([^chars cbuf ^Integer off ^Integer len] (.write writer cbuf off len)) ([x] (condp = (class x) String - (let [s #^String x] + (let [s ^String x] (.write writer (.toUpperCase s))) Integer - (let [c #^Character x] + (let [c ^Character x] (.write writer (int (Character/toUpperCase (char c)))))))))) (defn- capitalize-string "Capitalizes the words in a string. If first? is false, don't capitalize the first character of the string even if it's a letter." [s first?] - (let [#^Character f (first s) + (let [^Character f (first s) s (if (and first? f (Character/isLetter f)) (str (Character/toUpperCase f) (subs s 1)) s)] @@ -1065,51 +1065,51 @@ Note this should only be used for the last one in the sequence" offset (and match (inc (.start m)))] (if offset [(str (subs s 0 offset) - (Character/toUpperCase #^Character (nth s offset))) + (Character/toUpperCase ^Character (nth s offset))) (subs s (inc offset))] [s nil])))) s))))) (defn- capitalize-word-writer "Returns a proxy that wraps writer, captializing all words" - [#^java.io.Writer writer] + [^java.io.Writer writer] (let [last-was-whitespace? (ref true)] (proxy [java.io.Writer] [] (close [] (.close writer)) (flush [] (.flush writer)) (write - ([#^chars cbuf #^Integer off #^Integer len] + ([^chars cbuf ^Integer off ^Integer len] (.write writer cbuf off len)) ([x] (condp = (class x) String - (let [s #^String x] + (let [s ^String x] (.write writer - #^String (capitalize-string (.toLowerCase s) @last-was-whitespace?)) + ^String (capitalize-string (.toLowerCase s) @last-was-whitespace?)) (dosync (ref-set last-was-whitespace? (Character/isWhitespace - #^Character (nth s (dec (count s))))))) + ^Character (nth s (dec (count s))))))) Integer (let [c (char x)] - (let [mod-c (if @last-was-whitespace? (Character/toUpperCase #^Character (char x)) c)] + (let [mod-c (if @last-was-whitespace? (Character/toUpperCase ^Character (char x)) c)] (.write writer (int mod-c)) - (dosync (ref-set last-was-whitespace? (Character/isWhitespace #^Character (char x)))))))))))) + (dosync (ref-set last-was-whitespace? (Character/isWhitespace ^Character (char x)))))))))))) (defn- init-cap-writer "Returns a proxy that wraps writer, capitalizing the first word" - [#^java.io.Writer writer] + [^java.io.Writer writer] (let [capped (ref false)] (proxy [java.io.Writer] [] (close [] (.close writer)) (flush [] (.flush writer)) - (write ([#^chars cbuf #^Integer off #^Integer len] + (write ([^chars cbuf ^Integer off ^Integer len] (.write writer cbuf off len)) ([x] (condp = (class x) String - (let [s (.toLowerCase #^String x)] + (let [s (.toLowerCase ^String x)] (if (not @capped) (let [m (re-matcher #"\S" s) match (re-find m) @@ -1117,14 +1117,14 @@ Note this should only be used for the last one in the sequence" (if offset (do (.write writer (str (subs s 0 offset) - (Character/toUpperCase #^Character (nth s offset)) - (.toLowerCase #^String (subs s (inc offset))))) + (Character/toUpperCase ^Character (nth s offset)) + (.toLowerCase ^String (subs s (inc offset))))) (dosync (ref-set capped true))) (.write writer s))) (.write writer (.toLowerCase s)))) Integer - (let [c #^Character (char x)] + (let [c ^Character (char x)] (if (and (not @capped) (Character/isLetter c)) (do (dosync (ref-set capped true)) @@ -1230,10 +1230,10 @@ N.B. Only works on ColumnWriters right now." :bracket-info bracket-info, :generator-fn (concat '(fn [ params offset]) generator-fn) }]) -(defmacro #^{:private true} +(defmacro ^{:private true} defdirectives [ & directives ] - `(def #^{:private true} + `(def ^{:private true} directive-table (hash-map ~@(mapcat process-directive-table-element directives)))) (defdirectives @@ -1521,9 +1521,9 @@ N.B. Only works on ColumnWriters right now." ;;; directive in the format string. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def #^{:private true} +(def ^{:private true} param-pattern #"^([vV]|#|('.)|([+-]?\d+)|(?=,))") -(def #^{:private true} +(def ^{:private true} special-params #{ :parameter-from-args :remaining-arg-count }) (defn- extract-param [[s offset saw-comma]] @@ -1547,7 +1547,7 @@ N.B. Only works on ColumnWriters right now." (defn- translate-param "Translate the string representation of a param to the internalized representation" - [[#^String p offset]] + [[^String p offset]] [(cond (= (.length p) 0) nil (and (= (.length p) 1) (contains? #{\v \V} (nth p 0))) :parameter-from-args @@ -1556,7 +1556,7 @@ N.B. Only works on ColumnWriters right now." true (new Integer p)) offset]) -(def #^{:private true} +(def ^{:private true} flag-defs { \: :colon, \@ :at }) (defn- extract-flags [s offset] @@ -1621,7 +1621,7 @@ of parameters as well." (let [[raw-params [rest offset]] (extract-params s offset) [_ [rest offset flags]] (extract-flags rest offset) directive (first rest) - def (get directive-table (Character/toUpperCase #^Character directive)) + def (get directive-table (Character/toUpperCase ^Character directive)) params (if def (map-params def (map translate-param raw-params) flags offset))] (if (not directive) (format-error "Format string ended in the middle of a directive" offset)) @@ -1756,7 +1756,7 @@ performance when you're using the same format string repeatedly" (process-nesting (first (consume - (fn [[#^String s offset]] + (fn [[^String s offset]] (if (empty? s) [nil s] (let [tilde (.indexOf s (int \~))] @@ -1785,11 +1785,11 @@ column number or pretty printing" because the formatter macro uses it." {:skip-wiki true} ([stream format args] - (let [#^java.io.Writer real-stream (cond + (let [^java.io.Writer real-stream (cond (not stream) (java.io.StringWriter.) (true? stream) *out* :else stream) - #^java.io.Writer wrapped-stream (if (and (needs-pretty format) + ^java.io.Writer wrapped-stream (if (and (needs-pretty format) (not (pretty-writer? real-stream))) (get-pretty-writer real-stream) real-stream)] diff --git a/src/main/clojure/clojure/contrib/pprint/column_writer.clj b/src/main/clojure/clojure/contrib/pprint/column_writer.clj index 63718e29..32e62931 100644 --- a/src/main/clojure/clojure/contrib/pprint/column_writer.clj +++ b/src/main/clojure/clojure/contrib/pprint/column_writer.clj @@ -21,10 +21,10 @@ (def *default-page-width* 72) -(defn- get-field [#^Writer this sym] +(defn- get-field [^Writer this sym] (sym @@this)) -(defn- set-field [#^Writer this sym new-val] +(defn- set-field [^Writer this sym new-val] (alter @this assoc sym new-val)) (defn get-column [this] @@ -43,13 +43,13 @@ (defn get-writer [this] (get-field this :base)) -(defn- write-char [#^Writer this #^Integer c] +(defn- write-char [^Writer this ^Integer c] (dosync (if (= c (int \newline)) (do (set-field this :cur 0) (set-field this :line (inc (get-field this :line)))) (set-field this :cur (inc (get-field this :cur))))) - (.write #^Writer (get-field this :base) c)) + (.write ^Writer (get-field this :base) c)) (defn column-writer ([writer] (column-writer writer *default-page-width*)) @@ -58,13 +58,13 @@ (proxy [Writer IDeref] [] (deref [] fields) (write - ([#^chars cbuf #^Integer off #^Integer len] - (let [#^Writer writer (get-field this :base)] + ([^chars cbuf ^Integer off ^Integer len] + (let [^Writer writer (get-field this :base)] (.write writer cbuf off len))) ([x] (condp = (class x) String - (let [#^String s x + (let [^String s x nl (.lastIndexOf s (int \newline))] (dosync (if (neg? nl) (set-field this :cur (+ (get-field this :cur) (count s))) @@ -72,7 +72,7 @@ (set-field this :cur (- (count s) nl 1)) (set-field this :line (+ (get-field this :line) (count (filter #(= % \newline) s))))))) - (.write #^Writer (get-field this :base) s)) + (.write ^Writer (get-field this :base) s)) Integer (write-char this x) diff --git a/src/main/clojure/clojure/contrib/pprint/dispatch.clj b/src/main/clojure/clojure/contrib/pprint/dispatch.clj index 82db8746..2d742964 100644 --- a/src/main/clojure/clojure/contrib/pprint/dispatch.clj +++ b/src/main/clojure/clojure/contrib/pprint/dispatch.clj @@ -34,7 +34,7 @@ ;;; ~@ - Also fully eaten by the processing of ` and can't be used outside. ;;; , - is whitespace and is lost (like all other whitespace). Formats can generate commas ;;; where they deem them useful to help readability. -;;; #^ - Adding metadata completely disappears at read time and the data appears to be +;;; ^ - Adding metadata completely disappears at read time and the data appears to be ;;; completely lost. ;;; ;;; Most other syntax stuff is dealt with directly by the formats (like (), [], {}, and #{}) @@ -46,9 +46,9 @@ 'var "#'", 'clojure.core/unquote "~"}) (defn pprint-reader-macro [alis] - (let [#^String macro-char (reader-macros (first alis))] + (let [^String macro-char (reader-macros (first alis))] (when (and macro-char (= 2 (count alis))) - (.write #^java.io.Writer *out* macro-char) + (.write ^java.io.Writer *out* macro-char) (write-out (second alis)) true))) @@ -68,7 +68,7 @@ (when alis (write-out (first alis)) (when (next alis) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next alis))))))) @@ -83,7 +83,7 @@ (when aseq (write-out (first aseq)) (when (next aseq) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next aseq))))))) @@ -96,11 +96,11 @@ (when aseq (pprint-logical-block (write-out (ffirst aseq)) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (write-out (fnext (first aseq)))) (when (next aseq) - (.write #^java.io.Writer *out* ", ") + (.write ^java.io.Writer *out* ", ") (pprint-newline :linear) (recur (next aseq))))))) @@ -203,11 +203,11 @@ (pprint-logical-block binding (write-out (first binding)) (when (next binding) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :miser) (write-out (second binding)))) (when (next (rest binding)) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next (rest binding)))))))) @@ -233,18 +233,18 @@ (pprint-indent :block 1) (write-out (first alis)) (when (next alis) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (loop [alis (next alis)] (when alis (pprint-logical-block alis (write-out (first alis)) (when (next alis) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :miser) (write-out (second alis)))) (when (next (rest alis)) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next (rest alis))))))))) @@ -258,11 +258,11 @@ (pprint-logical-block alis (write-out (first alis)) (when (next alis) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :miser) (write-out (second alis)))) (when (next (rest alis)) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next (rest alis))))))) (pprint-simple-code-list alis))) @@ -299,7 +299,7 @@ (when alis (write-out (first alis)) (when (next alis) - (.write #^java.io.Writer *out* " ") + (.write ^java.io.Writer *out* " ") (pprint-newline :linear) (recur (next alis))))))) @@ -411,7 +411,7 @@ (add-to-buffer this (make-buffer-blob s white-space)))) Integer - (let [c #^Character x] + (let [c ^Character x] (if (= (getf :mode) :writing) (do (write-white-space this) diff --git a/src/main/clojure/clojure/contrib/pprint/pprint_base.clj b/src/main/clojure/clojure/contrib/pprint/pprint_base.clj index 636b551a..05d05390 100644 --- a/src/main/clojure/clojure/contrib/pprint/pprint_base.clj +++ b/src/main/clojure/clojure/contrib/pprint/pprint_base.clj @@ -27,56 +27,56 @@ (def - #^{ :doc "Bind to true if you want write to use pretty printing"} + ^{ :doc "Bind to true if you want write to use pretty printing"} *print-pretty* true) (defonce ; If folks have added stuff here, don't overwrite - #^{ :doc "The pretty print dispatch function. Use with-pprint-dispatch or set-pprint-dispatch + ^{ :doc "The pretty print dispatch function. Use with-pprint-dispatch or set-pprint-dispatch to modify."} *print-pprint-dispatch* nil) (def - #^{ :doc "Pretty printing will try to avoid anything going beyond this column. + ^{ :doc "Pretty printing will try to avoid anything going beyond this column. Set it to nil to have pprint let the line be arbitrarily long. This will ignore all non-mandatory newlines."} *print-right-margin* 72) (def - #^{ :doc "The column at which to enter miser style. Depending on the dispatch table, + ^{ :doc "The column at which to enter miser style. Depending on the dispatch table, miser style add newlines in more places to try to keep lines short allowing for further levels of nesting."} *print-miser-width* 40) ;;; TODO implement output limiting (def - #^{ :doc "Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)"} + ^{ :doc "Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)"} *print-lines* nil) ;;; TODO: implement circle and shared (def - #^{ :doc "Mark circular structures (N.B. This is not yet used)"} + ^{ :doc "Mark circular structures (N.B. This is not yet used)"} *print-circle* nil) ;;; TODO: should we just use *print-dup* here? (def - #^{ :doc "Mark repeated structures rather than repeat them (N.B. This is not yet used)"} + ^{ :doc "Mark repeated structures rather than repeat them (N.B. This is not yet used)"} *print-shared* nil) (def - #^{ :doc "Don't print namespaces with symbols. This is particularly useful when + ^{ :doc "Don't print namespaces with symbols. This is particularly useful when pretty printing the results of macro expansions"} *print-suppress-namespaces* nil) ;;; TODO: support print-base and print-radix in cl-format ;;; TODO: support print-base and print-radix in rationals (def - #^{ :doc "Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8, + ^{ :doc "Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8, or 16, then the radix specifier used is #b, #o, or #x, respectively. Otherwise the radix specifier is in the form #XXr where XX is the decimal value of *print-base* "} *print-radix* nil) (def - #^{ :doc "The base to use for printing integers and rationals."} + ^{ :doc "The base to use for printing integers and rationals."} *print-base* 10) @@ -86,9 +86,9 @@ radix specifier is in the form #XXr where XX is the decimal value of *print-base ;; structure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def #^{ :private true } *current-level* 0) +(def ^{ :private true } *current-level* 0) -(def #^{ :private true } *current-length* nil) +(def ^{ :private true } *current-length* nil) ;; TODO: add variables for length, lines. @@ -98,14 +98,14 @@ radix specifier is in the form #XXr where XX is the decimal value of *print-base (declare format-simple-number) -(def #^{:private true} orig-pr pr) +(def ^{:private true} orig-pr pr) (defn- pr-with-base [x] (if-let [s (format-simple-number x)] (print s) (orig-pr x))) -(def #^{:private true} write-option-table +(def ^{:private true} write-option-table {;:array *print-array* :base 'clojure.contrib.pprint/*print-base*, ;;:case *print-case*, @@ -124,7 +124,7 @@ radix specifier is in the form #XXr where XX is the decimal value of *print-base :suppress-namespaces 'clojure.contrib.pprint/*print-suppress-namespaces*}) -(defmacro #^{:private true} binding-map [amap & body] +(defmacro ^{:private true} binding-map [amap & body] (let [] `(do (. clojure.lang.Var (pushThreadBindings ~amap)) @@ -147,7 +147,7 @@ radix specifier is in the form #XXr where XX is the decimal value of *print-base [base-writer right-margin miser-width] (pretty-writer base-writer right-margin miser-width)) -(defmacro #^{:private true} with-pretty-writer [base-writer & body] +(defmacro ^{:private true} with-pretty-writer [base-writer & body] `(let [base-writer# ~base-writer new-writer# (not (pretty-writer? base-writer#))] (binding [*out* (if new-writer# @@ -223,7 +223,7 @@ The following keyword arguments can be passed with values: (binding [*out* base-writer] (pr object))) (if (nil? optval) - (.toString #^java.io.StringWriter base-writer))))))) + (.toString ^java.io.StringWriter base-writer))))))) (defn pprint @@ -294,7 +294,7 @@ and :suffix." [& args] (let [[options body] (parse-lb-options #{:prefix :per-line-prefix :suffix} args)] `(do (if (level-exceeded) - (.write #^java.io.Writer *out* "#") + (.write ^java.io.Writer *out* "#") (binding [*current-level* (inc *current-level*) *current-length* 0] (start-block *out* diff --git a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj index 91a1bcca..dfea976a 100644 --- a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj +++ b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj @@ -38,18 +38,18 @@ ;;; really utilities, but I'm experimenting with them here. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defmacro #^{:private true} +(defmacro ^{:private true} getf "Get the value of the field a named by the argument (which should be a keyword)." [sym] `(~sym @@~'this)) -(defmacro #^{:private true} +(defmacro ^{:private true} setf [sym new-val] "Set the value of the field SYM to NEW-VAL" `(alter @~'this assoc ~sym ~new-val)) -(defmacro #^{:private true} +(defmacro ^{:private true} deftype [type-name & fields] (let [name-str (name type-name)] `(do @@ -62,7 +62,7 @@ ;;; The data structures used by pretty-writer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defstruct #^{:private true} logical-block +(defstruct ^{:private true} logical-block :parent :section :start-col :indent :done-nl :intra-block-nl :prefix :per-line-prefix :suffix @@ -75,7 +75,7 @@ (identical? parent child) true :else (recur (:parent child))))) -(defstruct #^{:private true} section :parent) +(defstruct ^{:private true} section :parent) (defn buffer-length [l] (let [l (seq l)] @@ -102,22 +102,22 @@ (declare emit-nl) (defmulti write-token #(:type-tag %2)) -(defmethod write-token :start-block-t [#^Writer this token] +(defmethod write-token :start-block-t [^Writer this token] (when-let [cb (getf :logical-block-callback)] (cb :start)) (let [lb (:logical-block token)] (dosync - (when-let [#^String prefix (:prefix lb)] + (when-let [^String prefix (:prefix lb)] (.write (getf :base) prefix)) (let [col (get-column (getf :base))] (ref-set (:start-col lb) col) (ref-set (:indent lb) col))))) -(defmethod write-token :end-block-t [#^Writer this token] +(defmethod write-token :end-block-t [^Writer this token] (when-let [cb (getf :logical-block-callback)] (cb :end)) - (when-let [#^String suffix (:suffix (:logical-block token))] + (when-let [^String suffix (:suffix (:logical-block token))] (.write (getf :base) suffix))) -(defmethod write-token :indent-t [#^Writer this token] +(defmethod write-token :indent-t [^Writer this token] (let [lb (:logical-block token)] (ref-set (:indent lb) (+ (:offset token) @@ -125,28 +125,28 @@ :block @(:start-col lb) :current (get-column (getf :base))))))) -(defmethod write-token :buffer-blob [#^Writer this token] - (.write (getf :base) #^String (:data token))) +(defmethod write-token :buffer-blob [^Writer this token] + (.write (getf :base) ^String (:data token))) -(defmethod write-token :nl-t [#^Writer this token] +(defmethod write-token :nl-t [^Writer this token] ; (prlabel wt @(:done-nl (:logical-block token))) ; (prlabel wt (:type token) (= (:type token) :mandatory)) (if (or (= (:type token) :mandatory) (and (not (= (:type token) :fill)) @(:done-nl (:logical-block token)))) (emit-nl this token) - (if-let [#^String tws (getf :trailing-white-space)] + (if-let [^String tws (getf :trailing-white-space)] (.write (getf :base) tws))) (dosync (setf :trailing-white-space nil))) -(defn- write-tokens [#^Writer this tokens force-trailing-whitespace] +(defn- write-tokens [^Writer this tokens force-trailing-whitespace] (doseq [token tokens] (if-not (= (:type-tag token) :nl-t) - (if-let [#^String tws (getf :trailing-white-space)] + (if-let [^String tws (getf :trailing-white-space)] (.write (getf :base) tws))) (write-token this token) (setf :trailing-white-space (:trailing-white-space token))) - (let [#^String tws (getf :trailing-white-space)] + (let [^String tws (getf :trailing-white-space)] (when (and force-trailing-whitespace tws) (.write (getf :base) tws) (setf :trailing-white-space nil)))) @@ -157,7 +157,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn- tokens-fit? [#^Writer this tokens] +(defn- tokens-fit? [^Writer this tokens] ;;; (prlabel tf? (get-column (getf :base) (buffer-length tokens)) (let [maxcol (get-max-column (getf :base))] (or @@ -169,7 +169,7 @@ (or @(:done-nl lb) (not (tokens-fit? this section)))) -(defn- miser-nl? [#^Writer this lb section] +(defn- miser-nl? [^Writer this lb section] (let [miser-width (get-miser-width this) maxcol (get-max-column (getf :base))] (and miser-width maxcol @@ -225,14 +225,14 @@ (ref-set (:intra-block-nl lb) true) (recur (:parent lb))))))) -(defn emit-nl [#^Writer this nl] +(defn emit-nl [^Writer this nl] (.write (getf :base) (int \newline)) (dosync (setf :trailing-white-space nil)) (let [lb (:logical-block nl) - #^String prefix (:per-line-prefix lb)] + ^String prefix (:per-line-prefix lb)] (if prefix (.write (getf :base) prefix)) - (let [#^String istr (apply str (repeat (- @(:indent lb) (count prefix)) + (let [^String istr (apply str (repeat (- @(:indent lb) (count prefix)) \space))] (.write (getf :base) istr)) (update-nl-state lb))) @@ -285,7 +285,7 @@ ] result))))) -(defn- write-line [#^Writer this] +(defn- write-line [^Writer this] (dosync (loop [buffer (getf :buffer)] ;; (prlabel wl1 (toks buffer)) @@ -298,7 +298,7 @@ ;;; Add a buffer token to the buffer and see if it's time to start ;;; writing -(defn- add-to-buffer [#^Writer this token] +(defn- add-to-buffer [^Writer this token] ; (prlabel a2b token) (dosync (setf :buffer (conj (getf :buffer) token)) @@ -306,7 +306,7 @@ (write-line this)))) ;;; Write all the tokens that have been buffered -(defn- write-buffered-output [#^Writer this] +(defn- write-buffered-output [^Writer this] (write-line this) (if-let [buf (getf :buffer)] (do @@ -316,13 +316,13 @@ ;;; If there are newlines in the string, print the lines up until the last newline, ;;; making the appropriate adjustments. Return the remainder of the string (defn- write-initial-lines - [#^Writer this #^String s] + [^Writer this ^String s] (let [lines (.split s "\n" -1)] (if (= (count lines) 1) s (dosync - (let [#^String prefix (:per-line-prefix (first (getf :logical-blocks))) - #^String l (first lines)] + (let [^String prefix (:per-line-prefix (first (getf :logical-blocks))) + ^String l (first lines)] (if (= :buffering (getf :mode)) (let [oldpos (getf :pos) newpos (+ oldpos (count l))] @@ -331,7 +331,7 @@ (write-buffered-output this)) (.write (getf :base) l)) (.write (getf :base) (int \newline)) - (doseq [#^String l (next (butlast lines))] + (doseq [^String l (next (butlast lines))] (.write (getf :base) l) (.write (getf :base) (int \newline)) (if prefix @@ -340,13 +340,13 @@ (last lines)))))) -(defn write-white-space [#^Writer this] - (if-let [#^String tws (getf :trailing-white-space)] +(defn write-white-space [^Writer this] + (if-let [^String tws (getf :trailing-white-space)] (dosync (.write (getf :base) tws) (setf :trailing-white-space nil)))) -(defn- write-char [#^Writer this #^Integer c] +(defn- write-char [^Writer this ^Integer c] (if (= (getf :mode) :writing) (do (write-white-space this) @@ -386,8 +386,8 @@ ;; (prlabel write x (getf :mode)) (condp = (class x) String - (let [#^String s0 (write-initial-lines this x) - #^String s (.replaceFirst s0 "\\s+$" "") + (let [^String s0 (write-initial-lines this x) + ^String s (.replaceFirst s0 "\\s+$" "") white-space (.substring s0 (count s)) mode (getf :mode)] (dosync @@ -422,8 +422,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn start-block - [#^Writer this - #^String prefix #^String per-line-prefix #^String suffix] + [^Writer this + ^String prefix ^String per-line-prefix ^String suffix] (dosync (let [lb (struct logical-block (getf :logical-blocks) nil (ref 0) (ref 0) (ref false) (ref false) @@ -443,10 +443,10 @@ (setf :pos newpos) (add-to-buffer this (make-start-block-t lb oldpos newpos))))))) -(defn end-block [#^Writer this] +(defn end-block [^Writer this] (dosync (let [lb (getf :logical-blocks) - #^String suffix (:suffix lb)] + ^String suffix (:suffix lb)] (if (= (getf :mode) :writing) (do (write-white-space this) @@ -459,13 +459,13 @@ (add-to-buffer this (make-end-block-t lb oldpos newpos)))) (setf :logical-blocks (:parent lb))))) -(defn nl [#^Writer this type] +(defn nl [^Writer this type] (dosync (setf :mode :buffering) (let [pos (getf :pos)] (add-to-buffer this (make-nl-t type (getf :logical-blocks) pos pos))))) -(defn indent [#^Writer this relative-to offset] +(defn indent [^Writer this relative-to offset] (dosync (let [lb (getf :logical-blocks)] (if (= (getf :mode) :writing) @@ -478,11 +478,11 @@ (let [pos (getf :pos)] (add-to-buffer this (make-indent-t lb relative-to offset pos pos))))))) -(defn get-miser-width [#^Writer this] +(defn get-miser-width [^Writer this] (getf :miser-width)) -(defn set-miser-width [#^Writer this new-miser-width] +(defn set-miser-width [^Writer this new-miser-width] (dosync (setf :miser-width new-miser-width))) -(defn set-logical-block-callback [#^Writer this f] +(defn set-logical-block-callback [^Writer this f] (dosync (setf :logical-block-callback f))) diff --git a/src/main/clojure/clojure/contrib/probabilities/finite_distributions.clj b/src/main/clojure/clojure/contrib/probabilities/finite_distributions.clj index a93aa0d8..86e5aec0 100644 --- a/src/main/clojure/clojure/contrib/probabilities/finite_distributions.clj +++ b/src/main/clojure/clojure/contrib/probabilities/finite_distributions.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Finite probability distributions This library defines a monad for combining finite probability distributions."} diff --git a/src/main/clojure/clojure/contrib/probabilities/monte_carlo.clj b/src/main/clojure/clojure/contrib/probabilities/monte_carlo.clj index e3bc0f7e..73c89de8 100644 --- a/src/main/clojure/clojure/contrib/probabilities/monte_carlo.clj +++ b/src/main/clojure/clojure/contrib/probabilities/monte_carlo.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Monte-Carlo method support Monte-Carlo methods transform an input random number stream diff --git a/src/main/clojure/clojure/contrib/probabilities/random_numbers.clj b/src/main/clojure/clojure/contrib/probabilities/random_numbers.clj index bc21769b..8f7b358c 100644 --- a/src/main/clojure/clojure/contrib/probabilities/random_numbers.clj +++ b/src/main/clojure/clojure/contrib/probabilities/random_numbers.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Random number streams This library provides random number generators with a common diff --git a/src/main/clojure/clojure/contrib/profile.clj b/src/main/clojure/clojure/contrib/profile.clj index 2af2a014..19b61a47 100644 --- a/src/main/clojure/clojure/contrib/profile.clj +++ b/src/main/clojure/clojure/contrib/profile.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Sierra" +(ns ^{:author "Stuart Sierra" :doc "Simple code profiling & timing measurement. Wrap any section of code in the prof macro, giving it a name, like this: @@ -39,7 +39,7 @@ under the JVM. See the function documentation for more details. (def *profile-data* nil) -(def #^{:doc "Set this to false before loading/compiling to omit +(def ^{:doc "Set this to false before loading/compiling to omit profiling code."} *enable-profiling* true) (defmacro prof diff --git a/src/main/clojure/clojure/contrib/properties.clj b/src/main/clojure/clojure/contrib/properties.clj index 1be91d7e..fc738416 100644 --- a/src/main/clojure/clojure/contrib/properties.clj +++ b/src/main/clojure/clojure/contrib/properties.clj @@ -47,7 +47,7 @@ ; Not there is no corresponding props->map. Just destructure! -(defn #^Properties as-properties +(defn ^Properties as-properties "Convert any seq of pairs to a java.utils.Properties instance. Uses as-str to convert both keys and values into strings." {:tag Properties} @@ -69,6 +69,6 @@ {:tag Properties} ([m file-able] (write-properties m file-able nil)) ([m file-able comments] - (with-open [#^FileOutputStream f (FileOutputStream. (file file-able))] + (with-open [^FileOutputStream f (FileOutputStream. (file file-able))] (doto (as-properties m) - (.store f #^String comments))))) + (.store f ^String comments))))) diff --git a/src/main/clojure/clojure/contrib/prxml.clj b/src/main/clojure/clojure/contrib/prxml.clj index 264119a7..2c2ec761 100755 --- a/src/main/clojure/clojure/contrib/prxml.clj +++ b/src/main/clojure/clojure/contrib/prxml.clj @@ -23,24 +23,24 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Compact syntax for generating XML. See the documentation of \"prxml\" for details."} clojure.contrib.prxml (:use [clojure.contrib.string :only (escape as-str)])) (def - #^{:doc "If true, empty tags will have a space before the closing />"} + ^{:doc "If true, empty tags will have a space before the closing />"} *html-compatible* false) (def - #^{:doc "The number of spaces to indent sub-tags. nil for no indent + ^{:doc "The number of spaces to indent sub-tags. nil for no indent and no extra line-breaks."} *prxml-indent* nil) -(def #^{:private true} *prxml-tag-depth* 0) +(def ^{:private true} *prxml-tag-depth* 0) -(def #^{:private true} print-xml) ; forward declaration +(def ^{:private true} print-xml) ; forward declaration (defn- escape-xml [s] (escape {\< "<" @@ -56,7 +56,7 @@ for details."} (print (escape-xml (str value))) (print "\"")) -(defmulti #^{:private true} print-xml-tag (fn [tag attrs content] tag)) +(defmulti ^{:private true} print-xml-tag (fn [tag attrs content] tag)) (defmethod print-xml-tag :raw! [tag attrs contents] (doseq [c contents] (print c))) @@ -118,7 +118,7 @@ for details."} (print (if *html-compatible* " />" "/>"))))) -(defmulti #^{:private true} print-xml class) +(defmulti ^{:private true} print-xml class) (defmethod print-xml clojure.lang.IPersistentVector [x] (let [[tag & contents] x diff --git a/src/main/clojure/clojure/contrib/repl_ln.clj b/src/main/clojure/clojure/contrib/repl_ln.clj index 7b8ef052..9bef1c62 100644 --- a/src/main/clojure/clojure/contrib/repl_ln.clj +++ b/src/main/clojure/clojure/contrib/repl_ln.clj @@ -13,7 +13,7 @@ ;; Created 28 November 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "A repl with that provides support for lines and line numbers in the input stream."} clojure.contrib.repl-ln diff --git a/src/main/clojure/clojure/contrib/repl_utils.clj b/src/main/clojure/clojure/contrib/repl_utils.clj index ebe8e699..01c7a1d4 100644 --- a/src/main/clojure/clojure/contrib/repl_utils.clj +++ b/src/main/clojure/clojure/contrib/repl_utils.clj @@ -9,7 +9,7 @@ ; Utilities meant to be used interactively at the REPL (ns - #^{:author "Chris Houser, Christophe Grand, Stephen Gilardi, Michel Salim", + ^{:author "Chris Houser, Christophe Grand, Stephen Gilardi, Michel Salim", :doc "Utilities meant to be used interactively at the REPL"} clojure.contrib.repl-utils (:import (java.io File LineNumberReader InputStreamReader PushbackReader) @@ -140,7 +140,7 @@ str-or-pattern." ;; ---------------------------------------------------------------------- ;; Handle Ctrl-C keystrokes -(def #^{:doc "Threads to stop when Ctrl-C is pressed. See 'add-break-thread!'"} +(def ^{:doc "Threads to stop when Ctrl-C is pressed. See 'add-break-thread!'"} break-threads (atom {})) (let [first-time (atom true)] diff --git a/src/main/clojure/clojure/contrib/repl_utils/javadoc.clj b/src/main/clojure/clojure/contrib/repl_utils/javadoc.clj index 32551340..2b148066 100644 --- a/src/main/clojure/clojure/contrib/repl_utils/javadoc.clj +++ b/src/main/clojure/clojure/contrib/repl_utils/javadoc.clj @@ -16,7 +16,7 @@ (def *feeling-lucky* true) (def - #^{:doc "Ref to a list of local paths for Javadoc-generated HTML + ^{:doc "Ref to a list of local paths for Javadoc-generated HTML files."} *local-javadocs* (ref (list))) @@ -26,7 +26,7 @@ "http://java.sun.com/javase/6/docs/api/")) (def - #^{:doc "Ref to a map from package name prefixes to URLs for remote + ^{:doc "Ref to a map from package name prefixes to URLs for remote Javadocs."} *remote-javadocs* (ref (sorted-map @@ -55,11 +55,11 @@ "Searches for a URL for the given class name. Tries *local-javadocs* first, then *remote-javadocs*. Returns a string." {:tag String} - [#^String classname] + [^String classname] (let [file-path (.replace classname \. File/separatorChar) url-path (.replace classname \. \/)] - (if-let [file #^File (first - (filter #(.exists #^File %) + (if-let [file ^File (first + (filter #(.exists ^File %) (map #(File. (str %) (str file-path ".html")) @*local-javadocs*)))] (-> file .toURI str) @@ -75,7 +75,7 @@ "Opens a browser window displaying the javadoc for the argument. Tries *local-javadocs* first, then *remote-javadocs*." [class-or-object] - (let [#^Class c (if (instance? Class class-or-object) + (let [^Class c (if (instance? Class class-or-object) class-or-object (class class-or-object))] (if-let [url (find-javadoc-url (.getName c))] diff --git a/src/main/clojure/clojure/contrib/seq.clj b/src/main/clojure/clojure/contrib/seq.clj index 87986f94..1bbd2110 100644 --- a/src/main/clojure/clojure/contrib/seq.clj +++ b/src/main/clojure/clojure/contrib/seq.clj @@ -22,7 +22,7 @@ (ns - #^{:author "Stuart Sierra (and others)", + ^{:author "Stuart Sierra (and others)", :doc "Sequence utilities for Clojure"} clojure.contrib.seq (:import (java.util.concurrent LinkedBlockingQueue TimeUnit) diff --git a/src/main/clojure/clojure/contrib/seq_utils.clj b/src/main/clojure/clojure/contrib/seq_utils.clj index 3a199402..731257be 100644 --- a/src/main/clojure/clojure/contrib/seq_utils.clj +++ b/src/main/clojure/clojure/contrib/seq_utils.clj @@ -22,7 +22,7 @@ (ns - #^{:author "Stuart Sierra (and others)", + ^{:author "Stuart Sierra (and others)", :doc "Sequence utilities for Clojure"} clojure.contrib.seq-utils (:import (java.util.concurrent LinkedBlockingQueue TimeUnit) diff --git a/src/main/clojure/clojure/contrib/server_socket.clj b/src/main/clojure/clojure/contrib/server_socket.clj index fad77076..edfe461c 100644 --- a/src/main/clojure/clojure/contrib/server_socket.clj +++ b/src/main/clojure/clojure/contrib/server_socket.clj @@ -9,7 +9,7 @@ ;; Server socket library - includes REPL on socket (ns - #^{:author "Craig McDaniel", + ^{:author "Craig McDaniel", :doc "Server socket library - includes REPL on socket"} clojure.contrib.server-socket (:import (java.net InetAddress ServerSocket Socket SocketException) @@ -18,17 +18,17 @@ (:use [clojure.main :only (repl)])) (defn- on-thread [f] - (doto (Thread. #^Runnable f) + (doto (Thread. ^Runnable f) (.start))) -(defn- close-socket [#^Socket s] +(defn- close-socket [^Socket s] (when-not (.isClosed s) (doto s (.shutdownInput) (.shutdownOutput) (.close)))) -(defn- accept-fn [#^Socket s connections fun] +(defn- accept-fn [^Socket s connections fun] (let [ins (.getInputStream s) outs (.getOutputStream s)] (on-thread #(do @@ -41,7 +41,7 @@ (defstruct server-def :server-socket :connections) -(defn- create-server-aux [fun #^ServerSocket ss] +(defn- create-server-aux [fun ^ServerSocket ss] (let [connections (ref #{})] (on-thread #(when-not (.isClosed ss) (try @@ -58,7 +58,7 @@ Optional arguments support specifying a listen backlog and binding to a specific endpoint." - ([port fun backlog #^InetAddress bind-addr] + ([port fun backlog ^InetAddress bind-addr] (create-server-aux fun (ServerSocket. port backlog bind-addr))) ([port fun backlog] (create-server-aux fun (ServerSocket. port backlog))) @@ -69,7 +69,7 @@ (doseq [s @(:connections server)] (close-socket s)) (dosync (ref-set (:connections server) #{})) - (.close #^ServerSocket (:server-socket server))) + (.close ^ServerSocket (:server-socket server))) (defn connection-count [server] (count @(:connections server))) @@ -81,12 +81,12 @@ (defn- socket-repl [ins outs] (binding [*in* (LineNumberingPushbackReader. (InputStreamReader. ins)) *out* (OutputStreamWriter. outs) - *err* (PrintWriter. #^OutputStream outs true)] + *err* (PrintWriter. ^OutputStream outs true)] (repl))) (defn create-repl-server "create a repl on a socket" - ([port backlog #^InetAddress bind-addr] + ([port backlog ^InetAddress bind-addr] (create-server port socket-repl backlog bind-addr)) ([port backlog] (create-server port socket-repl backlog)) diff --git a/src/main/clojure/clojure/contrib/set.clj b/src/main/clojure/clojure/contrib/set.clj index 75c00018..fe53c5ec 100644 --- a/src/main/clojure/clojure/contrib/set.clj +++ b/src/main/clojure/clojure/contrib/set.clj @@ -14,7 +14,7 @@ ;; Created 2 Feb 2009 (ns - #^{:author "Jason Wolfe", + ^{:author "Jason Wolfe", :doc "Clojure functions for operating on sets (supplemental to clojure.set)"} clojure.contrib.set) diff --git a/src/main/clojure/clojure/contrib/shell.clj b/src/main/clojure/clojure/contrib/shell.clj index 3a24b19c..a4c610e9 100644 --- a/src/main/clojure/clojure/contrib/shell.clj +++ b/src/main/clojure/clojure/contrib/shell.clj @@ -12,7 +12,7 @@ ; collecting its stdout (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "Conveniently launch a sub-process providing to its stdin and collecting its stdout"} clojure.contrib.shell diff --git a/src/main/clojure/clojure/contrib/shell_out.clj b/src/main/clojure/clojure/contrib/shell_out.clj index 5e0be467..97c09ac1 100644 --- a/src/main/clojure/clojure/contrib/shell_out.clj +++ b/src/main/clojure/clojure/contrib/shell_out.clj @@ -12,7 +12,7 @@ ; collecting its stdout (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "Conveniently launch a sub-process providing to its stdin and collecting its stdout"} clojure.contrib.shell-out diff --git a/src/main/clojure/clojure/contrib/singleton.clj b/src/main/clojure/clojure/contrib/singleton.clj index b10223ff..2545d9c7 100644 --- a/src/main/clojure/clojure/contrib/singleton.clj +++ b/src/main/clojure/clojure/contrib/singleton.clj @@ -21,7 +21,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Singleton functions"} clojure.contrib.singleton) diff --git a/src/main/clojure/clojure/contrib/sql.clj b/src/main/clojure/clojure/contrib/sql.clj index 58448f86..c6946078 100644 --- a/src/main/clojure/clojure/contrib/sql.clj +++ b/src/main/clojure/clojure/contrib/sql.clj @@ -16,7 +16,7 @@ ;; Created 2 April 2008 (ns - #^{:author "Stephen C. Gilardi", + ^{:author "Stephen C. Gilardi", :doc "A Clojure interface to sql databases via jdbc." :see-also [["http://github.com/richhickey/clojure-contrib/blob/master/src/test/clojure/clojure/contrib/test_sql.clj" "Example code"]]} diff --git a/src/main/clojure/clojure/contrib/str_utils.clj b/src/main/clojure/clojure/contrib/str_utils.clj index 02bf7445..263a2136 100644 --- a/src/main/clojure/clojure/contrib/str_utils.clj +++ b/src/main/clojure/clojure/contrib/str_utils.clj @@ -13,7 +13,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "String utilities for Clojure"} clojure.contrib.str-utils (:import (java.util.regex Pattern))) @@ -22,8 +22,8 @@ "Splits the string on instances of 'pattern'. Returns a sequence of strings. Optional 'limit' argument is the maximum number of splits. Like Perl's 'split'." - ([#^Pattern pattern string] (seq (. pattern (split string)))) - ([#^Pattern pattern string limit] (seq (. pattern (split string limit))))) + ([^Pattern pattern string] (seq (. pattern (split string)))) + ([^Pattern pattern string limit] (seq (. pattern (split string limit))))) (defn re-partition "Splits the string into a lazy sequence of substrings, alternating @@ -35,7 +35,7 @@ For example: (re-partition #\"[a-z]+\" \"abc123def\") Returns: (\"\" \"abc\" \"123\" \"def\")" - [#^Pattern re string] + [^Pattern re string] (let [m (re-matcher re string)] ((fn step [prevend] (lazy-seq @@ -54,7 +54,7 @@ If (ifn? replacment) is true, the replacement is called with the match. " - [#^java.util.regex.Pattern regex replacement #^String string] + [^java.util.regex.Pattern regex replacement ^String string] (if (ifn? replacement) (let [parts (vec (re-partition regex string))] (apply str @@ -70,7 +70,7 @@ If (ifn? replacement) is true, the replacement is called with the match. " - [#^Pattern regex replacement #^String string] + [^Pattern regex replacement ^String string] (if (ifn? replacement) (let [m (re-matcher regex string)] (if (.find m) diff --git a/src/main/clojure/clojure/contrib/str_utils2.clj b/src/main/clojure/clojure/contrib/str_utils2.clj index d49351ac..eab43cc8 100644 --- a/src/main/clojure/clojure/contrib/str_utils2.clj +++ b/src/main/clojure/clojure/contrib/str_utils2.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Sierra" +(ns ^{:author "Stuart Sierra" :doc "This is a library of string manipulation functions. It is intented as a replacement for clojure.contrib.str-utils. @@ -44,7 +44,7 @@ (assert (vector bindings)) (assert (= 2 (count bindings))) ;; This seems to be the fastest way to iterate over characters. - `(let [#^String s# ~(second bindings)] + `(let [^String s# ~(second bindings)] (dotimes [i# (.length s#)] (let [~(first bindings) (.charAt s# i#)] ~@body)))) @@ -61,7 +61,7 @@ (assert (= 2 (count bindings))) (let [character (first bindings) string (second bindings)] - `(let [#^String s# ~string + `(let [^String s# ~string len# (.length s#)] (loop [i# 0] (when (< i# len#) @@ -77,9 +77,9 @@ (defn codepoints "Returns a sequence of integer Unicode code points in s. Handles Unicode supplementary characters (above U+FFFF) correctly." - [#^String s] + [^String s] (let [len (.length s) - f (fn thisfn [#^String s i] + f (fn thisfn [^String s i] (when (< i len) (let [c (.charAt s i)] (if (Character/isHighSurrogate c) @@ -87,11 +87,11 @@ (cons (int c) (thisfn s (inc i)))))))] (lazy-seq (f s 0)))) -(defn #^String escape +(defn ^String escape "Returns a new String by applying cmap (a function or a map) to each character in s. If cmap returns nil, the original character is added to the output unchanged." - [#^String s cmap] + [^String s cmap] (let [buffer (StringBuilder. (.length s))] (dochars [c s] (if-let [r (cmap c)] @@ -101,60 +101,60 @@ (defn blank? "True if s is nil, empty, or contains only whitespace." - [#^String s] - (every? (fn [#^Character c] (Character/isWhitespace c)) s)) + [^String s] + (every? (fn [^Character c] (Character/isWhitespace c)) s)) -(defn #^String take +(defn ^String take "Take first n characters from s, up to the length of s. Note the argument order is the opposite of clojure.core/take; this is to keep the string as the first argument for use with ->" - [#^String s n] + [^String s n] (if (< (count s) n) s (.substring s 0 n))) -(defn #^String drop +(defn ^String drop "Drops first n characters from s. Returns an empty string if n is greater than the length of s. Note the argument order is the opposite of clojure.core/drop; this is to keep the string as the first argument for use with ->" - [#^String s n] + [^String s n] (if (< (count s) n) "" (.substring s n))) -(defn #^String butlast +(defn ^String butlast "Returns s without the last n characters. Returns an empty string if n is greater than the length of s. Note the argument order is the opposite of clojure.core/butlast; this is to keep the string as the first argument for use with ->" - [#^String s n] + [^String s n] (if (< (count s) n) "" (.substring s 0 (- (count s) n)))) -(defn #^String tail +(defn ^String tail "Returns the last n characters of s." - [#^String s n] + [^String s n] (if (< (count s) n) s (.substring s (- (count s) n)))) -(defn #^String repeat +(defn ^String repeat "Returns a new String containing s repeated n times." - [#^String s n] + [^String s n] (apply str (clojure.core/repeat n s))) -(defn #^String reverse +(defn ^String reverse "Returns s with its characters reversed." - [#^String s] + [^String s] (.toString (.reverse (StringBuilder. s)))) (defmulti - #^{:doc "Replaces all instances of pattern in string with replacement. + ^{:doc "Replaces all instances of pattern in string with replacement. Allowed argument types for pattern and replacement are: 1. String and String @@ -167,19 +167,19 @@ :arglists '([string pattern replacement]) :tag String} replace - (fn [#^String string pattern replacement] + (fn [^String string pattern replacement] [(class pattern) (class replacement)])) -(defmethod replace [String String] [#^String s #^String a #^String b] +(defmethod replace [String String] [^String s ^String a ^String b] (.replace s a b)) -(defmethod replace [Character Character] [#^String s #^Character a #^Character b] +(defmethod replace [Character Character] [^String s ^Character a ^Character b] (.replace s a b)) -(defmethod replace [Pattern String] [#^String s re replacement] +(defmethod replace [Pattern String] [^String s re replacement] (.replaceAll (re-matcher re s) replacement)) -(defmethod replace [Pattern clojure.lang.IFn] [#^String s re replacement] +(defmethod replace [Pattern clojure.lang.IFn] [^String s re replacement] (let [m (re-matcher re s)] (let [buffer (StringBuffer. (.length s))] (loop [] @@ -190,7 +190,7 @@ (.toString buffer))))))) (defmulti - #^{:doc "Replaces the first instance of pattern in s with replacement. + ^{:doc "Replaces the first instance of pattern in s with replacement. Allowed argument types for pattern and replacement are: 1. String and String @@ -204,13 +204,13 @@ (fn [s pattern replacement] [(class pattern) (class replacement)])) -(defmethod replace-first [String String] [#^String s pattern replacement] +(defmethod replace-first [String String] [^String s pattern replacement] (.replaceFirst (re-matcher (Pattern/quote pattern) s) replacement)) -(defmethod replace-first [Pattern String] [#^String s re replacement] +(defmethod replace-first [Pattern String] [^String s re replacement] (.replaceFirst (re-matcher re s) replacement)) -(defmethod replace-first [Pattern clojure.lang.IFn] [#^String s #^Pattern re f] +(defmethod replace-first [Pattern clojure.lang.IFn] [^String s ^Pattern re f] (let [m (re-matcher re s)] (let [buffer (StringBuffer.)] (if (.find m) @@ -228,7 +228,7 @@ For example: (partition \"abc123def\" #\"[a-z]+\") returns: (\"\" \"abc\" \"123\" \"def\")" - [#^String s #^Pattern re] + [^String s ^Pattern re] (let [m (re-matcher re s)] ((fn step [prevend] (lazy-seq @@ -240,39 +240,39 @@ (list (.subSequence s prevend (.length s))))))) 0))) -(defn #^String join +(defn ^String join "Returns a string of all elements in coll, separated by separator. Like Perl's join." - [#^String separator coll] + [^String separator coll] (apply str (interpose separator coll))) -(defn #^String chop +(defn ^String chop "Removes the last character of string, does nothing on a zero-length string." - [#^String s] + [^String s] (let [size (count s)] (if (zero? size) s (subs s 0 (dec (count s)))))) -(defn #^String chomp +(defn ^String chomp "Removes all trailing newline \\n or return \\r characters from string. Note: String.trim() is similar and faster." - [#^String s] + [^String s] (replace s #"[\r\n]+$" "")) -(defn title-case [#^String s] +(defn title-case [^String s] (throw (Exception. "title-case not implemeted yet"))) -(defn #^String swap-case +(defn ^String swap-case "Changes upper case characters to lower case and vice-versa. Handles Unicode supplementary characters correctly. Uses the locale-sensitive String.toUpperCase() and String.toLowerCase() methods." - [#^String s] + [^String s] (let [buffer (StringBuilder. (.length s)) ;; array to make a String from one code point - #^"[I" array (make-array Integer/TYPE 1)] + ^"[I" array (make-array Integer/TYPE 1)] (docodepoints [c s] (aset-int array 0 c) (if (Character/isLowerCase c) @@ -282,32 +282,32 @@ (.append buffer (.toLowerCase (String. array 0 1))))) (.toString buffer))) -(defn #^String capitalize +(defn ^String capitalize "Converts first character of the string to upper-case, all other characters to lower-case." - [#^String s] + [^String s] (if (< (count s) 2) (.toUpperCase s) - (str (.toUpperCase #^String (subs s 0 1)) - (.toLowerCase #^String (subs s 1))))) + (str (.toUpperCase ^String (subs s 0 1)) + (.toLowerCase ^String (subs s 1))))) -(defn #^String ltrim +(defn ^String ltrim "Removes whitespace from the left side of string." - [#^String s] + [^String s] (replace s #"^\s+" "")) -(defn #^String rtrim +(defn ^String rtrim "Removes whitespace from the right side of string." - [#^String s] + [^String s] (replace s #"\s+$" "")) (defn split-lines "Splits s on \\n or \\r\\n." - [#^String s] + [^String s] (seq (.split #"\r?\n" s))) ;; borrowed from compojure.str-utils, by James Reeves, EPL 1.0 -(defn #^String map-str +(defn ^String map-str "Apply f to each element of coll, concatenate all results into a String." [f coll] @@ -340,34 +340,34 @@ ;; functions. They are included here for completeness, and for use ;; when mapping over a collection of strings. -(defn #^String upper-case +(defn ^String upper-case "Converts string to all upper-case." - [#^String s] + [^String s] (.toUpperCase s)) -(defn #^String lower-case +(defn ^String lower-case "Converts string to all lower-case." - [#^String s] + [^String s] (.toLowerCase s)) (defn split "Splits string on a regular expression. Optional argument limit is the maximum number of splits." - ([#^String s #^Pattern re] (seq (.split re s))) - ([#^String s #^Pattern re limit] (seq (.split re s limit)))) + ([^String s ^Pattern re] (seq (.split re s))) + ([^String s ^Pattern re limit] (seq (.split re s limit)))) -(defn #^String trim +(defn ^String trim "Removes whitespace from both ends of string." - [#^String s] + [^String s] (.trim s)) -(defn #^String contains? +(defn ^String contains? "True if s contains the substring." - [#^String s substring] + [^String s substring] (.contains s substring)) -(defn #^String get +(defn ^String get "Gets the i'th character in string." - [#^String s i] + [^String s i] (.charAt s i)) diff --git a/src/main/clojure/clojure/contrib/stream_utils.clj b/src/main/clojure/clojure/contrib/stream_utils.clj index 7a09ca6a..5e1738dd 100644 --- a/src/main/clojure/clojure/contrib/stream_utils.clj +++ b/src/main/clojure/clojure/contrib/stream_utils.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "Functions for setting up computational pipelines via data streams. NOTE: This library is experimental. It may change significantly diff --git a/src/main/clojure/clojure/contrib/string.clj b/src/main/clojure/clojure/contrib/string.clj index af713be6..b79ae33b 100644 --- a/src/main/clojure/clojure/contrib/string.clj +++ b/src/main/clojure/clojure/contrib/string.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. -(ns #^{:author "Stuart Sierra" +(ns ^{:author "Stuart Sierra" :doc "This is a library of string manipulation functions. It is intented as a replacement for clojure.contrib.string. @@ -44,7 +44,7 @@ (assert (vector bindings)) (assert (= 2 (count bindings))) ;; This seems to be the fastest way to iterate over characters. - `(let [#^String s# ~(second bindings)] + `(let [^String s# ~(second bindings)] (dotimes [i# (.length s#)] (let [~(first bindings) (.charAt s# i#)] ~@body)))) @@ -61,7 +61,7 @@ (assert (= 2 (count bindings))) (let [character (first bindings) string (second bindings)] - `(let [#^String s# ~string + `(let [^String s# ~string len# (.length s#)] (loop [i# 0] (when (< i# len#) @@ -77,9 +77,9 @@ (defn codepoints "Returns a sequence of integer Unicode code points in s. Handles Unicode supplementary characters (above U+FFFF) correctly." - [#^String s] + [^String s] (let [len (.length s) - f (fn thisfn [#^String s i] + f (fn thisfn [^String s i] (when (< i len) (let [c (.charAt s i)] (if (Character/isHighSurrogate c) @@ -87,11 +87,11 @@ (cons (int c) (thisfn s (inc i)))))))] (lazy-seq (f s 0)))) -(defn #^String escape +(defn ^String escape "Returns a new String by applying cmap (a function or a map) to each character in s. If cmap returns nil, the original character is added to the output unchanged." - [cmap #^String s] + [cmap ^String s] (let [buffer (StringBuilder. (.length s))] (dochars [c s] (if-let [r (cmap c)] @@ -101,68 +101,68 @@ (defn blank? "True if s is nil, empty, or contains only whitespace." - [#^String s] - (every? (fn [#^Character c] (Character/isWhitespace c)) s)) + [^String s] + (every? (fn [^Character c] (Character/isWhitespace c)) s)) -(defn #^String take +(defn ^String take "Take first n characters from s, up to the length of s." - [n #^String s] + [n ^String s] (if (< (count s) n) s (.substring s 0 n))) -(defn #^String drop +(defn ^String drop "Drops first n characters from s. Returns an empty string if n is greater than the length of s." - [n #^String s] + [n ^String s] (if (< (count s) n) "" (.substring s n))) -(defn #^String butlast +(defn ^String butlast "Returns s without the last n characters. Returns an empty string if n is greater than the length of s." - [n #^String s] + [n ^String s] (if (< (count s) n) "" (.substring s 0 (- (count s) n)))) -(defn #^String tail +(defn ^String tail "Returns the last n characters of s." - [n #^String s] + [n ^String s] (if (< (count s) n) s (.substring s (- (count s) n)))) -(defn #^String repeat +(defn ^String repeat "Returns a new String containing s repeated n times." - [n #^String s] + [n ^String s] (apply str (clojure.core/repeat n s))) -(defn #^String reverse +(defn ^String reverse "Returns s with its characters reversed." - [#^String s] + [^String s] (.toString (.reverse (StringBuilder. s)))) (defn replace-str "Replaces all instances of substring a with b in s." - [#^String a #^String b #^String s] + [^String a ^String b ^String s] (.replace s a b)) (defn replace-char "Replaces all instances of character a with character b in s." - [#^Character a #^Character b #^String s] + [^Character a ^Character b ^String s] (.replace s a b)) (defn replace-re "Replaces all matches of re with replacement in s." - [re replacement #^String s] + [re replacement ^String s] (.replaceAll (re-matcher re s) replacement)) (defn replace-by "Replaces all matches of re in s with the result of (f (re-groups the-match))." - [re f #^String s] + [re f ^String s] (let [m (re-matcher re s)] (let [buffer (StringBuffer. (.length s))] (loop [] @@ -174,18 +174,18 @@ (defn replace-first-str "Replace first occurance of substring a with b in s." - [#^String a #^String b #^String s] + [^String a ^String b ^String s] (.replaceFirst (re-matcher (Pattern/quote a) s) b)) (defn replace-first-re "Replace first match of re in s." - [#^Pattern re #^String replacement #^String s] + [^Pattern re ^String replacement ^String s] (.replaceFirst (re-matcher re s) replacement)) (defn replace-first-by "Replace first match of re in s with the result of (f (re-groups the-match))." - [#^Pattern re f #^String s] + [^Pattern re f ^String s] (let [m (re-matcher re s)] (let [buffer (StringBuffer.)] (if (.find m) @@ -203,7 +203,7 @@ For example: (partition #\"[a-z]+\" \"abc123def\") returns: (\"\" \"abc\" \"123\" \"def\")" - [#^Pattern re #^String s] + [^Pattern re ^String s] (let [m (re-matcher re s)] ((fn step [prevend] (lazy-seq @@ -215,39 +215,39 @@ (list (.subSequence s prevend (.length s))))))) 0))) -(defn #^String join +(defn ^String join "Returns a string of all elements in coll, separated by separator. Like Perl's join." - [#^String separator coll] + [^String separator coll] (apply str (interpose separator coll))) -(defn #^String chop +(defn ^String chop "Removes the last character of string, does nothing on a zero-length string." - [#^String s] + [^String s] (let [size (count s)] (if (zero? size) s (subs s 0 (dec (count s)))))) -(defn #^String chomp +(defn ^String chomp "Removes all trailing newline \\n or return \\r characters from string. Note: String.trim() is similar and faster." - [#^String s] + [^String s] (replace-re #"[\r\n]+$" "" s)) -(defn title-case [#^String s] +(defn title-case [^String s] (throw (Exception. "title-case not implemeted yet"))) -(defn #^String swap-case +(defn ^String swap-case "Changes upper case characters to lower case and vice-versa. Handles Unicode supplementary characters correctly. Uses the locale-sensitive String.toUpperCase() and String.toLowerCase() methods." - [#^String s] + [^String s] (let [buffer (StringBuilder. (.length s)) ;; array to make a String from one code point - #^"[I" array (make-array Integer/TYPE 1)] + ^"[I" array (make-array Integer/TYPE 1)] (docodepoints [c s] (aset-int array 0 c) (if (Character/isLowerCase c) @@ -257,32 +257,32 @@ (.append buffer (.toLowerCase (String. array 0 1))))) (.toString buffer))) -(defn #^String capitalize +(defn ^String capitalize "Converts first character of the string to upper-case, all other characters to lower-case." - [#^String s] + [^String s] (if (< (count s) 2) (.toUpperCase s) - (str (.toUpperCase #^String (subs s 0 1)) - (.toLowerCase #^String (subs s 1))))) + (str (.toUpperCase ^String (subs s 0 1)) + (.toLowerCase ^String (subs s 1))))) -(defn #^String ltrim +(defn ^String ltrim "Removes whitespace from the left side of string." - [#^String s] + [^String s] (replace-re #"^\s+" "" s)) -(defn #^String rtrim +(defn ^String rtrim "Removes whitespace from the right side of string." - [#^String s] + [^String s] (replace-re #"\s+$" "" s)) (defn split-lines "Splits s on \\n or \\r\\n." - [#^String s] + [^String s] (seq (.split #"\r?\n" s))) ;; borrowed from compojure.string, by James Reeves, EPL 1.0 -(defn #^String map-str +(defn ^String map-str "Apply f to each element of coll, concatenate all results into a String." [f coll] @@ -314,11 +314,11 @@ (name x) (str x))) ([x & ys] - ((fn [#^StringBuilder sb more] + ((fn [^StringBuilder sb more] (if more (recur (. sb (append (as-str (first more)))) (next more)) (str sb))) - (new StringBuilder #^String (as-str x)) ys))) + (new StringBuilder ^String (as-str x)) ys))) ;;; WRAPPERS @@ -327,34 +327,34 @@ ;; functions. They are included here for completeness, and for use ;; when mapping over a collection of strings. -(defn #^String upper-case +(defn ^String upper-case "Converts string to all upper-case." - [#^String s] + [^String s] (.toUpperCase s)) -(defn #^String lower-case +(defn ^String lower-case "Converts string to all lower-case." - [#^String s] + [^String s] (.toLowerCase s)) (defn split "Splits string on a regular expression. Optional argument limit is the maximum number of splits." - ([#^Pattern re #^String s] (seq (.split re s))) - ([#^Pattern re limit #^String s] (seq (.split re s limit)))) + ([^Pattern re ^String s] (seq (.split re s))) + ([^Pattern re limit ^String s] (seq (.split re s limit)))) -(defn #^String trim +(defn ^String trim "Removes whitespace from both ends of string." - [#^String s] + [^String s] (.trim s)) -(defn #^String substring? +(defn ^String substring? "True if s contains the substring." - [substring #^String s] + [substring ^String s] (.contains s substring)) -(defn #^String get +(defn ^String get "Gets the i'th character in string." - [#^String s i] + [^String s i] (.charAt s i)) diff --git a/src/main/clojure/clojure/contrib/strint.clj b/src/main/clojure/clojure/contrib/strint.clj index a627c16d..2333c5b1 100644 --- a/src/main/clojure/clojure/contrib/strint.clj +++ b/src/main/clojure/clojure/contrib/strint.clj @@ -13,7 +13,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Chas Emerick", + ^{:author "Chas Emerick", :doc "String interpolation for Clojure."} clojure.contrib.strint (:use [clojure.contrib.io :only (slurp*)])) @@ -36,7 +36,7 @@ (if-let [[form rest] (silent-read (subs s (if atom? 2 1)))] (cons form (interpolate (if atom? (subs rest 1) rest))) (cons (subs s 0 2) (interpolate (subs s 2)))))) - ([#^String s] + ([^String s] (if-let [start (->> ["~{" "~("] (map #(.indexOf s %)) (remove #(== -1 %)) diff --git a/src/main/clojure/clojure/contrib/test_is.clj b/src/main/clojure/clojure/contrib/test_is.clj index 62666b62..cffe4350 100644 --- a/src/main/clojure/clojure/contrib/test_is.clj +++ b/src/main/clojure/clojure/contrib/test_is.clj @@ -13,7 +13,7 @@ -(ns #^{:doc "Backwards-compatibility for clojure.contrib.test-is +(ns ^{:doc "Backwards-compatibility for clojure.contrib.test-is The clojure.contrib.test-is library moved from Contrib into the Clojure distribution as clojure.test. diff --git a/src/main/clojure/clojure/contrib/trace.clj b/src/main/clojure/clojure/contrib/trace.clj index a75953e7..0e53b4b3 100644 --- a/src/main/clojure/clojure/contrib/trace.clj +++ b/src/main/clojure/clojure/contrib/trace.clj @@ -32,13 +32,13 @@ (ns - #^{:author "Stuart Sierra, Michel Salim", + ^{:author "Stuart Sierra, Michel Salim", :doc "This file defines simple \"tracing\" macros to help you see what your code is doing."} clojure.contrib.trace) (def - #^{:doc "Current stack depth of traced function calls."} + ^{:doc "Current stack depth of traced function calls."} *trace-depth* 0) (defn tracer diff --git a/src/main/clojure/clojure/contrib/types.clj b/src/main/clojure/clojure/contrib/types.clj index f0b85267..88595e77 100644 --- a/src/main/clojure/clojure/contrib/types.clj +++ b/src/main/clojure/clojure/contrib/types.clj @@ -12,7 +12,7 @@ ;; remove this notice, or any other, from this software. (ns - #^{:author "Konrad Hinsen" + ^{:author "Konrad Hinsen" :doc "General and algebraic data types"} clojure.contrib.types (:refer-clojure :exclude (deftype)) diff --git a/src/main/clojure/clojure/contrib/with_ns.clj b/src/main/clojure/clojure/contrib/with_ns.clj index d874a4a5..b5dd3b3e 100644 --- a/src/main/clojure/clojure/contrib/with_ns.clj +++ b/src/main/clojure/clojure/contrib/with_ns.clj @@ -13,7 +13,7 @@ (ns - #^{:author "Stuart Sierra", + ^{:author "Stuart Sierra", :doc "Temporary namespace macro"} clojure.contrib.with-ns) diff --git a/src/main/clojure/clojure/contrib/zip_filter.clj b/src/main/clojure/clojure/contrib/zip_filter.clj index c7599bf8..14f60030 100644 --- a/src/main/clojure/clojure/contrib/zip_filter.clj +++ b/src/main/clojure/clojure/contrib/zip_filter.clj @@ -10,7 +10,7 @@ ; general, and xml trees in particular. (ns - #^{:author "Chris Houser", + ^{:author "Chris Houser", :doc "System for filtering trees and nodes generated by zip.clj in general, and xml trees in particular. "} @@ -52,7 +52,7 @@ general, and xml trees in particular. (defn children-auto "Returns a lazy sequence of all immediate children of location loc, left-to-right, marked so that a following tag= predicate will auto-descend." - #^{:private true} + ^{:private true} [loc] (when (zip/branch? loc) (map #(auto true %) (right-locs (zip/down loc))))) @@ -71,7 +71,7 @@ general, and xml trees in particular. (defn- fixup-apply "Calls (pred loc), and then converts the result to the 'appropriate' sequence." - #^{:private true} + ^{:private true} [pred loc] (let [rtn (pred loc)] (cond (and (map? (meta rtn)) (:zip-filter/is-node? (meta rtn))) (list rtn) @@ -82,7 +82,7 @@ general, and xml trees in particular. :else (list rtn)))) (defn mapcat-chain - #^{:private true} + ^{:private true} [loc preds mkpred] (reduce (fn [prevseq expr] (mapcat #(fixup-apply (or (mkpred expr) expr) %) prevseq)) diff --git a/src/main/clojure/clojure/contrib/zip_filter/xml.clj b/src/main/clojure/clojure/contrib/zip_filter/xml.clj index e6e8cb3d..7459b3fe 100644 --- a/src/main/clojure/clojure/contrib/zip_filter/xml.clj +++ b/src/main/clojure/clojure/contrib/zip_filter/xml.clj @@ -40,7 +40,7 @@ xpaths's value-of" [loc] (.replaceAll - #^String (apply str (xml-> loc zf/descendants zip/node string?)) + ^String (apply str (xml-> loc zf/descendants zip/node string?)) (str "[\\s" (char 160) "]+") " ")) (defn text= @@ -51,7 +51,7 @@ (defn seq-test "Returns a query predicate that matches a node when its xml content matches the query expresions given." - #^{:private true} + ^{:private true} [preds] (fn [loc] (and (seq (apply xml-> loc preds)) (list loc)))) (defn xml-> |