Commit 3fe8c8aa authored by Florian Brosch's avatar Florian Brosch Committed by Jürg Billeter

Comment handling improvements

Fixes bug 529040, bug 540513, and bug 546096.
parent 392bb600
......@@ -142,7 +142,7 @@ public class Vala.CCodeWriter {
* @param s a string
*/
public void write_string (string s) {
stream.printf ("%s", s);
stream.puts (s);
_bol = false;
}
......@@ -177,7 +177,7 @@ public class Vala.CCodeWriter {
indent--;
write_indent ();
stream.printf ("}");
stream.putc ('}');
}
/**
......@@ -187,7 +187,7 @@ public class Vala.CCodeWriter {
*/
public void write_comment (string text) {
write_indent ();
stream.printf ("/*");
stream.puts ("/*");
bool first = true;
/* separate declaration due to missing memory management in foreach statements */
......@@ -199,9 +199,17 @@ public class Vala.CCodeWriter {
} else {
first = false;
}
stream.printf ("%s", line);
var lineparts = line.split ("*/");
for (int i = 0; lineparts[i] != null; i++) {
stream.puts (lineparts[i]);
if (lineparts[i+1] != null) {
stream.puts ("* /");
}
}
}
stream.printf ("*/");
stream.puts ("*/");
write_newline ();
}
}
......@@ -609,11 +609,6 @@ internal class Vala.CCodeBaseModule : CCodeModule {
source_type_member_definition.append (cfunc);
}
CCodeComment comment = null;
if (source_file.comment != null) {
comment = new CCodeComment (source_file.comment);
}
var writer = new CCodeWriter (source_file.get_csource_filename ());
if (!writer.open ()) {
......@@ -621,9 +616,15 @@ internal class Vala.CCodeBaseModule : CCodeModule {
return;
}
writer.line_directives = context.debug;
if (comment != null) {
comment.write (writer);
var comments = source_file.get_comments();
if (comments != null) {
foreach (Comment comment in comments) {
var ccomment = new CCodeComment (comment.content);
ccomment.write (writer);
}
}
writer.write_newline ();
source_declarations.include_directives.write (writer);
writer.write_newline ();
......@@ -687,10 +688,6 @@ internal class Vala.CCodeBaseModule : CCodeModule {
cenum.add_value (new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode));
}
}
if (en.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (en.source_reference.comment));
}
decl_space.add_type_definition (cenum);
decl_space.add_type_definition (new CCodeNewline ());
......@@ -1568,11 +1565,6 @@ internal class Vala.CCodeBaseModule : CCodeModule {
if (stmt.error) {
continue;
}
var src = stmt.source_reference;
if (src != null && src.comment != null) {
cblock.add_statement (new CCodeComment (src.comment));
}
if (stmt.ccodenode is CCodeFragment) {
foreach (CCodeNode cstmt in ((CCodeFragment) stmt.ccodenode).get_children ()) {
......
......@@ -103,10 +103,6 @@ internal class Vala.CCodeDelegateModule : CCodeArrayModule {
}
var ctypedef = new CCodeTypeDefinition (return_type_cname, cfundecl);
if (d.source_reference != null && d.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (d.source_reference.comment));
}
decl_space.add_type_definition (ctypedef);
}
......
......@@ -455,9 +455,6 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
}
if (!m.coroutine) {
if (m.source_reference != null && m.source_reference.comment != null) {
source_type_member_definition.append (new CCodeComment (m.source_reference.comment));
}
source_type_member_definition.append (function);
}
......@@ -900,9 +897,6 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
vfunc.block = vblock;
if (m.is_abstract && m.source_reference != null && m.source_reference.comment != null) {
source_type_member_definition.append (new CCodeComment (m.source_reference.comment));
}
source_type_member_definition.append (vfunc);
}
......
......@@ -101,9 +101,6 @@ internal class Vala.CCodeStructModule : CCodeBaseModule {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (st.get_cname ()), new CCodeVariableDeclarator (st.get_cname ())));
if (st.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (st.source_reference.comment));
}
decl_space.add_type_definition (instance_struct);
var function = new CCodeFunction (st.get_dup_function (), st.get_cname () + "*");
......
......@@ -49,9 +49,6 @@ internal class Vala.GErrorModule : CCodeDelegateModule {
}
}
if (edomain.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (edomain.source_reference.comment));
}
decl_space.add_type_definition (cenum);
string quark_fun_name = edomain.get_lower_case_cprefix () + "quark";
......
......@@ -483,9 +483,6 @@ internal class Vala.GObjectModule : GTypeModule {
function.block = cblock;
if (c.source_reference.comment != null) {
source_type_member_definition.append (new CCodeComment (c.source_reference.comment));
}
source_type_member_definition.append (function);
} else if (c.binding == MemberBinding.CLASS) {
// class constructor
......
......@@ -309,9 +309,6 @@ internal class Vala.GTypeModule : GErrorModule {
}
}
if (cl.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (cl.source_reference.comment));
}
if (!cl.is_compact || cl.base_class == null) {
// derived compact classes do not have a struct
decl_space.add_type_definition (instance_struct);
......@@ -1773,9 +1770,6 @@ internal class Vala.GTypeModule : GErrorModule {
}
}
if (iface.source_reference.comment != null) {
decl_space.add_type_definition (new CCodeComment (iface.source_reference.comment));
}
decl_space.add_type_definition (type_struct);
var type_fun = create_interface_register_function (iface);
......
......@@ -40,6 +40,7 @@ libvalacore_la_VALASOURCES = \
valacodenode.vala \
valacodevisitor.vala \
valacodewriter.vala \
valacomment.vala \
valaconditionalexpression.vala \
valaconstant.vala \
valaconstructor.vala \
......
......@@ -241,10 +241,11 @@ public class Vala.Class : ObjectTypeSymbol {
*
* @param name type name
* @param source reference to source code
* @param comment class documentation
* @return newly created class
*/
public Class (string name, SourceReference? source_reference = null) {
base (name, source_reference);
public Class (string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
}
/**
......
/* valacomment.vala
*
* Copyright (C) 2008-2009 Florian Brosch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Florian Brosch <flo.brosch@gmail.com>
*/
using GLib;
/**
* A documentation comment used by valadoc
*/
public class Vala.Comment {
public Comment (string comment, SourceReference _source_reference) {
source_reference = _source_reference;
content = comment;
}
/**
* The text describing the referenced source code.
*/
public string content { set; get; }
/**
* References the location in the source file where this code node has
* been written.
*/
public SourceReference source_reference { get; set; }
}
......@@ -67,8 +67,8 @@ public class Vala.Constant : Member, Lockable {
* @param source_reference reference to source code
* @return newly created constant
*/
public Constant (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference) {
base (name, source_reference);
public Constant (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference, Comment? comment = null) {
base (name, source_reference, comment);
this.type_reference = type_reference;
this.initializer = initializer;
}
......
......@@ -59,8 +59,8 @@ public class Vala.CreationMethod : Method {
* @param source_reference reference to source code
* @return newly created method
*/
public CreationMethod (string? class_name, string? name, SourceReference? source_reference = null) {
base (name, new VoidType (), source_reference);
public CreationMethod (string? class_name, string? name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, new VoidType (), source_reference, comment);
this.class_name = class_name;
carray_length_parameter_position = -3;
......
......@@ -90,8 +90,8 @@ public class Vala.Delegate : TypeSymbol {
* @param source reference to source code
* @return newly created delegate
*/
public Delegate (string? name, DataType return_type, SourceReference? source_reference = null) {
base (name, source_reference);
public Delegate (string? name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.return_type = return_type;
// error is -1 (right of user_data)
......
......@@ -34,8 +34,8 @@ public class Vala.DynamicMethod : Method {
private string cname;
static int dynamic_method_id;
public DynamicMethod (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null) {
base (name, return_type, source_reference);
public DynamicMethod (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, return_type, source_reference, comment);
this.dynamic_type = dynamic_type;
}
......
......@@ -29,8 +29,8 @@ using Gee;
public class Vala.DynamicProperty : Property {
public DataType dynamic_type { get; set; }
public DynamicProperty (DataType dynamic_type, string name, SourceReference? source_reference = null) {
base (name, null, null, null, source_reference);
public DynamicProperty (DataType dynamic_type, string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, null, null, null, source_reference, comment);
this.dynamic_type = dynamic_type;
}
......
......@@ -30,8 +30,8 @@ public class Vala.DynamicSignal : Signal {
public Expression handler { get; set; }
public DynamicSignal (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null) {
base (name, return_type, source_reference);
public DynamicSignal (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, return_type, source_reference, comment);
this.dynamic_type = dynamic_type;
}
......
......@@ -52,8 +52,8 @@ public class Vala.Enum : TypeSymbol {
* @param source_reference reference to source code
* @return newly created enum
*/
public Enum (string name, SourceReference? source_reference = null) {
base (name, source_reference);
public Enum (string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
}
/**
......
......@@ -31,6 +31,8 @@ public class Vala.EnumValue : Symbol {
*/
public Expression value { get; set; }
public Comment comment { get; set; }
private string cname;
/**
......@@ -39,8 +41,9 @@ public class Vala.EnumValue : Symbol {
* @param name enum value name
* @return newly created enum value
*/
public EnumValue (string name, SourceReference? source_reference = null) {
public EnumValue (string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference);
this.comment = comment;
}
/**
......@@ -50,8 +53,8 @@ public class Vala.EnumValue : Symbol {
* @param value numerical representation
* @return newly created enum value
*/
public EnumValue.with_value (string name, Expression value, SourceReference? source_reference = null) {
this (name, source_reference);
public EnumValue.with_value (string name, Expression value, SourceReference? source_reference = null, Comment? comment = null) {
this (name, source_reference, comment);
this.value = value;
}
......
......@@ -39,8 +39,8 @@ public class Vala.ErrorCode : TypeSymbol {
* @param name enum value name
* @return newly created enum value
*/
public ErrorCode (string name, SourceReference? source_reference = null) {
base (name, source_reference);
public ErrorCode (string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
}
/**
......
......@@ -41,8 +41,8 @@ public class Vala.ErrorDomain : TypeSymbol {
* @param source_reference reference to source code
* @return newly created error domain
*/
public ErrorDomain (string name, SourceReference? source_reference = null) {
base (name, source_reference);
public ErrorDomain (string name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
}
/**
......
......@@ -115,8 +115,8 @@ public class Vala.Field : Member, Lockable {
* @param source reference to source code
* @return newly created field
*/
public Field (string name, DataType field_type, Expression? initializer, SourceReference? source_reference = null) {
base (name, source_reference);
public Field (string name, DataType field_type, Expression? initializer, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.field_type = field_type;
this.initializer = initializer;
}
......
......@@ -40,7 +40,7 @@ public class Vala.Genie.Parser : CodeVisitor {
// number of tokens in buffer
int size;
string comment;
Comment comment;
string class_name;
......@@ -194,14 +194,6 @@ public class Vala.Genie.Parser : CodeVisitor {
return new SourceReference (scanner.source_file, begin.line, begin.column, tokens[last_index].end.line, tokens[last_index].end.column);
}
SourceReference get_src_com (SourceLocation begin) {
int last_index = (index + BUFFER_SIZE - 1) % BUFFER_SIZE;
var src = new SourceReference.with_comment (scanner.source_file, begin.line, begin.column, tokens[last_index].end.line, tokens[last_index].end.column, comment);
comment = null;
return src;
}
SourceReference get_current_src () {
return new SourceReference (scanner.source_file, tokens[index].begin.line, tokens[index].begin.column, tokens[index].end.line, tokens[index].end.column);
}
......@@ -1564,7 +1556,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.EOL);
}
stmt = new EmptyStatement (get_src_com (begin));
stmt = new EmptyStatement (get_src (begin));
break;
......@@ -1700,7 +1692,7 @@ public class Vala.Genie.Parser : CodeVisitor {
comment = scanner.pop_comment ();
var block = new Block (get_src_com (get_location ()));
var block = new Block (get_src (get_location ()));
block.add_statement (parse_embedded_statement_without_block ());
return block;
......@@ -1730,7 +1722,7 @@ public class Vala.Genie.Parser : CodeVisitor {
Block parse_block () throws ParseError {
var begin = get_location ();
expect (TokenType.INDENT);
var block = new Block (get_src_com (begin));
var block = new Block (get_src (begin));
parse_statements (block);
if (!accept (TokenType.DEDENT)) {
// only report error if it's not a secondary error
......@@ -1752,7 +1744,7 @@ public class Vala.Genie.Parser : CodeVisitor {
accept (TokenType.SEMICOLON);
expect_terminator ();
return new EmptyStatement (get_src_com (begin));
return new EmptyStatement (get_src (begin));
}
void add_local_var_variable (Block block, string id) throws ParseError {
......@@ -1811,7 +1803,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (accept (TokenType.ASSIGN)) {
initializer = parse_expression ();
}
return new LocalVariable (variable_type, id, initializer, get_src_com (begin));
return new LocalVariable (variable_type, id, initializer, get_src (begin));
}
Statement parse_expression_statement () throws ParseError {
......@@ -1824,7 +1816,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect_terminator ();
}
return new ExpressionStatement (expr, get_src_com (begin));
return new ExpressionStatement (expr, get_src (begin));
}
Expression parse_statement_expression () throws ParseError {
......@@ -1847,7 +1839,7 @@ public class Vala.Genie.Parser : CodeVisitor {
accept (TokenType.EOL);
}
var src = get_src_com (begin);
var src = get_src (begin);
var true_stmt = parse_embedded_statement ();
Block false_stmt = null;
if (accept (TokenType.ELSE)) {
......@@ -1870,19 +1862,19 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.EOL);
var stmt = new SwitchStatement (condition, get_src_com (begin));
var stmt = new SwitchStatement (condition, get_src (begin));
expect (TokenType.INDENT);
while (current () != TokenType.DEDENT) {
var section = new SwitchSection (get_src_com (begin));
var section = new SwitchSection (get_src (begin));
if (accept (TokenType.WHEN)) {
do {
section.add_label (new SwitchLabel (parse_expression (), get_src_com (begin)));
section.add_label (new SwitchLabel (parse_expression (), get_src (begin)));
}
while (accept (TokenType.COMMA));
} else {
expect (TokenType.DEFAULT);
section.add_label (new SwitchLabel.with_default (get_src_com (begin)));
section.add_label (new SwitchLabel.with_default (get_src (begin)));
}
if (!accept (TokenType.EOL)) {
......@@ -1892,7 +1884,7 @@ public class Vala.Genie.Parser : CodeVisitor {
parse_statements (section);
/* add break statement for each block */
var break_stmt = new BreakStatement (get_src_com (begin));
var break_stmt = new BreakStatement (get_src (begin));
section.add_statement (break_stmt);
stmt.add_section (section);
......@@ -1913,7 +1905,7 @@ public class Vala.Genie.Parser : CodeVisitor {
}
var body = parse_embedded_statement ();
return new WhileStatement (condition, body, get_src_com (begin));
return new WhileStatement (condition, body, get_src (begin));
}
Statement parse_do_statement () throws ParseError {
......@@ -1927,7 +1919,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect_terminator ();
return new DoStatement (body, condition, get_src_com (begin));
return new DoStatement (body, condition, get_src (begin));
}
......@@ -2008,7 +2000,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.DO);
}
var src = get_src_com (begin);
var src = get_src (begin);
var body = parse_embedded_statement ();
var stmt = new ForStatement (condition, body, src);
......@@ -2046,7 +2038,7 @@ public class Vala.Genie.Parser : CodeVisitor {
if (!accept (TokenType.EOL)) {
expect (TokenType.DO);
}
var src = get_src_com (begin);
var src = get_src (begin);
var body = parse_embedded_statement ();
return new ForeachStatement (type, id, collection, body, src);
}
......@@ -2055,14 +2047,14 @@ public class Vala.Genie.Parser : CodeVisitor {
var begin = get_location ();
expect (TokenType.BREAK);
expect_terminator ();
return new BreakStatement (get_src_com (begin));
return new BreakStatement (get_src (begin));
}
Statement parse_continue_statement () throws ParseError {
var begin = get_location ();
expect (TokenType.CONTINUE);
expect_terminator ();
return new ContinueStatement (get_src_com (begin));
return new ContinueStatement (get_src (begin));
}
Statement parse_return_statement () throws ParseError {
......@@ -2073,7 +2065,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expr = parse_expression ();
}
expect_terminator ();
return new ReturnStatement (expr, get_src_com (begin));
return new ReturnStatement (expr, get_src (begin));
}
Statement parse_yield_statement () throws ParseError {
......@@ -2092,7 +2084,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.RAISE);
var expr = parse_expression ();
expect_terminator ();
return new ThrowStatement (expr, get_src_com (begin));
return new ThrowStatement (expr, get_src (begin));
}
Statement parse_try_statement () throws ParseError {
......@@ -2110,7 +2102,7 @@ public class Vala.Genie.Parser : CodeVisitor {
} else {
finally_clause = parse_finally_clause ();
}
var stmt = new TryStatement (try_block, finally_clause, get_src_com (begin));
var stmt = new TryStatement (try_block, finally_clause, get_src (begin));
foreach (CatchClause clause in catch_clauses) {
stmt.add_catch_clause (clause);
}
......@@ -2148,7 +2140,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var expr = parse_expression ();
expect (TokenType.CLOSE_PARENS);
var stmt = parse_embedded_statement ();
return new LockStatement (expr, stmt, get_src_com (begin));
return new LockStatement (expr, stmt, get_src (begin));
}
Statement parse_delete_statement () throws ParseError {
......@@ -2156,7 +2148,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.DELETE);
var expr = parse_expression ();
expect_terminator ();
return new DeleteStatement (expr, get_src_com (begin));
return new DeleteStatement (expr, get_src (begin));
}
Gee.List<Attribute>? parse_attributes () throws ParseError {
......@@ -2347,7 +2339,11 @@ public class Vala.Genie.Parser : CodeVisitor {
var begin = get_location ();
expect (TokenType.NAMESPACE);
var sym = parse_symbol_name ();
var ns = new Namespace (sym.name, get_src_com (begin));
var ns = new Namespace (sym.name, get_src (begin));
if (comment != null) {
ns.add_comment (comment);
comment = null;
}
set_attributes (ns, attrs);
expect (TokenType.EOL);
parse_declarations (ns);
......@@ -2453,7 +2449,7 @@ public class Vala.Genie.Parser : CodeVisitor {
accept (TokenType.EOL);
var cl = new Class (sym.name, get_src_com (begin));
var cl = new Class (sym.name, get_src (begin), comment);
if (ModifierFlags.PRIVATE in flags) {
cl.access = SymbolAccessibility.PRIVATE;
......@@ -2572,7 +2568,7 @@ public class Vala.Genie.Parser : CodeVisitor {
array_type.element_type.value_owned = false;
}
var c = new Constant (id, type, initializer, get_src_com (begin));
var c = new Constant (id, type, initializer, get_src (begin), comment);
c.access = get_access (id);
if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
......@@ -2595,7 +2591,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var type = parse_type ();
var f = new Field (id, type, null, get_src_com (begin));
var f = new Field (id, type, null, get_src (begin), comment);
if (ModifierFlags.ABSTRACT in flags || ModifierFlags.VIRTUAL in flags || ModifierFlags.OVERRIDE in flags) {
Report.error (f.source_reference, "abstract, virtual, and override modifiers are not applicable to fields");
......@@ -2657,8 +2653,8 @@ public class Vala.Genie.Parser : CodeVisitor {
var begin = get_location ();
DataType type = new VoidType ();
expect (TokenType.INIT);
var method = new Method (id, type, get_src_com (begin));
var method = new Method (id, type, get_src (begin), comment);
method.access = SymbolAccessibility.PUBLIC;
set_attributes (method, attrs);
......@@ -2704,15 +2700,13 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.CLOSE_PARENS);
/* deal with return value */
if (accept (TokenType.COLON)) {
type = parse_type ();
parse_type_parameter_list ();
}
var method = new Method (id, type, get_src_com (begin));
var method = new Method (id, type, get_src (begin), comment);
if (ModifierFlags.PRIVATE in flags) {
method.access = SymbolAccessibility.PRIVATE;
} else {
......@@ -2844,7 +2838,7 @@ public class Vala.Genie.Parser : CodeVisitor {
var type = parse_type (false);
var prop = new Property (id, type, null, null, get_src_com (begin));
var prop = new Property (id, type, null, null, get_src (begin), comment);
if (ModifierFlags.PRIVATE in flags) {
prop.access = SymbolAccessibility.PRIVATE;
} else {
......@@ -2993,7 +2987,7 @@ public class Vala.Genie.Parser : CodeVisitor {
type = new VoidType ();
}
var sig = new Vala.Signal (id, type, get_src_com (begin));
var sig = new Vala.Signal (id, type, get_src (begin), comment);
if (ModifierFlags.PRIVATE in flags) {
sig.access = SymbolAccessibility.PRIVATE;
} else {
......@@ -3022,7 +3016,7 @@ public class Vala.Genie.Parser : CodeVisitor {
expect (TokenType.INIT);
var flags = parse_member_declaration_modifiers ();
var c = new Constructor (get_src_com (begin));
var c = new Constructor (get_src (begin));
if (ModifierFlags.STATIC in flags) {
c.binding = MemberBinding.STATIC;
} else if (ModifierFlags.CLASS in flags) {
......@@ -3037,7 +3031,7 @@ public class Vala.Genie.Parser : CodeVisitor {
Destructor parse_destructor_declaration (Gee.List<Attribute>? attrs) throws ParseError {
var begin = get_location ();
expect (TokenType.FINAL);
var d = new Destructor (get_src_com (begin));
var d = new Destructor (get_src (begin));
accept_block ();
d.body = parse_block ();
return d;
......@@ -3054,7 +3048,8 @@ public class Vala.Genie.Parser : CodeVisitor {
if (accept (TokenType.COLON)) {
base_type = parse_type ();
}
var st = new Struct (sym.name, get_src_com (begin));
var st = new Struct (sym.name, get_src (begin), comment);