Merge branch 'master' into autocomplet-speedup
commit
118115fca5
|
@ -3,7 +3,6 @@
|
||||||
/.vscode export-ignore
|
/.vscode export-ignore
|
||||||
/fixtures export-ignore
|
/fixtures export-ignore
|
||||||
/images export-ignore
|
/images export-ignore
|
||||||
/tests export-ignore
|
|
||||||
/validation export-ignore
|
/validation export-ignore
|
||||||
/.dockerignore export-ignore
|
/.dockerignore export-ignore
|
||||||
/.editorconfig export-ignore
|
/.editorconfig export-ignore
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
/.gitmodules export-ignore
|
/.gitmodules export-ignore
|
||||||
/.npmrc export-ignore
|
/.npmrc export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
|
/appveyor.yml export-ignore
|
||||||
/codecov.yml export-ignore
|
/codecov.yml export-ignore
|
||||||
/dependencies.yml export-ignore
|
/dependencies.yml export-ignore
|
||||||
/Dockerfile export-ignore
|
/Dockerfile export-ignore
|
||||||
|
|
10
.travis.yml
10
.travis.yml
|
@ -30,9 +30,9 @@ jobs:
|
||||||
before_install:
|
before_install:
|
||||||
# Fix ruby error https://github.com/Homebrew/brew/issues/3299
|
# Fix ruby error https://github.com/Homebrew/brew/issues/3299
|
||||||
- brew update
|
- brew update
|
||||||
- brew tap homebrew/homebrew-php
|
- brew install php@7.1
|
||||||
- brew install php71
|
- brew link --force --overwrite php@7.1
|
||||||
- brew install homebrew/php/php71-xdebug
|
- pecl install xdebug-2.6.0
|
||||||
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
- php composer-setup.php
|
- php composer-setup.php
|
||||||
- ln -s "`pwd`/composer.phar" /usr/local/bin/composer
|
- ln -s "`pwd`/composer.phar" /usr/local/bin/composer
|
||||||
|
@ -41,13 +41,11 @@ jobs:
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
install:
|
install:
|
||||||
- composer install --prefer-dist --no-interaction
|
|
||||||
- nvm install 8
|
- nvm install 8
|
||||||
- nvm use 8
|
- nvm use 8
|
||||||
- npm install
|
- npm install
|
||||||
script:
|
script:
|
||||||
- docker build -t felixfbecker/php-language-server .
|
- ./node_modules/.bin/semantic-release
|
||||||
- npm run semantic-release
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
|
|
11
README.md
11
README.md
|
@ -4,7 +4,6 @@
|
||||||
[](https://travis-ci.org/felixfbecker/php-language-server)
|
[](https://travis-ci.org/felixfbecker/php-language-server)
|
||||||
[](https://ci.appveyor.com/project/felixfbecker/php-language-server/branch/master)
|
[](https://ci.appveyor.com/project/felixfbecker/php-language-server/branch/master)
|
||||||
[](https://codecov.io/gh/felixfbecker/php-language-server)
|
[](https://codecov.io/gh/felixfbecker/php-language-server)
|
||||||
[](https://gemnasium.com/github.com/felixfbecker/php-language-server)
|
|
||||||
[](https://github.com/semantic-release/semantic-release)
|
[](https://github.com/semantic-release/semantic-release)
|
||||||
[](https://php.net/)
|
[](https://php.net/)
|
||||||
[](https://github.com/felixfbecker/php-language-server/blob/master/LICENSE.txt)
|
[](https://github.com/felixfbecker/php-language-server/blob/master/LICENSE.txt)
|
||||||
|
@ -17,6 +16,16 @@ Uses the great [Tolerant PHP Parser](https://github.com/Microsoft/tolerant-php-p
|
||||||
[phpDocumentor's DocBlock reflection](https://github.com/phpDocumentor/ReflectionDocBlock)
|
[phpDocumentor's DocBlock reflection](https://github.com/phpDocumentor/ReflectionDocBlock)
|
||||||
and an [event loop](http://sabre.io/event/loop/) for concurrency.
|
and an [event loop](http://sabre.io/event/loop/) for concurrency.
|
||||||
|
|
||||||
|
**Table of Contents**
|
||||||
|
- [Features](#features)
|
||||||
|
- [Performance](#performance)
|
||||||
|
- [Versioning](#versioning)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Running](#running)
|
||||||
|
- [Used by](#used-by)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
### [Completion](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_completion)
|
### [Completion](https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_completion)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
"php": "^7.0",
|
"php": "^7.0",
|
||||||
"composer/xdebug-handler": "^1.0",
|
"composer/xdebug-handler": "^1.0",
|
||||||
"felixfbecker/advanced-json-rpc": "^3.0.0",
|
"felixfbecker/advanced-json-rpc": "^3.0.0",
|
||||||
|
"felixfbecker/language-server-protocol": "^1.0.1",
|
||||||
"jetbrains/phpstorm-stubs": "dev-master",
|
"jetbrains/phpstorm-stubs": "dev-master",
|
||||||
"microsoft/tolerant-php-parser": "0.0.*",
|
"microsoft/tolerant-php-parser": "0.0.*",
|
||||||
"netresearch/jsonmapper": "^1.0",
|
"netresearch/jsonmapper": "^1.0",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
34
package.json
34
package.json
|
@ -1,31 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "php-language-server",
|
|
||||||
"version": "0.0.0-development",
|
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"repository": {
|
||||||
"commitmsg": "validate-commit-msg",
|
"type": "git",
|
||||||
"semantic-release": "semantic-release"
|
"url": "https://github.com/felixfbecker/php-language-server.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@semantic-release/github": "^2.0.0",
|
"@semantic-release/exec": "^3.1.0",
|
||||||
"@semantic-release/last-release-git-tag": "^2.0.0",
|
"semantic-release": "^15.9.9",
|
||||||
"cz-conventional-changelog": "^2.0.0",
|
"semantic-release-docker": "^2.1.0"
|
||||||
"husky": "^0.14.3",
|
|
||||||
"semantic-release": "^11.0.0",
|
|
||||||
"semantic-release-docker": "^2.0.0",
|
|
||||||
"validate-commit-msg": "^2.14.0"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"commitizen": {
|
|
||||||
"path": "./node_modules/cz-conventional-changelog"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"release": {
|
"release": {
|
||||||
"verifyConditions": [
|
"verifyConditions": [
|
||||||
"@semantic-release/github",
|
"@semantic-release/github",
|
||||||
"semantic-release-docker"
|
"semantic-release-docker"
|
||||||
],
|
],
|
||||||
"getLastRelease": "@semantic-release/last-release-git-tag",
|
"prepare": [
|
||||||
|
{
|
||||||
|
"path": "@semantic-release/exec",
|
||||||
|
"cmd": "composer install --prefer-dist --no-interaction && docker build -t felixfbecker/php-language-server ."
|
||||||
|
}
|
||||||
|
],
|
||||||
"publish": [
|
"publish": [
|
||||||
"@semantic-release/github",
|
"@semantic-release/github",
|
||||||
{
|
{
|
||||||
|
@ -33,9 +27,5 @@
|
||||||
"name": "felixfbecker/php-language-server"
|
"name": "felixfbecker/php-language-server"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/felixfbecker/php-language-server.git"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer\Client;
|
namespace LanguageServer\Client;
|
||||||
|
|
||||||
use LanguageServer\ClientHandler;
|
use LanguageServer\ClientHandler;
|
||||||
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier};
|
use LanguageServerProtocol\{TextDocumentItem, TextDocumentIdentifier};
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use JsonMapper;
|
use JsonMapper;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer\Client;
|
namespace LanguageServer\Client;
|
||||||
|
|
||||||
use LanguageServer\ClientHandler;
|
use LanguageServer\ClientHandler;
|
||||||
use LanguageServer\Protocol\TextDocumentIdentifier;
|
use LanguageServerProtocol\TextDocumentIdentifier;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use JsonMapper;
|
use JsonMapper;
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@ class ClientHandler
|
||||||
{
|
{
|
||||||
$id = $this->idGenerator->generate();
|
$id = $this->idGenerator->generate();
|
||||||
return $this->protocolWriter->write(
|
return $this->protocolWriter->write(
|
||||||
new Protocol\Message(
|
new Message(
|
||||||
new AdvancedJsonRpc\Request($id, $method, (object)$params)
|
new AdvancedJsonRpc\Request($id, $method, (object)$params)
|
||||||
)
|
)
|
||||||
)->then(function () use ($id) {
|
)->then(function () use ($id) {
|
||||||
$promise = new Promise;
|
$promise = new Promise;
|
||||||
$listener = function (Protocol\Message $msg) use ($id, $promise, &$listener) {
|
$listener = function (Message $msg) use ($id, $promise, &$listener) {
|
||||||
if (AdvancedJsonRpc\Response::isResponse($msg->body) && $msg->body->id === $id) {
|
if (AdvancedJsonRpc\Response::isResponse($msg->body) && $msg->body->id === $id) {
|
||||||
// Received a response
|
// Received a response
|
||||||
$this->protocolReader->removeListener('message', $listener);
|
$this->protocolReader->removeListener('message', $listener);
|
||||||
|
@ -72,7 +72,7 @@ class ClientHandler
|
||||||
public function notify(string $method, $params): Promise
|
public function notify(string $method, $params): Promise
|
||||||
{
|
{
|
||||||
return $this->protocolWriter->write(
|
return $this->protocolWriter->write(
|
||||||
new Protocol\Message(
|
new Message(
|
||||||
new AdvancedJsonRpc\Notification($method, (object)$params)
|
new AdvancedJsonRpc\Notification($method, (object)$params)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,7 +4,8 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Factory\CompletionItemFactory;
|
||||||
|
use LanguageServerProtocol\{
|
||||||
TextEdit,
|
TextEdit,
|
||||||
Range,
|
Range,
|
||||||
Position,
|
Position,
|
||||||
|
@ -99,7 +100,23 @@ class CompletionProvider
|
||||||
'var',
|
'var',
|
||||||
'while',
|
'while',
|
||||||
'xor',
|
'xor',
|
||||||
'yield'
|
'yield',
|
||||||
|
|
||||||
|
// List of other reserved words (http://php.net/manual/en/reserved.other-reserved-words.php)
|
||||||
|
// (the ones which do not occur as actual keywords above.)
|
||||||
|
'int',
|
||||||
|
'float',
|
||||||
|
'bool',
|
||||||
|
'string',
|
||||||
|
'void',
|
||||||
|
'iterable',
|
||||||
|
'object',
|
||||||
|
|
||||||
|
// Pseudo keywords
|
||||||
|
'from', // As in yield from
|
||||||
|
'strict_types',
|
||||||
|
'ticks', // As in declare(ticks=1)
|
||||||
|
'encoding', // As in declare(encoding='EBCDIC')
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer\ContentRetriever;
|
namespace LanguageServer\ContentRetriever;
|
||||||
|
|
||||||
use LanguageServer\LanguageClient;
|
use LanguageServer\LanguageClient;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, TextDocumentItem};
|
use LanguageServerProtocol\{TextDocumentIdentifier, TextDocumentItem};
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver};
|
use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver};
|
||||||
use LanguageServer\Protocol\SymbolInformation;
|
use LanguageServerProtocol\SymbolInformation;
|
||||||
use Generator;
|
use Generator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,8 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use LanguageServer\Protocol\SymbolInformation;
|
use LanguageServer\Factory\SymbolInformationFactory;
|
||||||
|
use LanguageServerProtocol\SymbolInformation;
|
||||||
use Microsoft\PhpParser;
|
use Microsoft\PhpParser;
|
||||||
use Microsoft\PhpParser\Node;
|
use Microsoft\PhpParser\Node;
|
||||||
use Microsoft\PhpParser\FunctionLike;
|
use Microsoft\PhpParser\FunctionLike;
|
||||||
|
@ -36,7 +37,7 @@ class DefinitionResolver
|
||||||
private $docBlockFactory;
|
private $docBlockFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates SignatureInformation
|
* Creates SignatureInformation instances
|
||||||
*
|
*
|
||||||
* @var SignatureInformationFactory
|
* @var SignatureInformationFactory
|
||||||
*/
|
*/
|
||||||
|
@ -233,7 +234,7 @@ class DefinitionResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$def->symbolInformation = SymbolInformation::fromNode($node, $fqn);
|
$def->symbolInformation = SymbolInformationFactory::fromNode($node, $fqn);
|
||||||
|
|
||||||
if ($def->symbolInformation !== null) {
|
if ($def->symbolInformation !== null) {
|
||||||
$def->type = $this->getTypeFromNode($node);
|
$def->type = $this->getTypeFromNode($node);
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LanguageServer\Factory;
|
||||||
|
|
||||||
|
use LanguageServer\Definition;
|
||||||
|
use LanguageServerProtocol\CompletionItem;
|
||||||
|
use LanguageServerProtocol\CompletionItemKind;
|
||||||
|
use LanguageServerProtocol\SymbolKind;
|
||||||
|
|
||||||
|
class CompletionItemFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a CompletionItem for a Definition
|
||||||
|
*
|
||||||
|
* @param Definition $def
|
||||||
|
* @return CompletionItem|null
|
||||||
|
*/
|
||||||
|
public static function fromDefinition(Definition $def)
|
||||||
|
{
|
||||||
|
$item = new CompletionItem;
|
||||||
|
$item->label = $def->symbolInformation->name;
|
||||||
|
$item->kind = CompletionItemKind::fromSymbolKind($def->symbolInformation->kind);
|
||||||
|
if ($def->type) {
|
||||||
|
$item->detail = (string)$def->type;
|
||||||
|
} else if ($def->symbolInformation->containerName) {
|
||||||
|
$item->detail = $def->symbolInformation->containerName;
|
||||||
|
}
|
||||||
|
if ($def->documentation) {
|
||||||
|
$item->documentation = $def->documentation;
|
||||||
|
}
|
||||||
|
if ($def->isStatic && $def->symbolInformation->kind === SymbolKind::PROPERTY) {
|
||||||
|
$item->insertText = '$' . $def->symbolInformation->name;
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LanguageServer\Factory;
|
||||||
|
|
||||||
|
use LanguageServerProtocol\Location;
|
||||||
|
use LanguageServerProtocol\Position;
|
||||||
|
use LanguageServerProtocol\Range;
|
||||||
|
use Microsoft\PhpParser\Node;
|
||||||
|
use Microsoft\PhpParser\PositionUtilities;
|
||||||
|
|
||||||
|
class LocationFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the location of the node
|
||||||
|
*
|
||||||
|
* @param Node $node
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function fromNode(Node $node): Location
|
||||||
|
{
|
||||||
|
$range = PositionUtilities::getRangeFromPosition(
|
||||||
|
$node->getStart(),
|
||||||
|
$node->getWidth(),
|
||||||
|
$node->getFileContents()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Location($node->getUri(), new Range(
|
||||||
|
new Position($range->start->line, $range->start->character),
|
||||||
|
new Position($range->end->line, $range->end->character)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LanguageServer\Factory;
|
||||||
|
|
||||||
|
use LanguageServerProtocol\Position;
|
||||||
|
use LanguageServerProtocol\Range;
|
||||||
|
use Microsoft\PhpParser\Node;
|
||||||
|
use Microsoft\PhpParser\PositionUtilities;
|
||||||
|
|
||||||
|
class RangeFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the range the node spans
|
||||||
|
*
|
||||||
|
* @param Node $node
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function fromNode(Node $node)
|
||||||
|
{
|
||||||
|
$range = PositionUtilities::getRangeFromPosition(
|
||||||
|
$node->getStart(),
|
||||||
|
$node->getWidth(),
|
||||||
|
$node->getFileContents()
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Range(
|
||||||
|
new Position($range->start->line, $range->start->character),
|
||||||
|
new Position($range->end->line, $range->end->character)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,44 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
namespace LanguageServer\Factory;
|
||||||
|
|
||||||
use Microsoft\PhpParser;
|
use LanguageServerProtocol\Location;
|
||||||
|
use LanguageServerProtocol\SymbolInformation;
|
||||||
|
use LanguageServerProtocol\SymbolKind;
|
||||||
use Microsoft\PhpParser\Node;
|
use Microsoft\PhpParser\Node;
|
||||||
|
use Microsoft\PhpParser\ResolvedName;
|
||||||
|
use LanguageServer\Factory\LocationFactory;
|
||||||
|
|
||||||
/**
|
class SymbolInformationFactory
|
||||||
* Represents information about programming constructs like variables, classes,
|
|
||||||
* interfaces etc.
|
|
||||||
*/
|
|
||||||
class SymbolInformation
|
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The name of this symbol.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The kind of this symbol.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $kind;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The location of this symbol.
|
|
||||||
*
|
|
||||||
* @var Location
|
|
||||||
*/
|
|
||||||
public $location;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the symbol containing this symbol.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $containerName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a Node to a SymbolInformation
|
* Converts a Node to a SymbolInformation
|
||||||
*
|
*
|
||||||
|
@ -48,7 +20,7 @@ class SymbolInformation
|
||||||
*/
|
*/
|
||||||
public static function fromNode($node, string $fqn = null)
|
public static function fromNode($node, string $fqn = null)
|
||||||
{
|
{
|
||||||
$symbol = new self;
|
$symbol = new SymbolInformation();
|
||||||
if ($node instanceof Node\Statement\ClassDeclaration) {
|
if ($node instanceof Node\Statement\ClassDeclaration) {
|
||||||
$symbol->kind = SymbolKind::CLASS_;
|
$symbol->kind = SymbolKind::CLASS_;
|
||||||
} else if ($node instanceof Node\Statement\TraitDeclaration) {
|
} else if ($node instanceof Node\Statement\TraitDeclaration) {
|
||||||
|
@ -98,7 +70,7 @@ class SymbolInformation
|
||||||
$symbol->name = $node->getName();
|
$symbol->name = $node->getName();
|
||||||
} else if (isset($node->name)) {
|
} else if (isset($node->name)) {
|
||||||
if ($node->name instanceof Node\QualifiedName) {
|
if ($node->name instanceof Node\QualifiedName) {
|
||||||
$symbol->name = (string)PhpParser\ResolvedName::buildName($node->name->nameParts, $node->getFileContents());
|
$symbol->name = (string)ResolvedName::buildName($node->name->nameParts, $node->getFileContents());
|
||||||
} else {
|
} else {
|
||||||
$symbol->name = ltrim((string)$node->name->getText($node->getFileContents()), "$");
|
$symbol->name = ltrim((string)$node->name->getText($node->getFileContents()), "$");
|
||||||
}
|
}
|
||||||
|
@ -108,7 +80,7 @@ class SymbolInformation
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$symbol->location = Location::fromNode($node);
|
$symbol->location = LocationFactory::fromNode($node);
|
||||||
if ($fqn !== null) {
|
if ($fqn !== null) {
|
||||||
$parts = preg_split('/(::|->|\\\\)/', $fqn);
|
$parts = preg_split('/(::|->|\\\\)/', $fqn);
|
||||||
array_pop($parts);
|
array_pop($parts);
|
||||||
|
@ -116,18 +88,4 @@ class SymbolInformation
|
||||||
}
|
}
|
||||||
return $symbol;
|
return $symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $name
|
|
||||||
* @param int $kind
|
|
||||||
* @param Location $location
|
|
||||||
* @param string $containerName
|
|
||||||
*/
|
|
||||||
public function __construct($name = null, $kind = null, $location = null, $containerName = null)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
$this->kind = $kind;
|
|
||||||
$this->location = $location;
|
|
||||||
$this->containerName = $containerName;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ namespace LanguageServer;
|
||||||
use LanguageServer\Cache\Cache;
|
use LanguageServer\Cache\Cache;
|
||||||
use LanguageServer\FilesFinder\FilesFinder;
|
use LanguageServer\FilesFinder\FilesFinder;
|
||||||
use LanguageServer\Index\{DependenciesIndex, Index};
|
use LanguageServer\Index\{DependenciesIndex, Index};
|
||||||
use LanguageServer\Protocol\MessageType;
|
use LanguageServerProtocol\MessageType;
|
||||||
use Webmozart\PathUtil\Path;
|
use Webmozart\PathUtil\Path;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use function Sabre\Event\coroutine;
|
use function Sabre\Event\coroutine;
|
||||||
|
@ -147,7 +147,7 @@ class Indexer
|
||||||
$packageKey = null;
|
$packageKey = null;
|
||||||
$cacheKey = null;
|
$cacheKey = null;
|
||||||
$index = null;
|
$index = null;
|
||||||
foreach (array_merge($this->composerLock->packages, $this->composerLock->{'packages-dev'}) as $package) {
|
foreach (array_merge($this->composerLock->packages, (array)$this->composerLock->{'packages-dev'}) as $package) {
|
||||||
// Check if package name matches and version is absolute
|
// Check if package name matches and version is absolute
|
||||||
// Dynamic constraints are not cached, because they can change every time
|
// Dynamic constraints are not cached, because they can change every time
|
||||||
$packageVersion = ltrim($package->version, 'v');
|
$packageVersion = ltrim($package->version, 'v');
|
||||||
|
|
|
@ -3,15 +3,15 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
ServerCapabilities,
|
ServerCapabilities,
|
||||||
ClientCapabilities,
|
ClientCapabilities,
|
||||||
TextDocumentSyncKind,
|
TextDocumentSyncKind,
|
||||||
Message,
|
|
||||||
InitializeResult,
|
InitializeResult,
|
||||||
CompletionOptions,
|
CompletionOptions,
|
||||||
SignatureHelpOptions
|
SignatureHelpOptions
|
||||||
};
|
};
|
||||||
|
use LanguageServer\Message;
|
||||||
use LanguageServer\FilesFinder\{FilesFinder, ClientFilesFinder, FileSystemFilesFinder};
|
use LanguageServer\FilesFinder\{FilesFinder, ClientFilesFinder, FileSystemFilesFinder};
|
||||||
use LanguageServer\ContentRetriever\{ContentRetriever, ClientContentRetriever, FileSystemContentRetriever};
|
use LanguageServer\ContentRetriever\{ContentRetriever, ClientContentRetriever, FileSystemContentRetriever};
|
||||||
use LanguageServer\Index\{DependenciesIndex, GlobalIndex, Index, ProjectIndex, StubsIndex};
|
use LanguageServer\Index\{DependenciesIndex, GlobalIndex, Index, ProjectIndex, StubsIndex};
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use AdvancedJsonRpc\Message as MessageBody;
|
use AdvancedJsonRpc\Message as MessageBody;
|
||||||
|
use LanguageServer\Message;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Index\Index;
|
use LanguageServer\Index\Index;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
Diagnostic, Position, Range
|
Diagnostic, Position, Range
|
||||||
};
|
};
|
||||||
use Microsoft\PhpParser;
|
use Microsoft\PhpParser;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class ClientCapabilities
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The client supports workspace/xfiles requests
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $xfilesProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The client supports textDocument/xcontent requests
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $xcontentProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The client supports xcache/* requests
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $xcacheProvider;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains additional diagnostic information about the context in which
|
|
||||||
* a code action is run.
|
|
||||||
*/
|
|
||||||
class CodeActionContext
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* An array of diagnostics.
|
|
||||||
*
|
|
||||||
* @var Diagnostic[]
|
|
||||||
*/
|
|
||||||
public $diagnostics;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A code lens represents a command that should be shown along with
|
|
||||||
* source text, like the number of references, a way to run tests, etc.
|
|
||||||
*
|
|
||||||
* A code lens is _unresolved_ when no command is associated to it. For performance
|
|
||||||
* reasons the creation of a code lens and resolving should be done in two stages.
|
|
||||||
*/
|
|
||||||
class CodeLens
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range in which this code lens is valid. Should only span a single line.
|
|
||||||
*
|
|
||||||
* @var Range
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The command this code lens represents.
|
|
||||||
*
|
|
||||||
* @var Command|null
|
|
||||||
*/
|
|
||||||
public $command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A data entry field that is preserved on a code lens item between
|
|
||||||
* a code lens and a code lens resolve request.
|
|
||||||
*
|
|
||||||
* @var mixed|null
|
|
||||||
*/
|
|
||||||
public $data;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Code Lens options.
|
|
||||||
*/
|
|
||||||
class CodeLensOptions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Code lens has a resolve provider as well.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $resolveProvider;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a reference to a command. Provides a title which will be used to represent a command in the UI and,
|
|
||||||
* optionally, an array of arguments which will be passed to the command handler function when invoked.
|
|
||||||
*/
|
|
||||||
class Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Title of the command, like `save`.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The identifier of the actual command handler.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Arguments that the command handler should be
|
|
||||||
* invoked with.
|
|
||||||
*
|
|
||||||
* @var mixed[]|null
|
|
||||||
*/
|
|
||||||
public $arguments;
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Contains additional information about the context in which a completion request is triggered.
|
|
||||||
*/
|
|
||||||
class CompletionContext
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* How the completion was triggered.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $triggerKind;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The trigger character (a single character) that has trigger code complete.
|
|
||||||
* Is null if `triggerKind !== CompletionTriggerKind::TRIGGER_CHARACTER`
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $triggerCharacter;
|
|
||||||
|
|
||||||
public function __construct(int $triggerKind = null, string $triggerCharacter = null)
|
|
||||||
{
|
|
||||||
$this->triggerKind = $triggerKind;
|
|
||||||
$this->triggerCharacter = $triggerCharacter;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,164 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
use LanguageServer\Definition;
|
|
||||||
|
|
||||||
class CompletionItem
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The label of this completion item. By default
|
|
||||||
* also the text that is inserted when selecting
|
|
||||||
* this completion.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The kind of this completion item. Based of the kind
|
|
||||||
* an icon is chosen by the editor.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $kind;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A human-readable string with additional information
|
|
||||||
* about this item, like type or symbol information.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $detail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A human-readable string that represents a doc-comment.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $documentation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A string that shoud be used when comparing this item
|
|
||||||
* with other items. When `falsy` the label is used.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $sortText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A string that should be used when filtering a set of
|
|
||||||
* completion items. When `falsy` the label is used.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $filterText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A string that should be inserted a document when selecting
|
|
||||||
* this completion. When `falsy` the label is used.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $insertText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An edit which is applied to a document when selecting
|
|
||||||
* this completion. When an edit is provided the value of
|
|
||||||
* insertText is ignored.
|
|
||||||
*
|
|
||||||
* @var TextEdit|null
|
|
||||||
*/
|
|
||||||
public $textEdit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An optional array of additional text edits that are applied when
|
|
||||||
* selecting this completion. Edits must not overlap with the main edit
|
|
||||||
* nor with themselves.
|
|
||||||
*
|
|
||||||
* @var TextEdit[]|null
|
|
||||||
*/
|
|
||||||
public $additionalTextEdits;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An optional command that is executed *after* inserting this completion. *Note* that
|
|
||||||
* additional modifications to the current document should be described with the
|
|
||||||
* additionalTextEdits-property.
|
|
||||||
*
|
|
||||||
* @var Command|null
|
|
||||||
*/
|
|
||||||
public $command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An data entry field that is preserved on a completion item between
|
|
||||||
* a completion and a completion resolve request.
|
|
||||||
*
|
|
||||||
* @var mixed
|
|
||||||
*/
|
|
||||||
public $data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $label
|
|
||||||
* @param int|null $kind
|
|
||||||
* @param string|null $detail
|
|
||||||
* @param string|null $documentation
|
|
||||||
* @param string|null $sortText
|
|
||||||
* @param string|null $filterText
|
|
||||||
* @param string|null $insertText
|
|
||||||
* @param TextEdit|null $textEdit
|
|
||||||
* @param TextEdit[]|null $additionalTextEdits
|
|
||||||
* @param Command|null $command
|
|
||||||
* @param mixed|null $data
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
string $label = null,
|
|
||||||
int $kind = null,
|
|
||||||
string $detail = null,
|
|
||||||
string $documentation = null,
|
|
||||||
string $sortText = null,
|
|
||||||
string $filterText = null,
|
|
||||||
string $insertText = null,
|
|
||||||
TextEdit $textEdit = null,
|
|
||||||
array $additionalTextEdits = null,
|
|
||||||
Command $command = null,
|
|
||||||
$data = null
|
|
||||||
) {
|
|
||||||
$this->label = $label;
|
|
||||||
$this->kind = $kind;
|
|
||||||
$this->detail = $detail;
|
|
||||||
$this->documentation = $documentation;
|
|
||||||
$this->sortText = $sortText;
|
|
||||||
$this->filterText = $filterText;
|
|
||||||
$this->insertText = $insertText;
|
|
||||||
$this->textEdit = $textEdit;
|
|
||||||
$this->additionalTextEdits = $additionalTextEdits;
|
|
||||||
$this->command = $command;
|
|
||||||
$this->data = $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a CompletionItem for a Definition
|
|
||||||
*
|
|
||||||
* @param Definition $def
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public static function fromDefinition(Definition $def): self
|
|
||||||
{
|
|
||||||
$item = new CompletionItem;
|
|
||||||
$item->label = $def->symbolInformation->name;
|
|
||||||
$item->kind = CompletionItemKind::fromSymbolKind($def->symbolInformation->kind);
|
|
||||||
if ($def->type) {
|
|
||||||
$item->detail = (string)$def->type;
|
|
||||||
} else if ($def->symbolInformation->containerName) {
|
|
||||||
$item->detail = $def->symbolInformation->containerName;
|
|
||||||
}
|
|
||||||
if ($def->documentation) {
|
|
||||||
$item->documentation = $def->documentation;
|
|
||||||
}
|
|
||||||
if ($def->isStatic && $def->symbolInformation->kind === SymbolKind::PROPERTY) {
|
|
||||||
$item->insertText = '$' . $def->symbolInformation->name;
|
|
||||||
}
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The kind of a completion entry.
|
|
||||||
*/
|
|
||||||
abstract class CompletionItemKind
|
|
||||||
{
|
|
||||||
const TEXT = 1;
|
|
||||||
const METHOD = 2;
|
|
||||||
const FUNCTION = 3;
|
|
||||||
const CONSTRUCTOR = 4;
|
|
||||||
const FIELD = 5;
|
|
||||||
const VARIABLE = 6;
|
|
||||||
const CLASS_ = 7;
|
|
||||||
const INTERFACE = 8;
|
|
||||||
const MODULE = 9;
|
|
||||||
const PROPERTY = 10;
|
|
||||||
const UNIT = 11;
|
|
||||||
const VALUE = 12;
|
|
||||||
const ENUM = 13;
|
|
||||||
const KEYWORD = 14;
|
|
||||||
const SNIPPET = 15;
|
|
||||||
const COLOR = 16;
|
|
||||||
const FILE = 17;
|
|
||||||
const REFERENCE = 18;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the CompletionItemKind for a SymbolKind
|
|
||||||
*
|
|
||||||
* @param int $kind A SymbolKind
|
|
||||||
* @return int The CompletionItemKind
|
|
||||||
*/
|
|
||||||
public static function fromSymbolKind(int $kind): int
|
|
||||||
{
|
|
||||||
switch ($kind) {
|
|
||||||
case SymbolKind::PROPERTY:
|
|
||||||
case SymbolKind::FIELD:
|
|
||||||
return self::PROPERTY;
|
|
||||||
case SymbolKind::METHOD:
|
|
||||||
return self::METHOD;
|
|
||||||
case SymbolKind::CLASS_:
|
|
||||||
return self::CLASS_;
|
|
||||||
case SymbolKind::INTERFACE:
|
|
||||||
return self::INTERFACE;
|
|
||||||
case SymbolKind::FUNCTION:
|
|
||||||
return self::FUNCTION;
|
|
||||||
case SymbolKind::NAMESPACE:
|
|
||||||
case SymbolKind::MODULE:
|
|
||||||
case SymbolKind::PACKAGE:
|
|
||||||
return self::MODULE;
|
|
||||||
case SymbolKind::FILE:
|
|
||||||
return self::FILE;
|
|
||||||
case SymbolKind::STRING:
|
|
||||||
return self::TEXT;
|
|
||||||
case SymbolKind::NUMBER:
|
|
||||||
case SymbolKind::BOOLEAN:
|
|
||||||
case SymbolKind::ARRAY:
|
|
||||||
return self::VALUE;
|
|
||||||
case SymbolKind::ENUM:
|
|
||||||
return self::ENUM;
|
|
||||||
case SymbolKind::CONSTRUCTOR:
|
|
||||||
return self::CONSTRUCTOR;
|
|
||||||
case SymbolKind::VARIABLE:
|
|
||||||
case SymbolKind::CONSTANT:
|
|
||||||
return self::VARIABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a collection of completion items to be presented in
|
|
||||||
* the editor.
|
|
||||||
*/
|
|
||||||
class CompletionList
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This list it not complete. Further typing should result in recomputing this
|
|
||||||
* list.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $isIncomplete;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The completion items.
|
|
||||||
*
|
|
||||||
* @var CompletionItem[]
|
|
||||||
*/
|
|
||||||
public $items;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CompletionItem[] $items The completion items.
|
|
||||||
* @param bool $isIncomplete This list it not complete. Further typing should result in recomputing this list.
|
|
||||||
*/
|
|
||||||
public function __construct(array $items = [], bool $isIncomplete = false)
|
|
||||||
{
|
|
||||||
$this->items = $items;
|
|
||||||
$this->isIncomplete = $isIncomplete;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Completion options.
|
|
||||||
*/
|
|
||||||
class CompletionOptions
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* The server provides support to resolve additional information for a completion
|
|
||||||
* item.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $resolveProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The characters that trigger completion automatically.
|
|
||||||
*
|
|
||||||
* @var string[]|null
|
|
||||||
*/
|
|
||||||
public $triggerCharacters;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class CompletionTriggerKind
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Completion was triggered by invoking it manuall or using API.
|
|
||||||
*/
|
|
||||||
const INVOKED = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Completion was triggered by a trigger character.
|
|
||||||
*/
|
|
||||||
const TRIGGER_CHARACTER = 2;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event describing a change to a text document. If range and rangeLength are
|
|
||||||
* omitted the new text is considered to be the full content of the document.
|
|
||||||
*/
|
|
||||||
class ContentChangeEvent
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range of the document that changed.
|
|
||||||
*
|
|
||||||
* @var Range|null
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the range that got replaced.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $rangeLength;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new text of the document.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $text;
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class DependencyReference
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var mixed
|
|
||||||
*/
|
|
||||||
public $hints;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var object
|
|
||||||
*/
|
|
||||||
public $attributes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $attributes
|
|
||||||
* @param mixed $hints
|
|
||||||
*/
|
|
||||||
public function __construct($attributes = null, $hints = null)
|
|
||||||
{
|
|
||||||
$this->attributes = $attributes ?? new \stdClass;
|
|
||||||
$this->hints = $hints;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a
|
|
||||||
* resource.
|
|
||||||
*/
|
|
||||||
class Diagnostic
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range at which the message applies.
|
|
||||||
*
|
|
||||||
* @var Range
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The diagnostic's severity. Can be omitted. If omitted it is up to the
|
|
||||||
* client to interpret diagnostics as error, warning, info or hint.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $severity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The diagnostic's code. Can be omitted.
|
|
||||||
*
|
|
||||||
* @var int|string|null
|
|
||||||
*/
|
|
||||||
public $code;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A human-readable string describing the source of this
|
|
||||||
* diagnostic, e.g. 'typescript' or 'super lint'.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $source;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The diagnostic's message.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $message;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $message The diagnostic's message
|
|
||||||
* @param Range $range The range at which the message applies
|
|
||||||
* @param int $code The diagnostic's code
|
|
||||||
* @param int $severity DiagnosticSeverity
|
|
||||||
* @param string $source A human-readable string describing the source of this diagnostic
|
|
||||||
*/
|
|
||||||
public function __construct(string $message = null, Range $range = null, int $code = null, int $severity = null, string $source = null)
|
|
||||||
{
|
|
||||||
$this->message = $message;
|
|
||||||
$this->range = $range;
|
|
||||||
$this->code = $code;
|
|
||||||
$this->severity = $severity;
|
|
||||||
$this->source = $source;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
abstract class DiagnosticSeverity
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Reports an error.
|
|
||||||
*/
|
|
||||||
const ERROR = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports a warning.
|
|
||||||
*/
|
|
||||||
const WARNING = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports an information.
|
|
||||||
*/
|
|
||||||
const INFORMATION = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports a hint.
|
|
||||||
*/
|
|
||||||
const HINT = 4;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A document highlight is a range inside a text document which deserves
|
|
||||||
* special attention. Usually a document highlight is visualized by changing
|
|
||||||
* the background color of its range.
|
|
||||||
*/
|
|
||||||
class DocumentHighlight
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range this highlight applies to.
|
|
||||||
*
|
|
||||||
* @var Range
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The highlight kind, default is DocumentHighlightKind::TEXT.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $kind;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A document highlight kind.
|
|
||||||
*/
|
|
||||||
abstract class DocumentHighlightKind
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A textual occurrance.
|
|
||||||
*/
|
|
||||||
const TEXT = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read-access of a symbol, like reading a variable.
|
|
||||||
*/
|
|
||||||
const READ = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write-access of a symbol, like writing to a variable.
|
|
||||||
*/
|
|
||||||
const WRITE = 3;
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format document on type options
|
|
||||||
*/
|
|
||||||
class DocumentOnTypeFormattingOptions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A character on which formatting should be triggered, like `}`.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $firstTriggerCharacter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* More trigger characters.
|
|
||||||
*
|
|
||||||
* @var string[]|null
|
|
||||||
*/
|
|
||||||
public $moreTriggerCharacter;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum
|
|
||||||
*/
|
|
||||||
abstract class ErrorCode
|
|
||||||
{
|
|
||||||
const PARSE_ERROR = -32700;
|
|
||||||
const INVALID_REQUEST = -32600;
|
|
||||||
const METHOD_NOT_FOUND = -32601;
|
|
||||||
const INVALID_PARAMS = -32602;
|
|
||||||
const INTERNAL_ERROR = -32603;
|
|
||||||
const SERVER_ERROR_START = -32099;
|
|
||||||
const SERVER_ERROR_END = -32000;
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The file event type. Enum
|
|
||||||
*/
|
|
||||||
abstract class FileChangeType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The file got created.
|
|
||||||
*/
|
|
||||||
const CREATED = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The file got changed.
|
|
||||||
*/
|
|
||||||
const CHANGED = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The file got deleted.
|
|
||||||
*/
|
|
||||||
const DELETED = 3;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event describing a file change.
|
|
||||||
*/
|
|
||||||
class FileEvent
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The file's URI.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The change type.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $uri
|
|
||||||
* @param int $type
|
|
||||||
*/
|
|
||||||
public function __construct(string $uri, int $type)
|
|
||||||
{
|
|
||||||
$this->uri = $uri;
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Value-object describing what options formatting should use.
|
|
||||||
*/
|
|
||||||
class FormattingOptions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Size of a tab in spaces.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $tabSize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prefer spaces over tabs.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $insertSpaces;
|
|
||||||
|
|
||||||
// Can be extended with further properties.
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of a hover request.
|
|
||||||
*/
|
|
||||||
class Hover
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The hover's content
|
|
||||||
*
|
|
||||||
* @var string|MarkedString|string[]|MarkedString[]
|
|
||||||
*/
|
|
||||||
public $contents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An optional range
|
|
||||||
*
|
|
||||||
* @var Range|null
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string|MarkedString|string[]|MarkedString[] $contents The hover's content
|
|
||||||
* @param Range $range An optional range
|
|
||||||
*/
|
|
||||||
public function __construct($contents = null, $range = null)
|
|
||||||
{
|
|
||||||
$this->contents = $contents;
|
|
||||||
$this->range = $range;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class InitializeResult
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The capabilities the language server provides.
|
|
||||||
*
|
|
||||||
* @var LanguageServer\Protocol\ServerCapabilities
|
|
||||||
*/
|
|
||||||
public $capabilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param LanguageServer\Protocol\ServerCapabilities $capabilities
|
|
||||||
*/
|
|
||||||
public function __construct(ServerCapabilities $capabilities = null)
|
|
||||||
{
|
|
||||||
$this->capabilities = $capabilities ?? new ServerCapabilities();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
use Microsoft\PhpParser;
|
|
||||||
use Microsoft\PhpParser\Node;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a location inside a resource, such as a line inside a text file.
|
|
||||||
*/
|
|
||||||
class Location
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Range
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the location of the node
|
|
||||||
*
|
|
||||||
* @param Node $node
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public static function fromNode($node)
|
|
||||||
{
|
|
||||||
$range = PhpParser\PositionUtilities::getRangeFromPosition($node->getStart(), $node->getWidth(), $node->getFileContents());
|
|
||||||
return new self($node->getUri(), new Range(
|
|
||||||
new Position($range->start->line, $range->start->character),
|
|
||||||
new Position($range->end->line, $range->end->character)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct(string $uri = null, Range $range = null)
|
|
||||||
{
|
|
||||||
$this->uri = $uri;
|
|
||||||
$this->range = $range;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class MarkedString
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $language;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $value;
|
|
||||||
|
|
||||||
public function __construct(string $language = null, string $value = null)
|
|
||||||
{
|
|
||||||
$this->language = $language;
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class MessageActionItem
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A short title like 'Retry', 'Open Log' etc.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $title;
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum
|
|
||||||
*/
|
|
||||||
abstract class MessageType
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* An error message.
|
|
||||||
*/
|
|
||||||
const ERROR = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A warning message.
|
|
||||||
*/
|
|
||||||
const WARNING = 2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An information message.
|
|
||||||
*/
|
|
||||||
const INFO = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A log message.
|
|
||||||
*/
|
|
||||||
const LOG = 4;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uniquely identifies a Composer package
|
|
||||||
*/
|
|
||||||
class PackageDescriptor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The package name
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $name The package name
|
|
||||||
*/
|
|
||||||
public function __construct(string $name = null)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a parameter of a callable-signature. A parameter can
|
|
||||||
* have a label and a doc-comment.
|
|
||||||
*/
|
|
||||||
class ParameterInformation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The label of this signature. Will be shown in
|
|
||||||
* the UI.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The human-readable doc-comment of this signature. Will be shown
|
|
||||||
* in the UI but can be omitted.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $documentation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create ParameterInformation
|
|
||||||
*
|
|
||||||
* @param string $label The label of this signature. Will be shown in the UI.
|
|
||||||
* @param string $documentation The human-readable doc-comment of this signature. Will be shown in the UI but can
|
|
||||||
* be omitted.
|
|
||||||
*/
|
|
||||||
public function __construct(string $label, string $documentation = null)
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
$this->documentation = $documentation;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Position in a text document expressed as zero-based line and character offset.
|
|
||||||
*/
|
|
||||||
class Position
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Line position in a document (zero-based).
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $line;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Character offset on a line in a document (zero-based).
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $character;
|
|
||||||
|
|
||||||
public function __construct(int $line = null, int $character = null)
|
|
||||||
{
|
|
||||||
$this->line = $line;
|
|
||||||
$this->character = $character;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares this position to another position
|
|
||||||
* Returns
|
|
||||||
* - 0 if the positions match
|
|
||||||
* - a negative number if $this is before $position
|
|
||||||
* - a positive number otherwise
|
|
||||||
*
|
|
||||||
* @param Position $position
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function compare(Position $position): int
|
|
||||||
{
|
|
||||||
if ($this->line === $position->line && $this->character === $position->character) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->line !== $position->line) {
|
|
||||||
return $this->line - $position->line;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->character - $position->character;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the offset of the position in a string
|
|
||||||
*
|
|
||||||
* @param string $content
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function toOffset(string $content): int
|
|
||||||
{
|
|
||||||
$lines = explode("\n", $content);
|
|
||||||
$slice = array_slice($lines, 0, $this->line);
|
|
||||||
return array_sum(array_map('strlen', $slice)) + count($slice) + $this->character;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
use Microsoft\PhpParser;
|
|
||||||
use Microsoft\PhpParser\Node;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A range in a text document expressed as (zero-based) start and end positions.
|
|
||||||
*/
|
|
||||||
class Range
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range's start position.
|
|
||||||
*
|
|
||||||
* @var Position
|
|
||||||
*/
|
|
||||||
public $start;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The range's end position.
|
|
||||||
*
|
|
||||||
* @var Position
|
|
||||||
*/
|
|
||||||
public $end;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the range the node spans
|
|
||||||
*
|
|
||||||
* @param Node $node
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public static function fromNode(Node $node)
|
|
||||||
{
|
|
||||||
$range = PhpParser\PositionUtilities::getRangeFromPosition($node->getStart(), $node->getWidth(), $node->getFileContents());
|
|
||||||
|
|
||||||
return new self(
|
|
||||||
new Position($range->start->line, $range->start->character),
|
|
||||||
new Position($range->end->line, $range->end->character)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct(Position $start = null, Position $end = null)
|
|
||||||
{
|
|
||||||
$this->start = $start;
|
|
||||||
$this->end = $end;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a position is within the range
|
|
||||||
*
|
|
||||||
* @param Position $position
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function includes(Position $position): bool
|
|
||||||
{
|
|
||||||
return $this->start->compare($position) <= 0 && $this->end->compare($position) >= 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class ReferenceContext
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Include the declaration of the current symbol.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $includeDeclaration;
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about the symbol that can be used to identify or locate its
|
|
||||||
* definition.
|
|
||||||
*/
|
|
||||||
class ReferenceInformation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The location in the workspace where the `symbol` is referenced.
|
|
||||||
*
|
|
||||||
* @var Location
|
|
||||||
*/
|
|
||||||
public $reference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about the symbol that can be used to identify or locate its
|
|
||||||
* definition.
|
|
||||||
*
|
|
||||||
* @var SymbolDescriptor
|
|
||||||
*/
|
|
||||||
public $symbol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Location $reference The location in the workspace where the `symbol` is referenced.
|
|
||||||
* @param SymbolDescriptor $symbol Metadata about the symbol that can be used to identify or locate its definition.
|
|
||||||
*/
|
|
||||||
public function __construct(Location $reference = null, SymbolDescriptor $symbol = null)
|
|
||||||
{
|
|
||||||
$this->reference = $reference;
|
|
||||||
$this->symbol = $symbol;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class ServerCapabilities
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Defines how text documents are synced.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $textDocumentSync;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides hover support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $hoverProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides completion support.
|
|
||||||
*
|
|
||||||
* @var CompletionOptions|null
|
|
||||||
*/
|
|
||||||
public $completionProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides signature help support.
|
|
||||||
*
|
|
||||||
* @var SignatureHelpOptions|null
|
|
||||||
*/
|
|
||||||
public $signatureHelpProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides goto definition support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $definitionProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides find references support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $referencesProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides document highlight support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $documentHighlightProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides document symbol support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $documentSymbolProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides workspace symbol support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $workspaceSymbolProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides code actions.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $codeActionProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides code lens.
|
|
||||||
*
|
|
||||||
* @var CodeLensOptions|null
|
|
||||||
*/
|
|
||||||
public $codeLensProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides document formatting.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $documentFormattingProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides document range formatting.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $documentRangeFormattingProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides document formatting on typing.
|
|
||||||
*
|
|
||||||
* @var DocumentOnTypeFormattingOptions|null
|
|
||||||
*/
|
|
||||||
public $documentOnTypeFormattingProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides rename support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $renameProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides workspace references exporting support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $xworkspaceReferencesProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides extended text document definition support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $xdefinitionProvider;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The server provides workspace dependencies support.
|
|
||||||
*
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
public $dependenciesProvider;
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature help represents the signature of something
|
|
||||||
* callable. There can be multiple signature but only one
|
|
||||||
* active and only one active parameter.
|
|
||||||
*/
|
|
||||||
class SignatureHelp
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* One or more signatures.
|
|
||||||
*
|
|
||||||
* @var SignatureInformation[]
|
|
||||||
*/
|
|
||||||
public $signatures;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The active signature.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $activeSignature;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The active parameter of the active signature.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $activeParameter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a SignatureHelp
|
|
||||||
*
|
|
||||||
* @param SignatureInformation[] $signatures List of signature information
|
|
||||||
* @param int|null $activeSignature The active signature, zero based
|
|
||||||
* @param int|null $activeParameter The active parameter, zero based
|
|
||||||
*/
|
|
||||||
public function __construct(array $signatures = [], $activeSignature = null, int $activeParameter = null)
|
|
||||||
{
|
|
||||||
$this->signatures = $signatures;
|
|
||||||
$this->activeSignature = $activeSignature;
|
|
||||||
$this->activeParameter = $activeParameter;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature help options.
|
|
||||||
*/
|
|
||||||
class SignatureHelpOptions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The characters that trigger signature help automatically.
|
|
||||||
*
|
|
||||||
* @var string[]|null
|
|
||||||
*/
|
|
||||||
public $triggerCharacters;
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the signature of something callable. A signature
|
|
||||||
* can have a label, like a function-name, a doc-comment, and
|
|
||||||
* a set of parameters.
|
|
||||||
*/
|
|
||||||
class SignatureInformation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The label of this signature. Will be shown in
|
|
||||||
* the UI.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The human-readable doc-comment of this signature. Will be shown
|
|
||||||
* in the UI but can be omitted.
|
|
||||||
*
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
public $documentation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The parameters of this signature.
|
|
||||||
*
|
|
||||||
* @var ParameterInformation[]|null
|
|
||||||
*/
|
|
||||||
public $parameters;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a SignatureInformation
|
|
||||||
*
|
|
||||||
* @param string $label The label of this signature. Will be shown in the UI.
|
|
||||||
* @param ParameterInformation[]|null The parameters of this signature
|
|
||||||
* @param string|null The human-readable doc-comment of this signature. Will be shown in the UI
|
|
||||||
* but can be omitted.
|
|
||||||
*/
|
|
||||||
public function __construct(string $label, array $parameters = null, string $documentation = null)
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
$this->documentation = $documentation;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uniquely identifies a symbol
|
|
||||||
*/
|
|
||||||
class SymbolDescriptor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The fully qualified structural element name, a globally unique identifier for the symbol.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $fqsen;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identifies the Composer package the symbol is defined in (if any)
|
|
||||||
*
|
|
||||||
* @var PackageDescriptor|null
|
|
||||||
*/
|
|
||||||
public $package;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $fqsen The fully qualified structural element name, a globally unique identifier for the symbol.
|
|
||||||
* @param PackageDescriptor $package Identifies the Composer package the symbol is defined in
|
|
||||||
*/
|
|
||||||
public function __construct(string $fqsen = null, PackageDescriptor $package = null)
|
|
||||||
{
|
|
||||||
$this->fqsen = $fqsen;
|
|
||||||
$this->package = $package;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A symbol kind.
|
|
||||||
*/
|
|
||||||
abstract class SymbolKind
|
|
||||||
{
|
|
||||||
const FILE = 1;
|
|
||||||
const MODULE = 2;
|
|
||||||
const NAMESPACE = 3;
|
|
||||||
const PACKAGE = 4;
|
|
||||||
const CLASS_ = 5;
|
|
||||||
const METHOD = 6;
|
|
||||||
const PROPERTY = 7;
|
|
||||||
const FIELD = 8;
|
|
||||||
const CONSTRUCTOR = 9;
|
|
||||||
const ENUM = 10;
|
|
||||||
const INTERFACE = 11;
|
|
||||||
const FUNCTION = 12;
|
|
||||||
const VARIABLE = 13;
|
|
||||||
const CONSTANT = 14;
|
|
||||||
const STRING = 15;
|
|
||||||
const NUMBER = 16;
|
|
||||||
const BOOLEAN = 17;
|
|
||||||
const ARRAY = 18;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
declare(strict_types = 1);
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class SymbolLocationInformation
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The location where the symbol is defined, if any.
|
|
||||||
*
|
|
||||||
* @var Location|null
|
|
||||||
*/
|
|
||||||
public $location;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata about the symbol that can be used to identify or locate its
|
|
||||||
* definition.
|
|
||||||
*
|
|
||||||
* @var SymbolDescriptor
|
|
||||||
*/
|
|
||||||
public $symbol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SymbolDescriptor $symbol The location where the symbol is defined, if any
|
|
||||||
* @param Location $location Metadata about the symbol that can be used to identify or locate its definition
|
|
||||||
*/
|
|
||||||
public function __construct(SymbolDescriptor $symbol = null, Location $location = null)
|
|
||||||
{
|
|
||||||
$this->symbol = $symbol;
|
|
||||||
$this->location = $location;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An event describing a change to a text document. If range and rangeLength are omitted
|
|
||||||
* the new text is considered to be the full content of the document.
|
|
||||||
*/
|
|
||||||
class TextDocumentContentChangeEvent
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range of the document that changed.
|
|
||||||
*
|
|
||||||
* @var Range|null
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The length of the range that got replaced.
|
|
||||||
*
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
public $rangeLength;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The new text of the document.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $text;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class TextDocumentIdentifier
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The text document's URI.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $uri The text document's URI.
|
|
||||||
*/
|
|
||||||
public function __construct(string $uri = null)
|
|
||||||
{
|
|
||||||
$this->uri = $uri;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An item to transfer a text document from the client to the server.
|
|
||||||
*/
|
|
||||||
class TextDocumentItem
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The text document's URI.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $uri;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The text document's language identifier.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $languageId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The version number of this document (it will strictly increase after each
|
|
||||||
* change, including undo/redo).
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The content of the opened text document.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $text;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines how the host (editor) should sync document changes to the language server.
|
|
||||||
*/
|
|
||||||
abstract class TextDocumentSyncKind
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Documents should not be synced at all.
|
|
||||||
*/
|
|
||||||
const NONE = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Documents are synced by always sending the full content of the document.
|
|
||||||
*/
|
|
||||||
const FULL = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Documents are synced by sending the full content on open. After that only
|
|
||||||
* incremental updates to the document are sent.
|
|
||||||
*/
|
|
||||||
const INCREMENTAL = 2;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A textual edit applicable to a text document.
|
|
||||||
*/
|
|
||||||
class TextEdit
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The range of the text document to be manipulated. To insert
|
|
||||||
* text into a document create a range where start === end.
|
|
||||||
*
|
|
||||||
* @var Range
|
|
||||||
*/
|
|
||||||
public $range;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string to be inserted. For delete operations use an
|
|
||||||
* empty string.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $newText;
|
|
||||||
|
|
||||||
public function __construct(Range $range = null, string $newText = null)
|
|
||||||
{
|
|
||||||
$this->range = $range;
|
|
||||||
$this->newText = $newText;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
class VersionedTextDocumentIdentifier extends TextDocumentIdentifier
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The version number of this document.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $version;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace LanguageServer\Protocol;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A workspace edit represents changes to many resources managed in the workspace.
|
|
||||||
*/
|
|
||||||
class WorkspaceEdit
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Holds changes to existing resources. Associative Array from URI to TextEdit
|
|
||||||
*
|
|
||||||
* @var TextEdit[]
|
|
||||||
*/
|
|
||||||
public $changes;
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use AdvancedJsonRpc\Message as MessageBody;
|
use AdvancedJsonRpc\Message as MessageBody;
|
||||||
use Sabre\Event\{Loop, Emitter};
|
use Sabre\Event\{Loop, Emitter};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use Sabre\Event\{
|
use Sabre\Event\{
|
||||||
Loop,
|
Loop,
|
||||||
Promise
|
Promise
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
|
|
||||||
interface ProtocolWriter
|
interface ProtocolWriter
|
||||||
|
|
|
@ -7,7 +7,9 @@ use LanguageServer\{
|
||||||
CompletionProvider, SignatureHelpProvider, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver
|
CompletionProvider, SignatureHelpProvider, LanguageClient, PhpDocument, PhpDocumentLoader, DefinitionResolver
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Factory\LocationFactory;
|
||||||
|
use LanguageServer\Factory\RangeFactory;
|
||||||
|
use LanguageServerProtocol\{
|
||||||
FormattingOptions,
|
FormattingOptions,
|
||||||
Hover,
|
Hover,
|
||||||
Location,
|
Location,
|
||||||
|
@ -108,7 +110,7 @@ class TextDocument
|
||||||
* The document symbol request is sent from the client to the server to list all symbols found in a given text
|
* The document symbol request is sent from the client to the server to list all symbols found in a given text
|
||||||
* document.
|
* document.
|
||||||
*
|
*
|
||||||
* @param \LanguageServer\Protocol\TextDocumentIdentifier $textDocument
|
* @param \LanguageServerProtocol\TextDocumentIdentifier $textDocument
|
||||||
* @return Promise <SymbolInformation[]>
|
* @return Promise <SymbolInformation[]>
|
||||||
*/
|
*/
|
||||||
public function documentSymbol(TextDocumentIdentifier $textDocument): Promise
|
public function documentSymbol(TextDocumentIdentifier $textDocument): Promise
|
||||||
|
@ -127,7 +129,7 @@ class TextDocument
|
||||||
* document's truth is now managed by the client and the server must not try to read the document's truth using the
|
* document's truth is now managed by the client and the server must not try to read the document's truth using the
|
||||||
* document's uri.
|
* document's uri.
|
||||||
*
|
*
|
||||||
* @param \LanguageServer\Protocol\TextDocumentItem $textDocument The document that was opened.
|
* @param \LanguageServerProtocol\TextDocumentItem $textDocument The document that was opened.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function didOpen(TextDocumentItem $textDocument)
|
public function didOpen(TextDocumentItem $textDocument)
|
||||||
|
@ -141,8 +143,8 @@ class TextDocument
|
||||||
/**
|
/**
|
||||||
* The document change notification is sent from the client to the server to signal changes to a text document.
|
* The document change notification is sent from the client to the server to signal changes to a text document.
|
||||||
*
|
*
|
||||||
* @param \LanguageServer\Protocol\VersionedTextDocumentIdentifier $textDocument
|
* @param \LanguageServerProtocol\VersionedTextDocumentIdentifier $textDocument
|
||||||
* @param \LanguageServer\Protocol\TextDocumentContentChangeEvent[] $contentChanges
|
* @param \LanguageServerProtocol\TextDocumentContentChangeEvent[] $contentChanges
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function didChange(VersionedTextDocumentIdentifier $textDocument, array $contentChanges)
|
public function didChange(VersionedTextDocumentIdentifier $textDocument, array $contentChanges)
|
||||||
|
@ -157,7 +159,7 @@ class TextDocument
|
||||||
* The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the
|
* The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the
|
||||||
* truth now exists on disk).
|
* truth now exists on disk).
|
||||||
*
|
*
|
||||||
* @param \LanguageServer\Protocol\TextDocumentIdentifier $textDocument The document that was closed
|
* @param \LanguageServerProtocol\TextDocumentIdentifier $textDocument The document that was closed
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function didClose(TextDocumentIdentifier $textDocument)
|
public function didClose(TextDocumentIdentifier $textDocument)
|
||||||
|
@ -208,7 +210,7 @@ class TextDocument
|
||||||
if ($descendantNode instanceof Node\Expression\Variable &&
|
if ($descendantNode instanceof Node\Expression\Variable &&
|
||||||
$descendantNode->getName() === $node->getName()
|
$descendantNode->getName() === $node->getName()
|
||||||
) {
|
) {
|
||||||
$locations[] = Location::fromNode($descendantNode);
|
$locations[] = LocationFactory::fromNode($descendantNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,7 +236,7 @@ class TextDocument
|
||||||
$refs = $document->getReferenceNodesByFqn($fqn);
|
$refs = $document->getReferenceNodesByFqn($fqn);
|
||||||
if ($refs !== null) {
|
if ($refs !== null) {
|
||||||
foreach ($refs as $ref) {
|
foreach ($refs as $ref) {
|
||||||
$locations[] = Location::fromNode($ref);
|
$locations[] = LocationFactory::fromNode($ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,7 +335,7 @@ class TextDocument
|
||||||
}
|
}
|
||||||
yield waitForEvent($this->index, 'definition-added');
|
yield waitForEvent($this->index, 'definition-added');
|
||||||
}
|
}
|
||||||
$range = Range::fromNode($node);
|
$range = RangeFactory::fromNode($node);
|
||||||
if ($def === null) {
|
if ($def === null) {
|
||||||
return new Hover([], $range);
|
return new Hover([], $range);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ namespace LanguageServer\Server;
|
||||||
|
|
||||||
use LanguageServer\{LanguageClient, PhpDocumentLoader};
|
use LanguageServer\{LanguageClient, PhpDocumentLoader};
|
||||||
use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index};
|
use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index};
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Factory\LocationFactory;
|
||||||
|
use LanguageServerProtocol\{
|
||||||
FileChangeType,
|
FileChangeType,
|
||||||
FileEvent,
|
FileEvent,
|
||||||
SymbolInformation,
|
SymbolInformation,
|
||||||
|
@ -150,7 +151,7 @@ class Workspace
|
||||||
$doc = yield $this->documentLoader->getOrLoad($uri);
|
$doc = yield $this->documentLoader->getOrLoad($uri);
|
||||||
foreach ($doc->getReferenceNodesByFqn($fqn) as $node) {
|
foreach ($doc->getReferenceNodesByFqn($fqn) as $node) {
|
||||||
$refInfo = new ReferenceInformation;
|
$refInfo = new ReferenceInformation;
|
||||||
$refInfo->reference = Location::fromNode($node);
|
$refInfo->reference = LocationFactory::fromNode($node);
|
||||||
$refInfo->symbol = $query;
|
$refInfo->symbol = $query;
|
||||||
$refInfos[] = $refInfo;
|
$refInfos[] = $refInfo;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +170,7 @@ class Workspace
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$dependencyReferences = [];
|
$dependencyReferences = [];
|
||||||
foreach (array_merge($this->composerLock->packages, $this->composerLock->{'packages-dev'}) as $package) {
|
foreach (array_merge($this->composerLock->packages, (array)$this->composerLock->{'packages-dev'}) as $package) {
|
||||||
$dependencyReferences[] = new DependencyReference($package);
|
$dependencyReferences[] = new DependencyReference($package);
|
||||||
}
|
}
|
||||||
return $dependencyReferences;
|
return $dependencyReferences;
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Index\ReadableIndex;
|
use LanguageServer\Index\ReadableIndex;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
Position,
|
Position,
|
||||||
SignatureHelp,
|
SignatureHelp,
|
||||||
ParameterInformation
|
ParameterInformation
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{SignatureInformation, ParameterInformation};
|
use LanguageServerProtocol\{SignatureInformation, ParameterInformation};
|
||||||
use Microsoft\PhpParser\FunctionLike;
|
use Microsoft\PhpParser\FunctionLike;
|
||||||
|
|
||||||
class SignatureInformationFactory
|
class SignatureInformationFactory
|
||||||
|
|
|
@ -3,7 +3,8 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer;
|
namespace LanguageServer;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{Diagnostic, DiagnosticSeverity, Range, Position};
|
use LanguageServer\Factory\RangeFactory;
|
||||||
|
use LanguageServerProtocol\{Diagnostic, DiagnosticSeverity, Range, Position};
|
||||||
use phpDocumentor\Reflection\DocBlockFactory;
|
use phpDocumentor\Reflection\DocBlockFactory;
|
||||||
use Microsoft\PhpParser;
|
use Microsoft\PhpParser;
|
||||||
use Microsoft\PhpParser\Node;
|
use Microsoft\PhpParser\Node;
|
||||||
|
@ -100,7 +101,7 @@ class TreeAnalyzer
|
||||||
if ($method && $method->isStatic()) {
|
if ($method && $method->isStatic()) {
|
||||||
$this->diagnostics[] = new Diagnostic(
|
$this->diagnostics[] = new Diagnostic(
|
||||||
"\$this can not be used in static methods.",
|
"\$this can not be used in static methods.",
|
||||||
Range::fromNode($node),
|
RangeFactory::fromNode($node),
|
||||||
null,
|
null,
|
||||||
DiagnosticSeverity::ERROR,
|
DiagnosticSeverity::ERROR,
|
||||||
'php'
|
'php'
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace LanguageServer\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\ClientHandler;
|
use LanguageServer\ClientHandler;
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use AdvancedJsonRpc;
|
use AdvancedJsonRpc;
|
||||||
use Sabre\Event\Loop;
|
use Sabre\Event\Loop;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use LanguageServer\{
|
||||||
DefinitionResolver, TreeAnalyzer
|
DefinitionResolver, TreeAnalyzer
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{Index};
|
use LanguageServer\Index\{Index};
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
Diagnostic, DiagnosticSeverity, Position, Range
|
Diagnostic, DiagnosticSeverity, Position, Range
|
||||||
};
|
};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
|
@ -5,8 +5,8 @@ namespace LanguageServer\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\LanguageServer;
|
use LanguageServer\LanguageServer;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServer\Message;
|
||||||
Message,
|
use LanguageServerProtocol\{
|
||||||
ClientCapabilities,
|
ClientCapabilities,
|
||||||
TextDocumentSyncKind,
|
TextDocumentSyncKind,
|
||||||
MessageType,
|
MessageType,
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer\Tests;
|
namespace LanguageServer\Tests;
|
||||||
|
|
||||||
use LanguageServer\{ProtocolReader, ProtocolWriter};
|
use LanguageServer\{ProtocolReader, ProtocolWriter};
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use Sabre\Event\{Loop, Emitter, Promise};
|
use Sabre\Event\{Loop, Emitter, Promise};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@ use LanguageServer\{
|
||||||
use LanguageServer\Index\{
|
use LanguageServer\Index\{
|
||||||
Index
|
Index
|
||||||
};
|
};
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
Position
|
Position
|
||||||
};
|
};
|
||||||
use Microsoft\PhpParser;
|
use Microsoft\PhpParser;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace LanguageServer\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\{LanguageServer, ProtocolStreamReader, ProtocolStreamWriter};
|
use LanguageServer\{LanguageServer, ProtocolStreamReader, ProtocolStreamWriter};
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
|
use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody};
|
||||||
use Sabre\Event\Loop;
|
use Sabre\Event\Loop;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace LanguageServer\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use LanguageServer\ProtocolStreamWriter;
|
use LanguageServer\ProtocolStreamWriter;
|
||||||
use LanguageServer\Protocol\Message;
|
use LanguageServer\Message;
|
||||||
use AdvancedJsonRpc\{Request as RequestBody};
|
use AdvancedJsonRpc\{Request as RequestBody};
|
||||||
use Sabre\Event\Loop;
|
use Sabre\Event\Loop;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index};
|
use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{Position, Location, Range};
|
use LanguageServerProtocol\{Position, Location, Range};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
abstract class ServerTestCase extends TestCase
|
abstract class ServerTestCase extends TestCase
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
TextEdit,
|
TextEdit,
|
||||||
Range,
|
Range,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Location};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Position, Range, Location};
|
||||||
|
|
||||||
class GlobalFallbackTest extends ServerTestCase
|
class GlobalFallbackTest extends ServerTestCase
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types = 1);
|
||||||
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
||||||
|
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Location, Range};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Position, Location, Range};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
class GlobalTest extends ServerTestCase
|
class GlobalTest extends ServerTestCase
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
namespace LanguageServer\Tests\Server\TextDocument\Definition;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Location};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Location};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
class NamespacedTest extends GlobalTest
|
class NamespacedTest extends GlobalTest
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
VersionedTextDocumentIdentifier,
|
VersionedTextDocumentIdentifier,
|
||||||
TextDocumentContentChangeEvent,
|
TextDocumentContentChangeEvent,
|
||||||
Range,
|
Range,
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier};
|
use LanguageServerProtocol\{TextDocumentItem, TextDocumentIdentifier};
|
||||||
|
|
||||||
class DidCloseTest extends TestCase
|
class DidCloseTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\{Server, LanguageClient, Project};
|
use LanguageServer\{Server, LanguageClient, Project};
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, SymbolInformation, SymbolKind, Position, Location, Range};
|
use LanguageServerProtocol\{TextDocumentIdentifier, SymbolInformation, SymbolKind, Position, Location, Range};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
class DocumentSymbolTest extends ServerTestCase
|
class DocumentSymbolTest extends ServerTestCase
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use LanguageServer\{Server, LanguageClient, Project};
|
use LanguageServer\{Server, LanguageClient, Project};
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Hover, MarkedString};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Position, Range, Hover, MarkedString};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
class HoverTest extends ServerTestCase
|
class HoverTest extends ServerTestCase
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{TextDocumentItem, DiagnosticSeverity};
|
use LanguageServerProtocol\{TextDocumentItem, DiagnosticSeverity};
|
||||||
use Sabre\Event\Promise;
|
use Sabre\Event\Promise;
|
||||||
use JsonMapper;
|
use JsonMapper;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Index\{
|
use LanguageServer\Index\{
|
||||||
DependenciesIndex, Index, ProjectIndex
|
DependenciesIndex, Index, ProjectIndex
|
||||||
};
|
};
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
Location, Position, Range, ReferenceContext, TextDocumentIdentifier
|
Location, Position, Range, ReferenceContext, TextDocumentIdentifier
|
||||||
};
|
};
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\Tests\Server\TextDocument\References;
|
namespace LanguageServer\Tests\Server\TextDocument\References;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace LanguageServer\Tests\Server\TextDocument\References;
|
namespace LanguageServer\Tests\Server\TextDocument\References;
|
||||||
|
|
||||||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
use LanguageServerProtocol\{TextDocumentIdentifier, Position, ReferenceContext, Location, Range};
|
||||||
use function LanguageServer\pathToUri;
|
use function LanguageServer\pathToUri;
|
||||||
|
|
||||||
class NamespacedTest extends GlobalTest
|
class NamespacedTest extends GlobalTest
|
||||||
|
|
|
@ -10,7 +10,7 @@ use LanguageServer\{
|
||||||
};
|
};
|
||||||
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex};
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\Protocol\{
|
use LanguageServerProtocol\{
|
||||||
TextDocumentIdentifier,
|
TextDocumentIdentifier,
|
||||||
TextEdit,
|
TextEdit,
|
||||||
Range,
|
Range,
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace LanguageServer\Tests\Server\Workspace;
|
||||||
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
use LanguageServer\ContentRetriever\FileSystemContentRetriever;
|
||||||
use LanguageServer\{DefinitionResolver, LanguageClient, PhpDocumentLoader, Server};
|
use LanguageServer\{DefinitionResolver, LanguageClient, PhpDocumentLoader, Server};
|
||||||
use LanguageServer\Index\{DependenciesIndex, Index, ProjectIndex};
|
use LanguageServer\Index\{DependenciesIndex, Index, ProjectIndex};
|
||||||
use LanguageServer\Protocol\{FileChangeType, FileEvent, Message};
|
use LanguageServerProtocol\{FileChangeType, FileEvent};
|
||||||
|
use LanguageServer\Message;
|
||||||
use LanguageServer\Tests\MockProtocolStream;
|
use LanguageServer\Tests\MockProtocolStream;
|
||||||
use LanguageServer\Tests\Server\ServerTestCase;
|
use LanguageServer\Tests\Server\ServerTestCase;
|
||||||
use LanguageServer\Server\Workspace;
|
use LanguageServer\Server\Workspace;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue