]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
drivers: fix namespace comment selection
authorFlorian Brosch <flo.brosch@gmail.com>
Fri, 10 Aug 2012 20:02:03 +0000 (22:02 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 10 Aug 2012 20:02:03 +0000 (22:02 +0200)
src/driver/0.10.x/treebuilder.vala
src/driver/0.12.x/treebuilder.vala
src/driver/0.14.x/treebuilder.vala
src/driver/0.16.x/treebuilder.vala
src/driver/0.18.x/treebuilder.vala
src/libvaladoc/api/sourcefile.vala
src/libvaladoc/importer/girdocumentationimporter.vala

index 2b379819f2b8292368ed069419f1cc9f3e3ac0dc..163fe8675fcc32b8046e1a285b24945ac17123a9 100644 (file)
@@ -70,7 +70,11 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        this.package = package;
                }
 
-               public Namespace get_namespace (Vala.Namespace vns, SourceFile? file) {
+               private bool is_source_file (Vala.SourceFile file) {
+                       return (file.filename.has_suffix (".vala") || file.filename.has_suffix (".gs"));
+               }
+
+               public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
                        Namespace? ns = namespaces.get (vns);
                        if (ns != null) {
                                return ns;
@@ -80,7 +84,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        SourceComment? comment = null;
                        if (vns.source_reference != null) {
                                foreach (Vala.Comment c in vns.get_comments()) {
-                                       if (c.source_reference.file == vns.source_reference.file) {
+                                       if (c.source_reference.file == file.data ||
+                                               (is_source_file (c.source_reference.file)
+                                                && is_source_file ((Vala.SourceFile) file.data))
+                                       ) {
                                                Vala.SourceReference pos = c.source_reference;
                                                comment = new SourceComment (c.content, file, pos.first_line, pos.first_column, pos.last_line, pos.last_column);
                                                break;
@@ -271,7 +278,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
        }
 
        private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
-               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename ());
+               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename (), source_file);
                files.set (source_file, file);
 
                meta_data.register_source_file (source_file);
index f41b10c9ec486705aa490075a4dfcd73f7a8e4b6..95be543d3ace648ed8d76e1a090df909ebce42b9 100644 (file)
@@ -70,7 +70,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        this.package = package;
                }
 
-               public Namespace get_namespace (Vala.Namespace vns, SourceFile? file) {
+               public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
                        Namespace? ns = namespaces.get (vns);
                        if (ns != null) {
                                return ns;
@@ -80,7 +80,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        SourceComment? comment = null;
                        if (vns.source_reference != null) {
                                foreach (Vala.Comment c in vns.get_comments()) {
-                                       if (c.source_reference.file == vns.source_reference.file) {
+                                       if (c.source_reference.file == file.data ||
+                                               (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE
+                                                && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE)
+                                       ) {
                                                Vala.SourceReference pos = c.source_reference;
                                                comment = new SourceComment (c.content, file, pos.first_line, pos.first_column, pos.last_line, pos.last_column);
                                                break;
@@ -277,7 +280,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
        }
 
        private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
-               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename ());
+               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename (), source_file);
                files.set (source_file, file);
 
                meta_data.register_source_file (source_file);
index 422b2963d8e0485bba85a5a928d1c8ff036110a5..8f4ff5ee298aab3ade02ef765e2042562f251cc6 100644 (file)
@@ -70,7 +70,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        this.package = package;
                }
 
-               public Namespace get_namespace (Vala.Namespace vns, SourceFile? file) {
+               public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
                        Namespace? ns = namespaces.get (vns);
                        if (ns != null) {
                                return ns;
@@ -80,7 +80,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        SourceComment? comment = null;
                        if (vns.source_reference != null) {
                                foreach (Vala.Comment c in vns.get_comments()) {
-                                       if (c.source_reference.file == vns.source_reference.file) {
+                                       if (c.source_reference.file == file.data ||
+                                               (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE
+                                                && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE)
+                                       ) {
                                                Vala.SourceReference pos = c.source_reference;
                                                comment = new SourceComment (c.content, file, pos.first_line, pos.first_column, pos.last_line, pos.last_column);
                                                break;
@@ -403,7 +406,7 @@ message ("--%s--", symbol.name);
        }
 
        private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
-               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename ());
+               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename (), source_file);
                files.set (source_file, file);
 
                meta_data.register_source_file (source_file);
index 30008c30efdb24906b5406b0f4ac5ad1c141ad62..93a551010c1f35011c38c981c5f27a30a09cb41e 100644 (file)
@@ -80,7 +80,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        SourceComment? comment = null;
                        if (vns.source_reference != null) {
                                foreach (Vala.Comment c in vns.get_comments()) {
-                                       if (c.source_reference.file == vns.source_reference.file) {
+                                       if (c.source_reference.file == file.data ||
+                                               (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE
+                                                && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE)
+                                       ) {
                                                Vala.SourceReference pos = c.source_reference;
 #if ! VALA_0_15_0
                                                if (c is Vala.GirComment) {
@@ -358,7 +361,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
        }
 
        private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
-               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename ());
+               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename (), source_file);
                files.set (source_file, file);
 
                meta_data.register_source_file (source_file);
index 68e0f057cb27ac90ddb4e79fc7e21d28f398dd83..c8fd7e2d78aaab912b88c9da829390738c680be6 100644 (file)
@@ -70,7 +70,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        this.package = package;
                }
 
-               public Namespace get_namespace (Vala.Namespace vns, SourceFile? file) {
+               public Namespace get_namespace (Vala.Namespace vns, SourceFile file) {
                        Namespace? ns = namespaces.get (vns);
                        if (ns != null) {
                                return ns;
@@ -80,7 +80,10 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
                        SourceComment? comment = null;
                        if (vns.source_reference != null) {
                                foreach (Vala.Comment c in vns.get_comments()) {
-                                       if (c.source_reference.file == vns.source_reference.file) {
+                                       if (c.source_reference.file == file.data ||
+                                               (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE
+                                                && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE)
+                                       ) {
                                                Vala.SourceReference pos = c.source_reference;
                                                if (c is Vala.GirComment) {
 #if VALA_0_17_0
@@ -371,7 +374,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
        }
 
        private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) {
-               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename ());
+               SourceFile file = new SourceFile (meta_data.package, source_file.get_relative_filename (), source_file.get_csource_filename (), source_file);
                files.set (source_file, file);
 
                meta_data.register_source_file (source_file);
index 09b821fe8aedc3b3bbf2948b08978038bfd61386..8cb1d96129b92e5c36f3ffb6366fe18f7d55b6cd 100644 (file)
@@ -43,10 +43,16 @@ public class Valadoc.Api.SourceFile : Object {
                return Path.get_basename (relative_path);
        }
 
-       public SourceFile (Package package, string relative_path, string? relative_c_path) {
+       public void* data {
+               private set;
+               get;
+       }
+
+       public SourceFile (Package package, string relative_path, string? relative_c_path, void* data) {
                this.relative_c_path = relative_c_path;
                this.relative_path = relative_path;
                this.package = package;
+               this.data = data;
        }
 }
 
index d097e26fda5e16d650cfbc4835cf42852a167d1a..6319475db7c68190c7f9602b05da30bff26a27d0 100644 (file)
@@ -61,7 +61,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
        }
 
        public override void process (string source_file) {
-               this.file = new Api.SourceFile (new Api.Package (Path.get_basename (source_file), true, null), source_file, null);
+               this.file = new Api.SourceFile (new Api.Package (Path.get_basename (source_file), true, null), source_file, null, null);
                this.reader = new MarkupReader (source_file, reporter);
 
                // xml prolog