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
21 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
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
{
37 public Symbol (Node parent
, SourceFile file
, string? name
, SymbolAccessibility accessibility
,
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
);
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
);
71 public Vala
.Collection
<Attribute
> get_attributes () {
72 if (attributes
== null) {
73 return new Vala
.ArrayList
<Attribute
> ();
79 public Attribute?
get_attribute (string name
) {
80 if (attributes
!= null) {
81 foreach (Attribute att
in attributes
) {
82 if (att
.name
== name
) {
94 public override bool is_browsable (Settings settings
) {
95 if (!settings
._private
&& this
.is_private
) {
98 if (!settings
._internal
&& this
.is_internal
) {
101 if (!settings
._protected
&& this
.is_protected
) {
106 while (pos
!= null && pos is Symbol
&& pos is Namespace
== false) {
107 if (((Symbol
) pos
).is_browsable (settings
) == false) {
116 public SymbolAccessibility accessibility
{
122 * Specifies whether this symbol is public.
124 public bool is_public
{
126 return accessibility
== SymbolAccessibility
.PUBLIC
;
131 * Specifies whether this symbol is protected.
133 public bool is_protected
{
135 return accessibility
== SymbolAccessibility
.PROTECTED
;
140 * Specifies whether this symbol is internal.
142 public bool is_internal
{
144 return accessibility
== SymbolAccessibility
.INTERNAL
;
149 * Specifies whether this symbol is private.
151 public bool is_private
{
153 return accessibility
== SymbolAccessibility
.PRIVATE
;