~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
2
 
// 
3
 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
 
// software and associated documentation files (the "Software"), to deal in the Software
5
 
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
 
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
 
// to whom the Software is furnished to do so, subject to the following conditions:
8
 
// 
9
 
// The above copyright notice and this permission notice shall be included in all copies or
10
 
// substantial portions of the Software.
11
 
// 
12
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
 
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
 
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
 
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
 
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
 
// DEALINGS IN THE SOFTWARE.
18
 
 
19
 
using System;
20
 
using System.Collections.Generic;
21
 
using System.Diagnostics.Contracts;
22
 
using System.Linq;
23
 
 
24
 
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
25
 
{
26
 
        /// <summary>
27
 
        /// Default implementation for IType interface.
28
 
        /// </summary>
29
 
        [Serializable]
30
 
        public abstract class AbstractType : IType
31
 
        {
32
 
                public virtual string FullName {
33
 
                        get {
34
 
                                string ns = this.Namespace;
35
 
                                string name = this.Name;
36
 
                                if (string.IsNullOrEmpty(ns)) {
37
 
                                        return name;
38
 
                                } else {
39
 
                                        return ns + "." + name;
40
 
                                }
41
 
                        }
42
 
                }
43
 
                
44
 
                public abstract string Name { get; }
45
 
                
46
 
                public virtual string Namespace {
47
 
                        get { return string.Empty; }
48
 
                }
49
 
                
50
 
                public virtual string ReflectionName {
51
 
                        get { return this.FullName; }
52
 
                }
53
 
                
54
 
                public abstract bool? IsReferenceType  { get; }
55
 
                
56
 
                public abstract TypeKind Kind { get; }
57
 
                
58
 
                public virtual int TypeParameterCount {
59
 
                        get { return 0; }
60
 
                }
61
 
                
62
 
                public virtual IType DeclaringType {
63
 
                        get { return null; }
64
 
                }
65
 
                
66
 
                public virtual ITypeDefinition GetDefinition()
67
 
                {
68
 
                        return null;
69
 
                }
70
 
                
71
 
                public virtual IEnumerable<IType> DirectBaseTypes {
72
 
                        get { return EmptyList<IType>.Instance; }
73
 
                }
74
 
                
75
 
                public abstract ITypeReference ToTypeReference();
76
 
                
77
 
                public virtual IEnumerable<IType> GetNestedTypes(Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
78
 
                {
79
 
                        return EmptyList<IType>.Instance;
80
 
                }
81
 
                
82
 
                public virtual IEnumerable<IType> GetNestedTypes(IList<IType> typeArguments, Predicate<ITypeDefinition> filter = null, GetMemberOptions options = GetMemberOptions.None)
83
 
                {
84
 
                        return EmptyList<IType>.Instance;
85
 
                }
86
 
                
87
 
                public virtual IEnumerable<IMethod> GetMethods(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
88
 
                {
89
 
                        return EmptyList<IMethod>.Instance;
90
 
                }
91
 
                
92
 
                public virtual IEnumerable<IMethod> GetMethods(IList<IType> typeArguments, Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.None)
93
 
                {
94
 
                        return EmptyList<IMethod>.Instance;
95
 
                }
96
 
                
97
 
                public virtual IEnumerable<IMethod> GetConstructors(Predicate<IUnresolvedMethod> filter = null, GetMemberOptions options = GetMemberOptions.IgnoreInheritedMembers)
98
 
                {
99
 
                        return EmptyList<IMethod>.Instance;
100
 
                }
101
 
                
102
 
                public virtual IEnumerable<IProperty> GetProperties(Predicate<IUnresolvedProperty> filter = null, GetMemberOptions options = GetMemberOptions.None)
103
 
                {
104
 
                        return EmptyList<IProperty>.Instance;
105
 
                }
106
 
                
107
 
                public virtual IEnumerable<IField> GetFields(Predicate<IUnresolvedField> filter = null, GetMemberOptions options = GetMemberOptions.None)
108
 
                {
109
 
                        return EmptyList<IField>.Instance;
110
 
                }
111
 
                
112
 
                public virtual IEnumerable<IEvent> GetEvents(Predicate<IUnresolvedEvent> filter = null, GetMemberOptions options = GetMemberOptions.None)
113
 
                {
114
 
                        return EmptyList<IEvent>.Instance;
115
 
                }
116
 
                
117
 
                public virtual IEnumerable<IMember> GetMembers(Predicate<IUnresolvedMember> filter = null, GetMemberOptions options = GetMemberOptions.None)
118
 
                {
119
 
                        IEnumerable<IMember> members = GetMethods(filter, options);
120
 
                        return members
121
 
                                .Concat(GetProperties(filter, options))
122
 
                                .Concat(GetFields(filter, options))
123
 
                                .Concat(GetEvents(filter, options));
124
 
                }
125
 
                
126
 
                public override sealed bool Equals(object obj)
127
 
                {
128
 
                        return Equals(obj as IType);
129
 
                }
130
 
                
131
 
                public override int GetHashCode()
132
 
                {
133
 
                        return base.GetHashCode();
134
 
                }
135
 
                
136
 
                public virtual bool Equals(IType other)
137
 
                {
138
 
                        return this == other; // use reference equality by default
139
 
                }
140
 
                
141
 
                public override string ToString()
142
 
                {
143
 
                        return this.ReflectionName;
144
 
                }
145
 
                
146
 
                public virtual IType AcceptVisitor(TypeVisitor visitor)
147
 
                {
148
 
                        return visitor.VisitOtherType(this);
149
 
                }
150
 
                
151
 
                public virtual IType VisitChildren(TypeVisitor visitor)
152
 
                {
153
 
                        return this;
154
 
                }
155
 
        }
156
 
}