Clean query visitor text merging

This commit is contained in:
Mathieu Darse
2015-02-24 22:03:30 +01:00
parent fe7e63b3d7
commit dfc386cce1

View File

@@ -167,11 +167,9 @@ class QueryVisitor implements Visit
$root = new AST\TextNode($root->getValue(), $node); $root = new AST\TextNode($root->getValue(), $node);
continue; continue;
} }
// Merge text nodes together, but not with quoted ones // Merge text nodes together (quoted nodes do not)
if ($root instanceof AST\TextNode && if ($root instanceof AST\TextNode &&
$node instanceof AST\TextNode && $node instanceof AST\TextNode) {
!$root instanceof AST\QuotedTextNode &&
!$node instanceof AST\QuotedTextNode) {
// Prevent merge once a context is set // Prevent merge once a context is set
if ($root->hasContext()) { if ($root->hasContext()) {
throw new \Exception('Unexpected text node after context'); throw new \Exception('Unexpected text node after context');