]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: Avoid some lambdas by re-using methods
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 6 Sep 2017 16:01:22 +0000 (18:01 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Sep 2017 06:38:54 +0000 (08:38 +0200)
libvaladoc/documentation/documentationparser.vala
libvaladoc/importer/valadocdocumentationimporter.vala

index 878f8a1805f22434fc9ca7e7b4bc3897dbec3a99..b42453e07307f72192b7783309b31a15d0ecd752 100644 (file)
@@ -292,7 +292,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                text.content += str;
        }
 
-       private void add_content_space () {
+       private void add_content_space (Token token) throws ParserError {
                // avoid double spaces
                var head = peek ();
                Text text_node = null;
@@ -313,17 +313,17 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                }
        }
 
+       private void add_text (Token token) throws ParserError {
+               add_content_string (token.to_string ());
+       }
+
        private void init_valadoc_rules () {
                // Inline rules
 
                StubRule run = new StubRule ();
                run.set_name ("Run");
 
-               TokenType.Action add_text = (token) => {
-                       add_content_string (token.to_string ());
-               };
-
-               TokenType space = TokenType.SPACE.action ((token) => { add_content_space (); });
+               TokenType space = TokenType.SPACE.action (add_content_space);
                TokenType word = TokenType.any_word ().action (add_text);
 
                Rule optional_invisible_spaces =
@@ -334,7 +334,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                Rule optional_spaces = 
                        Rule.option ({
                                Rule.many ({
-                                       TokenType.SPACE.action ((token) => { add_content_space (); })
+                                       TokenType.SPACE.action (add_content_space)
                                })
                        });
 
@@ -378,7 +378,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
 
                multiline_run = Rule.many ({
                                run_with_spaces,
-                               TokenType.EOL.action (() => { add_content_space (); })
+                               TokenType.EOL.action (add_content_space)
                        })
                        .set_name ("MultiLineRun");
 
@@ -550,7 +550,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                }),
                                Rule.many ({
                                        run,
-                                       TokenType.EOL.action (() => { add_content_space (); })
+                                       TokenType.EOL.action (add_content_space)
                                })
                        })
                        .set_name ("Paragraph")
@@ -571,7 +571,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                optional_invisible_spaces,
                                Rule.many ({
                                        Rule.seq({optional_invisible_spaces, run}),
-                                       TokenType.EOL.action (() => { add_content_space (); })
+                                       TokenType.EOL.action (add_content_space)
                                })
                        })
                        .set_name ("Warning")
@@ -593,7 +593,7 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                optional_invisible_spaces,
                                Rule.many ({
                                        Rule.seq({optional_invisible_spaces, run}),
-                                       TokenType.EOL.action (() => { add_content_space (); })
+                                       TokenType.EOL.action (add_content_space)
                                })
                        })
                        .set_name ("Note")
index 62ef1d09f2d3b558806b72c255f98518acd6bcb0..5505896fe18b270c65e85d9bcd899d7cc7992353 100644 (file)
@@ -82,11 +82,11 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
                                TokenType.VALADOC_COMMENT_START.action ((token) => { _comment_location = token.end; }),
                                Rule.many ({
                                        Rule.one_of ({
-                                               TokenType.ANY_WORD.action ((token) => { _comment.append (token.to_string ()); }),
-                                               TokenType.VALADOC_COMMENT_START.action ((token) => { _comment.append (token.to_string ()); }),
-                                               TokenType.VALADOC_SPACE.action ((token) => { _comment.append (token.to_string ()); }),
-                                               TokenType.VALADOC_TAB.action ((token) => { _comment.append (token.to_string ()); }),
-                                               TokenType.VALADOC_EOL.action ((token) => { _comment.append (token.to_string ()); })
+                                               TokenType.ANY_WORD.action (add_comment),
+                                               TokenType.VALADOC_COMMENT_START.action (add_comment),
+                                               TokenType.VALADOC_SPACE.action (add_comment),
+                                               TokenType.VALADOC_TAB.action (add_comment),
+                                               TokenType.VALADOC_EOL.action (add_comment)
                                        })
                                }),
                                TokenType.VALADOC_COMMENT_END,
@@ -116,6 +116,10 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
                _parser.set_root_rule (file);
        }
 
+       private void add_comment (Token token) throws ParserError {
+               _comment.append (token.to_string ());
+       }
+
        private enum InsertionMode {
                APPEND,
                PREPEND,