diff --git a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs index 27e4016cdb..cb6e1cb3b9 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs @@ -262,5 +262,26 @@ namespace ICSharpCode.NRefactory.TypeSystem return new ProjectedList(context, constantValues, (c, t) => t.Resolve(c)); } #endregion + + #region GetSubTypeDefinitions + public static IEnumerable GetSubTypeDefinitions (this IType baseType) + { + var def = baseType.GetDefinition (); + if (def == null) + return Enumerable.Empty (); + return def.GetSubTypeDefinitions (); + } + + /// + /// Gets all sub type definitions defined in a context. + /// + public static IEnumerable GetSubTypeDefinitions (this ITypeDefinition baseType) + { + foreach (var contextType in baseType.Compilation.GetAllTypeDefinitions ()) { + if (contextType.IsDerivedFrom (baseType)) + yield return contextType; + } + } + #endregion } }