2016-09-30 09:30:08 +00:00
|
|
|
<?php
|
2016-09-30 09:54:49 +00:00
|
|
|
declare(strict_types = 1);
|
2016-09-30 09:30:08 +00:00
|
|
|
|
|
|
|
namespace LanguageServer\Server;
|
|
|
|
|
|
|
|
use PhpParser\{Error, Comment, Node, ParserFactory, NodeTraverser, Lexer};
|
|
|
|
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
|
|
|
|
use PhpParser\NodeVisitor\NameResolver;
|
2016-10-08 17:08:44 +00:00
|
|
|
use LanguageServer\{LanguageClient, ColumnCalculator, Project};
|
2016-09-30 09:30:08 +00:00
|
|
|
use LanguageServer\Protocol\{
|
|
|
|
TextDocumentItem,
|
|
|
|
TextDocumentIdentifier,
|
|
|
|
VersionedTextDocumentIdentifier,
|
|
|
|
Diagnostic,
|
|
|
|
DiagnosticSeverity,
|
|
|
|
Range,
|
|
|
|
Position,
|
|
|
|
FormattingOptions,
|
|
|
|
TextEdit,
|
|
|
|
SymbolInformation
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides method handlers for all workspace/* methods
|
|
|
|
*/
|
|
|
|
class Workspace
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The lanugage client object to call methods on the client
|
|
|
|
*
|
|
|
|
* @var \LanguageServer\LanguageClient
|
|
|
|
*/
|
|
|
|
private $client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current project database
|
|
|
|
*
|
|
|
|
* @var Project
|
|
|
|
*/
|
|
|
|
private $project;
|
|
|
|
|
|
|
|
public function __construct(Project $project, LanguageClient $client)
|
|
|
|
{
|
|
|
|
$this->project = $project;
|
|
|
|
$this->client = $client;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The workspace symbol request is sent from the client to the server to list project-wide symbols matching the query string.
|
|
|
|
*
|
|
|
|
* @param string $query
|
|
|
|
* @return SymbolInformation[]
|
|
|
|
*/
|
|
|
|
public function symbol(string $query): array
|
|
|
|
{
|
|
|
|
return $this->project->findSymbols($query);
|
|
|
|
}
|
|
|
|
}
|