1
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
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:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
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.
20
using System.Collections.Generic;
21
using ICSharpCode.NRefactory.Documentation;
23
namespace ICSharpCode.NRefactory.TypeSystem.Implementation
26
/// Implementation of <see cref="IEntity"/> that resolves an unresolved entity.
28
public abstract class AbstractResolvedEntity : IEntity
30
protected readonly IUnresolvedEntity unresolved;
31
protected readonly ITypeResolveContext parentContext;
33
protected AbstractResolvedEntity(IUnresolvedEntity unresolved, ITypeResolveContext parentContext)
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);
44
public EntityType EntityType {
45
get { return unresolved.EntityType; }
48
public DomRegion Region {
49
get { return unresolved.Region; }
52
public DomRegion BodyRegion {
53
get { return unresolved.BodyRegion; }
56
public ITypeDefinition DeclaringTypeDefinition {
57
get { return parentContext.CurrentTypeDefinition; }
60
public virtual IType DeclaringType {
61
get { return parentContext.CurrentTypeDefinition ?? (IType)SpecialType.UnknownType; }
64
public IAssembly ParentAssembly {
65
get { return parentContext.CurrentAssembly; }
68
public IList<IAttribute> Attributes { get; protected set; }
70
public virtual DocumentationComment Documentation {
72
IDocumentationProvider provider = FindDocumentation(parentContext);
74
return provider.GetDocumentation(this);
80
internal static IDocumentationProvider FindDocumentation(ITypeResolveContext context)
82
IAssembly asm = context.CurrentAssembly;
84
return asm.UnresolvedAssembly as IDocumentationProvider;
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; } }
95
public ICompilation Compilation {
96
get { return parentContext.Compilation; }
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; } }
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; } }
112
public override string ToString()
114
return "[" + this.EntityType.ToString() + " " + this.ReflectionName + "]";