public void RegisterCallbacks( AstManager astManager, ISolution solution, ProjectModelViewHost host, DteProtocolModel model ) { model.FileCodeModel_get_CodeElements.SetWithReadLock(projectItemModel => { var projectFile = host.GetItemById <IProjectFile>(projectItemModel.Id); var psiFile = projectFile ?.ToSourceFile() ?.GetPrimaryPsiFile(); if (psiFile == null) { return(new List <CodeElementModel>()); } var query = from child in psiFile.GetEnvDTEModelChildren() let childId = astManager.GetOrCreateId(child) let childTypeId = PsiElementRegistrar.GetTypeId(child) select new CodeElementModel(childTypeId, childId); return(query.ToList()); }); }
protected CodeElementModel CreateNamespaceModel([NotNull] ICSharpTypeDeclaration declaration) { var ns = declaration.OwnerNamespaceDeclaration; int id = AstManager.GetOrCreateId(ns); int typeId = PsiElementRegistrar.GetTypeId(ns); return(new CodeElementModel(typeId, id)); }
public static ITreeNode GetEnvDTEModelParent([NotNull] this ITreeNode node) { var current = node; do { if (PsiElementRegistrar.ShouldAddToModel(current)) { return(current); } current = current.Parent; }while (current != null); return(null); }
public static IEnumerable <ITreeNode> GetEnvDTEModelChildren([NotNull] this ITreeNode node) { foreach (var directChild in node.Children()) { if (PsiElementRegistrar.ShouldAddToModel(directChild)) { yield return(directChild); } else if (PsiElementRegistrar.ShouldVisitChildren(directChild)) { foreach (var modelChild in GetEnvDTEModelChildren(directChild)) { yield return(modelChild); } } } }