提交 b9475230 编写于 作者: H Heejae Chang

make us to accept project level build errors as well.

previously we rejected those and let project system to deal with it.

with this change, we will show code for those errors if possible as well.
上级 ad5b1bb4
......@@ -99,7 +99,8 @@ public async Task<AnalysisResult> GetAnalysisDataAsync(Project project, bool avo
if (!await TryDeserializeAsync(serializer, project, project.Id, _owner.NonLocalStateName, builder.AddOthers, cancellationToken).ConfigureAwait(false))
{
Contract.Requires(false, "How this can happen?");
// this can happen if SaveAsync is not yet called but active file merge happened. one of case is if user did build before the very first
// analysis happened.
}
return builder.ToResult();
......
......@@ -320,6 +320,18 @@ private void ClearDocumentErrors(ProjectId projectId, DocumentId documentId)
RaiseDiagnosticsRemoved(documentId, projectId, documentId);
}
public void AddNewErrors(ProjectId projectId, DiagnosticData diagnostic)
{
// capture state that will be processed in background thread.
var state = GetOrCreateInprogressState();
var asyncToken = _listener.BeginAsyncOperation("Project New Errors");
_taskQueue.ScheduleTask(() =>
{
state.AddError(projectId, diagnostic);
}).CompletesAsyncOperation(asyncToken);
}
public void AddNewErrors(DocumentId documentId, DiagnosticData diagnostic)
{
// capture state that will be processed in background thread.
......@@ -467,6 +479,11 @@ public void AddError(DocumentId key, DiagnosticData diagnostic)
AddError(_documentMap, key, diagnostic);
}
public void AddError(ProjectId key, DiagnosticData diagnostic)
{
AddError(_projectMap, key, diagnostic);
}
private void AddErrors<T>(Dictionary<T, HashSet<DiagnosticData>> map, T key, HashSet<DiagnosticData> diagnostics)
{
var errors = GetErrorSet(map, key);
......
......@@ -141,21 +141,6 @@ public void ReportError2(string bstrErrorMessage, string bstrErrorId, [ComAliasN
throw new ArgumentException(ServicesVSResources.EndPositionMustBeGreaterThanStart);
}
// We only handle errors that have positions. For the rest, we punt back to the
// project system.
if (iStartLine < 0 || iStartColumn < 0)
{
throw new NotImplementedException();
}
var hostProject = _workspace.GetHostProject(_projectId);
if (!hostProject.ContainsFile(bstrFileName))
{
throw new NotImplementedException();
}
var hostDocument = hostProject.GetCurrentDocumentFromPath(bstrFileName);
var priority = (VSTASKPRIORITY)nPriority;
DiagnosticSeverity severity;
switch (priority)
......@@ -173,6 +158,34 @@ public void ReportError2(string bstrErrorMessage, string bstrErrorId, [ComAliasN
throw new ArgumentException(ServicesVSResources.NotAValidValue, nameof(nPriority));
}
// We only handle errors that have positions. For the rest, we punt back to the
// project system.
if (iStartLine < 0 || iStartColumn < 0)
{
// we now takes care of errors that is not belong to file as well.
var projectDiagnostic = GetDiagnosticData(
null, bstrErrorId, bstrErrorMessage, severity,
null, 0, 0, 0, 0,
bstrFileName, 0, 0, 0, 0);
_diagnosticProvider.AddNewErrors(_projectId, projectDiagnostic);
return;
}
var hostProject = _workspace.GetHostProject(_projectId);
if (!hostProject.ContainsFile(bstrFileName))
{
var projectDiagnostic = GetDiagnosticData(
null, bstrErrorId, bstrErrorMessage, severity,
null, iStartLine, iStartColumn, iEndLine, iEndColumn,
bstrFileName, iStartLine, iStartColumn, iEndLine, iEndColumn);
_diagnosticProvider.AddNewErrors(_projectId, projectDiagnostic);
return;
}
var hostDocument = hostProject.GetCurrentDocumentFromPath(bstrFileName);
var diagnostic = GetDiagnosticData(
hostDocument.Id, bstrErrorId, bstrErrorMessage, severity,
null, iStartLine, iStartColumn, iEndLine, iEndColumn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册