[vala/staging] valadoc: Drop custom MarkupReader
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] valadoc: Drop custom MarkupReader
- Date: Tue, 9 Jan 2018 09:40:33 +0000 (UTC)
commit a8588da4c619abcafde892ffb9359e2c84d13eed
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Sep 7 09:56:40 2017 +0200
valadoc: Drop custom MarkupReader
libvaladoc/Makefile.am | 5 +-
libvaladoc/importer/girdocumentationimporter.vala | 58 ++--
libvaladoc/importer/internalidregistrar.vala | 26 +-
libvaladoc/markupreader.vala | 334 ---------------------
libvaladoc/markupsourcelocation.vala | 39 ---
libvaladoc/markuptokentype.vala | 51 ----
valadoc/tests/libvaladoc/markupreader.vala | 42 ++--
7 files changed, 65 insertions(+), 490 deletions(-)
---
diff --git a/libvaladoc/Makefile.am b/libvaladoc/Makefile.am
index 2a09d5d..7499a7a 100644
--- a/libvaladoc/Makefile.am
+++ b/libvaladoc/Makefile.am
@@ -11,6 +11,7 @@ AM_CFLAGS = \
$(GLIB_CFLAGS) \
$(GMODULE_CFLAGS) \
-I$(top_srcdir)/gee \
+ -I$(top_srcdir)/vala \
$(NULL)
AM_VALAFLAGS = \
@@ -33,9 +34,6 @@ libvaladoc_la_VALASOURCES = \
gtkdocmarkupwriter.vala \
devhelp-markupwriter.vala \
ctyperesolver.vala \
- markupsourcelocation.vala \
- markuptokentype.vala \
- markupreader.vala \
gtkdocrenderer.vala \
documentation/commentscanner.vala \
documentation/documentation.vala \
@@ -186,6 +184,7 @@ libvaladoc.vala.stamp: $(libvaladoc_la_VALASOURCES)
--vapidir $(top_srcdir)/vapi --pkg gmodule-2.0 \
--vapidir $(top_srcdir)/vapi --pkg libgvc \
--vapidir $(top_srcdir)/gee --pkg gee \
+ --vapidir $(top_srcdir)/vala --pkg vala \
--pkg config \
$(filter %.vala %.c,$^)
touch $@
diff --git a/libvaladoc/importer/girdocumentationimporter.vala
b/libvaladoc/importer/girdocumentationimporter.vala
index e64dfc6..8e4b6d4 100644
--- a/libvaladoc/importer/girdocumentationimporter.vala
+++ b/libvaladoc/importer/girdocumentationimporter.vala
@@ -34,13 +34,12 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
}
}
- private MarkupTokenType current_token;
- private MarkupSourceLocation begin;
- private MarkupSourceLocation end;
- private MarkupReader reader;
+ private Vala.MarkupTokenType current_token;
+ private Vala.SourceLocation begin;
+ private Vala.SourceLocation end;
+ private Vala.MarkupReader reader;
private DocumentationParser parser;
- private ErrorReporter reporter;
private Api.SourceFile file;
private string parent_c_identifier;
@@ -60,14 +59,13 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
ErrorReporter reporter)
{
base (tree, modules, settings);
- this.reporter = reporter;
this.parser = parser;
}
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, null);
- this.reader = new MarkupReader (source_file, reporter);
+ this.reader = new Vala.MarkupReader (source_file);
// xml prolog
next ();
@@ -162,34 +160,32 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
}
private void warning (string message) {
- reporter.warning (this.file.relative_path, this.begin.line, this.begin.column,
this.end.column,
- this.reader.get_line_content (this.begin.line), message);
+ Vala.Report.warning (new Vala.SourceReference ((Vala.SourceFile) file.data, begin, end),
message);
}
private void error (string message) {
- reporter.error (this.file.relative_path, this.begin.line, this.begin.column, this.end.column,
- this.reader.get_line_content (this.begin.line), message);
+ Vala.Report.error (new Vala.SourceReference ((Vala.SourceFile) file.data, begin, end),
message);
}
private void next () {
current_token = reader.read_token (out begin, out end);
// Skip <annotation /> (only generated by valac)
- if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "annotation") {
+ if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "annotation") {
next (); // MarkupTokenType.END_ELEMENT, annotation
next ();
}
}
private void start_element (string name) {
- if (current_token != MarkupTokenType.START_ELEMENT || reader.name != name) {
+ if (current_token != Vala.MarkupTokenType.START_ELEMENT || reader.name != name) {
// error
error ("expected start element of `%s'".printf (name));
}
}
private void end_element (string name) {
- if (current_token != MarkupTokenType.END_ELEMENT || reader.name != name) {
+ if (current_token != Vala.MarkupTokenType.END_ELEMENT || reader.name != name) {
// error
error ("expected end element of `%s'".printf (name));
}
@@ -207,7 +203,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
}
next ();
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "namespace") {
parse_namespace ();
} else if (reader.name == "include") {
@@ -251,11 +247,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
int level = 1;
while (level > 0) {
- if (current_token == MarkupTokenType.START_ELEMENT) {
+ if (current_token == Vala.MarkupTokenType.START_ELEMENT) {
level++;
- } else if (current_token == MarkupTokenType.END_ELEMENT) {
+ } else if (current_token == Vala.MarkupTokenType.END_ELEMENT) {
level--;
- } else if (current_token == MarkupTokenType.EOF) {
+ } else if (current_token == Vala.MarkupTokenType.EOF) {
error ("unexpected end of file");
break;
}
@@ -267,7 +263,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
start_element ("namespace");
next ();
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "alias") {
parse_alias ();
} else if (reader.name == "enumeration") {
@@ -321,7 +317,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
next ();
- if (current_token == MarkupTokenType.TEXT) {
+ if (current_token == Vala.MarkupTokenType.TEXT) {
comment = new Api.GirSourceComment (reader.content, file, begin.line,
begin.column, end.line, end.column);
next ();
@@ -379,7 +375,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
Api.SourceComment? comment = null;
- if (current_token == MarkupTokenType.TEXT) {
+ if (current_token == Vala.MarkupTokenType.TEXT) {
comment = new Api.SourceComment (reader.content, file, begin.line,
begin.column,
end.line, end.column);
next ();
@@ -397,7 +393,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
Api.GirSourceComment? comment = parse_symbol_doc ();
attach_comment (this.parent_c_identifier, comment);
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "member") {
parse_enumeration_member ();
} else if (reader.name == "function") {
@@ -515,7 +511,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
attach_comment (this.parent_c_identifier, comment);
}
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "field") {
parse_field ();
} else if (reader.name == "constructor") {
@@ -545,7 +541,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
Api.GirSourceComment? comment = parse_symbol_doc ();
attach_comment (this.parent_c_identifier, comment);
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "implements") {
skip_element ();
} else if (reader.name == "constant") {
@@ -585,7 +581,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
Api.GirSourceComment? comment = parse_symbol_doc ();
attach_comment (this.parent_c_identifier, comment);
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "prerequisite") {
skip_element ();
} else if (reader.name == "field") {
@@ -688,7 +684,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
string[] param_names = new string[0];
int array_length_ret = -1;
- if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
+ if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "return-value") {
Api.SourceComment? return_comment;
parse_return_value (out return_comment, out array_length_ret);
if (return_comment != null) {
@@ -701,11 +697,11 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
}
- if (current_token == MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
+ if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "parameters") {
start_element ("parameters");
next ();
- if (current_token == MarkupTokenType.START_ELEMENT && reader.name ==
"instance-parameter") {
+ if (current_token == Vala.MarkupTokenType.START_ELEMENT && reader.name ==
"instance-parameter") {
string instance_param_name = reader.get_attribute ("name");
next ();
@@ -724,7 +720,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
}
}
- for (int pcount = 0; current_token == MarkupTokenType.START_ELEMENT; pcount++) {
+ for (int pcount = 0; current_token == Vala.MarkupTokenType.START_ELEMENT; pcount++) {
Api.SourceComment? param_comment;
int array_length_pos;
int destroy_pos;
@@ -787,7 +783,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
// TODO: process comments
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "field") {
parse_field ();
} else if (reader.name == "constructor") {
@@ -821,7 +817,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter {
Api.GirSourceComment? comment = parse_symbol_doc ();
attach_comment (this.parent_c_identifier, comment);
- while (current_token == MarkupTokenType.START_ELEMENT) {
+ while (current_token == Vala.MarkupTokenType.START_ELEMENT) {
if (reader.name == "field") {
parse_field ();
} else if (reader.name == "constructor") {
diff --git a/libvaladoc/importer/internalidregistrar.vala b/libvaladoc/importer/internalidregistrar.vala
index c92cf3f..8bad9ab 100644
--- a/libvaladoc/importer/internalidregistrar.vala
+++ b/libvaladoc/importer/internalidregistrar.vala
@@ -48,37 +48,41 @@ public class Valadoc.Importer.InternalIdRegistrar {
public void read_index_sgml_file (string filename, string? index_sgml_online, ErrorReporter reporter)
{
- MarkupSourceLocation begin;
- MarkupSourceLocation end;
- MarkupTokenType token;
+ Vala.SourceLocation begin;
+ Vala.SourceLocation end;
+ Vala.MarkupTokenType token;
string base_path = index_sgml_online ?? realpath (filename);
- var reader = new MarkupReader (filename, reporter);
+ var reader = new Vala.MarkupReader (filename);
- while ((token = reader.read_token (out begin, out end)) != MarkupTokenType.EOF) {
- if (token == MarkupTokenType.START_ELEMENT && reader.name == "ONLINE") {
+ while ((token = reader.read_token (out begin, out end)) != Vala.MarkupTokenType.EOF) {
+ if (token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "ONLINE") {
if (index_sgml_online == null) {
base_path = reader.get_attribute ("href");
if (base_path == null) {
- reporter.error (filename, begin.line, begin.column,
end.column, reader.get_line_content (begin.line), "missing attribute `href' in <ONLINE>");
+ //reporter.error (filename, begin.line, begin.column,
end.column, reader.get_line_content (begin.line), "missing attribute `href' in <ONLINE>");
+ Vala.Report.error (null, "missing attribute `href' in
<ONLINE>");
}
}
- } else if (token == MarkupTokenType.START_ELEMENT && reader.name == "ANCHOR") {
+ } else if (token == Vala.MarkupTokenType.START_ELEMENT && reader.name == "ANCHOR") {
string id = reader.get_attribute ("id");
if (id == null) {
- reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "missing attribute `id' in <ANCHOR>");
+ //reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "missing attribute `id' in <ANCHOR>");
+ Vala.Report.error (null, "missing attribute `id' in <ANCHOR>");
}
string href = reader.get_attribute ("href");
if (href == null) {
- reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "missing attribute `href' in <ANCHOR>");
+ //reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "missing attribute `href' in <ANCHOR>");
+ Vala.Report.error (null, "missing attribute `href' in <ANCHOR>");
} else if (index_sgml_online != null) {
href = Path.get_basename (href);
}
map.set (id, Path.build_path ("/", base_path, href));
} else {
- reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "expected element of <ONLINE> or <ANCHOR>");
+ //reporter.error (filename, begin.line, begin.column, end.column,
reader.get_line_content (begin.line), "expected element of <ONLINE> or <ANCHOR>");
+ Vala.Report.error (null, "expected element of <ONLINE> or <ANCHOR>");
}
}
}
diff --git a/valadoc/tests/libvaladoc/markupreader.vala b/valadoc/tests/libvaladoc/markupreader.vala
index 3681b7e..363e4b4 100644
--- a/valadoc/tests/libvaladoc/markupreader.vala
+++ b/valadoc/tests/libvaladoc/markupreader.vala
@@ -36,12 +36,12 @@ public static void positive_1 () {
</root-element>""";
- var reader = new MarkupReader.from_string ("testfile", content, reporter);
+ var reader = new Vala.MarkupReader.from_string ("testfile", content);
assert (reader.filename == "testfile");
- MarkupSourceLocation begin;
- MarkupSourceLocation end;
- MarkupTokenType token;
+ Vala.SourceLocation begin;
+ Vala.SourceLocation end;
+ Vala.MarkupTokenType token;
token = reader.read_token (out begin, out end);
@@ -49,7 +49,7 @@ public static void positive_1 () {
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.START_ELEMENT);
+ assert (token == Vala.MarkupTokenType.START_ELEMENT);
assert (reader.name == "root-element");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -59,7 +59,7 @@ public static void positive_1 () {
assert (end.line == 2);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.START_ELEMENT);
+ assert (token == Vala.MarkupTokenType.START_ELEMENT);
assert (reader.name == "subelement");
assert (reader.content == null);
assert (reader.get_attributes ().size == 2);
@@ -71,7 +71,7 @@ public static void positive_1 () {
assert (end.line == 3);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.TEXT);
+ assert (token == Vala.MarkupTokenType.TEXT);
assert (reader.name == null);
assert (reader.content == "my text");
assert (reader.get_attributes ().size == 0);
@@ -81,7 +81,7 @@ public static void positive_1 () {
assert (end.line == 3);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.END_ELEMENT);
+ assert (token == Vala.MarkupTokenType.END_ELEMENT);
assert (reader.name == "subelement");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -91,7 +91,7 @@ public static void positive_1 () {
assert (end.line == 3);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.START_ELEMENT);
+ assert (token == Vala.MarkupTokenType.START_ELEMENT);
assert (reader.name == "simpletag1");
assert (reader.content == null);
assert (reader.get_attributes ().size == 2);
@@ -103,7 +103,7 @@ public static void positive_1 () {
assert (end.line == 4);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.END_ELEMENT);
+ assert (token == Vala.MarkupTokenType.END_ELEMENT);
assert (reader.name == "simpletag1");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -113,7 +113,7 @@ public static void positive_1 () {
assert (end.line == 4);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.START_ELEMENT);
+ assert (token == Vala.MarkupTokenType.START_ELEMENT);
assert (reader.name == "simpletag2");
assert (reader.content == null);
assert (reader.get_attributes ().size == 1);
@@ -124,7 +124,7 @@ public static void positive_1 () {
assert (end.line == 5);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.END_ELEMENT);
+ assert (token == Vala.MarkupTokenType.END_ELEMENT);
assert (reader.name == "simpletag2");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -134,7 +134,7 @@ public static void positive_1 () {
assert (end.line == 5);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.START_ELEMENT);
+ assert (token == Vala.MarkupTokenType.START_ELEMENT);
assert (reader.name == "simpletag3");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -144,7 +144,7 @@ public static void positive_1 () {
assert (end.line == 6);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.END_ELEMENT);
+ assert (token == Vala.MarkupTokenType.END_ELEMENT);
assert (reader.name == "simpletag3");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -154,7 +154,7 @@ public static void positive_1 () {
assert (end.line == 6);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.END_ELEMENT);
+ assert (token == Vala.MarkupTokenType.END_ELEMENT);
assert (reader.name == "root-element");
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -164,7 +164,7 @@ public static void positive_1 () {
assert (end.line == 7);
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.EOF);
+ assert (token == Vala.MarkupTokenType.EOF);
assert (reader.name == null);
assert (reader.content == null);
assert (reader.get_attributes ().size == 0);
@@ -180,15 +180,15 @@ public static void positive_2 () {
string content = "AA BB & "' < > %";
- var reader = new MarkupReader.from_string ("testfile", content, reporter);
+ var reader = new Vala.MarkupReader.from_string ("testfile", content);
assert (reader.filename == "testfile");
- MarkupSourceLocation begin;
- MarkupSourceLocation end;
- MarkupTokenType token;
+ Vala.SourceLocation begin;
+ Vala.SourceLocation end;
+ Vala.MarkupTokenType token;
token = reader.read_token (out begin, out end);
- assert (token == MarkupTokenType.TEXT);
+ assert (token == Vala.MarkupTokenType.TEXT);
assert (reader.content == "AA BB & \"' < > %");
assert (reader.name == null);
assert (reader.get_attributes ().size == 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]