示例#1
0
 public VBLspEditorClassificationFactoryService(VisualBasicLspClientServiceFactory vbLspClientServiceFactory, RemoteLanguageServiceWorkspace remoteLanguageServiceWorkspace,
                                                ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
     : base(vbLspClientServiceFactory, remoteLanguageServiceWorkspace, classificationTypeMap, threadingContext)
 {
 }
示例#2
0
 public EventHookupQuickInfoSourceProvider(ClassificationTypeMap classificationTypeMap, IClassificationFormatMapService classificationFormatMapService)
 {
     _classificationTypeMap          = classificationTypeMap;
     _classificationFormatMapService = classificationFormatMapService;
 }
示例#3
0
 public static TextBlock ToTextBlock(this TaggedText part, ClassificationTypeMap typeMap, ITaggedTextMappingService mappingService)
 {
     return(SpecializedCollections.SingletonEnumerable(part).ToTextBlock(typeMap, mappingService));
 }
示例#4
0
 public IClassifier Create(ITextBuffer textBuffer, ClassificationTypeMap typeMap) =>
 new SignatureHelpClassifier(textBuffer, typeMap);
        internal ChangeSignatureDialogViewModel(INotificationService notificationService, ParameterConfiguration parameters, ISymbol symbol, IClassificationFormatMap classificationFormatMap, ClassificationTypeMap classificationTypeMap)
        {
            _originalParameterConfiguration = parameters;
            _notificationService            = notificationService;
            _classificationFormatMap        = classificationFormatMap;
            _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;
        }
示例#6
0
 public static TagSpan <IClassificationTag> Convert(ClassificationTypeMap typeMap, ITextSnapshot snapshot, ClassifiedSpan classifiedSpan)
 {
     return(new TagSpan <IClassificationTag>(
                classifiedSpan.TextSpan.ToSnapshotSpan(snapshot),
                new ClassificationTag(typeMap.GetClassificationType(classifiedSpan.ClassificationType))));
 }
示例#7
0
        public static Run ToRun(this TaggedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
        {
            var text = part.ToVisibleDisplayString(includeLeftToRightMarker: true);

            var run = new Run(text);

            var format = formatMap.GetTextProperties(typeMap.GetClassificationType(
                                                         part.Tag.ToClassificationTypeName()));

            run.SetTextProperties(format);

            return(run);
        }
        public StackTraceExplorerTab(IThreadingContext threadingContext, VisualStudioWorkspace workspace, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap, int nameIndex)
        {
            NameIndex = nameIndex;

            _stackExplorerVM = new StackTraceExplorerViewModel(threadingContext, workspace, typeMap, formatMap);
            Content          = new StackTraceExplorer(_stackExplorerVM);

            CloseClick = new DelegateCommand(_ =>
            {
                OnClosed?.Invoke(this, null);
            });
        }
示例#9
0
        private static FrameworkElement CreateElement(
            ImmutableArray <TaggedText> taggedTexts,
            IWpfTextView textView,
            TextFormattingRunProperties format,
            IClassificationFormatMap formatMap,
            ClassificationTypeMap typeMap,
            bool classify)
        {
            // Constructs the hint block which gets assigned parameter name and fontstyles according to the options
            // page. Calculates a inline tag that will be 3/4s the size of a normal line. This shrink size tends to work
            // well with VS at any zoom level or font size.

            var block = new TextBlock
            {
                FontFamily = format.Typeface.FontFamily,
                FontSize   = 0.75 * format.FontRenderingEmSize,
                FontStyle  = FontStyles.Normal,
                Foreground = format.ForegroundBrush,

                // Adds a little bit of padding to the left of the text relative to the border
                // to make the text seem more balanced in the border
                Padding           = new Thickness(left: 1, top: 0, right: 1, bottom: 0),
                VerticalAlignment = VerticalAlignment.Center,
            };

            var(trimmedTexts, leftPadding, rightPadding) = Trim(taggedTexts);

            foreach (var taggedText in trimmedTexts)
            {
                var run = new Run(taggedText.ToVisibleDisplayString(includeLeftToRightMarker: true));

                if (classify && taggedText.Tag != TextTags.Text)
                {
                    var properties = formatMap.GetTextProperties(typeMap.GetClassificationType(taggedText.Tag.ToClassificationTypeName()));
                    var brush      = properties.ForegroundBrush.Clone();
                    run.Foreground = brush;
                }

                block.Inlines.Add(run);
            }

            // Encapsulates the textblock within a border. Gets foreground/background colors from the options menu.

            // If the tag is started or followed by a space, we trim that off but represent the space as buffer on hte
            // left or right side.
            var left  = leftPadding * 5;
            var right = rightPadding * 5;

            var border = new Border
            {
                Background   = format.BackgroundBrush,
                Child        = block,
                CornerRadius = new CornerRadius(2),

                // Place 3 pixels above/below the border object.  This works well as the highlighting lines are 2px
                // each, giving us 1 px of space on both side of the inline tag and them.  This gives the inline tag
                // an appropriate floating-halfway feeling on the line.
                Margin = new Thickness(left, top: 3, right, bottom: 3),
            };

            // Need to set these properties to avoid unnecessary reformatting because some dependancy properties
            // affect layout
            TextOptions.SetTextFormattingMode(border, TextOptions.GetTextFormattingMode(textView.VisualElement));
            TextOptions.SetTextHintingMode(border, TextOptions.GetTextHintingMode(textView.VisualElement));
            TextOptions.SetTextRenderingMode(border, TextOptions.GetTextRenderingMode(textView.VisualElement));

            border.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            return(border);
        }
 public CSharpLspEditorClassificationFactoryService(CSharpLspClientServiceFactory csharpLspClientServiceFactory, ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
 {
     _csharpLspClientServiceFactory = csharpLspClientServiceFactory ?? throw new ArgumentNullException(nameof(csharpLspClientServiceFactory));
     _classificationTypeMap         = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap));
     _threadingContext = threadingContext;
 }
 public VBLspEditorClassificationFactoryService(VisualBasicLspClientServiceFactory vbLspClientServiceFactory, ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
 {
     _vbLspClientServiceFactory = vbLspClientServiceFactory ?? throw new ArgumentNullException(nameof(vbLspClientServiceFactory));
     _classificationTypeMap     = classificationTypeMap ?? throw new ArgumentNullException(nameof(classificationTypeMap));
     _threadingContext          = threadingContext;
 }
示例#12
0
            private static Task ProduceTagsAsync(TaggerContext <IClassificationTag> context, DocumentSnapshotSpan documentSpan, ClassificationTypeMap typeMap)
            {
                var document = documentSpan.Document;

                var classificationService = document.GetLanguageService <IClassificationService>();

                if (classificationService != null)
                {
                    return(SemanticClassificationUtilities.ProduceTagsAsync(context, documentSpan, classificationService, typeMap));
                }

                return(Task.CompletedTask);
            }
示例#13
0
 public FrameViewModel(IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
 {
     _formatMap             = formatMap;
     _classificationTypeMap = typeMap;
 }
示例#14
0
 public StackTraceExplorerRootViewModel(IThreadingContext threadingContext, VisualStudioWorkspace workspace, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
 {
     _threadingContext = threadingContext;
     _workspace        = workspace;
     _formatMap        = formatMap;
     _typeMap          = typeMap;
 }
示例#15
0
 public static TextBlock ToTextBlock(this ImmutableArray <SymbolDisplayPart> parts, ClassificationTypeMap typeMap)
 {
     return(parts.AsEnumerable().ToTextBlock(typeMap));
 }
 public VisualStudioChangeSignatureOptionsService(IClassificationFormatMapService classificationFormatMapService, ClassificationTypeMap classificationTypeMap)
 {
     _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap("tooltip");
     _classificationTypeMap   = classificationTypeMap;
 }
示例#17
0
        public static TextBlock ToTextBlock(this IEnumerable <SymbolDisplayPart> parts, ClassificationTypeMap typeMap)
        {
            var result = new TextBlock();

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

            result.SetDefaultTextProperties(formatMap);

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

            return(result);
        }
示例#18
0
 public ToolTipProvider(ClassificationTypeMap typeMap)
 {
     _typeMap          = typeMap;
     _defaultTextBlock = new TaggedText(TextTags.Text, "...").ToTextBlock(typeMap);
 }
示例#19
0
        private static FrameworkElement CreateElement(
            ImmutableArray <TaggedText> taggedTexts,
            IWpfTextView textView,
            TextFormattingRunProperties format,
            IClassificationFormatMap formatMap,
            ClassificationTypeMap typeMap,
            bool classify)
        {
            // Constructs the hint block which gets assigned parameter name and fontstyles according to the options
            // page. Calculates a inline tag that will be 3/4s the size of a normal line. This shrink size tends to work
            // well with VS at any zoom level or font size.
            var block = new TextBlock
            {
                FontFamily = format.Typeface.FontFamily,
                FontSize   = 0.75 * format.FontRenderingEmSize,
                FontStyle  = FontStyles.Normal,
                Foreground = format.ForegroundBrush,
                // Adds a little bit of padding to the left of the text relative to the border to make the text seem
                // more balanced in the border
                Padding = new Thickness(left: 2, top: 0, right: 2, bottom: 0)
            };

            var(trimmedTexts, leftPadding, rightPadding) = Trim(taggedTexts);

            foreach (var taggedText in trimmedTexts)
            {
                var run = new Run(taggedText.ToVisibleDisplayString(includeLeftToRightMarker: true));

                if (classify && taggedText.Tag != TextTags.Text)
                {
                    var properties = formatMap.GetTextProperties(typeMap.GetClassificationType(taggedText.Tag.ToClassificationTypeName()));
                    var brush      = properties.ForegroundBrush.Clone();
                    run.Foreground = brush;
                }

                block.Inlines.Add(run);
            }

            block.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            // Encapsulates the textblock within a border. Gets foreground/background colors from the options menu.
            // If the tag is started or followed by a space, we trim that off but represent the space as buffer on hte
            // left or right side.
            var left  = leftPadding * 5;
            var right = rightPadding * 5;

            var border = new Border
            {
                Background        = format.BackgroundBrush,
                Child             = block,
                CornerRadius      = new CornerRadius(2),
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin            = new Thickness(left, top: 0, right, bottom: 0),
            };

            // gets pixel distance of baseline to top of the font height
            var dockPanelHeight = format.Typeface.FontFamily.Baseline * format.FontRenderingEmSize;
            var dockPanel       = new DockPanel
            {
                Height        = dockPanelHeight,
                LastChildFill = false,
                // VerticalAlignment is set to Top because it will rest to the top relative to the stackpanel
                VerticalAlignment = VerticalAlignment.Top
            };

            dockPanel.Children.Add(border);
            DockPanel.SetDock(border, Dock.Bottom);

            var stackPanel = new StackPanel
            {
                // Height set to align the baseline of the text within the TextBlock with the baseline of text in the editor
                Height      = dockPanelHeight + (block.DesiredSize.Height - (block.FontFamily.Baseline * block.FontSize)),
                Orientation = Orientation.Vertical
            };

            stackPanel.Children.Add(dockPanel);
            // Need to set these properties to avoid unnecessary reformatting because some dependancy properties
            // affect layout
            TextOptions.SetTextFormattingMode(stackPanel, TextOptions.GetTextFormattingMode(textView.VisualElement));
            TextOptions.SetTextHintingMode(stackPanel, TextOptions.GetTextHintingMode(textView.VisualElement));
            TextOptions.SetTextRenderingMode(stackPanel, TextOptions.GetTextRenderingMode(textView.VisualElement));

            return(stackPanel);
        }
示例#20
0
#pragma warning restore 67

        public SignatureHelpClassifier(ITextBuffer subjectBuffer, ClassificationTypeMap typeMap)
        {
            _subjectBuffer = subjectBuffer;
            _typeMap       = typeMap;
        }
        private static async Task <bool> TryClassifyContainingMemberSpanAsync(
            TaggerContext <IClassificationTag> context,
            DocumentSnapshotSpan spanToTag,
            IClassificationService 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;

            if (!document.SupportsSyntaxTree)
            {
                return(false);
            }

            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.GetLanguageService <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);
        }
示例#22
0
 private void CacheClassificationTag(ClassificationTypeMap typeMap)
 {
     // cache tag since it can't be changed
     s_tag = s_tag ?? new ClassificationTag(typeMap.GetClassificationType(ClassificationTypeDefinitions.UnnecessaryCode));
 }
示例#23
0
 public DocumentationCommentDeferredContentConverter(ClassificationTypeMap typeMap, IClassificationFormatMapService classificationFormatMapService)
 {
     _typeMap = typeMap;
     _classificationFormatMapService = classificationFormatMapService;
 }
 public StackTraceExplorerRootViewModel(IThreadingContext threadingContext, VisualStudioWorkspace workspace, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap, IStreamingFindUsagesPresenter streamingFindUsagesPresenter)
 {
     _threadingContext             = threadingContext;
     _workspace                    = workspace;
     _formatMap                    = formatMap;
     _typeMap                      = typeMap;
     _streamingFindUsagesPresenter = streamingFindUsagesPresenter;
 }
 public static TextBlock ToTextBlock(this TaggedText part, IClassificationFormatMap formatMap, ClassificationTypeMap typeMap)
 {
     return(SpecializedCollections.SingletonEnumerable(part).ToTextBlock(formatMap, typeMap));
 }
 public CSharpLspEditorClassificationFactory(CSharpLspClientServiceFactory csharpLspClientServiceFactory,
                                             ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
     : base(csharpLspClientServiceFactory, classificationTypeMap, threadingContext)
 {
 }
示例#27
0
        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 VBLspEditorClassificationServiceFactory(VisualBasicLspClientServiceFactory vbLspClientServiceFactory,
                                                ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
     : base(vbLspClientServiceFactory, classificationTypeMap, threadingContext)
 {
 }
 public SignatureHelpClassifierProvider(ClassificationTypeMap typeMap)
 {
     _typeMap = typeMap;
 }
示例#30
0
 public CSharpLspEditorClassificationFactoryService(CSharpLspClientServiceFactory csharpLspClientServiceFactory, RemoteLanguageServiceWorkspace remoteLanguageServiceWorkspace,
                                                    ClassificationTypeMap classificationTypeMap, IThreadingContext threadingContext)
     : base(csharpLspClientServiceFactory, remoteLanguageServiceWorkspace, classificationTypeMap, threadingContext)
 {
 }