Skip to content
Operate on Java source code in Clojure.
Java Clojure
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
java-src/bean/surgeon/antlr
src/bean
.gitignore
README.md
project.clj

README.md

Bean Surgeon

A somewhat silly library to modify Java source.

Extracted from an Android string-resource extractor.

Usage

This library is very rough and doesn't do much to cover up ANTLR-generated files yet.

Here's a little example:

;; Make all string literals uppercase:
(defn uppercase-all-strings
  [file-path]
  (let [changeset (transform
                   file-path
                   (fn
                     [node]
                     (= "STRINGLITERAL"
                        (nth bean.surgeon.antlr.JavaParser/tokenNames
                             (.getType node))))
                   (fn [sl]
                     (.toUpperCase (.getText sl))))]
    (file-diff file-path changeset)))

License

Copyright (C) 2012 Ryan Crum

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.