UcasRichard / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

Expose "index" in Mark #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
libyaml gives you access to "index", the offset into the file, in addition to 
line and column. Mark receives index in its contructor, but does not save it 
and does not expose it.

The "Psych" libyaml wrapper for Ruby 1.9.2 is going to add access to line, 
column and offset. We will need to follow suit in JRuby.

The attached patch saves index in Mark's constructor and adds an accessor for 
it.

Original issue reported on code.google.com by headius%...@gtempaccount.com on 17 Jan 2011 at 7:23

Attachments:

GoogleCodeExporter commented 9 years ago
This probably should have been filed as an enhancement. Oops.

Original comment by headius%...@gtempaccount.com on 17 Jan 2011 at 7:24

GoogleCodeExporter commented 9 years ago
FYI: http://jira.codehaus.org/browse/JRUBY-5375

Original comment by headius%...@gtempaccount.com on 17 Jan 2011 at 7:29

GoogleCodeExporter commented 9 years ago
The interface does not allow to create an 'Enhancement'. You have to create a 
defect and then it can be changed to Enhancement.
Since 'index' has no meaning for humans it is not exposed in SnakeYAML. It is 
not used for the snippet of YAML shown in errors. But it does not harm and it 
will be included in the coming release.

Original comment by py4fun@gmail.com on 19 Jan 2011 at 12:30

GoogleCodeExporter commented 9 years ago
Is index not the offset into the file?

Original comment by head...@gmail.com on 20 Jan 2011 at 3:33

GoogleCodeExporter commented 9 years ago
Yes it is. What I mean is that humans are not interested in this offset. That 
is why it is not shown as part of the error. Humans use text editors to see the 
line and the column (these are shown of course). Neither PyYAML nor SnakeYAML 
use the index. That is why it was not stored. Since SnakeYAML creates a lot of 
Marks it saves quite an amount of memory.

Original comment by aso...@gmail.com on 20 Jan 2011 at 4:58

GoogleCodeExporter commented 9 years ago
Ok, I understand. I think the reason the Psych author, Aaron Patterson, wants 
to add it is so he can show error messages with the line in context and use the 
offset to point at the exact start of the bad YAML structure. In any case, 
thanks for adding it!

Original comment by head...@gmail.com on 20 Jan 2011 at 7:52

GoogleCodeExporter commented 9 years ago
It will be included in 1.8 release

Original comment by aso...@gmail.com on 20 Jan 2011 at 11:25