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 | |
---|
21 | namespace ICSharpCode.NRefactory.TypeSystem |
---|
22 | { |
---|
23 | /// <summary> |
---|
24 | /// Represents a reference to a type. |
---|
25 | /// Must be resolved before it can be used as type. |
---|
26 | /// </summary> |
---|
27 | public interface ITypeReference |
---|
28 | { |
---|
29 | // Keep this interface simple: I decided against having GetMethods/GetEvents etc. here, |
---|
30 | // so that the Resolve step is never hidden from the consumer. |
---|
31 | |
---|
32 | // I decided against implementing IFreezable here: IUnresolvedTypeDefinition can be used as ITypeReference, |
---|
33 | // but when freezing the reference, one wouldn't expect the definition to freeze. |
---|
34 | |
---|
35 | /// <summary> |
---|
36 | /// Resolves this type reference. |
---|
37 | /// </summary> |
---|
38 | /// <param name="context"> |
---|
39 | /// Context to use for resolving this type reference. |
---|
40 | /// Which kind of context is required depends on the which kind of type reference this is; |
---|
41 | /// please consult the documentation of the method that was used to create this type reference, |
---|
42 | /// or that of the class implementing this method. |
---|
43 | /// </param> |
---|
44 | /// <returns> |
---|
45 | /// Returns the resolved type. |
---|
46 | /// In case of an error, returns an unknown type (<see cref="TypeKind.Unknown"/>). |
---|
47 | /// Never returns null. |
---|
48 | /// </returns> |
---|
49 | IType Resolve(ITypeResolveContext context); |
---|
50 | } |
---|
51 | |
---|
52 | public interface ITypeResolveContext : ICompilationProvider |
---|
53 | { |
---|
54 | /// <summary> |
---|
55 | /// Gets the current assembly. |
---|
56 | /// This property may return null if this context does not specify any assembly. |
---|
57 | /// </summary> |
---|
58 | IAssembly CurrentAssembly { get; } |
---|
59 | |
---|
60 | /// <summary> |
---|
61 | /// Gets the current type definition. |
---|
62 | /// </summary> |
---|
63 | ITypeDefinition CurrentTypeDefinition { get ;} |
---|
64 | |
---|
65 | /// <summary> |
---|
66 | /// Gets the current member. |
---|
67 | /// </summary> |
---|
68 | IMember CurrentMember { get; } |
---|
69 | |
---|
70 | ITypeResolveContext WithCurrentTypeDefinition(ITypeDefinition typeDefinition); |
---|
71 | ITypeResolveContext WithCurrentMember(IMember member); |
---|
72 | } |
---|
73 | } |
---|