private void CreateTrackingSpans() { _trackingSpans = new Dictionary <ITrackingSpan, CompileValue>(); if (!IsEnabled) { return; } var currentSnapshot = _buffer.CurrentSnapshot; MatchCollection matches = Regex.Matches(currentSnapshot.GetText(), @"#\s*include\s*[<""](.+)[>""]"); foreach (Match match in matches) { if (match.Success) { string file = match.Groups[1].Value; string fileName = Path.GetFileName(file).ToLower(); CompileValue value = CompilerData.Instance.GetValue(CompilerData.CompileCategory.Include, fileName); if (value != null && value.Severity > 0) { Span span = new Span(match.Index, match.Length); var trackingSpan = currentSnapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeExclusive); _trackingSpans.Add(trackingSpan, value); } } } }
private void ReadCompileValue(BinaryReader reader, List <CompileValue> list) { var name = reader.ReadString(); ulong acc = reader.ReadUInt64(); uint min = reader.ReadUInt32(); uint max = reader.ReadUInt32(); uint count = reader.ReadUInt32(); var compileData = new CompileValue(name, acc, min, max, count); list.Add(compileData); }
public ScoreGlyphTag(CompileValue value) { Value = value; }
// This is called on a background thread. public Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) { if (IsEnabled()) { var triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot); if (triggerPoint != null) { var line = triggerPoint.Value.GetContainingLine(); string lineStr = line.GetText(); Match match = Regex.Match(lineStr, @"#\s*include\s*[<""](.+)[>""]"); if (match.Success) { string file = match.Groups[1].Value; string fileName = Path.GetFileName(file); string lowerFilename = fileName.ToLower(); CompileValue value = CompilerData.Instance.GetValue(CompilerData.CompileCategory.Include, lowerFilename); Span span = new Span(line.Extent.Start + match.Index, match.Length); var trackingSpan = _textBuffer.CurrentSnapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeExclusive); var headerElm = new ContainerElement( ContainerElementStyle.Wrapped, new ImageElement(_icon), new ClassifiedTextElement( new ClassifiedTextRun(PredefinedClassificationTypeNames.PreprocessorKeyword, fileName) )); if (value != null && value.Severity > 0) { var scoreElm = new ContainerElement( ContainerElementStyle.Wrapped, new ClassifiedTextElement( new ClassifiedTextRun(PredefinedClassificationTypeNames.Keyword, "Compile Score: ") ), new ImageElement(value.Severity > 0 ? _severityOnIcon : _severityOffIcon), new ImageElement(value.Severity > 1 ? _severityOnIcon : _severityOffIcon), new ImageElement(value.Severity > 2 ? _severityOnIcon : _severityOffIcon), new ImageElement(value.Severity > 3 ? _severityOnIcon : _severityOffIcon), new ImageElement(value.Severity > 4 ? _severityOnIcon : _severityOffIcon) ); //Found tooltip var fullElm = new ContainerElement( ContainerElementStyle.Stacked, headerElm, scoreElm, new ClassifiedTextElement( new ClassifiedTextRun(PredefinedClassificationTypeNames.SymbolDefinition, "Max: "), new ClassifiedTextRun(PredefinedClassificationTypeNames.Comment, Common.UIConverters.GetTimeStr(value.Max)), new ClassifiedTextRun(PredefinedClassificationTypeNames.SymbolDefinition, " Min: "), new ClassifiedTextRun(PredefinedClassificationTypeNames.Comment, Common.UIConverters.GetTimeStr(value.Min)), new ClassifiedTextRun(PredefinedClassificationTypeNames.SymbolDefinition, " Average: "), new ClassifiedTextRun(PredefinedClassificationTypeNames.Comment, Common.UIConverters.GetTimeStr(value.Mean)), new ClassifiedTextRun(PredefinedClassificationTypeNames.SymbolDefinition, " Count: "), new ClassifiedTextRun(PredefinedClassificationTypeNames.Comment, $"{value.Count}") )); return(Task.FromResult(new QuickInfoItem(trackingSpan, fullElm))); } else { var fullElm = new ContainerElement( ContainerElementStyle.Stacked, headerElm, new ClassifiedTextElement( new ClassifiedTextRun(PredefinedClassificationTypeNames.Keyword, "Compile Score: "), new ClassifiedTextRun(PredefinedClassificationTypeNames.ExcludedCode, " - ") )); return(Task.FromResult(new QuickInfoItem(trackingSpan, fullElm))); } } } } return(Task.FromResult <QuickInfoItem>(null)); }
public HighlightTag(CompileValue value) : base("SeverityDefinition" + value.Severity) { Value = value; }