|
2 | 2 |
|
3 | 3 | namespace Phug\Tester; |
4 | 4 |
|
5 | | -use Phug\Formatter\ElementInterface; |
| 5 | +use Phug\Ast\NodeInterface as AstNodeInterface; |
6 | 6 | use Phug\Parser\Node\DocumentNode; |
7 | 7 | use Phug\Parser\NodeInterface; |
8 | 8 | use Phug\Renderer; |
@@ -279,24 +279,25 @@ protected function recordLocation(SourceLocationInterface $location = null, int |
279 | 279 | } |
280 | 280 | } |
281 | 281 |
|
282 | | - protected function listNodes(SplObjectStorage $list, ElementInterface $element) |
| 282 | + protected function listNodes(SplObjectStorage $list, $node) |
283 | 283 | { |
284 | | - $node = $element->getOriginNode(); |
285 | | - if ($node && !($node instanceof DocumentNode)) { |
| 284 | + if ($node instanceof NodeInterface && !($node instanceof DocumentNode) && !$list->offsetExists($node)) { |
286 | 285 | $list->attach($node); |
287 | 286 | $this->recordLocation($node->getSourceLocation()); |
288 | 287 | } |
289 | | - |
290 | | - foreach ($element->getChildren() as $child) { |
291 | | - if ($child instanceof ElementInterface) { |
292 | | - static::listNodes($list, $child); |
| 288 | + if ($node instanceof AstNodeInterface) { |
| 289 | + foreach ($node->getChildren() as $child) { |
| 290 | + $this->listNodes($list, $child); |
293 | 291 | } |
294 | 292 | } |
295 | 293 | } |
296 | 294 |
|
297 | 295 | protected function countFileNodes(string $file): int |
298 | 296 | { |
299 | | - $document = $this->renderer->getCompiler()->compileFileIntoElement($file); |
| 297 | + $compiler = $this->renderer->getCompiler(); |
| 298 | + $file = $compiler->resolve($file); |
| 299 | + $contents = $compiler->getFileContents($file); |
| 300 | + $document = $this->renderer->getCompiler()->getParser()->parse($contents); |
300 | 301 | $list = new SplObjectStorage(); |
301 | 302 |
|
302 | 303 | $this->listNodes($list, $document); |
|
0 commit comments