public object?Convert(object value, Type targetType, object parameter, CultureInfo culture) { var obj = value as FormatterObject <StackFrameVM>; if (obj is null) { return(null); } var writer = obj.VM.Context.TextClassifierTextColorWriter; writer.Clear(); var formatter = obj.VM.Context.Formatter; if (obj.Tag == PredefinedTextClassifierTags.CallStackWindowName) { formatter.WriteName(writer, obj.VM); } else { return(null); } var context = new TextClassifierContext(writer.Text, obj.Tag, obj.VM.Context.SyntaxHighlight, writer.Colors); return(obj.VM.Context.TextBlockContentInfoFactory.Create(obj.VM.Context.UIVersion, obj.VM.Context.ClassificationFormatMap, context, ContentTypes.CallStackWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { if (!settings.UnderlineManagedAssemblies) { yield break; } if (!(context is TreeViewNodeClassifierContext tvContext)) { yield break; } // Don't do a thing if it's a tooltip if (tvContext.IsToolTip) { yield break; } // Add the underline if (tvContext.Node is AssemblyDocumentNode) { yield return(new TextClassificationTag(new Span(0, context.Text.Length), classificationTypeRegistryService.GetClassificationType(TreeViewNodeColorizerClassifications.UnderlineClassificationType))); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var tagContext = context as TaggedTextClassifierContext; Debug.Assert(tagContext != null); if (tagContext == null) { yield break; } if (tagContext.TaggedParts.Length == 0) { yield break; } var part = tagContext.TaggedParts[0]; if (part.Tag == TextTags.Text) { var partText = part.Text; // Eg. "AddHandler statement\r\n[...]" contains CRLF int endOfLineIndex = partText.IndexOf("\r\n"); if (endOfLineIndex < 0) { endOfLineIndex = partText.Length; } foreach (var s in keywordSuffixes) { if (partText.IndexOf(s, 0, endOfLineIndex, StringComparison.Ordinal) == endOfLineIndex - s.Length) { yield return(new TextClassificationTag(new Span(0, endOfLineIndex - s.Length), themeClassificationTypeService.GetClassificationType(TextColor.Keyword))); break; } } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ExceptionVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new ExceptionPrinter(writer); if (tag == PredefinedTextClassifierTags.ExceptionSettingsWindowName) { printer.WriteName(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return(vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.ExceptionSettingsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var tvContext = context as TreeViewNodeClassifierContext; if (tvContext == null) { yield break; } // Don't do a thing if it's a tooltip if (tvContext.IsToolTip) { yield break; } // Add the underline if (tvContext.Node is AssemblyDocumentNode || tvContext.Node is MethodNode) { yield return(new TextClassificationTag(new Span(0, context.Text.Length), classificationTypeRegistryService.GetClassificationType(TreeViewNodeColorizerClassifications.UnderlineClassificationType))); } // Add light green background in the middle of the text yield return(new TextClassificationTag(new Span(context.Text.Length / 4, context.Text.Length / 2), classificationTypeRegistryService.GetClassificationType(TreeViewNodeColorizerClassifications.LightgreenBackgroundClassificationType))); }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { if (!(context is CompletionSuffixClassifierContext)) { yield break; } yield return(new TextClassificationTag(new Span(0, context.Text.Length), completionSuffixClassificationType)); }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { if (!context.Colorize) { yield break; } var tagContext = context as TaggedTextClassifierContext; if (tagContext == null) { yield break; } if (tagContext.TaggedParts.Length == 0) { yield break; } var part = tagContext.TaggedParts[0]; if (part.Tag == TextTags.Text) { var partText = part.Text; // Eg. "AddHandler statement\r\n[...]" contains CRLF int endOfLineIndex = partText.IndexOf("\r\n"); if (endOfLineIndex < 0) { endOfLineIndex = partText.Length; } foreach (var s in keywordSuffixes) { int endOfKeywordPart = endOfLineIndex - s.Length; if (partText.IndexOf(s, 0, endOfLineIndex, StringComparison.Ordinal) == endOfKeywordPart) { var keywords = part.Text.Substring(0, endOfKeywordPart); int keywordOffset = 0; while (keywordOffset < keywords.Length) { if (keywords[keywordOffset] == ' ') { keywordOffset++; continue; } int end = keywords.IndexOf(' ', keywordOffset); if (end < 0) { end = keywords.Length; } int keywordLen = end - keywordOffset; if (keywordLen > 0) { yield return(new TextClassificationTag(new Span(keywordOffset, keywordLen), themeClassificationTypeService.GetClassificationType(TextColor.Keyword))); } keywordOffset += keywordLen; } break; } } } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var tvContext = context as AppSettingsTreeViewNodeClassifierContext; if (tvContext == null) { yield break; } foreach (var span in tvContext.SearchMatcher.GetMatchSpans(tvContext.Text)) { yield return(new TextClassificationTag(span, appSettingsTreeViewNodeMatchHighlightClassificationType)); } }
object CreateUI(object?o, bool includeNamespace) { var writer = Cache.GetWriter(); try { CreateUI(writer, o, includeNamespace); var context = new TextClassifierContext(writer.Text, string.Empty, Context.SyntaxHighlight, writer.Colors); return(Context.TextElementProvider.CreateTextElement(Context.ClassificationFormatMap, context, ContentTypes.Search, TextElementFlags.FilterOutNewLines)); } finally { Cache.FreeWriter(writer); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var obj = value as FormatterObject <ProcessVM>; if (obj == null) { return(null); } var writer = obj.VM.Context.TextClassifierTextColorWriter; writer.Clear(); var formatter = obj.VM.Context.Formatter; if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowName) { formatter.WriteName(writer, obj.VM.Process); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowId) { formatter.WriteId(writer, obj.VM.Process); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowTitle) { formatter.WriteTitle(writer, obj.VM); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowState) { formatter.WriteState(writer, obj.VM); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowDebugging) { formatter.WriteDebugging(writer, obj.VM.Process); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowMachine) { formatter.WriteMachine(writer, obj.VM.Process.Machine); } else if (obj.Tag == PredefinedTextClassifierTags.ProcessesWindowPath) { formatter.WritePath(writer, obj.VM.Process); } else { return(null); } var context = new TextClassifierContext(writer.Text, obj.Tag, obj.VM.Context.SyntaxHighlight, writer.Colors); return(obj.VM.Context.TextElementProvider.CreateTextElement(obj.VM.Context.ClassificationFormatMap, context, ContentTypes.ProcessesWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as BreakpointVM; if (vm == null) { return(null); } var tag = parameter as string; if (tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new BreakpointPrinter(writer, vm.Context.UseHexadecimal, vm.Context.Decompiler); if (tag == PredefinedTextClassifierTags.BreakpointsWindowName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.BreakpointsWindowAssembly) { printer.WriteAssembly(vm); } else if (tag == PredefinedTextClassifierTags.BreakpointsWindowModule) { printer.WriteModule(vm); } else if (tag == PredefinedTextClassifierTags.BreakpointsWindowFile) { printer.WriteFile(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return(vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.BreakpointsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var tvContext = context as TreeViewNodeClassifierContext; if (tvContext == null) { yield break; } if (!tvContext.Colorize) { yield break; } foreach (var spanData in tvContext.Colors) { var ct = spanData.Data as IClassificationType ?? themeClassificationTypeService.GetClassificationType(spanData.Data as TextColor? ?? TextColor.Text); yield return(new TextClassificationTag(spanData.Span, ct)); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var completionContext = context as CompletionDisplayTextClassifierContext; if (completionContext == null) { yield break; } var spans = completionContext.CompletionSet.GetHighlightedSpansInDisplayText(context.Text); if (spans == null) { yield break; } foreach (var span in spans) { yield return(new TextClassificationTag(span, completionMatchHighlightClassificationType)); } }
// Called indirectly by GetTags() above IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var myContext = context as MyTextClassifierContext; Debug.Assert(myContext != null); if (myContext == null) { yield break; } var realContext = myContext.CompletionClassifierContext; foreach (var classifier in completionClassifiers) { foreach (var tag in classifier.GetTags(realContext)) { yield return(new TextClassificationTag(tag.Span, tag.ClassificationType)); } } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var tagContext = context as TaggedTextClassifierContext; if (tagContext == null) { yield break; } int pos = 0; foreach (var part in tagContext.TaggedParts) { var color = TextTagsHelper.ToTextColor(part.Tag); int len = part.Text.Length; yield return(new TextClassificationTag(new Span(pos, len), themeClassificationTypeService.GetClassificationType(color))); pos += len; } Debug.Assert(pos == context.Text.Length); }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var gacContext = context as OpenFromGACTextClassifierContext; if (gacContext == null) { yield break; } if (gacContext.Tag != PredefinedTextClassifierTags.GacDialogName) { yield break; } foreach (var part in gacContext.SearchText.Split(seps, StringSplitOptions.RemoveEmptyEntries)) { int index = gacContext.Text.IndexOf(part, StringComparison.CurrentCultureIgnoreCase); if (index >= 0) { yield return(new TextClassificationTag(new Span(index, part.Length), gacMatchHighlightClassificationType)); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { var flags = WriteObjectFlags.None; if (parameter != null) { foreach (var c in (string)parameter) { if (c == 's') { flags |= WriteObjectFlags.ShortInstruction; } } } var writer = Cache.GetWriter(); try { BodyUtils.WriteObject(writer, value, flags); const bool colorize = true; var context = new TextClassifierContext(writer.Text, PredefinedTextClassifierTags.MethodBodyEditor, colorize, writer.Colors); var elem = textElementProvider.CreateTextElement(classificationFormatMap, context, ContentTypes.MethodBodyEditor, TextElementFlags.CharacterEllipsis | TextElementFlags.FilterOutNewLines); Cache.FreeWriter(writer); return(elem); } finally { Cache.FreeWriter(writer); } } catch (Exception ex) { Debug.Fail(ex.ToString()); } if (value == null) { return(string.Empty); } return(value.ToString()); }
public object?Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as TabVM; var tag = parameter as string; if (vm is null || tag is null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new TabPrinter(writer); if (tag == PredefinedTextClassifierTags.TabsDialogName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.TabsDialogModule) { printer.WriteModule(vm); } else if (tag == PredefinedTextClassifierTags.TabsDialogPath) { printer.WritePath(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Owner.Settings.SyntaxHighlight, writer.Colors); return(vm.Owner.TextElementProvider.CreateTextElement(vm.Owner.ClassificationFormatMap, context, ContentTypes.TabsDialog, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ThreadVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new ThreadPrinter(writer, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (tag == PredefinedTextClassifierTags.ThreadsWindowId) { printer.WriteId(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowManagedId) { printer.WriteManagedId(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowCategoryText) { printer.WriteCategory(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowLocation) { printer.WriteLocation(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowPriority) { printer.WritePriority(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowAffinityMask) { printer.WriteAffinityMask(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowSuspended) { printer.WriteSuspended(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowProcess) { printer.WriteProcess(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowAppDomain) { printer.WriteAppDomain(vm); } else if (tag == PredefinedTextClassifierTags.ThreadsWindowUserState) { printer.WriteUserState(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return(vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.ThreadsWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) { var completionContext = context as CompletionDisplayTextClassifierContext; if (completionContext == null) { yield break; } var completion = completionContext.Completion as RoslynCompletion; if (completion == null) { yield break; } var completionSet = completionContext.CompletionSet as RoslynCompletionSet; if (completionSet == null) { yield break; } // The completion API doesn't create tagged text so try to extract that information // from the string so we get nice colorized text. var color = completion.CompletionItem.Tags.ToCompletionKind().ToTextColor(); var text = context.Text; // Check if the namespace or enclosing class name is part of the text if (text.IndexOf('.') < 0) { // The common case is just an identifier, and in that case, the tag is correct int punctIndex = text.IndexOfAny(punctuationChars, 0); if (punctIndex < 0) { yield return(new TextClassificationTag(new Span(0, text.Length), themeClassificationTypeService.GetClassificationType(color))); yield break; } // Check for CLASS<> or METHOD() if (punctIndex + 2 == text.Length && text.IndexOfAny(punctuationChars, punctIndex + 1) == punctIndex + 1) { yield return(new TextClassificationTag(new Span(0, punctIndex), themeClassificationTypeService.GetClassificationType(color))); yield return(new TextClassificationTag(new Span(punctIndex, 2), punctuationClassificationType)); yield break; } // Check for Visual Basic generics special case const string VBOf = "(Of …)"; if (text.Length - VBOf.Length == punctIndex && text.EndsWith(VBOf)) { yield return(new TextClassificationTag(new Span(0, punctIndex), themeClassificationTypeService.GetClassificationType(color))); yield return(new TextClassificationTag(new Span(punctIndex, 1), punctuationClassificationType)); yield return(new TextClassificationTag(new Span(punctIndex + 1, 2), themeClassificationTypeService.GetClassificationType(TextColor.Keyword))); yield return(new TextClassificationTag(new Span(punctIndex + VBOf.Length - 1, 1), punctuationClassificationType)); yield break; } } // The text is usually identical to the description and it's classified var description = completionSet.GetDescriptionAsync(completion).GetAwaiter().GetResult(); var indexes = GetMatchIndexes(completion, description); if (indexes != null) { int pos = 0; var parts = description.TaggedParts; int endIndex = indexes.Value.Value; for (int i = indexes.Value.Key; i <= endIndex; i++) { var part = parts[i]; if (part.Tag == TextTags.LineBreak) { break; } var color2 = TextTagsHelper.ToTextColor(part.Tag); yield return(new TextClassificationTag(new Span(pos, part.Text.Length), themeClassificationTypeService.GetClassificationType(color2))); pos += part.Text.Length; } if (pos < text.Length) { // The remaining text is unknown, just use the tag color yield return(new TextClassificationTag(Span.FromBounds(pos, text.Length), themeClassificationTypeService.GetClassificationType(color))); } yield break; } // Give up, use the same color for all the text yield return(new TextClassificationTag(new Span(0, text.Length), themeClassificationTypeService.GetClassificationType(color))); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ProcessVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new ProcessPrinter(writer, false); HorizontalAlignment?horizAlign = null; if (tag == PredefinedTextClassifierTags.AttachToProcessWindowFullPath) { printer.WriteFullPath(vm); } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowFilename) { printer.WriteFilename(vm); } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowPid) { printer.WritePID(vm); horizAlign = HorizontalAlignment.Right; } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowClrVersion) { printer.WriteCLRVersion(vm); } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowType) { printer.WriteType(vm); } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowMachine) { printer.WriteMachine(vm); } else if (tag == PredefinedTextClassifierTags.AttachToProcessWindowTitle) { printer.WriteTitle(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); var elem = vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.AttachToProcessWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis); if (horizAlign != null) { elem.HorizontalAlignment = horizAlign.Value; } return(elem); } finally { Cache.FreeWriter(writer); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vm = value as ModuleVM; var tag = parameter as string; if (vm == null || tag == null) { return(null); } var writer = Cache.GetWriter(); try { var printer = new ModulePrinter(writer, vm.Context.UseHexadecimal, vm.Context.TheDebugger.Debugger); if (tag == PredefinedTextClassifierTags.ModulesWindowName) { printer.WriteName(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowPath) { printer.WritePath(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowOptimized) { printer.WriteOptimized(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowDynamic) { printer.WriteDynamic(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowInMemory) { printer.WriteInMemory(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowOrder) { printer.WriteOrder(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowVersion) { printer.WriteVersion(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowTimestamp) { printer.WriteTimestamp(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowAddress) { printer.WriteAddress(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowProcess) { printer.WriteProcess(vm); } else if (tag == PredefinedTextClassifierTags.ModulesWindowAppDomain) { printer.WriteAppDomain(vm); } else { return(null); } var context = new TextClassifierContext(writer.Text, tag, vm.Context.SyntaxHighlight, writer.Colors); return(vm.Context.TextElementProvider.CreateTextElement(vm.Context.ClassificationFormatMap, context, ContentTypes.ModulesWindow, TextElementFlags.FilterOutNewLines | TextElementFlags.CharacterEllipsis)); } finally { Cache.FreeWriter(writer); } }
public IEnumerable <TextClassificationTag> GetTags(TextClassifierContext context) => owner.GetTags(context);
public TextBlockContentInfo Create(int version, IClassificationFormatMap classificationFormatMap, TextClassifierContext context, string contentType, TextElementFlags flags, double opacity) { if (classificationFormatMap == null) { throw new ArgumentNullException(nameof(classificationFormatMap)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } if (contentType == null) { throw new ArgumentNullException(nameof(contentType)); } var ct = contentTypeRegistryService.GetContentType(contentType); if (ct == null) { throw new ArgumentException($"Invalid content type: {contentType}"); } if (!toAggregator.TryGetValue(ct, out var aggregator)) { toAggregator.Add(ct, aggregator = textClassifierAggregatorService.Create(ct)); } var tags = aggregator.GetTags(context).ToArray(); return(new TextBlockContentInfo(textElementFactory, version, classificationFormatMap, context.Text, tags, flags, opacity)); }