Esempio n. 1
0
        private IdentifierTooltipContent TryPresentColorized([NotNull] DeclaredElementInfo info, [NotNull] IContextBoundSettingsStore settings)
        {
            PsiLanguageType  languageType = info.File.Language;
            IDeclaredElement element      = info.DeclaredElement;
            IPsiModule       psiModule    = info.File.GetPsiModule();

            RichText identifierText = _colorizerPresenter.TryPresent(
                new DeclaredElementInstance(element, info.Substitution),
                PresenterOptions.ForToolTip(settings),
                languageType,
                settings.GetValue(HighlightingSettingsAccessor.IdentifierHighlightingEnabled));

            if (identifierText == null || identifierText.IsEmpty)
            {
                return(null);
            }

            var identifierContent = new IdentifierTooltipContent(identifierText, info.SourceRange)
            {
                Description = TryGetDescription(element, psiModule, languageType, DeclaredElementDescriptionStyle.NO_OBSOLETE_SUMMARY_STYLE),
            };

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowIcon))
            {
                identifierContent.Icon = TryGetIcon(element);
            }

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowObsolete))
            {
                identifierContent.Obsolete = TryRemoveObsoletePrefix(TryGetDescription(element, psiModule, languageType, DeclaredElementDescriptionStyle.OBSOLETE_DESCRIPTION));
            }

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowExceptions))
            {
                identifierContent.Exceptions.AddRange(GetExceptions(element, languageType, psiModule, info.File.GetResolveContext()));
            }

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowOverloadCount))
            {
                identifierContent.OverloadCount = TryGetOverloadCountCount(element as IFunction, info.Reference, languageType);
            }

            return(identifierContent);
        }
Esempio n. 2
0
        private IdentifierTooltipContent TryPresentColorized([NotNull] DeclaredElementInstance elementInstance, [NotNull] PsiLanguageType languageType,
                                                             [NotNull] IPsiSourceFile psiSourceFile, [NotNull] IContextBoundSettingsStore settings, [CanBeNull] string highlighterAttributeId)
        {
            RichText identifierText = _colorizerPresenter.TryPresent(elementInstance, PresenterOptions.ForToolTip(settings), languageType, highlighterAttributeId);

            if (identifierText == null || identifierText.IsEmpty)
            {
                return(null);
            }

            IDeclaredElement element   = elementInstance.Element;
            IPsiModule       psiModule = psiSourceFile.PsiModule;

            var identifierContent = new IdentifierTooltipContent {
                Text        = identifierText,
                Description = TryGetDescription(element, psiModule, languageType, DeclaredElementDescriptionStyle.NO_OBSOLETE_SUMMARY_STYLE),
            };

            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowIcon))
            {
                identifierContent.Icon = TryGetIcon(element);
            }
            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowObsolete))
            {
                identifierContent.Obsolete = TryRemoveObsoletePrefix(TryGetDescription(element, psiModule, languageType, DeclaredElementDescriptionStyle.OBSOLETE_DESCRIPTION));
            }
            if (settings.GetValue((IdentifierTooltipSettings s) => s.ShowExceptions))
            {
                identifierContent.Exceptions.AddRange(GetExceptions(element, languageType, psiModule, psiSourceFile.ResolveContext));
            }
            return(identifierContent);
        }