extensions/felixfbecker.php-intellisense-0.0.12/vendor/felixfbecker/language-server/src/PhpDocument.php
/**
     * Updates the content on this document.
     * Re-parses a source file, updates symbols and reports parsing errors
     * that may have occured as diagnostics.
     *
     * @param string $content
     * @return void
     */
Updates the content on this document.
Re-parses a source file, updates symbols and reports parsing errors
that may have occured as diagnostics.

@param string $content
@return void
Updates the content on this document . Re - parses a source file updates symbols and reports parsing errors that may have occured as diagnostics . @param string $content @return void
public function updateContent(string $content)
    {
        $this->content = $content;
        $stmts = null;
        $errorHandler = new ErrorHandler\Collecting;
        $stmts = $this->parser->parse($content, $errorHandler);
        $diagnostics = [];
        foreach ($errorHandler->getErrors() as $error) {
            $diagnostics[] = Diagnostic::fromError($error, $this->content, DiagnosticSeverity::ERROR, 'php');
        }
        if ($stmts) {
            $traverser = new NodeTraverser;
            $traverser->addVisitor(new NameResolver($errorHandler));
            $traverser->addVisitor(new ReferencesAdder($this));
            $traverser->addVisitor(new ColumnCalculator($content));
            $docBlockParser = new DocBlockParser($this->docBlockFactory);
            $traverser->addVisitor($docBlockParser);
            $traverser->traverse($stmts);
            foreach ($docBlockParser->errors as $error) {
                $diagnostics[] = Diagnostic::fromError($error, $this->content, DiagnosticSeverity::WARNING, 'php');
            }
            $traverser = new NodeTraverser;
            $definitionCollector = new DefinitionCollector;
            $traverser->addVisitor($definitionCollector);
            $referencesCollector = new ReferencesCollector;
            $traverser->addVisitor($referencesCollector);
            $traverser->traverse($stmts);
            if (isset($this->definitions)) {
                foreach ($this->definitions as $fqn => $node) {
                    $this->project->removeSymbol($fqn);
                }
            }
            $this->definitions = $definitionCollector->definitions;
            $this->symbols = $definitionCollector->symbols;
            foreach ($definitionCollector->symbols as $fqn => $symbol) {
                $this->project->setSymbol($fqn, $symbol);
            }
            if (isset($this->references)) {
                foreach ($this->references as $fqn => $node) {
                    $this->project->removeReferenceUri($fqn, $this->uri);
                }
            }
            $this->references = $referencesCollector->references;
            foreach ($referencesCollector->references as $fqn => $nodes) {
                $this->project->addReferenceUri($fqn, $this->uri);
            }
            $this->stmts = $stmts;
        }
        if (!$this->isVendored()) {
            $this->client->textDocument->publishDiagnostics($this->uri, $diagnostics);
        }
    }
public function updateContent ( string $ content ) { $ this -> content = $ content ; $ stmts = null ; $ errorHandler = new ErrorHandler \ Collecting ; $ stmts = $ this -> parser -> parse ( $ content , $ errorHandler ) ; $ diagnostics = [ ] ; foreach ( $ errorHandler -> getErrors ( ) as $ error ) { $ diagnostics [ ] = Diagnostic :: fromError ( $ error , $ this -> content , DiagnosticSeverity :: ERROR , 'php' ) ; } if ( $ stmts ) { $ traverser = new NodeTraverser ; $ traverser -> addVisitor ( new NameResolver ( $ errorHandler ) ) ; $ traverser -> addVisitor ( new ReferencesAdder ( $ this ) ) ; $ traverser -> addVisitor ( new ColumnCalculator ( $ content ) ) ; $ docBlockParser = new DocBlockParser ( $ this -> docBlockFactory ) ; $ traverser -> addVisitor ( $ docBlockParser ) ; $ traverser -> traverse ( $ stmts ) ; foreach ( $ docBlockParser -> errors as $ error ) { $ diagnostics [ ] = Diagnostic :: fromError ( $ error , $ this -> content , DiagnosticSeverity :: WARNING , 'php' ) ; } $ traverser = new NodeTraverser ; $ definitionCollector = new DefinitionCollector ; $ traverser -> addVisitor ( $ definitionCollector ) ; $ referencesCollector = new ReferencesCollector ; $ traverser -> addVisitor ( $ referencesCollector ) ; $ traverser -> traverse ( $ stmts ) ; if ( isset ( $ this -> definitions ) ) { foreach ( $ this -> definitions as $ fqn => $ node ) { $ this -> project -> removeSymbol ( $ fqn ) ; } } $ this -> definitions = $ definitionCollector -> definitions ; $ this -> symbols = $ definitionCollector -> symbols ; foreach ( $ definitionCollector -> symbols as $ fqn => $ symbol ) { $ this -> project -> setSymbol ( $ fqn , $ symbol ) ; } if ( isset ( $ this -> references ) ) { foreach ( $ this -> references as $ fqn => $ node ) { $ this -> project -> removeReferenceUri ( $ fqn , $ this -> uri ) ; } } $ this -> references = $ referencesCollector -> references ; foreach ( $ referencesCollector -> references as $ fqn => $ nodes ) { $ this -> project -> addReferenceUri ( $ fqn , $ this -> uri ) ; } $ this -> stmts = $ stmts ; } if ( ! $ this -> isVendored ( ) ) { $ this -> client -> textDocument -> publishDiagnostics ( $ this -> uri , $ diagnostics ) ; } }
Updates the content on this document.
Updates the content on this document .
// $stmts can be null in case of a fatal parsing error // Resolve aliased names to FQNs // Add parentNode, previousSibling, nextSibling attributes // Add column attributes to nodes // Parse docblocks and add docBlock attributes to nodes // Report errors from parsing docblocks // Collect all definitions // Collect all references // Unregister old definitions // Register this document on the project for all the symbols defined in it // Unregister old references // Register this document on the project for references