public override void ReportErrors(Microsoft.Cci.ErrorEventArgs errorEventArguments) { this.SynchronousReportErrors(errorEventArguments); }
/// <summary> /// Raises the CompilationErrors event with the given error wrapped up in an error event arguments object. /// The event is raised on a separate thread. /// </summary> /// <param name="error">The error to report.</param> public void ReportError(IErrorMessage error) { if (this.Errors != null) { List<IErrorMessage> errors = new List<IErrorMessage>(1); errors.Add(error); Microsoft.Cci.ErrorEventArgs errorEventArguments = new Microsoft.Cci.ErrorEventArgs(error.ErrorReporter, error.Location, errors.AsReadOnly()); this.ReportErrors(errorEventArguments); } }
internal 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 (!error.IsWarning) { hasError = true; } 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) { Console.Out.WriteLine(error.Message); continue; } string docName = primarySourceLocation.SourceDocument.Name.Value; int startLine = primarySourceLocation.StartLine; int startColumn = primarySourceLocation.StartColumn; int endLine = primarySourceLocation.EndLine; int endColumn = primarySourceLocation.EndColumn; IncludedSourceLocation /*?*/ includedSourceLocation = primarySourceLocation as IncludedSourceLocation; if (includedSourceLocation != null) { docName = includedSourceLocation.OriginalSourceDocumentName; startLine = includedSourceLocation.OriginalStartLine; endLine = includedSourceLocation.OriginalEndLine; } if (!displayFileName) { docName = ""; } Console.Out.WriteLine("{6}({0},{1})-({2},{3}): {4}: {5}", startLine, startColumn, endLine, endColumn, error.IsWarning ? "warning" : "error", error.Message, docName); 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.Name.Value; startLine = primarySourceLocation.StartLine; startColumn = primarySourceLocation.StartColumn; endLine = primarySourceLocation.EndLine; endColumn = primarySourceLocation.EndColumn; includedSourceLocation = primarySourceLocation as IncludedSourceLocation; if (includedSourceLocation != null) { docName = includedSourceLocation.OriginalSourceDocumentName; startLine = includedSourceLocation.OriginalStartLine; endLine = includedSourceLocation.OriginalEndLine; } Console.Out.WriteLine("({0},{1})-({2},{3}): (Location of symbol related to previous {4}.)", startLine, startColumn, endLine, endColumn, error.IsWarning ? "warning" : "error"); } //TODO: deal with non source locations } } }