4
* Message emitted by a linter, like an error or warning.
6
final class ArcanistLintMessage {
14
protected $description;
15
protected $originalText;
16
protected $replacementText;
17
protected $appliedToDisk;
18
protected $dependentMessages = array();
19
protected $otherLocations = array();
21
protected $granularity;
22
protected $bypassChangedLineFiltering;
24
public static function newFromDictionary(array $dict) {
25
$message = new ArcanistLintMessage();
27
$message->setPath($dict['path']);
28
$message->setLine($dict['line']);
29
$message->setChar($dict['char']);
30
$message->setCode($dict['code']);
31
$message->setSeverity($dict['severity']);
32
$message->setName($dict['name']);
33
$message->setDescription($dict['description']);
34
if (isset($dict['original'])) {
35
$message->setOriginalText($dict['original']);
37
if (isset($dict['replacement'])) {
38
$message->setReplacementText($dict['replacement']);
40
$message->setGranularity(idx($dict, 'granularity'));
41
$message->setOtherLocations(idx($dict, 'locations', array()));
42
if (isset($dict['bypassChangedLineFiltering'])) {
43
$message->bypassChangedLineFiltering($dict['bypassChangedLineFiltering']);
48
public function toDictionary() {
50
'path' => $this->getPath(),
51
'line' => $this->getLine(),
52
'char' => $this->getChar(),
53
'code' => $this->getCode(),
54
'severity' => $this->getSeverity(),
55
'name' => $this->getName(),
56
'description' => $this->getDescription(),
57
'original' => $this->getOriginalText(),
58
'replacement' => $this->getReplacementText(),
59
'granularity' => $this->getGranularity(),
60
'locations' => $this->getOtherLocations(),
61
'bypassChangedLineFiltering' => $this->shouldBypassChangedLineFiltering(),
65
public function setPath($path) {
70
public function getPath() {
74
public function setLine($line) {
79
public function getLine() {
83
public function setChar($char) {
88
public function getChar() {
92
public function setCode($code) {
97
public function getCode() {
101
public function setSeverity($severity) {
102
$this->severity = $severity;
106
public function getSeverity() {
107
return $this->severity;
110
public function setName($name) {
115
public function getName() {
119
public function setDescription($description) {
120
$this->description = $description;
124
public function getDescription() {
125
return $this->description;
128
public function setOriginalText($original) {
129
$this->originalText = $original;
133
public function getOriginalText() {
134
return $this->originalText;
137
public function setReplacementText($replacement) {
138
$this->replacementText = $replacement;
142
public function getReplacementText() {
143
return $this->replacementText;
147
* @param dict Keys 'path', 'line', 'char', 'original'.
149
public function setOtherLocations(array $locations) {
150
assert_instances_of($locations, 'array');
151
$this->otherLocations = $locations;
155
public function getOtherLocations() {
156
return $this->otherLocations;
159
public function isError() {
160
return $this->getSeverity() == ArcanistLintSeverity::SEVERITY_ERROR;
163
public function isWarning() {
164
return $this->getSeverity() == ArcanistLintSeverity::SEVERITY_WARNING;
167
public function isAutofix() {
168
return $this->getSeverity() == ArcanistLintSeverity::SEVERITY_AUTOFIX;
171
public function hasFileContext() {
172
return ($this->getLine() !== null);
175
public function setObsolete($obsolete) {
176
$this->obsolete = $obsolete;
180
public function getObsolete() {
181
return $this->obsolete;
184
public function isPatchable() {
185
return ($this->getReplacementText() !== null) &&
186
($this->getReplacementText() !== $this->getOriginalText());
189
public function didApplyPatch() {
190
if ($this->appliedToDisk) {
193
$this->appliedToDisk = true;
194
foreach ($this->dependentMessages as $message) {
195
$message->didApplyPatch();
200
public function isPatchApplied() {
201
return $this->appliedToDisk;
204
public function setGranularity($granularity) {
205
$this->granularity = $granularity;
209
public function getGranularity() {
210
return $this->granularity;
213
public function setDependentMessages(array $messages) {
214
assert_instances_of($messages, 'ArcanistLintMessage');
215
$this->dependentMessages = $messages;
219
public function setBypassChangedLineFiltering($bypass_changed_lines) {
220
$this->bypassChangedLineFiltering = $bypass_changed_lines;
224
public function shouldBypassChangedLineFiltering() {
225
return $this->bypassChangedLineFiltering;