Example #1
0
        /// <summary>
        /// Creates diagnostic for specific node.
        /// </summary>
        public static Diagnostic CreateDiagnosticForNode([NotNull] INode node, [NotNull] IDiagnosticMessage message, params object[] args)
        {
            var sourceFile = NodeStructureExtensions.GetSourceFile(node);
            var span       = DiagnosticUtilities.GetErrorSpanForNode(sourceFile, node);

            return(CreateFileDiagnostic(sourceFile, span.Start, span.Length, message, args));
        }
Example #2
0
        /// <summary>
        /// Creates diagnostic for specific node with a message chain.
        /// </summary>
        public static Diagnostic CreateDiagnosticForNodeFromMessageChain([NotNull] INode node, [NotNull] DiagnosticMessageChain messageChain)
        {
            var sourceFile = NodeStructureExtensions.GetSourceFile(node);
            var span       = DiagnosticUtilities.GetErrorSpanForNode(sourceFile, node);

            Message message = messageChain.Next != null ? messageChain : (Message)messageChain.MessageText;

            return(new Diagnostic(
                       sourceFile,
                       span.Start,
                       span.Length,
                       message,
                       messageChain.Category,
                       messageChain.Code));
        }