protected virtual string GetTitle(IDeclaredElement declaredElement) { string kind = DeclaredElementPresenter.Format(PresentationUtil.GetPresentationLanguage(declaredElement), DeclaredElementPresenter.KIND_PRESENTER, declaredElement); string name = DeclaredElementPresenter.Format(PresentationUtil.GetPresentationLanguage(declaredElement), DeclaredElementPresenter.NAME_PRESENTER, declaredElement); return(string.Format("Declarations of {1} '{0}'", name, kind)); }
private string FormatTypeElement(string format) { // uses DeclaredElementPresenter to format type element, which is standard way to present code elements var style = new DeclaredElementPresenterStyle(NameStyle.SHORT) { ShowTypeParameters = TypeParameterStyle.FULL }; string typeElementText = DeclaredElementPresenter.Format(PresentationUtil.GetPresentationLanguage(TypeElement), style, TypeElement); return(string.Format(format, typeElementText)); }
private static IEnumerable GetChildren(ITypeElement typeElement, bool instanceVisible) { // Obtain language service for the type PsiLanguageType language = PresentationUtil.GetPresentationLanguage(typeElement); if (language.IsNullOrUnknown()) { return(Enumerable.Empty <DeclaredElementEnvoy <ITypeMember> >()); } LanguageService languageService = language.LanguageService(); if (languageService == null) { return(Enumerable.Empty <DeclaredElementEnvoy <ITypeMember> >()); } // Get symbol table for the typeElement and filter it with OverriddenFilter // This filter removes all but leaf members for override chains ISymbolTable symbolTable = TypeFactory.CreateType(typeElement).GetSymbolTable(typeElement.Module); symbolTable = symbolTable.Filter(OverriddenFilter.INSTANCE); // Obtain ITypeElement for System.Object // We don't want ToString(), GetHashCode(), GetType() and Equals() to pollute tree view ITypeElement objectType = typeElement.Module.GetPredefinedType(typeElement.ResolveContext).Object.GetTypeElement(); var children = new List <DeclaredElementEnvoy <ITypeMember> >(); foreach (string name in symbolTable.Names()) { foreach (ISymbolInfo info in symbolTable.GetSymbolInfos(name)) { // Select all ITypeMembers from symbol table var member = info.GetDeclaredElement() as ITypeMember; if (member == null) { continue; } // Checks that member is visible in language. For example, get_Property() member is not visible in C# if (!languageService.IsTypeMemberVisible(member)) { continue; } // Do not show members of System.Object // This doesn't hide respective overrides, though if (Equals(member.GetContainingType(), objectType)) { continue; } // Checks that member is not "synthetic". Synthetic members are generated by ReSharper to support // generative languages, like ASP.NET if (member.IsSynthetic()) { continue; } // Checks if member should be displayed according to its accessibility AccessibilityDomain.AccessibilityDomainType access = member.AccessibilityDomain.DomainType; if (access == AccessibilityDomain.AccessibilityDomainType.PRIVATE) { continue; } // If we want only instance members, filter further if (instanceVisible) { // Don't show nested types if (member is ITypeElement) { continue; } // Don't show constructors if (member is IConstructor) { continue; } // hide static, protected and "protected internal" members if (member.IsStatic) { continue; } if (access == AccessibilityDomain.AccessibilityDomainType.PROTECTED) { continue; } if (access == AccessibilityDomain.AccessibilityDomainType.PROTECTED_AND_INTERNAL) { continue; } } // It passed all filters! Create an envoy and add to collection children.Add(new DeclaredElementEnvoy <ITypeMember>(member)); } } return(children); }