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



commit 8bbc99bea1b14977d7a570149911b09c0e2d5c0d
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 f52fba893..032e2638b 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3073,7 +3073,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)) {
@@ -3084,6 +3086,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
@@ -3137,13 +3140,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]