]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Split process-comments into parse and check runs
authorFlorian Brosch <flo.brosch@gmail.com>
Sat, 23 Aug 2014 02:26:59 +0000 (04:26 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 29 Aug 2014 13:52:00 +0000 (15:52 +0200)
16 files changed:
src/libvaladoc/api/enumvalue.vala
src/libvaladoc/api/errorcode.vala
src/libvaladoc/api/item.vala
src/libvaladoc/api/member.vala
src/libvaladoc/api/namespace.vala
src/libvaladoc/api/node.vala
src/libvaladoc/api/property.vala
src/libvaladoc/api/sourcefile.vala
src/libvaladoc/api/tree.vala
src/libvaladoc/api/typesymbol.vala
src/libvaladoc/content/comment.vala
src/libvaladoc/content/page.vala
src/libvaladoc/documentation/documentationparser.vala
src/libvaladoc/documentation/gtkdoccommentparser.vala
src/libvaladoc/documentation/gtkdocmarkdownparser.vala
src/libvaladoc/documentation/wiki.vala

index b71559533fc11949dcda6300451f8a6708b55a60..34804ff5567fad08be01fa23c7f96e361bb7d6c8 100644 (file)
@@ -55,7 +55,7 @@ public class Valadoc.Api.EnumValue: Symbol {
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (documentation != null) {
                        return ;
                }
@@ -64,7 +64,18 @@ public class Valadoc.Api.EnumValue: Symbol {
                        documentation = parser.parse (this, source_comment);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (documentation != null) {
+                       parser.check (this, documentation);
+               }
+
+               base.check_comments (settings, parser);
        }
 
        /**
index 71d365fd5d51e516df1c85693d8599ea689dfba3..d7cf55128d11174aa4825c42971612782314ca64 100644 (file)
@@ -45,7 +45,7 @@ public class Valadoc.Api.ErrorCode : Symbol {
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (documentation != null) {
                        return ;
                }
@@ -54,7 +54,18 @@ public class Valadoc.Api.ErrorCode : Symbol {
                        documentation = parser.parse (this, source_comment);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (documentation != null) {
+                       parser.check (this, documentation);
+               }
+
+               base.check_comments (settings, parser);
        }
 
        /**
index 125362364e51c0018ae15e06d7a28d831a6b2ede..63b994736cf06e14671aac9b98aa201c19e4c406 100644 (file)
@@ -47,9 +47,13 @@ public abstract class Valadoc.Api.Item : Object {
                this.data = data;
        }
 
-       internal virtual void process_comments (Settings settings, DocumentationParser parser) {
+       internal virtual void parse_comments (Settings settings, DocumentationParser parser) {
        }
 
+       internal virtual void check_comments (Settings settings, DocumentationParser parser) {
+       }
+
+
        /**
         * The signature of this item.
         */
index 02754c7b7618902ad6907d50cde07a8ffe426467..b8271c37bbe616172a7e6a602b344a93071bbefa 100644 (file)
@@ -34,7 +34,11 @@ public abstract class Valadoc.Api.Member : Symbol {
                this.source_comment = comment;
        }
 
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (documentation != null) {
                        return ;
                }
@@ -43,6 +47,17 @@ public abstract class Valadoc.Api.Member : Symbol {
                        documentation = parser.parse (this, source_comment);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (documentation != null) {
+                       parser.check (this, documentation);
+               }
+
+               base.check_comments (settings, parser);
        }
 }
index 9bcb233b0392d464761da643c23187815f2cb79a..ff19db8ca193b0d76c0e0d6997e444f0cc801533 100644 (file)
@@ -36,10 +36,11 @@ public class Valadoc.Api.Namespace : Symbol {
                this.source_comment = comment;
        }
 
+
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (documentation != null) {
                        return ;
                }
@@ -48,9 +49,21 @@ public class Valadoc.Api.Namespace : Symbol {
                        documentation = parser.parse (this, source_comment);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (documentation != null) {
+                       parser.check (this, documentation);
+               }
+
+               base.check_comments (settings, parser);
        }
 
+
        /**
         * {@inheritDoc}
         */
index 9b2cee7feb4abf241333bd6d4796ce8141ab946a..2cbfe7c6abff50aab1d77a43317d61c9bb26c7c8 100644 (file)
@@ -116,16 +116,29 @@ public abstract class Valadoc.Api.Node : Item, Browsable, Documentation, Compara
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                do_document = true;
 
                foreach (Node node in per_name_children.values) {
                        if (node.is_browsable (settings)) {
-                               node.process_comments (settings, parser);
+                               node.parse_comments (settings, parser);
                        }
                }
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+
+               foreach (Node node in per_name_children.values) {
+                       if (node.is_browsable (settings)) {
+                               node.check_comments (settings, parser);
+                       }
+               }
+       }
+
+
        /**
         * Specifies whether this node has at least one visible child with the given type
         *
index 895ddcdf7a4535831ffac60bb398ec4966d7deca..556c7c9bfa94d823ff833b7c6d6a76db418fb21b 100644 (file)
@@ -125,18 +125,34 @@ public class Valadoc.Api.Property : Member {
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (getter != null && getter.is_browsable (settings)) {
-                       getter.process_comments (settings, parser);
+                       getter.parse_comments (settings, parser);
                }
 
                if (setter != null && setter.is_browsable (settings)) {
-                       setter.process_comments (settings, parser);
+                       setter.parse_comments (settings, parser);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (getter != null && getter.is_browsable (settings)) {
+                       getter.check_comments (settings, parser);
+               }
+
+               if (setter != null && setter.is_browsable (settings)) {
+                       setter.check_comments (settings, parser);
+               }
+
+               base.check_comments (settings, parser);
+       }
+
+
        /**
         * {@inheritDoc}
         */
index 8cb1d96129b92e5c36f3ffb6366fe18f7d55b6cd..46d1801be3ec215f392bc13fbc5df2f1ed24aa1c 100644 (file)
@@ -24,6 +24,7 @@
  * Represents a source file
  */
 public class Valadoc.Api.SourceFile : Object {
+
        public Package package {
                private set;
                get;
index 493a4b45da42bd52aba0e8f45afa822cfbae2ae2..e21770186a5454660b6d04e9be6d8ce5688baa5b 100644 (file)
@@ -36,6 +36,7 @@ public class Valadoc.Api.Tree {
        private Settings settings;
        private ErrorReporter reporter;
        private CTypeResolver _cresolver = null;
+       private Package _source_package;
 
        public void add_package(Package package) {
                this.packages.add (package);
@@ -233,36 +234,63 @@ public class Valadoc.Api.Tree {
        }
 
        private Package? get_source_package () {
-               foreach (Package pkg in packages) {
-                       if (!pkg.is_package) {
-                               return pkg;
+               if (_source_package == null) {
+                       foreach (Package pkg in packages) {
+                               if (!pkg.is_package) {
+                                       _source_package = pkg;
+                                       break;
+                               }
                        }
                }
 
-               return null;
+               return _source_package;
+       }
+
+       public void process_comments (DocumentationParser docparser) {
+               parse_comments (docparser);
+               check_comments (docparser);
        }
 
-       private void process_wiki (DocumentationParser docparser) {
-               this.wikitree = new WikiPageTree(reporter, settings);
+       private void parse_wiki (DocumentationParser docparser) {
+               this.wikitree = new WikiPageTree ();
                var pkg = get_source_package ();
                if (pkg != null) {
-                       wikitree.create_tree (docparser, pkg, reporter);
+                       wikitree.parse (settings, docparser, pkg, reporter);
                }
        }
 
-       public void process_comments (DocumentationParser docparser) {
-               process_wiki (docparser);
+       private void check_wiki (DocumentationParser docparser) {
+               var pkg = get_source_package ();
+               if (pkg != null) {
+                       wikitree.check (settings, docparser, pkg);
+               }
+       }
+
+       private void parse_comments (DocumentationParser docparser) {
+               parse_wiki (docparser);
 
                foreach (Package pkg in this.packages) {
                        if (pkg.is_browsable (settings)) {
-                               pkg.process_comments (settings, docparser);
+                               pkg.parse_comments (settings, docparser);
                        }
                }
+       }
+
+       private void check_comments (DocumentationParser docparser) {
+               check_wiki (docparser);
+
+               foreach (Package pkg in this.packages) {
+                       if (pkg.is_browsable (settings)) {
+                               pkg.check_comments (settings, docparser);
+                       }
+               }
+
 
-               // parse inherited non-public comments
+               // Parse & check inherited non-public comments:
                while (!this.unbrowsable_documentation_dependencies.is_empty) {
                        var node = this.unbrowsable_documentation_dependencies.poll_head ();
-                       node.process_comments (settings, docparser);
+                       node.parse_comments (settings, docparser);
+                       node.check_comments (settings, docparser);
                }
        }
 
index d6331ed324efe42a6333a9614effdea3732f6dff..3574688e6b5e9604bc4594443d8cf43d2bc289ae 100644 (file)
@@ -89,7 +89,7 @@ public abstract class Valadoc.Api.TypeSymbol : Symbol {
        /**
         * {@inheritDoc}
         */
-       internal override void process_comments (Settings settings, DocumentationParser parser) {
+       internal override void parse_comments (Settings settings, DocumentationParser parser) {
                if (documentation != null) {
                        return ;
                }
@@ -98,6 +98,17 @@ public abstract class Valadoc.Api.TypeSymbol : Symbol {
                        documentation = parser.parse (this, source_comment);
                }
 
-               base.process_comments (settings, parser);
+               base.parse_comments (settings, parser);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       internal override void check_comments (Settings settings, DocumentationParser parser) {
+               if (documentation != null) {
+                       parser.check (this, documentation);
+               }
+
+               base.check_comments (settings, parser);
        }
 }
index 71b80b9adf880a1a57f4785b33d2a3ed36beb5df..f1f1d4169b5c9d3188a124b5e5e8debde4330fcd 100644 (file)
@@ -31,6 +31,9 @@ public class Valadoc.Content.Comment : BlockContent {
        public Gee.List<Taglet> taglets { get { return _taglets; } }
        private Gee.List<Taglet> _taglets;
 
+       private bool checked = false;
+
+
        internal Comment () {
                base ();
                _taglets = new ArrayList<Taglet> ();
@@ -46,6 +49,13 @@ public class Valadoc.Content.Comment : BlockContent {
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
                                                                ErrorReporter reporter, Settings settings)
        {
+               if (checked == true) {
+                       return ;
+               }
+
+               checked = true;
+
+
                base.check (api_root, container, file_path, reporter, settings);
 
                foreach (Taglet element in _taglets) {
index 662ee89710ef76b41cb43ef4b0e784d33efce354..f180be84f1cba7f442683a8e404bb2b90d49f354 100644 (file)
@@ -24,6 +24,9 @@ using Gee;
 
 
 public class Valadoc.Content.Page : BlockContent {
+       private bool checked = false;
+
+
        internal Page () {
                base ();
        }
@@ -32,6 +35,19 @@ public class Valadoc.Content.Page : BlockContent {
                visitor.visit_page (this);
        }
 
+       public override void check (Api.Tree api_root, Api.Node container, string file_path,
+                                                               ErrorReporter reporter, Settings settings)
+       {
+               if (checked == true) {
+                       return ;
+               }
+
+               checked = true;
+
+
+               base.check (api_root, container, file_path, reporter, settings);
+       }
+
        public override ContentElement copy (ContentElement? new_parent = null) {
                assert (new_parent == null);
 
index a4a1201a7755b3850e0005c48ad7abd4bba01596..d94af81c31c0d9bb0bbb4799e328c78b3a3e2748 100644 (file)
@@ -93,14 +93,13 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
        {
                try {
                        Comment doc_comment = parse_comment (content, filename, first_line, first_column);
-                       doc_comment.check (_tree, element, filename, _reporter, _settings);
                        return doc_comment;
                } catch (ParserError error) {
                        return null;
                }
        }
 
-       public Page? parse_wikipage (WikiPage page, Api.Package pkg) {
+       public Page? parse_wikipage (Api.Package pkg, WikiPage page) {
                if (page.documentation != null) {
                        return page.documentation;
                }
@@ -111,7 +110,6 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 
                try {
                        Page documentation = parse_wiki (page.documentation_str, page.get_filename ());
-                       documentation.check (_tree, pkg, page.path, _reporter, _settings);
                        return documentation;
                } catch (ParserError error) {
                        return null;
@@ -136,6 +134,14 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                return (Page) pop ();
        }
 
+       public void check (Api.Node element, Comment comment) {
+               comment.check (_tree, element, element.get_source_file ().get_name (), _reporter, _settings);
+       }
+
+       public void check_wikipage (Api.Package package, Page page) {
+               page.check (_tree, package, package.get_source_file ().get_name (), _reporter, _settings);
+       }
+
        private GirMetaData get_metadata_for_comment (Api.GirSourceComment gir_comment) {
                GirMetaData metadata = metadata.get (gir_comment.file);
                if (metadata != null) {
index 417590be8e516e1ad3220794ae2097e90433ec2a..a9553c8cbac03272290cb9415aee4455228e8f54 100644 (file)
@@ -165,7 +165,6 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator {
                        first = false;
                }
 
-               comment.check (tree, element, gir_comment.file.relative_path, reporter, settings);
                return comment;
        }
 
index 341dff050f8980404d36a8dc7a266c23986924b5..721572d1dcf1abf4d70c23c29caa0e97bd133a59 100644 (file)
@@ -671,8 +671,6 @@ public class Valadoc.Gtkdoc.MarkdownParser : Object, ResourceLocator {
                }
 
 
-               cmnt.check (_tree, element, gir_comment.file.relative_path, _reporter, _settings);
-
                this.metadata = null;
                this.gir_comment = null;
                this.element = element;
index 614d91848cde1cae54151bf1edcd2404163a95b6..56227a4412ecfa204a0d233523a080b011d874d4 100644 (file)
@@ -22,6 +22,7 @@
 
 using Gee;
 
+
 public class Valadoc.WikiPage : Object, Documentation {
        public Content.Page documentation {
                protected set;
@@ -75,22 +76,21 @@ public class Valadoc.WikiPage : Object, Documentation {
                }
        }
 
-       public bool parse (DocumentationParser docparser, Api.Package pkg) {
-               documentation = docparser.parse_wikipage (this, pkg);
-               return true;
+       public void parse (DocumentationParser docparser, Api.Package pkg) {
+               documentation = docparser.parse_wikipage (pkg, this);
+       }
+
+       public void check (DocumentationParser docparser, Api.Package pkg) {
+               docparser.check_wikipage (pkg, documentation);
        }
 }
 
 
 public class Valadoc.WikiPageTree : Object {
        private ArrayList<WikiPage> wikipages;
-       private ErrorReporter reporter;
-       private Settings settings;
 
-       //TODO: reporter, settings -> create_tree
-       public WikiPageTree (ErrorReporter reporter, Settings settings) {
-               this.reporter = reporter;
-               this.settings = settings;
+
+       public WikiPageTree () {
        }
 
        public Collection<WikiPage> get_pages () {
@@ -111,7 +111,7 @@ public class Valadoc.WikiPageTree : Object {
        }
 
        private void create_tree_from_path (DocumentationParser docparser, Api.Package package,
-                                                                               ErrorReporter reporer, string path, string? nameoffset = null)
+                                                                               ErrorReporter reporter, string path, string? nameoffset = null)
        {
                try {
                        Dir dir = Dir.open (path);
@@ -135,10 +135,10 @@ public class Valadoc.WikiPageTree : Object {
                }
        }
 
-       public void create_tree (DocumentationParser docparser, Api.Package package, ErrorReporter reporer) {
-               weak string path = this.settings.wiki_directory;
+       public void parse (Settings settings, DocumentationParser docparser, Api.Package package, ErrorReporter reporter) {
+               weak string path = settings.wiki_directory;
                if (path == null) {
-                       return;
+                       return ;
                }
 
                this.wikipages = new ArrayList<WikiPage> ();
@@ -148,6 +148,16 @@ public class Valadoc.WikiPageTree : Object {
                        page.parse (docparser, package);
                }
        }
+
+       public void check (Settings settings, DocumentationParser docparser, Api.Package pkg) {
+               if (this.wikipages == null) {
+                       return ;
+               }
+
+               foreach (WikiPage page in this.wikipages) {
+                       page.check (docparser, pkg);
+               }
+       }
 }