Make location info like line number, column number accessible from elements
Description
Environment
Attachments
- 25 Nov 2016, 09:13 AM
- 24 Nov 2016, 10:14 AM
Activity

Herwig HochleitnerNovember 27, 2016 at 4:43 PM
Squashed the patches and added a ticket number to the commit message: https://github.com/clojure/data.xml/commit/144f799507a5041a00ba683681ef41300eb7c9ca
Thanks!

Tamás JungNovember 25, 2016 at 9:22 AM
Yeah, absolutely makes sense, pls find the additional patch. Unfortunately ignoring whitespaces in diff comes in handy again
https://github.com/clojure/data.xml/compare/master...lambdawerk:add-location-info?expand=1&w=1

Herwig HochleitnerNovember 25, 2016 at 4:39 AM
Thanks! Tests still run and formatting is ok now.
The issue that you mention in the test files, about character offset and column number being "odd":
After some investigation, it seems to me that .getLocation returns the current stream position of the reader. So if we wanted to locate the beginning of each START_ELEMENT, it might make sense to record the latest location for each event and base any encountered START_ELEMENT's location on that, what do you think?

Tamás JungNovember 24, 2016 at 10:44 AM
Refreshed the patch. See this new branch: https://github.com/clojure/data.xml/compare/master...lambdawerk:add-location-info?expand=1 (without w=1 !!). Agree, the diff shows a much cleaner picture now, blame is not cheated, the whole business with higher order options is removed.

Herwig HochleitnerNovember 23, 2016 at 7:19 PM
Thanks for the new patch. It seems that we are mostly on the same page now, as far as functionality goes, though I'm still not convinced of the necessity of a separate `event-element-with-meta`, when `event-element` could already find location-info (or their lack) on events and could then construct nodes with the appropriate metadata from the start. Remember, `with-meta` or `vary-meta` will copy the object, which seems wasteful for a function that gets called for every START_ELEMENT event, especially now that adding location info is the default.
Your editor still seems to disagree about the amount of whitespace to use for indentation. That's not a problem per se, but including all those changed lines, that only differ in whitespace, into your patch, concerns me because it makes life harder not only for reviewers here, but also for anybody trying to look at the revision history, be it via `git log`, `git blame`, ...
Please try to submit minimal and focused patches. That is, patches where every single change is justified by the goal stated in the commit message.
I truly regret git's diffs being line-based and not based on syntax trees, but we have to work within the constraints of our preset process.
I hope that my nit-picking doesn't seem petty to you, my hope is that I can help you to avoid similar friction in your hopefully many future contributions.
If you want any further guidance before submitting another patch, feel free to contact me @bendlas on irc, github, ...
Details
Assignee
Herwig HochleitnerHerwig HochleitnerReporter
Tamás JungTamás JungPatch
Code and TestPriority
Minor
Details
Details
Assignee

Reporter

In the domain of manual validation, error reporting accessing the line number is crucial. The patch makes this possible.
(deftest test-location-meta
(let [input "<a/>"]
(is (= 1 (-> input (parse-str :with-location-meta true) meta :line-number)))))
https://github.com/clojure/data.xml/compare/master...lambdawerk:add-location-meta?expand=1