Пример #1
0
 private void TryResolveMissingInfo(CompilerLogItem item)
 {
     try
     {
         if (item.Line == 0 && item.Column == 0)
         {
             if (item.Entity != null && item.Entity.Region != null)
             {
                 item.Line   = item.Entity.Region.BeginLine;
                 item.Column = item.Entity.Region.BeginColumn;
             }
             else if (item.Node != null && item.Node.StartLocation != null)
             {
                 item.Line   = item.Node.StartLocation.Line;
                 item.Column = item.Node.StartLocation.Column;
             }
         }
         if (item.ProjectRelativeFilename == null && item.AbsoluteFilename == null)
         {
             if (item.Node != null)
             {
                 item.ProjectRelativeFilename = item.Node.GetFileName();
             }
             else if (item.Entity != null && item.Entity.Region != null)
             {
                 item.ProjectRelativeFilename = item.Entity.Region.FileName;
             }
             if (item.ProjectRelativeFilename.IsNotNullOrEmpty())
             {
                 item.AbsoluteFilename = Path.GetFullPath(item.ProjectRelativeFilename);
             }
         }
     }
     catch
     {
     }
 }
Пример #2
0
        public void Log(CompilerLogItem item)
        {
            if (item == null)
            {
                return;
            }
            TryResolveMissingInfo(item);
            Items.Enqueue(item);
            var sb = new StringBuilder();

            if (item.ProjectRelativeFilename.IsNotNullOrEmpty())
            {
                sb.AppendFormat("{0}", item.ProjectRelativeFilename);
            }
            if (item.Line > 0 && item.Column > 0)
            {
                sb.AppendFormat("({0},{1})", item.Line, item.Column);
            }
            if (item.ProjectRelativeFilename.IsNotNullOrEmpty() || (item.Line > 0 && item.Column > 0))
            {
                sb.Append(": ");
            }

            sb.AppendFormat("{0} {1}{2}: {3}", item.Type.ToString().ToLower(), "SK", item.Code.ToString("0000"), item.Text);
            if (item.AbsoluteFilename.IsNotNullOrEmpty())
            {
                sb.AppendFormat(" [{0}]", item.AbsoluteFilename);
            }
            var ss = sb.ToString();

            Console.WriteLine(ss);
            if (CompilerConfig.Current.EnableLogging)
            {
                Debug(ss);
            }
        }
Пример #3
0
 protected override void ParseCsFiles()
 {
     base.ParseCsFiles();
     if (!CSharpParser.HasErrors)
     {
         return;
     }
     foreach (var error in CSharpParser.ErrorsAndWarnings)
     {
         var item = new CompilerLogItem
         {
             ProjectRelativeFilename = error.Region.FileName,
             Line   = error.Region.BeginLine,
             Column = error.Region.BeginColumn,
             Text   = error.Message,
             Type   = CompilerLogItemType.Error,
         };
         if (error.ErrorType == ErrorType.Warning)
         {
             item.Type = CompilerLogItemType.Warning;
         }
         Compiler.Log.Log(item);
     }
 }