コード例 #1
0
        private static MessageSinkFromDelegate ToMessageSink(IVsGeneratorProgress progressCallback)
        {
            var sink = new MessageSinkFromDelegate(
                (Symbol severity, object context, string message, object[] args) =>
            {
                if (MessageSink.GetSeverity(severity) >= MessageSink.GetSeverity(MessageSink.Warning))
                {
                    int line = 0, col = 0;
                    if (context is LNode)
                    {
                        var range = ((LNode)context).Range;
                        line      = range.Begin.Line;
                        col       = range.Begin.PosInLine;
                    }
                    progressCallback.GeneratorError(severity == MessageSink.Warning ? 1 : 0, 0u,
                                                    Localize.From(message, args), (uint)line - 1u, (uint)col);
                }
                else
                {
                    MessageSink.Console.Write(severity, context, message, args);
                }
            });

            return(sink);
        }
コード例 #2
0
ファイル: BasicSinks.cs プロジェクト: dadhi/ecsharp
        public void WriteCore(Severity type, object context, string text)
        {
            string loc = MessageSink.ContextToString(context);

            if (!string.IsNullOrEmpty(loc))
            {
                text = loc + ": " + text;
            }
            Trace.WriteLine(text, type.ToString());
        }
コード例 #3
0
ファイル: BasicSinks.cs プロジェクト: dadhi/ecsharp
        public static void WriteColoredMessage(ConsoleColor color, object context, string text)
        {
            string loc = MessageSink.ContextToString(context);

            if (!string.IsNullOrEmpty(loc))
            {
                Console.Write(loc + ": ");
            }

            ConsoleColor oldColor = Console.ForegroundColor;

            Console.ForegroundColor = color;
            Console.WriteLine(text);
            Console.ForegroundColor = oldColor;
        }
コード例 #4
0
        void WriteCore(Severity type, object context, string text)
        {
            string loc = MessageSink.LocationString(context);

            if (!string.IsNullOrEmpty(loc))
            {
                Console.Write(loc + ": ");
            }

            string       typeText;
            ConsoleColor oldColor = Console.ForegroundColor;

            Console.ForegroundColor = PickColor(type, out typeText);
            if (typeText != null)
            {
                text = typeText + ": " + text;
            }
            Console.WriteLine(text);
            Console.ForegroundColor = oldColor;
        }
コード例 #5
0
 public override string ToString()
 {
     return(MessageSink.FormatMessage(Severity, Context, Format, _args));
 }