in EnvDTE.Host/Callback/Impl/AstImpl/CodeTypeCallbackProvider.cs [18:49]
public class CodeTypeCallbackProvider(AstManager astManager, ProjectModelViewHost host)
: CodeElementCallbackProviderBase(astManager, host)
{
protected override void DoRegisterCallbacks(ProjectModelViewHost host, DteProtocolModel model)
{
MapWithAstManager<ITypeDeclaration, ITypeElement, List<CodeElementModel>>(
model.CodeElement_get_Bases,
node => GetSuperTypes(node.DeclaredElement).AsList(),
element => GetSuperTypes(element).AsList(),
type => [ToModel(TypeFactory.CreateTypeByCLRName("System.Array", type.Module))]
);
MapWithAstManager<ICSharpTypeDeclaration, ITypeElement, CodeElementModel>(
model.CodeElement_get_Namespace,
CreateNamespaceModel,
element => ToModel(element.GetContainingNamespace()),
type => throw new NotImplementedException()
);
return;
IEnumerable<CodeElementModel> GetSuperTypes(ITypeElement declaredType)
{
using var _ = CompilationContextCookie.GetExplicitUniversalContextIfNotSet();
return from typeElement in declaredType.NotNull().GetSuperTypeElements()
where typeElement != null
let child = ToModel(typeElement)
where child != null
select child;
}
}
}