From: Rico Tzschichholz Date: Tue, 20 Nov 2018 11:31:52 +0000 (+0100) Subject: parser: Use comment which was already retrieved in parse_declaration() X-Git-Tag: 0.42.4~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=235552f934e8269a95198380c8bd3b86096c56c6;p=thirdparty%2Fvala.git parser: Use comment which was already retrieved in parse_declaration() This caused to loose comment of first element of enums and error domains. Regression of 540aa1492c342f482be6838b97f54437f3b776e4 --- diff --git a/vala/valaparser.vala b/vala/valaparser.vala index c4d8a5313..59d659f35 100644 --- a/vala/valaparser.vala +++ b/vala/valaparser.vala @@ -3103,7 +3103,9 @@ public class Vala.Parser : CodeVisitor { var value_attrs = parse_attributes (); var value_begin = get_location (); string id = parse_identifier (); - comment = scanner.pop_comment (); + if (comment == null) { + comment = scanner.pop_comment (); + } Expression value = null; if (accept (TokenType.ASSIGN)) { @@ -3114,6 +3116,7 @@ public class Vala.Parser : CodeVisitor { ev.access = SymbolAccessibility.PUBLIC; set_attributes (ev, value_attrs); en.add_value (ev); + comment = null; } while (accept (TokenType.COMMA)); if (accept (TokenType.SEMICOLON)) { // enum methods @@ -3167,13 +3170,17 @@ public class Vala.Parser : CodeVisitor { var code_attrs = parse_attributes (); var code_begin = get_location (); string id = parse_identifier (); - comment = scanner.pop_comment (); + if (comment == null) { + comment = scanner.pop_comment (); + } + var ec = new ErrorCode (id, get_src (code_begin), comment); set_attributes (ec, code_attrs); if (accept (TokenType.ASSIGN)) { ec.value = parse_expression (); } ed.add_code (ec); + comment = null; } while (accept (TokenType.COMMA)); if (accept (TokenType.SEMICOLON)) { // errordomain methods