Esempio n. 1
0
        public ITagger <T> CreateTagger <T>(ITextBuffer buffer)
            where T : ITag
        {
            ITagger <IOutliningRegionTag> CreateBufferTagger()
            {
                Language language = DocumentItem.GetLanguage(buffer);

                ThreadHelper.ThrowIfNotOnUIThread();
                ITagger <IOutliningRegionTag> tagger;

                if (MainPackage.RegionOptions.IsSupported(language) && ScanInfo.TryGet(language, out ScanInfo scanInfo))
                {
                    tagger = new OutliningTagger(buffer, scanInfo);
                }
                else
                {
                    tagger = NonOutliningTagger.Instance;
                }

                return(tagger);
            }

            ITagger <IOutliningRegionTag> result = buffer.Properties.GetOrCreateSingletonProperty(CreateBufferTagger);

            return(result as ITagger <T>);
        }
Esempio n. 2
0
        public ITagger <T> CreateTagger <T>(ITextBuffer buffer)
            where T : ITag
        {
            Func <OutliningTagger> createBufferTagger = () =>
            {
                Language language = DocumentItem.GetLanguage(buffer);
                ScanInfo scanInfo;
                ScanInfo.TryGet(language, out scanInfo);
                return(new OutliningTagger(buffer, scanInfo));
            };

            OutliningTagger result = buffer.Properties.GetOrCreateSingletonProperty <OutliningTagger>(createBufferTagger);

            return(result as ITagger <T>);
        }