Uploaded image for project: 'tools.reader'
  1. TRDR-9

Add more source metadata to read objects


    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Labels:
    • Patch:
      Code and Test


      I'm working on a static analyzer for Clojure, where I'd like to have a reader which provides precise form coordinates and source representations.

      Specifically this enables analyses where it's straightforward to bind an object like:

      (fn* [p1__3615#] (inc (conj p1__3615#)))

      to the source form which it was read from:

      "#(inc (conj %))"

      Would this kind of functionality be considered appropriate to tools.reader? Specifically I'd like to make a change such that

      • Read data is unchanged
      • When an IMeta is read, additional information is embedded in the metadata, but no existing metadata is changed
      • The additional metadata would include the source character string, the ending column, and the ending line from the source stream

      As an example, reading a stream that contained the following on the first line:

      #(inc (conj %))

      Would return a list as follows:

      (fn* [p1__3615#] (inc (conj p1__3615#)))

      And would change the metadata from:

      {:line 1, :column 1}

      to augment it with more metadata, as follows:

      {:line 1, :column 1, :end-line 1, :end-column 15, :source "#(inc (conj %))"}

      I'd happily contribute a patch to include this behavior if you'd be inclined to accept it. I'd like to first see if it would be considered appropriate, and also discuss any other concerns you might have (such as having this behavior be optionally enabled, etc)




            • Assignee:
              aredington Alexander Redington
              aredington Alexander Redington
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: