Cleanup
parent
abb01766e7
commit
6f494d1db9
14
README.md
14
README.md
|
@ -49,6 +49,10 @@ Non-Standard: An empty query will return _all_ symbols found in the workspace.
|
|||
PHP parse errors are reported as errors, parse errors of docblocks are reported as warnings.
|
||||
Errors/Warnings from the `vendor` directory are ignored.
|
||||
|
||||
### Stubs for PHP built-ins
|
||||
|
||||
Completion, type resolval etc. will use the standard PHP library and common extensions.
|
||||
|
||||
### What is considered a definition?
|
||||
|
||||
Globally searchable definitions are:
|
||||
|
@ -108,7 +112,7 @@ and references to an in-memory index.
|
|||
The time this takes depends on the project size.
|
||||
At the time of writing, this project contains 78 files + 1560 files in dependencies which take 97s to parse
|
||||
and consume 76 MB on a Surface Pro 3.
|
||||
The language server is fully operational while indexing and can respond to requests with the definitions already indexed.
|
||||
The language server is fully operational whilLe indexing and can respond to requests with the definitions already indexed.
|
||||
Follow-up requests will be almost instant because the index is kept in memory.
|
||||
|
||||
Having XDebug enabled heavily impacts performance and can even crash the server if the `max_nesting_level` setting is too low.
|
||||
|
@ -131,6 +135,11 @@ Simply run
|
|||
and you will get the latest stable release and all dependencies.
|
||||
Running `composer update` will update the server to the latest non-breaking version.
|
||||
|
||||
After installing the language server and its dependencies,
|
||||
you must parse the stubs for standard PHP symbols and save the index for fast initialization.
|
||||
|
||||
composer run-script --working-dir=vendor/felixfbecker/language-server parse-stubs
|
||||
|
||||
## Running
|
||||
|
||||
Start the language server with
|
||||
|
@ -178,6 +187,9 @@ Clone the repository and run
|
|||
composer install
|
||||
|
||||
to install dependencies.
|
||||
Then parse the stubs with
|
||||
|
||||
composer run-script parse-stubs
|
||||
|
||||
Run the tests with
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
|
|||
use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver};
|
||||
use LanguageServer\Protocol\SymbolInformation;
|
||||
use LanguageServer\Index\ReadableIndex;
|
||||
use Sabre\Event\Promise;
|
||||
use function Sabre\Event\coroutine;
|
||||
|
||||
class DefinitionResolver
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Index;
|
||||
|
||||
use LanguageServer\Definition;
|
||||
|
||||
abstract class AbstractAggregateIndex implements ReadableIndex
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,7 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Index;
|
||||
|
||||
use LanguageServer\Protocol\{SymbolInformation, TextDocumentIdentifier, ClientCapabilities};
|
||||
use LanguageServer\Definition;
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
use Sabre\Event\Promise;
|
||||
use function Sabre\Event\coroutine;
|
||||
|
||||
/**
|
||||
* Represents the index of a project or dependency
|
||||
|
|
|
@ -3,12 +3,6 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Index;
|
||||
|
||||
use LanguageServer\Protocol\{SymbolInformation, TextDocumentIdentifier, ClientCapabilities};
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
use LanguageServer\ContentRetriever\ContentRetriever;
|
||||
use Sabre\Event\Promise;
|
||||
use function Sabre\Event\coroutine;
|
||||
|
||||
/**
|
||||
* A project index manages the source and dependency indexes
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,8 @@ declare(strict_types = 1);
|
|||
|
||||
namespace LanguageServer\Index;
|
||||
|
||||
use LanguageServer\Definition;
|
||||
|
||||
/**
|
||||
* The ReadableIndex interface provides methods to lookup definitions and references
|
||||
*/
|
||||
|
|
|
@ -42,19 +42,29 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
*/
|
||||
public $workspace;
|
||||
|
||||
public $telemetry;
|
||||
/**
|
||||
* @var Server\Window
|
||||
*/
|
||||
public $window;
|
||||
|
||||
public $telemetry;
|
||||
public $completionItem;
|
||||
public $codeLens;
|
||||
|
||||
/**
|
||||
* @var ProtocolReader
|
||||
*/
|
||||
private $protocolReader;
|
||||
private $protocolWriter;
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var AggregateIndex
|
||||
* @var ProtocolWriter
|
||||
*/
|
||||
private $index;
|
||||
private $protocolWriter;
|
||||
|
||||
/**
|
||||
* @var LanguageClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var FilesFinder
|
||||
|
@ -64,8 +74,12 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
/**
|
||||
* @var ContentRetriever
|
||||
*/
|
||||
private $contentRetrieverFinder;
|
||||
private $contentRetriever;
|
||||
|
||||
/**
|
||||
* @param PotocolReader $reader
|
||||
* @param ProtocolWriter $writer
|
||||
*/
|
||||
public function __construct(ProtocolReader $reader, ProtocolWriter $writer)
|
||||
{
|
||||
parent::__construct($this, '/');
|
||||
|
@ -232,7 +246,6 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
|
||||
// Give LS to the chance to handle requests while indexing
|
||||
yield timeout();
|
||||
$path = Uri\parse($uri);
|
||||
$this->client->window->logMessage(
|
||||
MessageType::LOG,
|
||||
"Parsing file $i/$count: {$uri}"
|
||||
|
|
|
@ -10,16 +10,13 @@ use LanguageServer\NodeVisitor\{
|
|||
DocBlockParser,
|
||||
DefinitionCollector,
|
||||
ColumnCalculator,
|
||||
ReferencesCollector,
|
||||
VariableReferencesCollector
|
||||
ReferencesCollector
|
||||
};
|
||||
use LanguageServer\Index\Index;
|
||||
use PhpParser\{Error, ErrorHandler, Node, NodeTraverser};
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
use phpDocumentor\Reflection\DocBlockFactory;
|
||||
use Sabre\Event\Promise;
|
||||
use Sabre\Uri;
|
||||
use function Sabre\Event\coroutine;
|
||||
|
||||
class PhpDocument
|
||||
{
|
||||
|
@ -99,11 +96,12 @@ class PhpDocument
|
|||
private $diagnostics;
|
||||
|
||||
/**
|
||||
* @param string $uri The URI of the document
|
||||
* @param string $content The content of the document
|
||||
* @param Index $index The Index to register definitions and references to
|
||||
* @param Parser $parser The PHPParser instance
|
||||
* @param DocBlockFactory $docBlockFactory The DocBlockFactory instance to parse docblocks
|
||||
* @param string $uri The URI of the document
|
||||
* @param string $content The content of the document
|
||||
* @param Index $index The Index to register definitions and references to
|
||||
* @param Parser $parser The PHPParser instance
|
||||
* @param DocBlockFactory $docBlockFactory The DocBlockFactory instance to parse docblocks
|
||||
* @param DefinitionResolver $definitionResolver The DefinitionResolver to resolve definitions to symbols in the workspace
|
||||
*/
|
||||
public function __construct(
|
||||
string $uri,
|
||||
|
|
|
@ -27,7 +27,6 @@ use LanguageServer\Protocol\{
|
|||
use LanguageServer\Index\ReadableIndex;
|
||||
use Sabre\Event\Promise;
|
||||
use function Sabre\Event\coroutine;
|
||||
use function LanguageServer\getReferenceNodesByNode;
|
||||
|
||||
/**
|
||||
* Provides method handlers for all textDocument/* methods
|
||||
|
@ -61,9 +60,17 @@ class TextDocument
|
|||
*/
|
||||
private $completionProvider;
|
||||
|
||||
private $openDocuments = [];
|
||||
/**
|
||||
* @var ReadableIndex
|
||||
*/
|
||||
private $index;
|
||||
|
||||
/**
|
||||
* @param PhpDocumentLoader $documentLoader
|
||||
* @param DefinitionResolver $definitionResolver
|
||||
* @param LanguageClient $client
|
||||
* @param ReadableIndex $index
|
||||
*/
|
||||
public function __construct(
|
||||
PhpDocumentLoader $documentLoader,
|
||||
DefinitionResolver $definitionResolver,
|
||||
|
|
Loading…
Reference in New Issue