Release 0.41.92
[vala-gnome.git] / libvaladoc / api / symbol.vala
blob3b375a330bba158aff2b7d471ebadb87f5e7c814
1 /* symbol.vala
3 * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
4 * Copyright (C) 2011 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 /**
26 * Represents a node in the symbol tree.
28 public abstract class Valadoc.Api.Symbol : Node {
29 private Vala.ArrayList<Attribute> attributes;
31 public bool is_deprecated {
32 default = false;
33 private set;
34 get;
37 public Symbol (Node parent, SourceFile file, string? name, SymbolAccessibility accessibility,
38 Vala.Symbol data)
40 base (parent, file, name, data);
42 this.accessibility = accessibility;
45 public void add_attribute (Attribute att) {
46 if (attributes == null) {
47 attributes = new Vala.ArrayList<Attribute> ();
50 // register deprecated symbols:
51 if (att.name == "Version") {
52 AttributeArgument? deprecated = att.get_argument ("deprecated");
53 AttributeArgument? version = att.get_argument ("deprecated_since");
54 if ((deprecated != null && deprecated.get_value_as_boolean ()) || version != null) {
55 string? version_str = (version != null) ? version.get_value_as_string () : null;
57 package.register_deprecated_symbol (this, version_str);
58 is_deprecated = true;
60 } else if (att.name == "Deprecated") {
61 AttributeArgument? version = att.get_argument ("version");
62 string? version_str = (version != null) ? version.get_value_as_string () : null;
64 package.register_deprecated_symbol (this, version_str);
65 is_deprecated = true;
68 attributes.add (att);
71 public Vala.Collection<Attribute> get_attributes () {
72 if (attributes == null) {
73 return new Vala.ArrayList<Attribute> ();
74 } else {
75 return attributes;
79 public Attribute? get_attribute (string name) {
80 if (attributes != null) {
81 foreach (Attribute att in attributes) {
82 if (att.name == name) {
83 return att;
88 return null;
91 /**
92 * {@inheritDoc}
94 public override bool is_browsable (Settings settings) {
95 if (!settings._private && this.is_private) {
96 return false;
98 if (!settings._internal && this.is_internal) {
99 return false;
101 if (!settings._protected && this.is_protected) {
102 return false;
105 Item? pos = parent;
106 while (pos != null && pos is Symbol && pos is Namespace == false) {
107 if (((Symbol) pos).is_browsable (settings) == false) {
108 return false;
110 pos = pos.parent;
113 return true;
116 public SymbolAccessibility accessibility {
117 private set;
118 get;
122 * Specifies whether this symbol is public.
124 public bool is_public {
125 get {
126 return accessibility == SymbolAccessibility.PUBLIC;
131 * Specifies whether this symbol is protected.
133 public bool is_protected {
134 get {
135 return accessibility == SymbolAccessibility.PROTECTED;
140 * Specifies whether this symbol is internal.
142 public bool is_internal {
143 get {
144 return accessibility == SymbolAccessibility.INTERNAL;
149 * Specifies whether this symbol is private.
151 public bool is_private {
152 get {
153 return accessibility == SymbolAccessibility.PRIVATE;