Ejemplo n.º 1
0
        public static Location ConvertLocation(
            this DiagnosticDataLocation dataLocation, SyntacticDocument document = null)
        {
            if (dataLocation?.DocumentId == null)
            {
                return(Location.None);
            }

            if (document == null)
            {
                if (dataLocation?.OriginalFilePath == null || dataLocation.SourceSpan == null)
                {
                    return(Location.None);
                }

                var span = dataLocation.SourceSpan.Value;
                return(Location.Create(dataLocation?.OriginalFilePath, span, new LinePositionSpan(
                                           new LinePosition(dataLocation.OriginalStartLine, dataLocation.OriginalStartColumn),
                                           new LinePosition(dataLocation.OriginalEndLine, dataLocation.OriginalEndColumn))));
            }

            Contract.ThrowIfFalse(dataLocation.DocumentId == document.Document.Id);

            var syntaxTree = document.SyntaxTree;

            return(syntaxTree.GetLocation(dataLocation.SourceSpan ?? DiagnosticData.GetTextSpan(dataLocation, document.Text)));
        }
Ejemplo n.º 2
0
        public static async Task <Location> ConvertLocationAsync(
            this DiagnosticDataLocation dataLocation, Project project, CancellationToken cancellationToken)
        {
            if (dataLocation?.DocumentId == null)
            {
                return(Location.None);
            }

            var document = project.GetDocument(dataLocation?.DocumentId);

            if (document == null)
            {
                return(Location.None);
            }


            if (document.SupportsSyntaxTree)
            {
                var syntacticDocument = await SyntacticDocument.CreateAsync(document, cancellationToken).ConfigureAwait(false);

                return(dataLocation.ConvertLocation(syntacticDocument));
            }

            return(dataLocation.ConvertLocation());
        }
Ejemplo n.º 3
0
        public static TextSpan GetTextSpan(DiagnosticDataLocation dataLocation, SourceText text)
        {
            var lines = text.Lines;

            if (lines.Count == 0)
            {
                return(default);
Ejemplo n.º 4
0
 public DiagnosticData(
     string id,
     string category,
     string message,
     string enuMessageForBingSearch,
     DiagnosticSeverity severity,
     bool isEnabledByDefault,
     int warningLevel,
     Workspace workspace,
     ProjectId projectId,
     DiagnosticDataLocation location = null,
     IReadOnlyCollection <DiagnosticDataLocation> additionalLocations = null,
     string title       = null,
     string description = null,
     string helpLink    = null,
     bool isSuppressed  = false,
     IReadOnlyList <string> customTags = null,
     ImmutableDictionary <string, string> properties = null) :
     this(
         id, category, message, enuMessageForBingSearch,
         severity, severity, isEnabledByDefault, warningLevel,
         customTags ?? ImmutableArray <string> .Empty, properties ?? ImmutableDictionary <string, string> .Empty,
         workspace, projectId, location, additionalLocations, title, description, helpLink, isSuppressed)
 {
 }
Ejemplo n.º 5
0
        public DiagnosticData(
            string id,
            string category,
            string message,
            string enuMessageForBingSearch,
            DiagnosticSeverity severity,
            DiagnosticSeverity defaultSeverity,
            bool isEnabledByDefault,
            int warningLevel,
            IReadOnlyList <string> customTags,
            ImmutableDictionary <string, string> properties,
            Workspace workspace,
            ProjectId projectId,
            DiagnosticDataLocation location = null,
            IReadOnlyCollection <DiagnosticDataLocation> additionalLocations = null,
            string title       = null,
            string description = null,
            string helpLink    = null,
            bool isSuppressed  = false)
        {
            this.Id       = id;
            this.Category = category;
            this.Message  = message;
            this.ENUMessageForBingSearch = enuMessageForBingSearch;

            this.Severity           = severity;
            this.DefaultSeverity    = defaultSeverity;
            this.IsEnabledByDefault = isEnabledByDefault;
            this.WarningLevel       = warningLevel;
            this.CustomTags         = customTags;
            this.Properties         = properties;

            this.Workspace           = workspace;
            this.ProjectId           = projectId;
            this.DataLocation        = location;
            this.AdditionalLocations = additionalLocations;

            this.Title        = title;
            this.Description  = description;
            this.HelpLink     = helpLink;
            this.IsSuppressed = isSuppressed;
        }