Commit 0a3331d3 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque-ls] supress lint messages after error

An error can easily cause a lot of false positive lint messages, due to
unused variables, macros, etc. Thus we suppress subsequent lint messages
when there are errors.

Bug: v8:8880
Change-Id: I5c8ba89312b8eacb7ab22523677854bf9fe45da6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1789160
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64217}
parent 364bcdf2
......@@ -87,6 +87,8 @@ void ResetCompilationErrorDiagnostics(MessageWriter writer) {
class DiagnosticCollector {
public:
void AddTorqueMessage(const TorqueMessage& message) {
if (!ShouldAddMessageOfKind(message.kind)) return;
SourceId id =
message.position ? message.position->source : SourceId::Invalid();
auto& notification = GetOrCreateNotificationForSource(id);
......@@ -120,6 +122,20 @@ class DiagnosticCollector {
return notification;
}
bool ShouldAddMessageOfKind(TorqueMessage::Kind kind) {
// An error can easily cause a lot of false positive lint messages, due to
// unused variables, macros, etc. Thus we suppress subsequent lint messages
// when there are errors.
switch (kind) {
case TorqueMessage::Kind::kError:
suppress_lint_messages_ = true;
return true;
case TorqueMessage::Kind::kLint:
if (suppress_lint_messages_) return false;
return true;
}
}
void PopulateRangeFromSourcePosition(Range range,
const SourcePosition& position) {
range.start().set_line(position.start.line);
......@@ -138,6 +154,7 @@ class DiagnosticCollector {
}
std::map<SourceId, PublishDiagnosticsNotification> notifications_;
bool suppress_lint_messages_ = false;
};
void SendCompilationDiagnostics(const TorqueCompilerResult& result,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment