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.TypeSystem; |
---|
22 | |
---|
23 | namespace ICSharpCode.NRefactory.TypeSystem |
---|
24 | { |
---|
25 | /// <summary> |
---|
26 | /// Method/field/property/event. |
---|
27 | /// </summary> |
---|
28 | public interface IUnresolvedMember : IUnresolvedEntity, IMemberReference |
---|
29 | { |
---|
30 | /// <summary> |
---|
31 | /// Gets the return type of this member. |
---|
32 | /// This property never returns null. |
---|
33 | /// </summary> |
---|
34 | ITypeReference ReturnType { get; } |
---|
35 | |
---|
36 | /// <summary> |
---|
37 | /// Gets whether this member is explicitly implementing an interface. |
---|
38 | /// If this property is true, the member can only be called through the interfaces it implements. |
---|
39 | /// </summary> |
---|
40 | bool IsExplicitInterfaceImplementation { get; } |
---|
41 | |
---|
42 | /// <summary> |
---|
43 | /// Gets the interfaces that are explicitly implemented by this member. |
---|
44 | /// </summary> |
---|
45 | IList<IMemberReference> ExplicitInterfaceImplementations { get; } |
---|
46 | |
---|
47 | /// <summary> |
---|
48 | /// Gets if the member is virtual. Is true only if the "virtual" modifier was used, but non-virtual |
---|
49 | /// members can be overridden, too; if they are abstract or overriding a method. |
---|
50 | /// </summary> |
---|
51 | bool IsVirtual { get; } |
---|
52 | |
---|
53 | /// <summary> |
---|
54 | /// Gets whether this member is overriding another member. |
---|
55 | /// </summary> |
---|
56 | bool IsOverride { get; } |
---|
57 | |
---|
58 | /// <summary> |
---|
59 | /// Gets if the member can be overridden. Returns true when the member is "abstract", "virtual" or "override" but not "sealed". |
---|
60 | /// </summary> |
---|
61 | bool IsOverridable { get; } |
---|
62 | |
---|
63 | /// <summary> |
---|
64 | /// Resolves the member. |
---|
65 | /// </summary> |
---|
66 | /// <param name="context"> |
---|
67 | /// Context for looking up the member. The context must specify the current assembly. |
---|
68 | /// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient. |
---|
69 | /// </param> |
---|
70 | /// <returns> |
---|
71 | /// Returns the resolved member, or <c>null</c> if the member could not be found. |
---|
72 | /// </returns> |
---|
73 | new IMember Resolve(ITypeResolveContext context); |
---|
74 | |
---|
75 | /// <summary> |
---|
76 | /// Creates the resolved member. |
---|
77 | /// </summary> |
---|
78 | /// <param name="context"> |
---|
79 | /// The language-specific context that includes the parent type definition. |
---|
80 | /// <see cref="IUnresolvedTypeDefinition.CreateResolveContext"/> |
---|
81 | /// </param> |
---|
82 | IMember CreateResolved(ITypeResolveContext context); |
---|
83 | } |
---|
84 | |
---|
85 | public interface IMemberReference : ISymbolReference |
---|
86 | { |
---|
87 | /// <summary> |
---|
88 | /// Gets the declaring type reference for the member. |
---|
89 | /// </summary> |
---|
90 | ITypeReference DeclaringTypeReference { get; } |
---|
91 | |
---|
92 | /// <summary> |
---|
93 | /// Resolves the member. |
---|
94 | /// </summary> |
---|
95 | /// <param name="context"> |
---|
96 | /// Context to use for resolving this member reference. |
---|
97 | /// Which kind of context is required depends on the which kind of member reference this is; |
---|
98 | /// please consult the documentation of the method that was used to create this member reference, |
---|
99 | /// or that of the class implementing this method. |
---|
100 | /// </param> |
---|
101 | /// <returns> |
---|
102 | /// Returns the resolved member, or <c>null</c> if the member could not be found. |
---|
103 | /// </returns> |
---|
104 | new IMember Resolve(ITypeResolveContext context); |
---|
105 | } |
---|
106 | |
---|
107 | /// <summary> |
---|
108 | /// Method/field/property/event. |
---|
109 | /// </summary> |
---|
110 | public interface IMember : IEntity |
---|
111 | { |
---|
112 | /// <summary> |
---|
113 | /// Gets the original member definition for this member. |
---|
114 | /// Returns <c>this</c> if this is not a specialized member. |
---|
115 | /// Specialized members are the result of overload resolution with type substitution. |
---|
116 | /// </summary> |
---|
117 | IMember MemberDefinition { get; } |
---|
118 | |
---|
119 | /// <summary> |
---|
120 | /// Gets the unresolved member instance from which this member was created. |
---|
121 | /// This property may return <c>null</c> for special members that do not have a corresponding unresolved member instance. |
---|
122 | /// </summary> |
---|
123 | /// <remarks> |
---|
124 | /// For specialized members, this property returns the unresolved member for the original member definition. |
---|
125 | /// For partial methods, this property returns the implementing partial method declaration, if one exists, and the |
---|
126 | /// defining partial method declaration otherwise. |
---|
127 | /// For the members used to represent the built-in C# operators like "operator +(int, int);", this property returns <c>null</c>. |
---|
128 | /// </remarks> |
---|
129 | IUnresolvedMember UnresolvedMember { get; } |
---|
130 | |
---|
131 | /// <summary> |
---|
132 | /// Gets the return type of this member. |
---|
133 | /// This property never returns <c>null</c>. |
---|
134 | /// </summary> |
---|
135 | IType ReturnType { get; } |
---|
136 | |
---|
137 | /// <summary> |
---|
138 | /// Gets the interface members implemented by this member (both implicitly and explicitly). |
---|
139 | /// </summary> |
---|
140 | IList<IMember> ImplementedInterfaceMembers { get; } |
---|
141 | |
---|
142 | /// <summary> |
---|
143 | /// Gets whether this member is explicitly implementing an interface. |
---|
144 | /// </summary> |
---|
145 | bool IsExplicitInterfaceImplementation { get; } |
---|
146 | |
---|
147 | /// <summary> |
---|
148 | /// Gets if the member is virtual. Is true only if the "virtual" modifier was used, but non-virtual |
---|
149 | /// members can be overridden, too; if they are abstract or overriding a method. |
---|
150 | /// </summary> |
---|
151 | bool IsVirtual { get; } |
---|
152 | |
---|
153 | /// <summary> |
---|
154 | /// Gets whether this member is overriding another member. |
---|
155 | /// </summary> |
---|
156 | bool IsOverride { get; } |
---|
157 | |
---|
158 | /// <summary> |
---|
159 | /// Gets if the member can be overridden. Returns true when the member is "abstract", "virtual" or "override" but not "sealed". |
---|
160 | /// </summary> |
---|
161 | bool IsOverridable { get; } |
---|
162 | |
---|
163 | /// <summary> |
---|
164 | /// Creates a member reference that can be used to rediscover this member in another compilation. |
---|
165 | /// </summary> |
---|
166 | /// <remarks> |
---|
167 | /// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context. |
---|
168 | /// Otherwise, the main resolve context of a compilation is sufficient. |
---|
169 | /// </remarks> |
---|
170 | [Obsolete("Use the ToReference method instead.")] |
---|
171 | IMemberReference ToMemberReference(); |
---|
172 | |
---|
173 | /// <summary> |
---|
174 | /// Creates a member reference that can be used to rediscover this member in another compilation. |
---|
175 | /// </summary> |
---|
176 | /// <remarks> |
---|
177 | /// If this member is specialized using open generic types, the resulting member reference will need to be looked up in an appropriate generic context. |
---|
178 | /// Otherwise, the main resolve context of a compilation is sufficient. |
---|
179 | /// </remarks> |
---|
180 | new IMemberReference ToReference(); |
---|
181 | |
---|
182 | /// <summary> |
---|
183 | /// Gets the substitution belonging to this specialized member. |
---|
184 | /// Returns TypeParameterSubstitution.Identity for not specialized members. |
---|
185 | /// </summary> |
---|
186 | TypeParameterSubstitution Substitution { |
---|
187 | get; |
---|
188 | } |
---|
189 | |
---|
190 | /// <summary> |
---|
191 | /// Specializes this member with the given substitution. |
---|
192 | /// If this member is already specialized, the new substitution is composed with the existing substition. |
---|
193 | /// </summary> |
---|
194 | IMember Specialize(TypeParameterSubstitution substitution); |
---|
195 | } |
---|
196 | } |
---|