diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2010-11-11 15:51:21 +0100 |
---|---|---|
committer | Brice Figureau <brice-puppet@daysofwonder.com> | 2010-11-11 15:51:21 +0100 |
commit | 9604f1c4cd5a368da08c6f3219b44908a9b9921c (patch) | |
tree | aaf9e1d52bcf1be6d23078809436b25c68f50011 /lib/puppet | |
parent | cc5224c1912f2e95663c14ca803700070130fb69 (diff) | |
download | puppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.tar.gz puppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.tar.xz puppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.zip |
Fix #5252 - line number mis-attribution during parsing
It is a resurgence of #2366 that appeared because of the commit
8971d8.
Before this commit, for associating documentation comments, we
were preferring line numbers coming from the parser currently reducing rule,
instead of the current lexer line number (which can be in advance
of several tokens due to the nature of LALR parsers).
We now merge the ast line number before fetching the comment from the
lexer.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/parser_support.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index c90c1978f..7bbebb124 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -46,12 +46,12 @@ class Puppet::Parser::Parser # Create an AST object, and automatically add the file and line information if # available. def ast(klass, hash = {}) - klass.new ast_context(klass.use_docs).merge(hash) + klass.new ast_context(klass.use_docs, hash[:line]).merge(hash) end - def ast_context(include_docs = false) + def ast_context(include_docs = false, ast_line = nil) result = { - :line => lexer.line, + :line => ast_line || lexer.line, :file => lexer.file } result[:doc] = lexer.getcomment(result[:line]) if include_docs |