diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-09-06 18:01:22 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2017-09-06 20:22:49 +0200 |
commit | d40b13461c0f4af767ee0ecf71fd6870ec394f4b (patch) | |
tree | a4f18f846175acd6cff1b342e3dfa1fb52ab7f9d | |
parent | ce878cb1980e12fce2e7e421f450f1eb6b797929 (diff) | |
download | vala-wip/docs.tar.gz |
libvaladoc: Avoid some lambdas by re-using methodswip/docs
-rw-r--r-- | libvaladoc/documentation/documentationparser.vala | 22 | ||||
-rw-r--r-- | libvaladoc/importer/valadocdocumentationimporter.vala | 14 |
2 files changed, 20 insertions, 16 deletions
diff --git a/libvaladoc/documentation/documentationparser.vala b/libvaladoc/documentation/documentationparser.vala index 878f8a180..b42453e07 100644 --- a/libvaladoc/documentation/documentationparser.vala +++ b/libvaladoc/documentation/documentationparser.vala @@ -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") diff --git a/libvaladoc/importer/valadocdocumentationimporter.vala b/libvaladoc/importer/valadocdocumentationimporter.vala index 62ef1d09f..5505896fe 100644 --- a/libvaladoc/importer/valadocdocumentationimporter.vala +++ b/libvaladoc/importer/valadocdocumentationimporter.vala @@ -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, |