Page MenuHomePhabricator

D14107.diff
No OneTemporary

D14107.diff

diff --git a/src/parser/aast/api/AASTNode.php b/src/parser/aast/api/AASTNode.php
--- a/src/parser/aast/api/AASTNode.php
+++ b/src/parser/aast/api/AASTNode.php
@@ -254,11 +254,10 @@
public function getIndentation() {
$tokens = $this->getTokens();
- $left = head($tokens);
+ $head = head($tokens);
+ $left = $head;
- while ($left &&
- (!$left->isAnyWhitespace() ||
- strpos($left->getValue(), "\n") === false)) {
+ while ($left && strpos($left->getValue(), "\n") === false) {
$left = $left->getPrevToken();
}
@@ -266,7 +265,17 @@
return null;
}
- return preg_replace("/^.*\n/s", '', $left->getValue());
+ $next = $left;
+ while ($next->getTokenID() != $head->getTokenID() &&
+ !$next->isAnyWhitespace()) {
+ $next = $next->getNextToken();
+ }
+
+ if ($next->getTokenID() == $head->getTokenID()) {
+ return null;
+ }
+
+ return str_replace("\n", '', $next->getValue());
}
public function getDescription() {

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 5, 7:19 PM (16 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6830593
Default Alt Text
D14107.diff (1 KB)

Event Timeline