]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: Make better use of properties
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 6 Apr 2023 10:01:00 +0000 (12:01 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 6 Apr 2023 14:11:37 +0000 (16:11 +0200)
libvaladoc/content/blockcontent.vala
libvaladoc/content/comment.vala
libvaladoc/content/inlinecontent.vala
libvaladoc/content/list.vala
libvaladoc/content/table.vala
libvaladoc/content/tablerow.vala

index 06e3d0594449b711abb6bf8788ef966ae7ebe4f1..a58d13d37303e9641282c97555be9ce285583f62 100644 (file)
 
 
 public abstract class Valadoc.Content.BlockContent : ContentElement {
-       public Vala.List<Block> content { get { return _content; } }
-
-       private Vala.List<Block> _content;
+       public Vala.List<Block> content { get; private set; }
 
        construct {
-               _content = new Vala.ArrayList<Block> ();
+               content = new Vala.ArrayList<Block> ();
        }
 
        internal BlockContent () {
@@ -40,14 +38,14 @@ public abstract class Valadoc.Content.BlockContent : ContentElement {
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
                                                                ErrorReporter reporter, Settings settings)
        {
-               foreach (Block element in _content) {
+               foreach (Block element in content) {
                        element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
        }
 
        public override void accept_children (ContentVisitor visitor) {
-               foreach (Block element in _content) {
+               foreach (Block element in content) {
                        element.accept (visitor);
                }
        }
index 79362f5a18b1eab139a888880ee4f53870f97bf8..16e35f8fb36cc452c0d155e14ecb90efba5059b1 100644 (file)
 using Valadoc.Taglets;
 
 public class Valadoc.Content.Comment : BlockContent {
-       public Vala.List<Taglet> taglets { get { return _taglets; } }
-       private Vala.List<Taglet> _taglets;
+       public Vala.List<Taglet> taglets { get; private set; }
 
        private bool checked = false;
 
 
        internal Comment () {
                base ();
-               _taglets = new Vala.ArrayList<Taglet> ();
+               taglets = new Vala.ArrayList<Taglet> ();
        }
 
        public override void configure (Settings settings, ResourceLocator locator) {
@@ -51,7 +50,7 @@ public class Valadoc.Content.Comment : BlockContent {
 
                base.check (api_root, container, file_path, reporter, settings);
 
-               foreach (Taglet element in _taglets) {
+               foreach (Taglet element in taglets) {
                        element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
@@ -64,7 +63,7 @@ public class Valadoc.Content.Comment : BlockContent {
        public override void accept_children (ContentVisitor visitor) {
                base.accept_children (visitor);
 
-               foreach (Taglet element in _taglets) {
+               foreach (Taglet element in taglets) {
                        element.accept (visitor);
                }
        }
@@ -74,7 +73,7 @@ public class Valadoc.Content.Comment : BlockContent {
 
                // TODO inherit stuff if needed
 
-               foreach (Taglet taglet in _taglets) {
+               foreach (Taglet taglet in taglets) {
                        if (taglet.get_type () == taglet_type) {
                                selected_taglets.add (taglet);
                        }
@@ -94,7 +93,7 @@ public class Valadoc.Content.Comment : BlockContent {
                        comment.content.add (copy);
                }
 
-               foreach (Taglet taglet in _taglets) {
+               foreach (Taglet taglet in taglets) {
                        Taglet copy = taglet.copy (comment) as Taglet;
                        comment.taglets.add (copy);
                }
index 8fdb82d92f4ad09f7b04e9bd9f1872b6892e578a..7ecab8ace299050ff7aeb5158474b2bdc2e65a53 100644 (file)
 
 
 public abstract class Valadoc.Content.InlineContent : ContentElement {
-       public Vala.List<Inline> content {
-               get {
-                       return _content;
-               }
-       }
-
-       private Vala.List<Inline> _content;
+       public Vala.List<Inline> content { get; private set; }
 
        construct {
-               _content = new Vala.ArrayList<Inline> ();
+               content = new Vala.ArrayList<Inline> ();
        }
 
        internal InlineContent () {
@@ -41,14 +35,14 @@ public abstract class Valadoc.Content.InlineContent : ContentElement {
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
                                                                ErrorReporter reporter, Settings settings)
        {
-               foreach (Inline element in _content) {
+               foreach (Inline element in content) {
                        element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
        }
 
        public override void accept_children (ContentVisitor visitor) {
-               foreach (Inline element in _content) {
+               foreach (Inline element in content) {
                        element.accept (visitor);
                }
        }
@@ -64,10 +58,10 @@ public abstract class Valadoc.Content.InlineContent : ContentElement {
        }
 
        internal void replace_node (Inline old, Inline replacement) {
-               int index = _content.index_of (old);
+               int index = content.index_of (old);
                assert (index >= 0);
 
-               _content.set (index, replacement);
+               content.set (index, replacement);
        }
 }
 
index e47ed0b6308d6e6db9d66f984e7ff2dac83373eb..095a86d7a30f2f8a3fe45603889cabd6aaca5580 100644 (file)
@@ -101,25 +101,19 @@ public class Valadoc.Content.List : ContentElement, Block {
        }
 
        // TODO add initial value (either a number or some letters)
-       public Vala.List<ListItem> items {
-               get {
-                       return _items;
-               }
-       }
-
-       private Vala.List<ListItem> _items;
+       public Vala.List<ListItem> items { get; private set; }
 
        internal List () {
                base ();
-               _bullet = Bullet.NONE;
-               _items = new Vala.ArrayList<ListItem> ();
+               bullet = Bullet.NONE;
+               items = new Vala.ArrayList<ListItem> ();
        }
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
                                                                ErrorReporter reporter, Settings settings)
        {
                // Check individual list items
-               foreach (ListItem element in _items) {
+               foreach (ListItem element in items) {
                        element.parent = this;
                        element.check (api_root, container, file_path, reporter, settings);
                }
@@ -130,13 +124,13 @@ public class Valadoc.Content.List : ContentElement, Block {
        }
 
        public override void accept_children (ContentVisitor visitor) {
-               foreach (ListItem element in _items) {
+               foreach (ListItem element in items) {
                        element.accept (visitor);
                }
        }
 
        public override bool is_empty () {
-               return _items.size == 0;
+               return items.size == 0;
        }
 
        public override ContentElement copy (ContentElement? new_parent = null) {
index baae1a0393e376af30f5a08b62153aeab1ad0928..bf7f72f4505cd62924a915fbe0fa166166dd82bf 100644 (file)
 
 
 public class Valadoc.Content.Table : ContentElement, Block {
-       public Vala.List<TableRow> rows {
-               get {
-                       return _rows;
-               }
-       }
-
-       private Vala.List<TableRow> _rows;
+       public Vala.List<TableRow> rows { get; private set; }
 
        internal Table () {
                base ();
-               _rows = new Vala.ArrayList<TableRow> ();
+               rows = new Vala.ArrayList<TableRow> ();
        }
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
@@ -42,7 +36,7 @@ public class Valadoc.Content.Table : ContentElement, Block {
                // Check the table consistency in term of row/column number
 
                // Check individual rows
-               foreach (var row in _rows) {
+               foreach (var row in rows) {
                        row.parent = this;
                        row.check (api_root, container, file_path, reporter, settings);
                }
@@ -53,7 +47,7 @@ public class Valadoc.Content.Table : ContentElement, Block {
        }
 
        public override void accept_children (ContentVisitor visitor) {
-               foreach (TableRow element in _rows) {
+               foreach (TableRow element in rows) {
                        element.accept (visitor);
                }
        }
@@ -66,7 +60,7 @@ public class Valadoc.Content.Table : ContentElement, Block {
                Table table = new Table ();
                table.parent = new_parent;
 
-               foreach (var row in _rows) {
+               foreach (var row in rows) {
                        TableRow copy = row.copy (table) as TableRow;
                        table.rows.add (copy);
                }
index 97b024b75b7ab350e0be4dd68431c9b93f1c14d8..3863703c06b1272e33168feaa24c77f922bf3ebc 100644 (file)
 
 
 public class Valadoc.Content.TableRow : ContentElement {
-       public Vala.List<TableCell> cells {
-               get {
-                       return _cells;
-               }
-       }
-
-       private Vala.List<TableCell> _cells;
+       public Vala.List<TableCell> cells { get; private set; }
 
        internal TableRow () {
                base ();
-               _cells = new Vala.ArrayList<TableCell> ();
+               cells = new Vala.ArrayList<TableCell> ();
        }
 
        public override void check (Api.Tree api_root, Api.Node container, string file_path,
                                                                ErrorReporter reporter, Settings settings)
        {
                // Check individual cells
-               foreach (var cell in _cells) {
+               foreach (var cell in cells) {
                        cell.parent = this;
                        cell.check (api_root, container, file_path, reporter, settings);
                }
@@ -51,7 +45,7 @@ public class Valadoc.Content.TableRow : ContentElement {
        }
 
        public override void accept_children (ContentVisitor visitor) {
-               foreach (TableCell element in _cells) {
+               foreach (TableCell element in cells) {
                        element.accept (visitor);
                }
        }
@@ -64,7 +58,7 @@ public class Valadoc.Content.TableRow : ContentElement {
                TableRow row = new TableRow ();
                row.parent = new_parent;
 
-               foreach (TableCell cell in _cells) {
+               foreach (TableCell cell in cells) {
                        TableCell copy = cell.copy (row) as TableCell;
                        row.cells.add (copy);
                }