private IEnumerable <ITypeElement> GetTypesFromNamespace(ITextControl textControl, ISolution solution) { var symbolCache = solution.GetPsiServices().Symbols; var namespaceDeclaration = TextControlToPsi.GetElementFromCaretPosition <INamespaceDeclaration>(solution, textControl); if (namespaceDeclaration?.DeclaredElement != null) { var symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive: true); return(namespaceDeclaration.DeclaredElement.GetNestedTypeElements(symbolScope)); } return(EmptyList <ITypeElement> .InstanceList); }
public IEnumerable <ITypeElement> GetTypesFromCaretOrFile(ITextControl textControl, ISolution solution) { var classDeclaration = TextControlToPsi.GetElementFromCaretPosition <ITypeDeclaration>(solution, textControl); if (classDeclaration != null) { return new[] { classDeclaration.DeclaredElement } } ; var symbolCache = solution.GetPsiServices().Symbols; var psiSourceFile = textControl.Document.GetPsiSourceFile(solution); if (psiSourceFile != null) { return(symbolCache.GetTypesAndNamespacesInFile(psiSourceFile).OfType <ITypeElement>()); } return(EmptyList <ITypeElement> .InstanceList); }