]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
valadoc: Drop custom MarkupReader
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Sep 2017 07:56:40 +0000 (09:56 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 9 Jan 2018 09:18:53 +0000 (10:18 +0100)
libvaladoc/Makefile.am
libvaladoc/importer/girdocumentationimporter.vala
libvaladoc/importer/internalidregistrar.vala
libvaladoc/markupreader.vala [deleted file]
libvaladoc/markupsourcelocation.vala [deleted file]
libvaladoc/markuptokentype.vala [deleted file]
valadoc/tests/libvaladoc/markupreader.vala

index 2a09d5d07e3a7b7ae594d37a5177931a81164855..7499a7ada495bd04bcb63c9686c8ff062f5a97e8 100644 (file)
@@ -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 $@
index e64dfc68417776f71f8404c0c71cd646990ea384..8e4b6d4c0e713fd6c24b5e1c9efca3d9c3e52008 100644 (file)
@@ -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") {
index c92cf3f06ec693b49b6ec2af32fa8d4430ec22af..8bad9ab1eeefc5f343a71b6cfe88a71eee875797 100644 (file)
@@ -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/libvaladoc/markupreader.vala b/libvaladoc/markupreader.vala
deleted file mode 100644 (file)
index c2e10a4..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/* markupreader.vala
- *
- * Copyright (C) 2008-2009  Jürg Billeter
- * Copyright (C) 2011       Florian Brosch
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- *
- * Author:
- *     Jürg Billeter <j@bitron.ch>
- */
-
-
-/**
- * Simple reader for a subset of XML.
- */
-public class Valadoc.MarkupReader : Object {
-       public string filename {
-               private set;
-               get;
-       }
-
-       public string name {
-               private set;
-               get;
-       }
-
-       public string content {
-               private set;
-               get;
-       }
-
-       private MappedFile mapped_file;
-
-       private string[] lines;
-       private char* begin;
-       private char* current;
-       private char* end;
-
-       private int line;
-       private int column;
-
-       private Vala.Map<string, string> attributes = new Vala.HashMap<string, string> (str_hash, str_equal);
-       private bool empty_element;
-
-       private ErrorReporter reporter;
-
-       public MarkupReader.from_string (string filename, string content, ErrorReporter reporter) {
-               this.filename = filename;
-               this.reporter = reporter;
-
-               lines = content.split ("\n");
-               begin = content;
-               end = begin + content.length;
-               current = begin;
-
-               column = 1;
-               line = 1;
-       }
-
-       public MarkupReader (string filename, ErrorReporter reporter) {
-               this.filename = filename;
-               this.reporter = reporter;
-
-               try {
-                       mapped_file = new MappedFile (filename, false);
-                       begin = mapped_file.get_contents ();
-                       lines = ((string) begin).split ("\n");
-                       end = begin + mapped_file.get_length ();
-
-                       current = begin;
-
-                       line = 1;
-                       column = 1;
-               } catch (FileError e) {
-                       reporter.simple_error (null, "Unable to map file '%s': %s", filename, e.message);
-               }
-       }
-
-       public string? get_line_content (int line_nr) {
-               if (this.lines.length > line_nr) {
-                       return this.lines[line_nr];
-               }
-
-               return null;
-       }
-
-       public string? get_attribute (string attr) {
-               return attributes[attr];
-       }
-
-       /*
-        * Returns a copy of the current attributes.
-        *
-        * @return map of current attributes
-        */
-       public Vala.Map<string,string> get_attributes () {
-               var result = new Vala.HashMap<string, string> (str_hash, str_equal);
-               foreach (var key in attributes.get_keys ()) {
-                       result.set (key, attributes.get (key));
-               }
-               return result;
-       }
-
-       private string read_name () {
-               char* begin = current;
-               while (current < end) {
-                       if (current[0] == ' ' || current[0] == '\t' || current[0] == '>'
-                           || current[0] == '/' || current[0] == '=' || current[0] == '\n') {
-                               break;
-                       }
-                       unichar u = ((string) current).get_char_validated ((long) (end - current));
-                       if (u != (unichar) (-1)) {
-                               current += u.to_utf8 (null);
-                       } else {
-                               reporter.simple_error ("%s:%d".printf (filename, line),
-                                                                          "invalid UTF-8 character");
-                       }
-               }
-               if (current == begin) {
-                       // syntax error: invalid name
-               }
-               return ((string) begin).substring (0, (int) (current - begin));
-       }
-
-       public MarkupTokenType read_token (out MarkupSourceLocation token_begin, out MarkupSourceLocation token_end) {
-               attributes.clear ();
-
-               if (empty_element) {
-                       empty_element = false;
-                       token_begin = MarkupSourceLocation (begin, line, column);
-                       token_end = MarkupSourceLocation (begin, line, column);
-                       return MarkupTokenType.END_ELEMENT;
-               }
-
-               content = null;
-               name = null;
-
-               space ();
-
-               MarkupTokenType type = MarkupTokenType.NONE;
-               char* begin = current;
-               token_begin = MarkupSourceLocation (begin, line, column);
-
-               if (current >= end) {
-                       type = MarkupTokenType.EOF;
-               } else if (current[0] == '<') {
-                       current++;
-                       if (current >= end) {
-                               // error
-                       } else if (current[0] == '?') {
-                               // processing instruction
-                       } else if (current[0] == '!') {
-                               // comment or doctype
-                               current++;
-                               if (current < end - 1 && current[0] == '-' && current[1] == '-') {
-                                       // comment
-                                       current += 2;
-                                       while (current < end - 2) {
-                                               if (current[0] == '-' && current[1] == '-' && current[2] == '>') {
-                                                       // end of comment
-                                                       current += 3;
-                                                       break;
-                                               } else if (current[0] == '\n') {
-                                                       line++;
-                                                       column = 0;
-                                               }
-                                               current++;
-                                       }
-
-                                       // ignore comment, read next token
-                                       return read_token (out token_begin, out token_end);
-                               }
-                       } else if (current[0] == '/') {
-                               type = MarkupTokenType.END_ELEMENT;
-                               current++;
-                               name = read_name ();
-                               if (current >= end || current[0] != '>') {
-                                       // error
-                               }
-                               current++;
-                       } else {
-                               type = MarkupTokenType.START_ELEMENT;
-                               name = read_name ();
-                               space ();
-                               while (current < end && current[0] != '>' && current[0] != '/') {
-                                       string attr_name = read_name ();
-                                       if (current >= end || current[0] != '=') {
-                                               // error
-                                       }
-                                       current++;
-                                       // FIXME allow single quotes
-                                       if (current >= end || current[0] != '"') {
-                                               // error
-                                       }
-                                       current++;
-
-                                       string attr_value = text ('"', false);
-
-                                       if (current >= end || current[0] != '"') {
-                                               // error
-                                       }
-                                       current++;
-                                       attributes.set (attr_name, attr_value);
-                                       space ();
-                               }
-                               if (current[0] == '/') {
-                                       empty_element = true;
-                                       current++;
-                                       space ();
-                               } else {
-                                       empty_element = false;
-                               }
-                               if (current >= end || current[0] != '>') {
-                                       // error
-                               }
-                               current++;
-                       }
-               } else {
-                       space ();
-
-                       if (current[0] != '<') {
-                               content = text ('<', true);
-                       } else {
-                               // no text
-                               // read next token
-                               return read_token (out token_begin, out token_end);
-                       }
-
-                       type = MarkupTokenType.TEXT;
-               }
-
-               token_end = MarkupSourceLocation (current, line, column - 1);
-
-               return type;
-       }
-
-       private string text (char end_char, bool rm_trailing_whitespace) {
-               StringBuilder content = new StringBuilder ();
-               char* text_begin = current;
-               char* last_linebreak = current;
-
-               while (current < end && current[0] != end_char) {
-                       unichar u = ((string) current).get_char_validated ((long) (end - current));
-                       if (u == (unichar) (-1)) {
-                               reporter.simple_error ("%s:%d".printf (filename, line),
-                                                                          "invalid UTF-8 character");
-                       } else if (u == '&') {
-                               char* next_pos = current + u.to_utf8 (null);
-                               if (((string) next_pos).has_prefix ("amp;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('&');
-                                       current += 5;
-                                       text_begin = current;
-                               } else if (((string) next_pos).has_prefix ("quot;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('"');
-                                       current += 6;
-                                       text_begin = current;
-                               } else if (((string) next_pos).has_prefix ("apos;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('\'');
-                                       current += 6;
-                                       text_begin = current;
-                               } else if (((string) next_pos).has_prefix ("lt;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('<');
-                                       current += 4;
-                                       text_begin = current;
-                               } else if (((string) next_pos).has_prefix ("gt;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('>');
-                                       current += 4;
-                                       text_begin = current;
-                               } else if (((string) next_pos).has_prefix ("percnt;")) {
-                                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-                                       content.append_c ('%');
-                                       current += 8;
-                                       text_begin = current;
-                               } else {
-                                       current += u.to_utf8 (null);
-                               }
-                       } else {
-                               if (u == '\n') {
-                                       line++;
-                                       column = 0;
-                                       last_linebreak = current;
-                               }
-
-                               current += u.to_utf8 (null);
-                               column++;
-                       }
-               }
-
-               if (text_begin != current) {
-                       content.append (((string) text_begin).substring (0, (int) (current - text_begin)));
-               }
-
-               column += (int) (current - last_linebreak);
-
-               // Removes trailing whitespace
-               if (rm_trailing_whitespace) {
-                       char* str_pos = ((char*)content.str) + content.len;
-                       for (str_pos--; str_pos > ((char*)content.str) && str_pos[0].isspace(); str_pos--);
-                       content.erase ((ssize_t) (str_pos-((char*) content.str) + 1), -1);
-               }
-
-               return content.str;
-       }
-
-       private void space () {
-               while (current < end && current[0].isspace ()) {
-                       if (current[0] == '\n') {
-                               line++;
-                               column = 0;
-                       }
-                       current++;
-                       column++;
-               }
-       }
-}
-
-
diff --git a/libvaladoc/markupsourcelocation.vala b/libvaladoc/markupsourcelocation.vala
deleted file mode 100644 (file)
index af7dff1..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* valasourcelocation.vala
- *
- * Copyright (C) 2008  Jürg Billeter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- *
- * Author:
- *     Jürg Billeter <j@bitron.ch>
- */
-
-using GLib;
-
-/**
- * Represents a position in a source file.
- */
-public struct Valadoc.MarkupSourceLocation {
-       public char* pos;
-       public int line;
-       public int column;
-
-       public MarkupSourceLocation (char* _pos, int _line, int _column) {
-               pos = _pos;
-               line = _line;
-               column = _column;
-       }
-}
-
diff --git a/libvaladoc/markuptokentype.vala b/libvaladoc/markuptokentype.vala
deleted file mode 100644 (file)
index d2dcad7..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* markuptokentype.vala
- *
- * Copyright (C) 2008-2009  Jürg Billeter
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- *
- * Author:
- *     Jürg Billeter <j@bitron.ch>
- */
-
-
-public enum Valadoc.MarkupTokenType {
-       NONE,
-       COMMENT,
-       START_ELEMENT,
-       END_ELEMENT,
-       TEXT,
-       EOF;
-
-       public string to_string () {
-               switch (this) {
-               case START_ELEMENT:
-                       return "start element";
-
-               case END_ELEMENT:
-                       return "end element";
-
-               case TEXT:
-                       return "text";
-
-               case EOF:
-                       return "end of file";
-
-               default:
-                       return "unknown token type";
-               }
-       }
-}
-
index 3681b7e99155d0073f021e02bbaf5d1b0b641315..363e4b462df53759f09d9baf8d80d8f2658f162d 100644 (file)
@@ -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 &amp; &quot;&apos; &lt; &gt; &percnt;";
 
-       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);