Release 0.41.92
[vala-gnome.git] / libvaladoc / content / link.vala
blobc48429c411986a776384e000566f9fbd40cf0cf7
1 /* link.vala
3 * Copyright (C) 2008-2009 Didier Villevalois
4 * Copyright (C) 2008-2014 Florian Brosch
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Author:
21 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
25 public class Valadoc.Content.Link : InlineContent, Inline {
26 public string url {
27 set;
28 get;
31 /**
32 * Used by importers to transform internal URLs
34 public Importer.InternalIdRegistrar id_registrar {
35 internal set;
36 get;
40 internal Link () {
41 base ();
44 public override void configure (Settings settings, ResourceLocator locator) {
47 public override void check (Api.Tree api_root, Api.Node container, string file_path,
48 ErrorReporter reporter, Settings settings)
51 // Internal gktdoc-id? (gir-importer)
52 if (id_registrar != null) {
53 Api.Node? node = id_registrar.map_symbol_id (url);
54 if (node != null) {
55 InlineContent _parent = parent as InlineContent;
56 assert (_parent != null);
58 SymbolLink replacement = new SymbolLink (node);
59 replacement.content.add_all (content);
61 replacement.check (api_root, container, file_path, reporter, settings);
62 _parent.replace_node (this, replacement);
63 return ;
67 string _url = id_registrar.map_url_id (url);
68 if (_url == null) {
69 string node_segment = (container is Api.Package)? "" : container.get_full_name () + ": ";
70 reporter.simple_warning ("%s: %s[[".printf (file_path, node_segment),
71 "unknown imported internal id '%s'", url);
73 InlineContent _parent = parent as InlineContent;
74 assert (_parent != null);
76 Run replacement = new Run (Run.Style.ITALIC);
77 replacement.content.add_all (content);
78 replacement.check (api_root, container, file_path, reporter, settings);
80 _parent.replace_node (this, replacement);
81 return ;
84 url = _url;
88 //TODO: check url
89 base.check (api_root, container, file_path, reporter, settings);
92 public override void accept (ContentVisitor visitor) {
93 visitor.visit_link (this);
96 public override bool is_empty () {
97 return false;
100 public override ContentElement copy (ContentElement? new_parent = null) {
101 Link link = new Link ();
102 link.id_registrar = id_registrar;
103 link.parent = new_parent;
104 link.url = url;
106 foreach (Inline element in content) {
107 Inline copy = element.copy (link) as Inline;
108 link.content.add (copy);
111 return link;