]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Write "Source" attribute in fast-vapi mode
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 30 Mar 2019 18:37:45 +0000 (19:37 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 18 Apr 2019 14:28:03 +0000 (16:28 +0200)
This enables users to reference to the original source of a symbol.

[Source (filename = "...", line = ..., column = ...)]

vala/valacodewriter.vala
vala/valausedattr.vala

index f3967a15c6623b6f223d27e6264b5a484ef0c53c..943cb43394eae7fac0ecb4a338420b4e58168c11 100644 (file)
@@ -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) {
index c4c05cdaaf6ee414e14b79e3f893edd26c2dbf04..ce9fbaf1d32208130f536353cf3899c0242f9995 100644 (file)
@@ -76,6 +76,8 @@ public class Vala.UsedAttr : CodeVisitor {
                "ScanfFormat", "",
                "FormatArg", "",
 
+               "Source", "filename", "line", "column", "",
+
                "GtkChild", "name", "internal", "",
                "GtkTemplate", "ui", "",
                "GtkCallback", "name", "",