Ejemplo n.º 1
0
        public void AddError(Diagnostic diagnostic, TextSpan span)
        {
            lock (_lockObject)
            {
                if (_disposed)
                    return;

                var sourceText = span.SourceText as VisualStudioSourceText;
                if (sourceText == null)
                    return;

                var line = sourceText.Snapshot.GetLineFromPosition(span.Start);

                var task = new ErrorTask
                {
                    Text = diagnostic.Message,
                    Line = line.LineNumber,
                    Column = span.Start - line.Start.Position,
                    Category = TaskCategory.CodeSense,
                    ErrorCategory = (diagnostic.Severity == DiagnosticSeverity.Error)
                        ? TaskErrorCategory.Error
                        : TaskErrorCategory.Warning,
                    Priority = TaskPriority.Normal,
                    Document = span.Filename ?? _textDocument.FilePath
                };

                task.Navigate += OnTaskNavigate;

                _errorListProvider.Tasks.Add(task);
            }
        }
Ejemplo n.º 2
0
        public void AddError(ITextSnapshot snapshot, Diagnostic diagnostic, TextSpan span)
        {
            var line = snapshot.GetLineFromPosition(span.Start);

            var task = new ErrorTask
            {
                Text = diagnostic.Message,
                Line = line.LineNumber,
                Column = span.Start - line.Start.Position,
                Category = TaskCategory.CodeSense,
                ErrorCategory = TaskErrorCategory.Error,
                Priority = TaskPriority.Normal,
                Document = span.Filename
            };

            task.Navigate += OnTaskNavigate;

            _errorListProvider.Tasks.Add(task);
        }
Ejemplo n.º 3
0
 public static void ReportAmbiguousInvocation(this ICollection<Diagnostic> diagnostics, TextSpan span, InvocableSymbol symbol1, InvocableSymbol symbol2, IReadOnlyList<TypeSymbol> argumentTypes)
 {
     if (argumentTypes.Count > 0)
     {
         var displayTypes = string.Join(@", ", argumentTypes.Select(t => t.ToDisplayName()));
         diagnostics.Report(span, DiagnosticId.AmbiguousInvocation, symbol1, symbol2, displayTypes);
     }
     else
     {
         var message = string.Format(CultureInfo.CurrentCulture, "Invocation is ambiguous between '{0}' and '{1}'.", symbol1, symbol2);
         var diagnostic = new Diagnostic(span, DiagnosticId.AmbiguousInvocation, message);
         diagnostics.Add(diagnostic);
     }
 }
Ejemplo n.º 4
0
 public void AddDiagnostic(Diagnostic diagnostic)
 {
     _diagnostics.Add(diagnostic);
 }