Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.ExtLibs/HeuristicLab.NRefactory/5.5.0/NRefactory-5.5.0/TypeSystem/ITypeDefinition.cs @ 15682

Last change on this file since 15682 was 11700, checked in by jkarder, 9 years ago

#2077: created branch and added first version

File size: 6.6 KB
Line 
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
19using System;
20using System.Collections.Generic;
21using System.Diagnostics.Contracts;
22
23namespace ICSharpCode.NRefactory.TypeSystem
24{
25  /// <summary>
26  /// Represents an unresolved class, enum, interface, struct, delegate or VB module.
27  /// For partial classes, an unresolved type definition represents only a single part.
28  /// </summary>
29  public interface IUnresolvedTypeDefinition : ITypeReference, IUnresolvedEntity
30  {
31    TypeKind Kind { get; }
32   
33    FullTypeName FullTypeName { get; }
34    IList<ITypeReference> BaseTypes { get; }
35    IList<IUnresolvedTypeParameter> TypeParameters { get; }
36   
37    IList<IUnresolvedTypeDefinition> NestedTypes { get; }
38    IList<IUnresolvedMember> Members { get; }
39   
40    IEnumerable<IUnresolvedMethod> Methods { get; }
41    IEnumerable<IUnresolvedProperty> Properties { get; }
42    IEnumerable<IUnresolvedField> Fields { get; }
43    IEnumerable<IUnresolvedEvent> Events { get; }
44   
45    /// <summary>
46    /// Gets whether the type definition contains extension methods.
47    /// Returns null when the type definition needs to be resolved in order to determine whether
48    /// methods are extension methods.
49    /// </summary>
50    bool? HasExtensionMethods { get; }
51   
52    /// <summary>
53    /// Gets whether the partial modifier is set on this part of the type definition.
54    /// </summary>
55    bool IsPartial { get; }
56   
57    /// <summary>
58    /// Gets whether this unresolved type definition causes the addition of a default constructor
59    /// if no other constructor is present.
60    /// </summary>
61    bool AddDefaultConstructorIfRequired { get; }
62   
63    /// <summary>
64    /// Looks up the resolved type definition from the <paramref name="context"/> corresponding to this unresolved
65    /// type definition.
66    /// </summary>
67    /// <param name="context">
68    /// Context for looking up the type. The context must specify the current assembly.
69    /// A <see cref="SimpleTypeResolveContext"/> that specifies the current assembly is sufficient.
70    /// </param>
71    /// <returns>
72    /// Returns the resolved type definition.
73    /// In case of an error, returns an <see cref="Implementation.UnknownType"/> instance.
74    /// Never returns null.
75    /// </returns>
76    new IType Resolve(ITypeResolveContext context);
77   
78    /// <summary>
79    /// This method is used to add language-specific elements like the C# UsingScope
80    /// to the type resolve context.
81    /// </summary>
82    /// <param name="parentContext">The parent context (e.g. the parent assembly),
83    /// including the parent type definition for inner classes.</param>
84    /// <returns>
85    /// The parent context, modified to include language-specific elements (e.g. using scope)
86    /// associated with this type definition.
87    /// </returns>
88    /// <remarks>
89    /// Use <c>unresolvedTypeDef.CreateResolveContext(parentContext).WithTypeDefinition(typeDef)</c> to
90    /// create the context for use within the type definition.
91    /// </remarks>
92    ITypeResolveContext CreateResolveContext(ITypeResolveContext parentContext);
93  }
94 
95  /// <summary>
96  /// Represents a class, enum, interface, struct, delegate or VB module.
97  /// For partial classes, this represents the whole class.
98  /// </summary>
99  public interface ITypeDefinition : IType, IEntity
100  {
101    /// <summary>
102    /// Returns all parts that contribute to this type definition.
103    /// Non-partial classes have a single part that represents the whole class.
104    /// </summary>
105    IList<IUnresolvedTypeDefinition> Parts { get; }
106   
107    IList<ITypeParameter> TypeParameters { get; }
108   
109    IList<ITypeDefinition> NestedTypes { get; }
110    IList<IMember> Members { get; }
111   
112    IEnumerable<IField> Fields { get; }
113    IEnumerable<IMethod> Methods { get; }
114    IEnumerable<IProperty> Properties { get; }
115    IEnumerable<IEvent> Events { get; }
116   
117    /// <summary>
118    /// Gets the known type code for this type definition.
119    /// </summary>
120    KnownTypeCode KnownTypeCode { get; }
121   
122    /// <summary>
123    /// For enums: returns the underlying primitive type.
124    /// For all other types: returns <see cref="SpecialType.UnknownType"/>.
125    /// </summary>
126    IType EnumUnderlyingType { get; }
127   
128    /// <summary>
129    /// Gets the full name of this type.
130    /// </summary>
131    FullTypeName FullTypeName { get; }
132   
133    /// <summary>
134    /// Gets/Sets the declaring type (incl. type arguments, if any).
135    /// This property never returns null -- for top-level entities, it returns SharedTypes.UnknownType.
136    /// </summary>
137    new IType DeclaringType { get; } // solves ambiguity between IType.DeclaringType and IEntity.DeclaringType
138   
139    /// <summary>
140    /// Gets whether this type contains extension methods.
141    /// </summary>
142    /// <remarks>This property is used to speed up the search for extension methods.</remarks>
143    bool HasExtensionMethods { get; }
144   
145    /// <summary>
146    /// Gets whether this type definition is made up of one or more partial classes.
147    /// </summary>
148    bool IsPartial { get; }
149   
150    /// <summary>
151    /// Determines how this type is implementing the specified interface member.
152    /// </summary>
153    /// <returns>
154    /// The method on this type that implements the interface member;
155    /// or null if the type does not implement the interface.
156    /// </returns>
157    IMember GetInterfaceImplementation(IMember interfaceMember);
158   
159    /// <summary>
160    /// Determines how this type is implementing the specified interface members.
161    /// </summary>
162    /// <returns>
163    /// For each interface member, this method returns the class member
164    /// that implements the interface member.
165    /// For interface members that are missing an implementation, the
166    /// result collection will contain a null element.
167    /// </returns>
168    IList<IMember> GetInterfaceImplementation(IList<IMember> interfaceMembers);
169  }
170}
Note: See TracBrowser for help on using the repository browser.