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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedEntity.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) 2010-2013 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 ICSharpCode.NRefactory.Documentation;
 
22
 
 
23
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
 
24
{
 
25
        /// <summary>
 
26
        /// Implementation of <see cref="IEntity"/> that resolves an unresolved entity.
 
27
        /// </summary>
 
28
        public abstract class AbstractResolvedEntity : IEntity
 
29
        {
 
30
                protected readonly IUnresolvedEntity unresolved;
 
31
                protected readonly ITypeResolveContext parentContext;
 
32
                
 
33
                protected AbstractResolvedEntity(IUnresolvedEntity unresolved, ITypeResolveContext parentContext)
 
34
                {
 
35
                        if (unresolved == null)
 
36
                                throw new ArgumentNullException("unresolved");
 
37
                        if (parentContext == null)
 
38
                                throw new ArgumentNullException("parentContext");
 
39
                        this.unresolved = unresolved;
 
40
                        this.parentContext = parentContext;
 
41
                        this.Attributes = unresolved.Attributes.CreateResolvedAttributes(parentContext);
 
42
                }
 
43
                
 
44
                public EntityType EntityType {
 
45
                        get { return unresolved.EntityType; }
 
46
                }
 
47
                
 
48
                public DomRegion Region {
 
49
                        get { return unresolved.Region; }
 
50
                }
 
51
                
 
52
                public DomRegion BodyRegion {
 
53
                        get { return unresolved.BodyRegion; }
 
54
                }
 
55
                
 
56
                public ITypeDefinition DeclaringTypeDefinition {
 
57
                        get { return parentContext.CurrentTypeDefinition; }
 
58
                }
 
59
                
 
60
                public virtual IType DeclaringType {
 
61
                        get { return parentContext.CurrentTypeDefinition ?? (IType)SpecialType.UnknownType; }
 
62
                }
 
63
                
 
64
                public IAssembly ParentAssembly {
 
65
                        get { return parentContext.CurrentAssembly; }
 
66
                }
 
67
                
 
68
                public IList<IAttribute> Attributes { get; protected set; }
 
69
                
 
70
                public virtual DocumentationComment Documentation {
 
71
                        get {
 
72
                                IDocumentationProvider provider = FindDocumentation(parentContext);
 
73
                                if (provider != null)
 
74
                                        return provider.GetDocumentation(this);
 
75
                                else
 
76
                                        return null;
 
77
                        }
 
78
                }
 
79
                
 
80
                internal static IDocumentationProvider FindDocumentation(ITypeResolveContext context)
 
81
                {
 
82
                        IAssembly asm = context.CurrentAssembly;
 
83
                        if (asm != null)
 
84
                                return asm.UnresolvedAssembly as IDocumentationProvider;
 
85
                        else
 
86
                                return null;
 
87
                }
 
88
                
 
89
                public bool IsStatic { get { return unresolved.IsStatic; } }
 
90
                public bool IsAbstract { get { return unresolved.IsAbstract; } }
 
91
                public bool IsSealed { get { return unresolved.IsSealed; } }
 
92
                public bool IsShadowing { get { return unresolved.IsShadowing; } }
 
93
                public bool IsSynthetic { get { return unresolved.IsSynthetic; } }
 
94
                
 
95
                public ICompilation Compilation {
 
96
                        get { return parentContext.Compilation; }
 
97
                }
 
98
                
 
99
                public string FullName { get { return unresolved.FullName; } }
 
100
                public string Name { get { return unresolved.Name; } }
 
101
                public string ReflectionName { get { return unresolved.ReflectionName; } }
 
102
                public string Namespace { get { return unresolved.Namespace; } }
 
103
                
 
104
                public Accessibility Accessibility { get { return unresolved.Accessibility; } }
 
105
                public bool IsPrivate { get { return unresolved.IsPrivate; } }
 
106
                public bool IsPublic { get { return unresolved.IsPublic; } }
 
107
                public bool IsProtected { get { return unresolved.IsProtected; } }
 
108
                public bool IsInternal { get { return unresolved.IsInternal; } }
 
109
                public bool IsProtectedOrInternal { get { return unresolved.IsProtectedOrInternal; } }
 
110
                public bool IsProtectedAndInternal { get { return unresolved.IsProtectedAndInternal; } }
 
111
                
 
112
                public override string ToString()
 
113
                {
 
114
                        return "[" + this.EntityType.ToString() + " " + this.ReflectionName + "]";
 
115
                }
 
116
        }
 
117
}