Parse a node to update the parent node model.

@param mixed         $node   The node to parse.
@param NodeInterface $parent The parent node.
424408
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Property || ! $parent instanceof TraitModelInterface) {
            throw new Exception('AttributeNodeParser is made to parse a property node');
        }
        $isStatic   = $node->isStatic();
        $visibility = AttributeVisibilityHelper::getVisibility($node);

        foreach ($node->props as $property) {
            $attribute = new AttributeModel();
            $attribute->setParentNode($parent);
            $attribute->setName($property->name);
            $attribute->setIsStatic($isStatic);
            $attribute->setVisibility($visibility);

            if ($property->default !== null) {
                $this->valueNodeParser->invoke($property->default, $attribute);
            }

            $parent->addAttribute($attribute);
        }
    }
815234
public function belongsTo(NodeInterface $node)
	{
		$this->masterNode = $node;
		$this->refresh();
		
		if ($node instanceof NodeLeafInterface) {
			$this->setLeafInterface(true);
		}
	}
1152512
public static function fromNode($node, $parent) {
        if (is_null($node["value"]))
            return new Feature($node, $parent, $node->children());
        else
            return new ValueFeature($node, $parent, $node->children());
    }
543311
public function handle(NodeInterface $node, array $data)
    {
        if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
            if (isset($data['title'])) {
                $node->setProperty('title', $data['title']);
            }
            $node->setProperty('uriPathSegment', $this->nodeUriPathSegmentGenerator->generateUriPathSegment($node, (isset($data['title']) ? $data['title'] : null)));
        }
    }
1055956
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Doc || ! $parent instanceof DocumentationInterface) {
            throw new Exception('DocumentationNodeParser is made to parse a documentation node');
        }

        $documentation = $node->getText();
        $parent->setDocumentation($documentation);

        $this->annotationParser->invoke($parent, $documentation);
    }
1004170
private function deleteNode( $node ) {
		$this->deleteChildren( $node );
		$parent = $node->parentNode;
		$oldnode = $parent->removeChild( $node );
	}
293564
public function setDefaultValues(NodeInterface $node)
    {
        $nodeType = $node->getNodeType();
        foreach ($nodeType->getDefaultValuesForProperties() as $propertyName => $defaultValue) {
            $value = $node->getProperty($propertyName);
            if ((is_scalar($value) && trim($value) === '') || $value === null) {
                $node->setProperty($propertyName, $defaultValue);
            }
        }
    }
1122131
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
    {
        $compiler = $this->getCompiler();
        $compiler->assert(
            $node instanceof ImportNode,
            'Unexpected '.get_class($node).' given to import compiler.',
            $node
        );

        /** @var ImportNode $node */
        $path = $node->getPath();
        $isAbsolutePath = mb_substr($path, 0, 1) === '/';

        $compiler->assert(
            !($isAbsolutePath && empty($compiler->getOption('paths'))),
            'Either the "basedir" or "paths" option is required'.
            ' to use includes and extends with "absolute" paths'
        );

        $paths = $isAbsolutePath
            ? null
            : [dirname($compiler->getPath()) ?: '.'];

        $path = $compiler->resolve($node->getPath(), $paths);
        $compiler->registerImportPath($path);

        /** @var FilterNode $filter */
        if ($filter = $node->getFilter()) {
            $text = new TextNode();
            $text->setValue($compiler->getFileContents($path));
            $filter->appendChild($text);
            $import = $filter->getImport();
            $filter->setImport(null);
            $element = $compiler->compileNode($filter, $parent);
            $filter->setImport($import);

            return $element;
        }

        if (!$this->isPugImport($path)) {
            return new TextElement($compiler->getFileContents($path), $node);
        }

        $subCompiler = clone $compiler;
        $subCompiler->setParentCompiler($compiler);
        $subCompiler->setImportNode($compiler->getImportNode() ?: $node);
        $element = $subCompiler->compileFileIntoElement($path);
        $compiler->importBlocks($subCompiler->getBlocks());
        $isIncludeImport = $node->getName() === 'include';

        if ($layout = $subCompiler->getLayout()) {
            $element = $layout->getDocument();
            $layoutCompiler = $layout->getCompiler();
            if ($isIncludeImport) {
                $layoutCompiler->compileBlocks();
            }
        }

        if (!$subCompiler->isImportNodeYielded()) {
            $yield = $element;
            while ($yield instanceof ElementInterface && $yield->hasChildren()) {
                $yield = $yield->getChildAt($yield->getChildCount() - 1);
            }
            while ($yield instanceof CodeElement ||
                $yield instanceof ExpressionElement ||
                $yield instanceof TextElement
            ) {
                if ($yield instanceof CodeElement &&
                    trim($yield->getValue(), '; ') === 'break' &&
                    $yield->getPreviousSibling()
                ) {
                    $yield = $yield->getPreviousSibling();

                    continue;
                }
                $yield = $yield->getParent();
            }
            if ($yield instanceof MarkupElement && in_array($yield->getName(), [
                'script',
                'link',
                'img',
                'input',
                'meta',
                'hr',
            ])) {
                $yield = $yield->getParent();
            }
            if ($compiler->getImportNode()) {
                $node->appendChild(new YieldNode());
            }
            // TODO: check answers on https://github.com/pugjs/pug/issues/2878
            $this->compileNodeChildren($node, $yield);
        }

        if ($isIncludeImport) {
            $parentLayout = $compiler->getLayout();
            if ($parentLayout) {
                $parentDocument = $parentLayout->getDocument();
                foreach ($element->getChildren() as $child) {
                    if ($child instanceof MixinElement) {
                        $parentDocument->appendChild(clone $child);
                    }
                }
            }

            return $element;
        }

        if ($node->getName() === 'extend') {
            $layout = new Layout($element, $subCompiler);
            $subDocument = $layout->getDocument();
            foreach ($node->getParent()->getChildren() as $child) {
                if ($child instanceof MixinNode) {
                    $mixinElement = $subCompiler->compileNode($child, $subDocument);
                    if ($mixinElement) {
                        $subDocument->appendChild($mixinElement);
                    }
                }
            }
            $compiler->setLayout($layout);
        }

        return null;
    }
1007922
private function rename(NodeInterface $node, $name)
    {
        $names = (array) $node->getParent()->getNodeNames();
        $pos = array_search($node->getName(), $names);
        $next = isset($names[$pos + 1]) ? $names[$pos + 1] : null;

        $node->rename($name);

        if ($next) {
            $node->getParent()->orderBefore($name, $next);
        }
    }
210682
public function handle(Parser $parser, \DOMNode $node, NodeInterface $target)
    {
        $target->{$this->setterName}($this->getNodeContent($node));
    }
185810
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
    {
        $nodeEvent = new NodeEvent($node);
        $this->trigger($nodeEvent);
        $node = $nodeEvent->getNode();

        $this->currentNode = $node;

        foreach ($this->nodeCompilers as $className => $compiler) {
            if (is_a($node, $className)) {
                if (!($compiler instanceof NodeCompilerInterface)) {
                    $compiler = $this->getNamedCompiler($compiler);
                }

                $element = $compiler->compileNode($node, $parent);

                if ($element instanceof ElementInterface && !($element instanceof BlockElement)) {
                    $elementEvent = new ElementEvent($nodeEvent, $element);
                    $this->trigger($elementEvent);
                    $element = $elementEvent->getElement();
                }

                return $element;
            }
        }

        $this->throwException(
            'No compiler found able to compile '.get_class($node),
            $node
        );
    }
1150458
public function register(Node\NodeInterface $node)
	{
		if ( ! in_array($node, $this->array, true)) {
			$this->array[] = $node;
		}
	}
460355
public function parse(\Twig_NodeInterface $node)
    {
        foreach ($node as $subNode) {

            if (! $subNode instanceof \Twig_NodeInterface) {
                continue;
            }

            $nodeClass = get_class($subNode);

            switch ($nodeClass) {
                case 'Twig_Node_Set':
                    $this->context[] = $this->env->getCompiler()->compile($subNode)->getSource();
                    break;
                
                default:
                    $this->parse($subNode);
                    break;
            }
        }

        return $this;
    }
1352984
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Function_ || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('FunctionNodeParser is made to parse a function node');
        }

        $function = new FunctionModel();
        $function->setParentNode($parent);
        $function->setName($node->name);
        $function->setIsGlobal(true);

        $this->parseFunction($node, $function);

        if (($documentation = $node->getDocComment()) !== null) {
            $this->documentationNodeParser->invoke($documentation, $function);
        }

        $parent->addFunction($function);
    }
686780
protected function hasHiddenNodeParent(NodeInterface $node): bool
    {
        $rootNode = $node->getContext()->getRootNode();
        $nodesOnPath = $node->getContext()->getNodesOnPath($rootNode, $node);

        return count($nodesOnPath) < $node->getDepth();
    }
953339
public function setParent(AbstractParentNode $parent)
    {
        if (null !== $this->parent) {
            throw new \InvalidArgumentException('Node already got a parent!');
        }

        $this->parent = $parent;
    }
47794
public function addNode(NodeInterface $node): NodeInterface
    {
        $this->_nodes[$node->getId()] = $node;

        if ($this->getParent()) {
            $this->getParent()->addNode($node);
        }

        return $this;
    }