From: Rico Tzschichholz Date: Sat, 30 Mar 2019 18:37:45 +0000 (+0100) Subject: vala: Write "Source" attribute in fast-vapi mode X-Git-Tag: 0.45.1~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a90ab383c92b501cd25b744764b6ca6dca3a01e;p=thirdparty%2Fvala.git vala: Write "Source" attribute in fast-vapi mode This enables users to reference to the original source of a symbol. [Source (filename = "...", line = ..., column = ...)] --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index f3967a15c..943cb4339 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -1584,6 +1584,10 @@ public class Vala.CodeWriter : CodeVisitor { continue; } + if (attr.name == "Source") { + continue; + } + if (sym != null && attr.args.size == 1 && attr.name == "Version") { string since_val = attr.get_string ("since"); if (since_val != null && skip_since_tag_check (sym, since_val)) { @@ -1621,6 +1625,15 @@ public class Vala.CodeWriter : CodeVisitor { write_newline (); } } + + if (type == CodeWriterType.FAST && !(node is Parameter || node is PropertyAccessor)) { + var source_reference = node.source_reference; + if (source_reference != null) { + write_indent (); + stream.puts ("[Source (filename = \"%s\", line = %i, column = %i)]".printf (source_reference.file.get_relative_filename (), source_reference.begin.line, source_reference.begin.column)); + write_newline (); + } + } } private void write_accessibility (Symbol sym) { diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala index c4c05cdaa..ce9fbaf1d 100644 --- a/vala/valausedattr.vala +++ b/vala/valausedattr.vala @@ -76,6 +76,8 @@ public class Vala.UsedAttr : CodeVisitor { "ScanfFormat", "", "FormatArg", "", + "Source", "filename", "line", "column", "", + "GtkChild", "name", "internal", "", "GtkTemplate", "ui", "", "GtkCallback", "name", "",