1
0
Fork 0

Rename some functions

pull/63/head
Felix Becker 2016-10-11 10:51:28 +02:00
parent c5947c5b79
commit 20ea090af7
3 changed files with 18 additions and 29 deletions

View File

@ -145,7 +145,7 @@ class PhpDocument
// Register this document on the project for all the symbols defined in it
foreach ($definitionCollector->definitions as $fqn => $node) {
$this->project->addDefinitionDocument($fqn, $this->uri);
$this->project->setDefinitionUri($fqn, $this->uri);
}
$this->statements = $stmts;
@ -160,7 +160,7 @@ class PhpDocument
*/
public function getFormattedText()
{
if (empty($this->getContent())) {
if (empty($this->content)) {
return [];
}
return Formatter::format($this->content, $this->uri);
@ -170,23 +170,12 @@ class PhpDocument
* Returns this document's text content.
*
* @return string
* @throws Exception If the content was not loaded
*/
public function getContent()
{
return $this->content;
}
/**
* Returns this document's AST.
*
* @return Node[]
*/
public function &getStatements()
{
return $this->statements;
}
/**
* Returns the URI of the document
*
@ -227,9 +216,8 @@ class PhpDocument
* Returns a map from fully qualified name (FQN) to Nodes defined in this document
*
* @return Node[]
* @throws Exception If the definitions are not loaded
*/
public function &getDefinitions()
public function getDefinitions()
{
return $this->definitions;
}

View File

@ -123,12 +123,24 @@ class Project
}
/**
* Adds a document as the container for a specific symbol
* Returns an associative array [string => string] that maps fully qualified symbol names
* to URIs of the document where the symbol is defined
*
* @return PhpDocument[]
*/
public function getDefinitionUris()
{
return $this->definitions;
}
/**
* Adds a document URI as the container for a specific symbol
*
* @param string $fqn The fully qualified name of the symbol
* @param string $uri The URI
* @return void
*/
public function addDefinitionDocument(string $fqn, string $uri)
public function setDefinitionUri(string $fqn, string $uri)
{
$this->definitions[$fqn] = $uri;
}
@ -144,17 +156,6 @@ class Project
return isset($this->definitions[$fqn]) ? $this->getDocument($this->definitions[$fqn]) : null;
}
/**
* Returns an associative array [string => string] that maps fully qualified symbol names
* to URIs of the document where the symbol is defined
*
* @return PhpDocument[]
*/
public function &getDefinitionDocuments()
{
return $this->definitions;
}
/**
* Returns true if the given FQN is defined in the project
*

View File

@ -54,7 +54,7 @@ class Workspace
public function symbol(string $query): array
{
$symbols = [];
foreach ($this->project->getDefinitionDocuments() as $fqn => $uri) {
foreach ($this->project->getDefinitionUris() as $fqn => $uri) {
if ($query === '' || stripos($fqn, $query) !== false) {
$symbols[] = SymbolInformation::fromNode($this->project->getDocument($uri)->getDefinitionByFqn($fqn), $fqn);
}