[vala/0.42] parser: Use comment which was already retrieved in parse_declaration()



commit 235552f934e8269a95198380c8bd3b86096c56c6
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Nov 20 12:31:52 2018 +0100

    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

 vala/valaparser.vala | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]