~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/AbstractMember.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
 
 
7
namespace ICSharpCode.SharpDevelop.Dom
 
8
{
 
9
        public abstract class AbstractMember : AbstractEntity, IMember
 
10
        {
 
11
                IReturnType returnType;
 
12
                DomRegion region;
 
13
                IList<ExplicitInterfaceImplementation> interfaceImplementations;
 
14
                IReturnType declaringTypeReference;
 
15
                
 
16
                protected override void FreezeInternal()
 
17
                {
 
18
                        interfaceImplementations = FreezeList(interfaceImplementations);
 
19
                        base.FreezeInternal();
 
20
                }
 
21
                
 
22
                public sealed override ICompilationUnit CompilationUnit {
 
23
                        [System.Diagnostics.DebuggerStepThrough]
 
24
                        get {
 
25
                                return this.DeclaringType.CompilationUnit;
 
26
                        }
 
27
                }
 
28
                
 
29
                public virtual DomRegion Region {
 
30
                        get {
 
31
                                return region;
 
32
                        }
 
33
                        set {
 
34
                                CheckBeforeMutation();
 
35
                                region = value;
 
36
                        }
 
37
                }
 
38
                
 
39
                public virtual IReturnType ReturnType {
 
40
                        get {
 
41
                                return returnType;
 
42
                        }
 
43
                        set {
 
44
                                CheckBeforeMutation();
 
45
                                returnType = value;
 
46
                        }
 
47
                }
 
48
                
 
49
                /// <summary>
 
50
                /// Gets the declaring type reference (declaring type incl. type arguments)
 
51
                /// </summary>
 
52
                public virtual IReturnType DeclaringTypeReference {
 
53
                        get {
 
54
                                return declaringTypeReference ?? this.DeclaringType.DefaultReturnType;
 
55
                        }
 
56
                        set {
 
57
                                CheckBeforeMutation();
 
58
                                declaringTypeReference = value;
 
59
                        }
 
60
                }
 
61
                
 
62
                public IList<ExplicitInterfaceImplementation> InterfaceImplementations {
 
63
                        get {
 
64
                                return interfaceImplementations ?? (interfaceImplementations = new List<ExplicitInterfaceImplementation>());
 
65
                        }
 
66
                }
 
67
                
 
68
                public AbstractMember(IClass declaringType, string name) : base(declaringType, name)
 
69
                {
 
70
                        // members must have a parent class
 
71
                        if (declaringType == null)
 
72
                                throw new ArgumentNullException("declaringType");
 
73
                }
 
74
                
 
75
                public abstract IMember Clone();
 
76
                
 
77
                object ICloneable.Clone()
 
78
                {
 
79
                        return this.Clone();
 
80
                }
 
81
                
 
82
                public override string Documentation {
 
83
                        get { 
 
84
                                if (genericMember != null)
 
85
                                        return genericMember.Documentation;
 
86
                                return base.Documentation; 
 
87
                        }
 
88
                        set { 
 
89
                                base.Documentation = value; 
 
90
                        }
 
91
                }
 
92
                
 
93
                IMember genericMember;
 
94
                
 
95
                public virtual IMember GenericMember {
 
96
                        get { return genericMember; }
 
97
                }
 
98
                
 
99
                public virtual IMember CreateSpecializedMember()
 
100
                {
 
101
                        AbstractMember copy = Clone() as AbstractMember;
 
102
                        if (copy == null)
 
103
                                throw new Exception("Clone() must return an AbstractMember instance, or CreateSpecializedMember must also be overridden.");
 
104
                        copy.genericMember = this;
 
105
                        return copy;
 
106
                }
 
107
        }
 
108
}