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

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.CSharp/Resolver/ReducedExtensionMethod.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
ļ»æ//
 
2
// ReducedExtensionMethod.cs
 
3
//
 
4
// Author:
 
5
//       Mike KrĆ¼ger <mkrueger@xamarin.com>
 
6
//
 
7
// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
 
8
//
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
//
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
//
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
using System;
 
27
using ICSharpCode.NRefactory.TypeSystem;
 
28
using System.Collections.Generic;
 
29
using System.Linq;
 
30
using ICSharpCode.NRefactory.TypeSystem.Implementation;
 
31
 
 
32
namespace ICSharpCode.NRefactory.CSharp
 
33
{
 
34
        /// <summary>
 
35
        /// An invocated extension method hides the extension parameter in its parameter list.
 
36
        /// It's used to hide the internals of extension method invocation in certain situation to simulate the 
 
37
        /// syntactic way of writing extension methods on semantic level.
 
38
        /// </summary>
 
39
        public class ReducedExtensionMethod : IMethod
 
40
        {
 
41
                readonly IMethod baseMethod;
 
42
 
 
43
                public ReducedExtensionMethod(IMethod baseMethod)
 
44
                {
 
45
                        this.baseMethod = baseMethod;
 
46
                }
 
47
 
 
48
                public override bool Equals(object obj)
 
49
                {
 
50
                        var other = obj as ReducedExtensionMethod;
 
51
                        if (other == null)
 
52
                                return false;
 
53
                        return baseMethod.Equals(other.baseMethod);
 
54
                }
 
55
                
 
56
                public override int GetHashCode()
 
57
                {
 
58
                        unchecked {
 
59
                                return baseMethod.GetHashCode() + 1;
 
60
                        }
 
61
                }
 
62
 
 
63
                public override string ToString()
 
64
                {
 
65
                        return string.Format("[ReducedExtensionMethod: ReducedFrom={0}]", ReducedFrom);
 
66
                }
 
67
 
 
68
                #region IMember implementation
 
69
 
 
70
                [Serializable]
 
71
                public sealed class ReducedExtensionMethodMemberReference : IMemberReference
 
72
                {
 
73
                        readonly IMethod baseMethod;
 
74
 
 
75
                        public ReducedExtensionMethodMemberReference (IMethod baseMethod)
 
76
                        {
 
77
                                this.baseMethod = baseMethod;
 
78
                        }
 
79
 
 
80
                        #region IMemberReference implementation
 
81
                        public IMember Resolve(ITypeResolveContext context)
 
82
                        {
 
83
                                return new ReducedExtensionMethod ((IMethod)baseMethod.ToMemberReference ().Resolve (context));
 
84
                        }
 
85
 
 
86
                        public ITypeReference DeclaringTypeReference {
 
87
                                get {
 
88
                                        return baseMethod.ToMemberReference ().DeclaringTypeReference;
 
89
                                }
 
90
                        }
 
91
                        #endregion
 
92
                }
 
93
 
 
94
                public IMemberReference ToMemberReference()
 
95
                {
 
96
                        return new ReducedExtensionMethodMemberReference (baseMethod);
 
97
                }
 
98
 
 
99
                public IMember MemberDefinition {
 
100
                        get {
 
101
                                return baseMethod.MemberDefinition;
 
102
                        }
 
103
                }
 
104
 
 
105
                public IUnresolvedMember UnresolvedMember {
 
106
                        get {
 
107
                                return baseMethod.UnresolvedMember;
 
108
                        }
 
109
                }
 
110
 
 
111
                public IType ReturnType {
 
112
                        get {
 
113
                                return baseMethod.ReturnType;
 
114
                        }
 
115
                }
 
116
 
 
117
                public System.Collections.Generic.IList<IMember> ImplementedInterfaceMembers {
 
118
                        get {
 
119
                                return baseMethod.ImplementedInterfaceMembers;
 
120
                        }
 
121
                }
 
122
 
 
123
                public bool IsExplicitInterfaceImplementation {
 
124
                        get {
 
125
                                return baseMethod.IsExplicitInterfaceImplementation;
 
126
                        }
 
127
                }
 
128
 
 
129
                public bool IsVirtual {
 
130
                        get {
 
131
                                return baseMethod.IsVirtual;
 
132
                        }
 
133
                }
 
134
 
 
135
                public bool IsOverride {
 
136
                        get {
 
137
                                return baseMethod.IsOverride;
 
138
                        }
 
139
                }
 
140
 
 
141
                public bool IsOverridable {
 
142
                        get {
 
143
                                return baseMethod.IsOverridable;
 
144
                        }
 
145
                }
 
146
 
 
147
                public TypeParameterSubstitution Substitution {
 
148
                        get {
 
149
                                return baseMethod.Substitution;
 
150
                        }
 
151
                }
 
152
 
 
153
                public IMethod Specialize(TypeParameterSubstitution substitution)
 
154
                {
 
155
                        return new ReducedExtensionMethod((IMethod)baseMethod.Specialize(substitution));
 
156
                }
 
157
                
 
158
                IMember IMember.Specialize(TypeParameterSubstitution substitution)
 
159
                {
 
160
                        return Specialize(substitution);
 
161
                }
 
162
                
 
163
                public bool IsParameterized {
 
164
                        get  { return baseMethod.IsParameterized; }
 
165
                }
 
166
 
 
167
                #endregion
 
168
 
 
169
                #region IMethod implementation
 
170
 
 
171
                public System.Collections.Generic.IList<IUnresolvedMethod> Parts {
 
172
                        get {
 
173
                                return baseMethod.Parts;
 
174
                        }
 
175
                }
 
176
 
 
177
                public System.Collections.Generic.IList<IAttribute> ReturnTypeAttributes {
 
178
                        get {
 
179
                                return baseMethod.ReturnTypeAttributes;
 
180
                        }
 
181
                }
 
182
 
 
183
                public System.Collections.Generic.IList<ITypeParameter> TypeParameters {
 
184
                        get {
 
185
                                return baseMethod.TypeParameters;
 
186
                        }
 
187
                }
 
188
 
 
189
                public bool IsExtensionMethod {
 
190
                        get {
 
191
                                return true;
 
192
                        }
 
193
                }
 
194
 
 
195
                public bool IsConstructor {
 
196
                        get {
 
197
                                return baseMethod.IsConstructor;
 
198
                        }
 
199
                }
 
200
 
 
201
                public bool IsDestructor {
 
202
                        get {
 
203
                                return baseMethod.IsDestructor;
 
204
                        }
 
205
                }
 
206
 
 
207
                public bool IsOperator {
 
208
                        get {
 
209
                                return baseMethod.IsOperator;
 
210
                        }
 
211
                }
 
212
 
 
213
                public bool IsPartial {
 
214
                        get {
 
215
                                return baseMethod.IsPartial;
 
216
                        }
 
217
                }
 
218
 
 
219
                public bool IsAsync {
 
220
                        get {
 
221
                                return baseMethod.IsAsync;
 
222
                        }
 
223
                }
 
224
 
 
225
                public bool HasBody {
 
226
                        get {
 
227
                                return baseMethod.HasBody;
 
228
                        }
 
229
                }
 
230
 
 
231
                public bool IsAccessor {
 
232
                        get {
 
233
                                return baseMethod.IsAccessor;
 
234
                        }
 
235
                }
 
236
 
 
237
                public IMember AccessorOwner {
 
238
                        get {
 
239
                                return baseMethod.AccessorOwner;
 
240
                        }
 
241
                }
 
242
 
 
243
                public IMethod ReducedFrom { 
 
244
                        get {
 
245
                                return baseMethod;
 
246
                        } 
 
247
                }
 
248
 
 
249
                public IList<IType> TypeArguments {
 
250
                        get {
 
251
                                return baseMethod.TypeArguments;
 
252
                        }
 
253
                }
 
254
                #endregion
 
255
 
 
256
                #region IParameterizedMember implementation
 
257
                List<IParameter> parameters;
 
258
                public System.Collections.Generic.IList<IParameter> Parameters {
 
259
                        get {
 
260
                                if (parameters == null)
 
261
                                        parameters = new List<IParameter> (baseMethod.Parameters.Skip (1));
 
262
                                return parameters;
 
263
                        }
 
264
                }
 
265
 
 
266
                #endregion
 
267
 
 
268
                #region IEntity implementation
 
269
 
 
270
                public EntityType EntityType {
 
271
                        get {
 
272
                                return baseMethod.EntityType;
 
273
                        }
 
274
                }
 
275
 
 
276
                public DomRegion Region {
 
277
                        get {
 
278
                                return baseMethod.Region;
 
279
                        }
 
280
                }
 
281
 
 
282
                public DomRegion BodyRegion {
 
283
                        get {
 
284
                                return baseMethod.BodyRegion;
 
285
                        }
 
286
                }
 
287
 
 
288
                public ITypeDefinition DeclaringTypeDefinition {
 
289
                        get {
 
290
                                return baseMethod.DeclaringTypeDefinition;
 
291
                        }
 
292
                }
 
293
 
 
294
                public IType DeclaringType {
 
295
                        get {
 
296
                                return baseMethod.DeclaringType;
 
297
                        }
 
298
                }
 
299
 
 
300
                public IAssembly ParentAssembly {
 
301
                        get {
 
302
                                return baseMethod.ParentAssembly;
 
303
                        }
 
304
                }
 
305
 
 
306
                public System.Collections.Generic.IList<IAttribute> Attributes {
 
307
                        get {
 
308
                                return baseMethod.Attributes;
 
309
                        }
 
310
                }
 
311
 
 
312
                public ICSharpCode.NRefactory.Documentation.DocumentationComment Documentation {
 
313
                        get {
 
314
                                return baseMethod.Documentation;
 
315
                        }
 
316
                }
 
317
 
 
318
                public bool IsStatic {
 
319
                        get {
 
320
                                return false;
 
321
                        }
 
322
                }
 
323
 
 
324
                public bool IsAbstract {
 
325
                        get {
 
326
                                return baseMethod.IsAbstract;
 
327
                        }
 
328
                }
 
329
 
 
330
                public bool IsSealed {
 
331
                        get {
 
332
                                return baseMethod.IsSealed;
 
333
                        }
 
334
                }
 
335
 
 
336
                public bool IsShadowing {
 
337
                        get {
 
338
                                return baseMethod.IsShadowing;
 
339
                        }
 
340
                }
 
341
 
 
342
                public bool IsSynthetic {
 
343
                        get {
 
344
                                return baseMethod.IsSynthetic;
 
345
                        }
 
346
                }
 
347
 
 
348
                #endregion
 
349
 
 
350
                #region IHasAccessibility implementation
 
351
 
 
352
                public Accessibility Accessibility {
 
353
                        get {
 
354
                                return baseMethod.Accessibility;
 
355
                        }
 
356
                }
 
357
 
 
358
                public bool IsPrivate {
 
359
                        get {
 
360
                                return baseMethod.IsPrivate;
 
361
                        }
 
362
                }
 
363
 
 
364
                public bool IsPublic {
 
365
                        get {
 
366
                                return baseMethod.IsPublic;
 
367
                        }
 
368
                }
 
369
 
 
370
                public bool IsProtected {
 
371
                        get {
 
372
                                return baseMethod.IsProtected;
 
373
                        }
 
374
                }
 
375
 
 
376
                public bool IsInternal {
 
377
                        get {
 
378
                                return baseMethod.IsInternal;
 
379
                        }
 
380
                }
 
381
 
 
382
                public bool IsProtectedOrInternal {
 
383
                        get {
 
384
                                return baseMethod.IsProtectedOrInternal;
 
385
                        }
 
386
                }
 
387
 
 
388
                public bool IsProtectedAndInternal {
 
389
                        get {
 
390
                                return baseMethod.IsProtectedAndInternal;
 
391
                        }
 
392
                }
 
393
 
 
394
                #endregion
 
395
 
 
396
                #region INamedElement implementation
 
397
 
 
398
                public string FullName {
 
399
                        get {
 
400
                                return baseMethod.FullName;
 
401
                        }
 
402
                }
 
403
 
 
404
                public string Name {
 
405
                        get {
 
406
                                return baseMethod.Name;
 
407
                        }
 
408
                }
 
409
 
 
410
                public string ReflectionName {
 
411
                        get {
 
412
                                return baseMethod.ReflectionName;
 
413
                        }
 
414
                }
 
415
 
 
416
                public string Namespace {
 
417
                        get {
 
418
                                return baseMethod.Namespace;
 
419
                        }
 
420
                }
 
421
 
 
422
                #endregion
 
423
 
 
424
                #region ICompilationProvider implementation
 
425
 
 
426
                public ICompilation Compilation {
 
427
                        get {
 
428
                                return baseMethod.Compilation;
 
429
                        }
 
430
                }
 
431
 
 
432
                #endregion
 
433
        }
 
434
}
 
435