public ClassifiableDeferredContent(
     IList<TaggedText> content,
     ClassificationTypeMap typeMap)
 {
     this.ClassifiableContent = content;
     _typeMap = typeMap;
 }
            public TagComputer(
                ITextBuffer subjectBuffer,
                IForegroundNotificationService notificationService,
                IAsynchronousOperationListener asyncListener,
                ClassificationTypeMap typeMap,
                SyntacticClassificationTaggerProvider taggerProvider,
                IViewSupportsClassificationService viewSupportsClassificationServiceOpt,
                ITextBufferAssociatedViewService associatedViewService,
                IEditorClassificationService editorClassificationService,
                string languageName)
            {
                _subjectBuffer = subjectBuffer;
                _notificationService = notificationService;
                _listener = asyncListener;
                _typeMap = typeMap;
                _taggerProvider = taggerProvider;
                _viewSupportsClassificationServiceOpt = viewSupportsClassificationServiceOpt;
                _associatedViewService = associatedViewService;
                _editorClassificationService = editorClassificationService;
                _languageName = languageName;

                _workQueue = new AsynchronousSerialWorkQueue(asyncListener);
                _reportChangeCancellationSource = new CancellationTokenSource();

                _lastLineCache = new LastLineCache();

                _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
                _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;

                ConnectToWorkspace(_workspaceRegistration.Workspace);
            }
            public TagComputer(
                ITextBuffer subjectBuffer,
                IForegroundNotificationService notificationService,
                IAsynchronousOperationListener asyncListener,
                ClassificationTypeMap typeMap,
                SyntacticClassificationTaggerProvider taggerProvider)
            {
                _subjectBuffer = subjectBuffer;
                _notificationService = notificationService;
                _listener = asyncListener;
                _typeMap = typeMap;
                _taggerProvider = taggerProvider;

                _workQueue = new AsynchronousSerialWorkQueue(asyncListener);
                _reportChangeCancellationSource = new CancellationTokenSource();

                _lastLineCache = new LastLineCache();

                _workspaceRegistration = Workspace.GetWorkspaceRegistration(subjectBuffer.AsTextContainer());
                _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged;

                if (_workspaceRegistration.Workspace != null)
                {
                    ConnectToWorkspace(_workspaceRegistration.Workspace);
                }
            }
 public static List<ITagSpan<IClassificationTag>> ConvertAndReturnList(ClassificationTypeMap typeMap, ITextSnapshot snapshot, List<ClassifiedSpan> classifiedSpans)
 {
     var result = new List<ITagSpan<IClassificationTag>>();
     Convert(typeMap, snapshot, classifiedSpans, result.Add);
     ReturnClassifiedSpanList(classifiedSpans);
     return result;
 }
 public DocumentationCommentDeferredContent(
     string documentationComment,
     ClassificationTypeMap typeMap)
 {
     _documentationComment = documentationComment;
     _typeMap = typeMap;
 }
        public StreamingFindReferencesPresenter(
            Shell.SVsServiceProvider serviceProvider,
            ITextBufferFactoryService textBufferFactoryService,
            IProjectionBufferFactoryService projectionBufferFactoryService,
            IEditorOptionsFactoryService editorOptionsFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            IContentTypeRegistryService contentTypeRegistryService,
            ClassificationTypeMap typeMap,
            IEditorFormatMapService formatMapService,
            [ImportMany] IEnumerable<Lazy<IAsynchronousOperationListener, FeatureMetadata>> asyncListeners)
        {
            _serviceProvider = serviceProvider;
            _textBufferFactoryService = textBufferFactoryService;
            _projectionBufferFactoryService = projectionBufferFactoryService;
            _editorOptionsFactoryService = editorOptionsFactoryService;
            _contentTypeRegistryService = contentTypeRegistryService;

            _textEditorFactoryService = textEditorFactoryService;
            _typeMap = typeMap;
            _formatMapService = formatMapService;

            _asyncListener = new AggregateAsynchronousOperationListener(
                asyncListeners, FeatureAttribute.ReferenceHighlighting);

            _vsFindAllReferencesService = (IFindAllReferencesService)_serviceProvider.GetService(typeof(SVsFindAllReferences));
        }
        internal ChangeSignatureDialogViewModel(INotificationService notificationService, ParameterConfiguration parameters, ISymbol symbol, ClassificationTypeMap classificationTypeMap)
        {
            _originalParameterConfiguration = parameters;
            _notificationService = notificationService;
            _classificationTypeMap = classificationTypeMap;

            int startingSelectedIndex = 0;

            if (parameters.ThisParameter != null)
            {
                startingSelectedIndex++;

                _thisParameter = new ParameterViewModel(this, parameters.ThisParameter);
                _disabledParameters.Add(parameters.ThisParameter);
            }

            if (parameters.ParamsParameter != null)
            {
                _paramsParameter = new ParameterViewModel(this, parameters.ParamsParameter);
            }

            _symbol = symbol;
            _declarationParts = symbol.ToDisplayParts(s_symbolDeclarationDisplayFormat);

            _parameterGroup1 = parameters.ParametersWithoutDefaultValues.Select(p => new ParameterViewModel(this, p)).ToList();
            _parameterGroup2 = parameters.RemainingEditableParameters.Select(p => new ParameterViewModel(this, p)).ToList();
            this.SelectedIndex = startingSelectedIndex;
        }
 public static void Convert(ClassificationTypeMap typeMap, ITextSnapshot snapshot, List<ClassifiedSpan> list, Action<ITagSpan<IClassificationTag>> addTag)
 {
     foreach (var classifiedSpan in list)
     {
         addTag(new TagSpan<IClassificationTag>(
             classifiedSpan.TextSpan.ToSnapshotSpan(snapshot),
             new ClassificationTag(typeMap.GetClassificationType(classifiedSpan.ClassificationType))));
     }
 }
        private static async Task<bool> TryClassifyContainingMemberSpan(TaggerContext<IClassificationTag> context, DocumentSnapshotSpan spanToTag,
            IEditorClassificationService classificationService, ClassificationTypeMap typeMap)
        {
            var range = context.TextChangeRange;
            if (range == null)
            {
                // There was no text change range, we can't just reclassify a member body.
                return false;
            }

            // there was top level edit, check whether that edit updated top level element
            var document = spanToTag.Document;
            var cancellationToken = context.CancellationToken;

            var lastSemanticVersion = (VersionStamp?)context.State;
            if (lastSemanticVersion != null)
            {
                var currentSemanticVersion = await document.Project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);
                if (lastSemanticVersion.Value != currentSemanticVersion)
                {
                    // A top level change was made.  We can't perform this optimization.
                    return false;
                }
            }

            var service = document.Project.LanguageServices.GetService<ISyntaxFactsService>();

            // perf optimization. Check whether all edits since the last update has happened within
            // a member. If it did, it will find the member that contains the changes and only refresh
            // that member.  If possible, try to get a speculative binder to make things even cheaper.

            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var changedSpan = new TextSpan(range.Value.Span.Start, range.Value.NewLength);
            var member = service.GetContainingMemberDeclaration(root, changedSpan.Start);
            if (member == null || !member.FullSpan.Contains(changedSpan))
            {
                // The edit was not fully contained in a member.  Reclassify everything.
                return false;
            }

            var subTextSpan = service.GetMemberBodySpanForSpeculativeBinding(member);
            if (subTextSpan.IsEmpty)
            {
                // Wasn't a member we could reclassify independently.
                return false;
            }

            var subSpan = subTextSpan.Contains(changedSpan) ? subTextSpan.ToSpan() : member.FullSpan.ToSpan();

            var subSpanToTag = new DocumentSnapshotSpan(spanToTag.Document,
                new SnapshotSpan(spanToTag.SnapshotSpan.Snapshot, subSpan));

            // re-classify only the member we're inside.
            await ClassifySpansAsync(context, subSpanToTag, classificationService, typeMap).ConfigureAwait(false);
            return true;
        }
 public AbstractSemanticQuickInfoProvider(
     IProjectionBufferFactoryService projectionBufferFactoryService,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     ITextEditorFactoryService textEditorFactoryService,
     IGlyphService glyphService,
     ClassificationTypeMap typeMap)
     : base(projectionBufferFactoryService, editorOptionsFactoryService,
            textEditorFactoryService, glyphService, typeMap)
 {
 }
        public static TextBlock ToTextBlock(
            this IEnumerable<TaggedText> parts,
            ClassificationTypeMap typeMap,
            string classificationFormatMap = null)
        {
            classificationFormatMap = classificationFormatMap ?? "tooltip";

            var inlines = parts.ToInlines(typeMap, classificationFormatMap);
            return inlines.ToTextBlock(typeMap, classificationFormatMap);
        }
 public static IList<Inline> ToInlines(
     this IEnumerable<TaggedText> parts,
     ClassificationTypeMap typeMap,
     string classificationFormatMap = null)
 {
     var classifiedTexts = parts.Select(p =>
         new ClassifiedText(
             p.Tag.ToClassificationTypeName(),
             p.ToVisibleDisplayString(includeLeftToRightMarker: true)));
     return classifiedTexts.ToInlines(typeMap, classificationFormatMap);
 }
 public ClassifiableDeferredContent(
     IList<SymbolDisplayPart> content,
     ITextBufferFactoryService textBufferFactoryService,
     IContentTypeRegistryService contentTypeRegistryService,
     ClassificationTypeMap typeMap)
 {
     this.ClassifiableContent = content;
     _textBufferFactoryService = textBufferFactoryService;
     _contentTypeRegistryService = contentTypeRegistryService;
     _typeMap = typeMap;
 }
        public static Run ToRun(this SymbolDisplayPart part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.ToVisibleDisplayString(includeLeftToRightMarker: true);

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(part.Kind.ToClassificationTypeName()));
            run.SetTextProperties(format);

            return run;
        }
        public static Run ToRun(this ClassifiedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.Text;

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(
                part.ClassificationType));
            run.SetTextProperties(format);

            return run;
        }
 public SemanticQuickInfoProvider(
     ITextBufferFactoryService textBufferFactoryService,
     IContentTypeRegistryService contentTypeRegistryService,
     IProjectionBufferFactoryService projectionBufferFactoryService,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     ITextEditorFactoryService textEditorFactoryService,
     IGlyphService glyphService,
     ClassificationTypeMap typeMap)
     : base(textBufferFactoryService, contentTypeRegistryService, projectionBufferFactoryService,
            editorOptionsFactoryService, textEditorFactoryService, glyphService, typeMap)
 {
 }
        public static List<ITagSpan<IClassificationTag>> Convert(ClassificationTypeMap typeMap, ITextSnapshot snapshot, List<ClassifiedSpan> list)
        {
            var result = new List<ITagSpan<IClassificationTag>>();

            foreach (var classifiedSpan in list)
            {
                result.Add(new TagSpan<IClassificationTag>(
                    classifiedSpan.TextSpan.ToSnapshotSpan(snapshot),
                    new ClassificationTag(typeMap.GetClassificationType(classifiedSpan.ClassificationType))));
            }

            return result;
        }
 protected AbstractQuickInfoProvider(
     IProjectionBufferFactoryService projectionBufferFactoryService,
     IEditorOptionsFactoryService editorOptionsFactoryService,
     ITextEditorFactoryService textEditorFactoryService,
     IGlyphService glyphService,
     ClassificationTypeMap typeMap)
 {
     _projectionBufferFactoryService = projectionBufferFactoryService;
     _editorOptionsFactoryService = editorOptionsFactoryService;
     _textEditorFactoryService = textEditorFactoryService;
     _glyphService = glyphService;
     _typeMap = typeMap;
 }
        public static TextBlock ToTextBlock(this IEnumerable<SymbolDisplayPart> parts, ClassificationTypeMap typeMap)
        {
            var result = new TextBlock() { TextWrapping = TextWrapping.Wrap };

            var formatMap = typeMap.ClassificationFormatMapService.GetClassificationFormatMap("tooltip");
            result.SetDefaultTextProperties(formatMap);

            foreach (var part in parts)
            {
                result.Inlines.Add(part.ToRun(formatMap, typeMap));
            }

            return result;
        }
        public static TextBlock ToTextBlock(
            this IEnumerable<Inline> inlines,
            ClassificationTypeMap typeMap,
            string classificationFormatMap = null)
        {
            classificationFormatMap = classificationFormatMap ?? "tooltip";
            var formatMap = typeMap.ClassificationFormatMapService.GetClassificationFormatMap(classificationFormatMap);

            var textBlock = new TextBlock { TextWrapping = TextWrapping.Wrap };
            textBlock.SetDefaultTextProperties(formatMap);
            textBlock.Inlines.AddRange(inlines);

            return textBlock;
        }
        private FrameworkElement CreateContent(string eventName, ClassificationTypeMap classificationTypeMap)
        {
            var textBlock = new TextBlock { TextWrapping = TextWrapping.NoWrap };
            textBlock.SetDefaultTextProperties(classificationTypeMap.ClassificationFormatMapService.GetClassificationFormatMap("tooltip"));

            var eventNameRun = new Run(eventName + ";");
            eventNameRun.FontWeight = FontWeights.Bold;
            textBlock.Inlines.Add(eventNameRun);

            var pressTabRun = new Run(CSharpEditorResources.Press_TAB_to_insert);
            textBlock.Inlines.Add(pressTabRun);

            return textBlock;
        }
        public static async Task ProduceTagsAsync(TaggerContext<IClassificationTag> context, DocumentSnapshotSpan spanToTag,
            IEditorClassificationService classificationService, ClassificationTypeMap typeMap)
        {
            var document = spanToTag.Document;
            if (document == null)
            {
                return;
            }

            if (await TryClassifyContainingMemberSpan(context, spanToTag, classificationService, typeMap).ConfigureAwait(false))
            {
                return;
            }

            // We weren't able to use our specialized codepaths for semantic classifying. 
            // Fall back to classifying the full span that was asked for.
            await ClassifySpansAsync(context, spanToTag, classificationService, typeMap).ConfigureAwait(false);
        }
        public static TextBlock ToTextBlock(
            this IEnumerable<Inline> inlines,
            ClassificationTypeMap typeMap,
            string classificationFormatMap = null,
            bool wrap = true)
        {
            classificationFormatMap = classificationFormatMap ?? "tooltip";
            var formatMap = typeMap.ClassificationFormatMapService.GetClassificationFormatMap(classificationFormatMap);

            var textBlock = new TextBlock
            {
                TextWrapping = wrap ? TextWrapping.Wrap : TextWrapping.NoWrap,
                TextTrimming = wrap ? TextTrimming.None : TextTrimming.CharacterEllipsis
            };
            textBlock.SetDefaultTextProperties(formatMap);
            textBlock.Inlines.AddRange(inlines);

            return textBlock;
        }
        public static IList<ClassificationSpan> ToClassificationSpans(
            this IEnumerable<SymbolDisplayPart> parts,
            ITextSnapshot textSnapshot,
            ClassificationTypeMap typeMap)
        {
            var result = new List<ClassificationSpan>();

            var index = 0;
            foreach (var part in parts)
            {
                var text = part.ToString();
                result.Add(new ClassificationSpan(
                    new SnapshotSpan(textSnapshot, new Microsoft.VisualStudio.Text.Span(index, text.Length)),
                    typeMap.GetClassificationType(part.Kind.ToClassificationTypeName())));

                index += text.Length;
            }

            return result;
        }
        public StreamingFindUsagesPresenter(
            Shell.SVsServiceProvider serviceProvider,
            ITextBufferFactoryService textBufferFactoryService,
            IProjectionBufferFactoryService projectionBufferFactoryService,
            IEditorOptionsFactoryService editorOptionsFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            IContentTypeRegistryService contentTypeRegistryService,
            ClassificationTypeMap typeMap,
            IEditorFormatMapService formatMapService)
        {
            _serviceProvider = serviceProvider;
            _textBufferFactoryService = textBufferFactoryService;
            _projectionBufferFactoryService = projectionBufferFactoryService;
            _editorOptionsFactoryService = editorOptionsFactoryService;
            _contentTypeRegistryService = contentTypeRegistryService;

            _textEditorFactoryService = textEditorFactoryService;
            _typeMap = typeMap;
            _formatMapService = formatMapService;

            _vsFindAllReferencesService = (IFindAllReferencesService)_serviceProvider.GetService(typeof(SVsFindAllReferences));
        }
        public static IList<Inline> ToInlines(
            this IEnumerable<TaggedText> parts, 
            ClassificationTypeMap typeMap,
            string classificationFormatMap = null,
            Action<Run, TaggedText, int> runCallback = null)
        {
            classificationFormatMap = classificationFormatMap ?? "tooltip";

            var formatMap = typeMap.ClassificationFormatMapService.GetClassificationFormatMap(classificationFormatMap);
            var inlines = new List<Inline>();

            var position = 0;
            foreach (var part in parts)
            {
                var run = part.ToRun(formatMap, typeMap);
                runCallback?.Invoke(run, part, position);
                inlines.Add(run);

                position += part.Text.Length;
            }

            return inlines;
        }
        private static async Task ClassifySpansAsync(TaggerContext<IClassificationTag> context, DocumentSnapshotSpan spanToTag,
            IEditorClassificationService classificationService, ClassificationTypeMap typeMap)
        {
            try
            {
                var document = spanToTag.Document;
                var snapshotSpan = spanToTag.SnapshotSpan;
                var snapshot = snapshotSpan.Snapshot;

                var cancellationToken = context.CancellationToken;
                using (Logger.LogBlock(FunctionId.Tagger_SemanticClassification_TagProducer_ProduceTags, cancellationToken))
                {
                    var classifiedSpans = ClassificationUtilities.GetOrCreateClassifiedSpanList();

                    await classificationService.AddSemanticClassificationsAsync(
                        document, snapshotSpan.Span.ToTextSpan(), classifiedSpans, cancellationToken: cancellationToken).ConfigureAwait(false);

                    ClassificationUtilities.Convert(typeMap, snapshotSpan.Snapshot, classifiedSpans, context.AddTag);
                    ClassificationUtilities.ReturnClassifiedSpanList(classifiedSpans);

                    var version = await document.Project.GetDependentSemanticVersionAsync(cancellationToken).ConfigureAwait(false);

                    // Let the context know that this was the span we actually tried to tag.
                    context.SetSpansTagged(SpecializedCollections.SingletonEnumerable(spanToTag));
                    context.State = version;
                }
            }
            catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }
 public static TextBlock ToTextBlock(this TaggedText part, ClassificationTypeMap typeMap)
 {
     return SpecializedCollections.SingletonEnumerable(part).ToTextBlock(typeMap);
 }
#pragma warning restore 67

        public SignatureHelpClassifier(ITextBuffer subjectBuffer, ClassificationTypeMap typeMap)
        {
            _subjectBuffer = subjectBuffer;
            _typeMap = typeMap;
        }
 public EventHookupQuickInfoSource(ITextBuffer textBuffer, ClassificationTypeMap classificationTypeMap)
 {
     _textBuffer = textBuffer;
     _classificationTypeMap = classificationTypeMap;
 }