示例#1
0
        public void HandleErrors(object sender, Microsoft.Cci.ErrorEventArgs args)
        {
            foreach (IErrorMessage error in args.Errors)
            {
                ISourceLocation /*?*/ sourceLocation = error.Location as ISourceLocation;
                if (sourceLocation == null)
                {
                    continue;
                }
                if (this.DebugOnWarningOrError)
                {
                    System.Diagnostics.Debugger.Launch();
                }
                bool isError = !error.IsWarning || WarningsAsErrors;
                if (!isError && GetWarningLevel(error.Code) > WarningLevel)
                {
                    continue;
                }
                if (isError)
                {
                    VccCommandLineHost.IncreaseErrorCount();
                }
                CompositeSourceDocument /*?*/ compositeDocument = sourceLocation.SourceDocument as CompositeSourceDocument;
                if (compositeDocument != null)
                {
                    foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sourceLocation))
                    {
                        sourceLocation = sl;
                        break;
                    }
                }
                IPrimarySourceLocation /*?*/ primarySourceLocation = sourceLocation as IPrimarySourceLocation;
                if (primarySourceLocation == null)
                {
                    Logger.Instance.Error(error.Message);
                    continue;
                }
                string docName     = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                int    startLine   = primarySourceLocation.StartLine;
                int    startColumn = primarySourceLocation.StartColumn;
                IncludedSourceLocation /*?*/ includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                if (includedSourceLocation != null)
                {
                    docName = includedSourceLocation.OriginalSourceDocumentName;
                    if (docName != null)
                    {
                        docName = docName.Replace("\\\\", "\\");
                    }
                    startLine = includedSourceLocation.OriginalStartLine;
                }
                long id = error.IsWarning ? ErrorToId(error.Code) : error.Code;
                if (WarningIsDisabled(id))
                {
                    return;
                }

                Logger.Instance.LogWithLocation(String.Format("VC{0:0000}", id), error.Message, new Location(docName, startLine, startColumn), isError ? LogKind.Error : LogKind.Warning, false);

                string firstErrFile = docName;
                int    firstErrLine = startLine;

                foreach (ILocation relatedLocation in error.RelatedLocations)
                {
                    ISourceLocation /*?*/ sloc = relatedLocation as ISourceLocation;
                    if (sloc != null)
                    {
                        compositeDocument = sloc.SourceDocument as CompositeSourceDocument;
                        if (compositeDocument != null)
                        {
                            foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sloc))
                            {
                                sloc = sl;
                                break;
                            }
                        }
                        primarySourceLocation = sloc as IPrimarySourceLocation;
                        if (primarySourceLocation == null)
                        {
                            continue;
                        }
                        docName                = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                        startLine              = primarySourceLocation.StartLine;
                        startColumn            = primarySourceLocation.StartColumn;
                        includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                        if (includedSourceLocation != null)
                        {
                            docName = includedSourceLocation.OriginalSourceDocumentName;
                            if (docName != null)
                            {
                                docName = docName.Replace("\\\\", "\\");
                            }
                            startLine = includedSourceLocation.OriginalStartLine;
                        }
                        if (docName != firstErrFile || firstErrLine != startLine)
                        {
                            Logger.Instance.LogWithLocation(
                                null,
                                String.Format("(Location of symbol related to previous {0}.)", isError ? "error" : "warning"),
                                new Location(docName, startLine, startColumn),
                                isError ? LogKind.Error : LogKind.Warning,
                                true);
                        }
                    }
                    //TODO: deal with non source locations
                }
            }
        }
示例#2
0
文件: Host.cs 项目: tupipa/vcc
 public override void ReportErrors(Microsoft.Cci.ErrorEventArgs errorEventArguments)
 {
     this.SynchronousReportErrors(errorEventArguments);
 }
示例#3
0
 public void ReportErrors(ErrorEventArgs errorEventArguments)
 {
     Contract.Requires(errorEventArguments != null);
     throw new NotImplementedException();
 }