Coverage Report

Created: 2021-06-15 06:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/tools/lldb-vscode/ProgressEvent.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ProgressEvent.cpp ---------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "VSCodeForward.h"
10
11
#include "llvm/Support/JSON.h"
12
13
namespace lldb_vscode {
14
15
enum ProgressEventType {
16
  progressInvalid,
17
  progressStart,
18
  progressUpdate,
19
  progressEnd
20
};
21
22
class ProgressEvent {
23
public:
24
0
  ProgressEvent() {}
25
26
  ProgressEvent(uint64_t progress_id, const char *message, uint64_t completed,
27
                uint64_t total);
28
29
  llvm::json::Value ToJSON() const;
30
31
  /// This operator returns \b true if two event messages
32
  /// would result in the same event for the IDE, e.g.
33
  /// same rounded percentage.
34
  bool operator==(const ProgressEvent &other) const;
35
36
  const char *GetEventName() const;
37
38
  bool IsValid() const;
39
40
  uint64_t GetID() const;
41
42
private:
43
  uint64_t m_progress_id;
44
  const char *m_message;
45
  ProgressEventType m_event_type;
46
  llvm::Optional<uint32_t> m_percentage;
47
};
48
49
/// Class that filters out progress event messages that shouldn't be reported
50
/// to the IDE, either because they are invalid or because they are too chatty.
51
class ProgressEventFilterQueue {
52
public:
53
  ProgressEventFilterQueue(std::function<void(ProgressEvent)> callback);
54
55
  void Push(const ProgressEvent &event);
56
57
private:
58
  std::function<void(ProgressEvent)> m_callback;
59
  std::map<uint64_t, ProgressEvent> m_last_events;
60
};
61
62
} // namespace lldb_vscode