本文整理汇总了PHP中ArcanistLintMessage::setOriginalText方法的典型用法代码示例。如果您正苦于以下问题:PHP ArcanistLintMessage::setOriginalText方法的具体用法?PHP ArcanistLintMessage::setOriginalText怎么用?PHP ArcanistLintMessage::setOriginalText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArcanistLintMessage
的用法示例。
在下文中一共展示了ArcanistLintMessage::setOriginalText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$report_dom = new DOMDocument();
$ok = @$report_dom->loadXML($stdout);
if (!$ok) {
return false;
}
$files = $report_dom->getElementsByTagName('file');
$messages = array();
foreach ($files as $file) {
foreach ($file->childNodes as $child) {
if (!$child instanceof DOMElement) {
continue;
}
$data = $this->getData($path);
$lines = explode("\n", $data);
$name = $child->getAttribute('reason');
$severity = $child->getAttribute('severity') == 'warning' ? ArcanistLintSeverity::SEVERITY_WARNING : ArcanistLintSeverity::SEVERITY_ERROR;
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($child->getAttribute('line'));
$message->setChar($child->getAttribute('char'));
$message->setCode('CSSLint');
$message->setDescription($child->getAttribute('reason'));
$message->setSeverity($severity);
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
$line = $lines[$child->getAttribute('line') - 1];
$text = substr($line, $child->getAttribute('char') - 1);
$message->setOriginalText($text);
}
$messages[] = $message;
}
}
return $messages;
}
示例2: newFromDictionary
public static function newFromDictionary(array $dict)
{
$message = new ArcanistLintMessage();
$message->setPath($dict['path']);
$message->setLine($dict['line']);
$message->setChar($dict['char']);
$message->setCode($dict['code']);
$message->setSeverity($dict['severity']);
$message->setName($dict['name']);
$message->setDescription($dict['description']);
if (isset($dict['original'])) {
$message->setOriginalText($dict['original']);
}
if (isset($dict['replacement'])) {
$message->setReplacementText($dict['replacement']);
}
return $message;
}
示例3: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$json = phutil_json_decode($stdout);
$messages = array();
foreach ($json as $fix) {
if ($fix === null) {
return;
}
$message = new ArcanistLintMessage();
$message->setCode($this->getLinterName());
$message->setPath($path);
$message->setLine($fix['startLine']);
$message->setChar($fix['startColumn']);
$message->setName($fix['hint']);
$message->setOriginalText($fix['from']);
$message->setReplacementText($fix['to']);
/* Some improvements may slightly change semantics, so attach
all necessary notes too. */
$notes = '';
foreach ($fix['note'] as $note) {
$notes .= ' **NOTE**: ' . trim($note, '"') . '.';
}
$message->setDescription(pht('In module `%s`, declaration `%s`.%s', $fix['module'], $fix['decl'], $notes));
switch ($fix['severity']) {
case 'Error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
case 'Warning':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
break;
}
$messages[] = $message;
}
return $messages;
}
示例4: newFromDictionary
public static function newFromDictionary(array $dict)
{
$message = new ArcanistLintMessage();
$message->setPath($dict['path']);
$message->setLine($dict['line']);
$message->setChar($dict['char']);
$message->setCode($dict['code']);
$message->setSeverity($dict['severity']);
$message->setName($dict['name']);
$message->setDescription($dict['description']);
if (isset($dict['original'])) {
$message->setOriginalText($dict['original']);
}
if (isset($dict['replacement'])) {
$message->setReplacementText($dict['replacement']);
}
$message->setGranularity(idx($dict, 'granularity'));
$message->setOtherLocations(idx($dict, 'locations', array()));
if (isset($dict['bypassChangedLineFiltering'])) {
$message->bypassChangedLineFiltering($dict['bypassChangedLineFiltering']);
}
return $message;
}
示例5: resolveFuture
protected function resolveFuture(Future $future)
{
list($stdout) = $future->resolvex();
$all_results = json_decode($stdout);
foreach ($all_results as $results) {
if ($results === null || $results->Issues === null) {
return;
}
foreach ($results->Issues as $issue) {
$message = new ArcanistLintMessage();
$message->setPath($results->FileName);
$message->setLine($issue->LineNumber);
$message->setCode($issue->Index->Code);
$message->setName($issue->Index->Name);
$message->setChar($issue->Column);
$message->setOriginalText($issue->OriginalText);
$message->setReplacementText($issue->ReplacementText);
$desc = @vsprintf($issue->Index->Message, $issue->Parameters);
if ($desc === false) {
$desc = $issue->Index->Message;
}
$message->setDescription($desc);
$severity = ArcanistLintSeverity::SEVERITY_ADVICE;
switch ($issue->Index->Severity) {
case 0:
$severity = ArcanistLintSeverity::SEVERITY_ADVICE;
break;
case 1:
$severity = ArcanistLintSeverity::SEVERITY_AUTOFIX;
break;
case 2:
$severity = ArcanistLintSeverity::SEVERITY_WARNING;
break;
case 3:
$severity = ArcanistLintSeverity::SEVERITY_ERROR;
break;
case 4:
$severity = ArcanistLintSeverity::SEVERITY_DISABLED;
break;
}
$severity_override = $this->getLintMessageSeverity($issue->Index->Code);
if ($severity_override !== null) {
$severity = $severity_override;
}
$message->setSeverity($severity);
$this->addLintMessage($message);
}
}
}
示例6: lintPath
public function lintPath($path)
{
list($rc, $stdout) = $this->results[$path];
$report = Filesystem::readFile($this->reports[$path]);
if ($report) {
$report_dom = new DOMDocument();
libxml_clear_errors();
$report_dom->loadXML($report);
}
if (!$report || libxml_get_errors()) {
throw new ArcanistUsageException('PHPCS Linter failed to load ' . 'reporting file. Something happened when running phpcs. ' . "Output:\n{$stdout}" . "\nTry running lint with --trace flag to get more details.");
}
$files = $report_dom->getElementsByTagName('file');
foreach ($files as $file) {
foreach ($file->childNodes as $child) {
if (!$child instanceof DOMElement) {
continue;
}
$data = $this->getData($path);
$lines = explode("\n", $data);
$line = $lines[$child->getAttribute('line') - 1];
$text = substr($line, $child->getAttribute('column') - 1);
$name = $this->getLinterName() . ' - ' . $child->getAttribute('source');
$severity = $child->tagName == 'error' ? ArcanistLintSeverity::SEVERITY_ERROR : ArcanistLintSeverity::SEVERITY_WARNING;
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($child->getAttribute('line'));
$message->setChar($child->getAttribute('column'));
$message->setCode($child->getAttribute('severity'));
$message->setName($name);
$message->setDescription($child->nodeValue);
$message->setSeverity($severity);
$message->setOriginalText($text);
$this->addLintMessage($message);
}
}
}
示例7: parseLinterOutput
protected function parseLinterOutput($path, $err, $stdout, $stderr)
{
$messages = array();
if (strlen($stdout) == 0) {
return $messages;
}
$matches = explode("\n", $stdout, 2);
if (count($matches) < 2) {
return $messages;
}
$description = $matches[0];
$diff = $matches[1];
if (strlen($diff) == 0) {
return $messages;
}
$parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($diff);
foreach ($changes as $change) {
foreach ($change->getHunks() as $hunk) {
$repl = array();
$orig = array();
$lines = phutil_split_lines($hunk->getCorpus(), false);
foreach ($lines as $line) {
$char = strlen($line) ? $line[0] : '~';
$rest = strlen($line) == 1 ? '' : substr($line, 1);
switch ($char) {
case '-':
$orig[] = $rest;
break;
case '+':
$repl[] = $rest;
break;
case '~':
break;
case ' ':
$orig[] = $rest;
$repl[] = $rest;
break;
}
}
$replacementText = join("\n", $repl);
$originalText = join("\n", $orig);
// print("\n-orig------------------------\n");
// print($originalText);
// print("\n-repl------------------------\n");
// print($replacementText);
// print("\n-------------------------\n");
$message = new ArcanistLintMessage();
$message->setPath($path);
$message->setLine($hunk->getOldOffset());
$message->setChar(1);
$message->setCode('Improper imports');
$message->setName('ISORT');
// $message->setSeverity(ArcanistLintSeverity::SEVERITY_AUTOFIX);
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
$message->setReplacementText($replacementText);
$message->setOriginalText($originalText);
$messages[] = $message;
}
}
if ($err && !$messages) {
return false;
}
return $messages;
}