Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14151172
D14107.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14107.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D14107: Fix wrong indentation returned by AASTNode::getIndentation() when calling it on a statement node that is preceded by a comment token.
Attached
Detach File
Event Timeline
Log In to Comment