public RichText TryPresent(
            [NotNull] DeclaredElementInstance declaredElementInstance,
            [NotNull] PresenterOptions options,
            [NotNull] PsiLanguageType languageType,
            [NotNull] HighlighterIdProvider highlighterIdProvider)
        {
            PresentedInfo presentedInfo;

            return(TryPresent(declaredElementInstance, options, languageType, highlighterIdProvider, out presentedInfo));
        }
Beispiel #2
0
 public CSharpColorizer(
     [NotNull] RichText richText,
     [NotNull] TextStyleHighlighterManager textStyleHighlighterManager,
     [NotNull] CodeAnnotationsConfiguration codeAnnotationsConfiguration,
     [NotNull] HighlighterIdProvider highlighterIdProvider)
 {
     _richText = richText;
     _textStyleHighlighterManager  = textStyleHighlighterManager;
     _codeAnnotationsConfiguration = codeAnnotationsConfiguration;
     _highlighterIdProvider        = highlighterIdProvider;
 }
Beispiel #3
0
        public RichText?TryPresent(
            ITreeNode presentableNode,
            PresenterOptions options,
            PsiLanguageType languageType,
            HighlighterIdProvider highlighterIdProvider)
        {
            var richText = new RichText();

            if (TryCreateColorizer(richText, languageType, highlighterIdProvider) is { } colorizer)
            {
                colorizer.AppendPresentableNode(presentableNode, options);
                return(richText);
            }

            return(null);
        }
        public RichText TryPresent(
            [NotNull] ITreeNode presentableNode,
            [NotNull] PresenterOptions options,
            [NotNull] PsiLanguageType languageType,
            [NotNull] HighlighterIdProvider highlighterIdProvider)
        {
            var        richText  = new RichText();
            IColorizer colorizer = TryCreateColorizer(richText, languageType, highlighterIdProvider);

            if (colorizer == null)
            {
                return(null);
            }

            colorizer.AppendPresentableNode(presentableNode, options);
            return(richText);
        }
Beispiel #5
0
        /// <summary>
        /// Presents a given <see cref="DeclaredElementInstance"/> using a colorizer.
        /// </summary>
        /// <param name="declaredElementInstance">The declared element instance.</param>
        /// <param name="options">The options to use to present the element.</param>
        /// <param name="languageType">The type of language used to present the element.</param>
        /// <param name="highlighterIdProvider">An object determining which highlightings to use.</param>
        /// <param name="contextualNode">The tree node where the element is presented.</param>
        /// <param name="presentedInfo">When the method returns, a <see cref="PresentedInfo"/> containing range information about the presented element.</param>
        /// <returns>A <see cref="RichText"/> representing <paramref name="declaredElementInstance"/>.</returns>
        public RichText?TryPresent(
            DeclaredElementInstance declaredElementInstance,
            PresenterOptions options,
            PsiLanguageType languageType,
            HighlighterIdProvider highlighterIdProvider,
            ITreeNode?contextualNode,
            out PresentedInfo presentedInfo)
        {
            var richText = new RichText();

            if (TryCreateColorizer(richText, languageType, highlighterIdProvider) is { } colorizer)
            {
                presentedInfo = colorizer.AppendDeclaredElement(declaredElementInstance.Element, declaredElementInstance.Substitution, options, contextualNode);
                return(richText);
            }

            presentedInfo = new PresentedInfo();
            return(null);
        }
        public RichText TryPresent(
            [NotNull] DeclaredElementInstance declaredElementInstance,
            [NotNull] PresenterOptions options,
            [NotNull] PsiLanguageType languageType,
            [NotNull] HighlighterIdProvider highlighterIdProvider,
            [CanBeNull] ITreeNode contextualNode,
            [NotNull] out PresentedInfo presentedInfo)
        {
            var        richText  = new RichText();
            IColorizer colorizer = TryCreateColorizer(richText, languageType, highlighterIdProvider);

            if (colorizer == null)
            {
                presentedInfo = new PresentedInfo();
                return(null);
            }

            presentedInfo = colorizer.AppendDeclaredElement(declaredElementInstance.Element, declaredElementInstance.Substitution, options, contextualNode);
            return(richText);
        }
 private IColorizer TryCreateColorizer([NotNull] RichText richText, [NotNull] PsiLanguageType languageType, [NotNull] HighlighterIdProvider highlighterIdProvider)
 {
     // TODO: add a language service instead of checking the language
     if (languageType.Is <CSharpLanguage>())
     {
         return(new CSharpColorizer(richText, _textStyleHighlighterManager, _codeAnnotationsConfiguration, highlighterIdProvider));
     }
     return(null);
 }