Exemplo n.º 1
0
 /// <nodoc />
 public DiagnosticMessageChain(string messageText, DiagnosticCategory category, int code, DiagnosticMessageChain next)
 {
     MessageText = messageText;
     Category    = category;
     Code        = code;
     Next        = next;
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override string ToString()
        {
            if (m_message != null)
            {
                return(m_message);
            }

            // see flattenDiagnosticMessageText from program.ts to see similar implementation
            DiagnosticMessageChain chain = m_messageChain;
            int indent  = 0;
            var builder = new StringBuilder();

            while (chain != null)
            {
                if (indent != 0)
                {
                    builder.AppendLine();
                    builder.Append(new string(' ', indent * 2));
                }

                builder.Append(chain.MessageText);
                indent++;
                chain = chain.Next;
            }

            return(builder.ToString());
        }
Exemplo n.º 3
0
        /// <nodoc />
        public static DiagnosticMessageChain ChainDiagnosticMessages(DiagnosticMessageChain details, IDiagnosticMessage message,
                                                                     params object[] args)
        {
            var text = GetLocaleSpecificMessage(message);

            // arguments is a JavaScript concept!
            if (args?.Length > 0)
            {
                text = FormatStringFromArgs(text, args);
            }

            return(new DiagnosticMessageChain(text, message.Category, message.Code, details));
        }
Exemplo n.º 4
0
        /// <nodoc />
        public static DiagnosticMessageChain ConcatenateDiagnosticMessageChains(
            DiagnosticMessageChain headChain,
            DiagnosticMessageChain tailChain)
        {
            var lastChain = headChain;

            while (lastChain.Next != null)
            {
                lastChain = lastChain.Next;
            }

            lastChain.Next = tailChain;
            return(headChain);
        }
Exemplo n.º 5
0
 private Message(DiagnosticMessageChain messageChain)
 {
     Contract.Requires(messageChain != null);
     m_messageChain = messageChain;
 }
Exemplo n.º 6
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));
        }