From 18c6ccd137b0bbe794a854fb8e9b18d574136dc4 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 9 Sep 2018 13:37:35 +0100 Subject: [PATCH] refactor: use protocol package (#661) Adapts the Language Server to use the extracted php language server protocol --- composer.json | 1 + src/Client/TextDocument.php | 2 +- src/Client/Workspace.php | 2 +- src/ClientHandler.php | 6 +- src/CompletionProvider.php | 11 +- .../ClientContentRetriever.php | 2 +- src/Definition.php | 2 +- src/DefinitionResolver.php | 7 +- src/Factory/CompletionItemFactory.php | 36 ++++ src/Factory/LocationFactory.php | 32 ++++ src/Factory/RangeFactory.php | 31 ++++ .../SymbolInformationFactory.php} | 62 ++----- src/Indexer.php | 2 +- src/LanguageServer.php | 4 +- src/{Protocol => }/Message.php | 3 +- src/PhpDocument.php | 2 +- src/Protocol/ClientCapabilities.php | 27 --- src/Protocol/CodeActionContext.php | 17 -- src/Protocol/CodeLens.php | 35 ---- src/Protocol/CodeLensOptions.php | 16 -- src/Protocol/Command.php | 32 ---- src/Protocol/CompletionContext.php | 30 ---- src/Protocol/CompletionItem.php | 164 ------------------ src/Protocol/CompletionItemKind.php | 70 -------- src/Protocol/CompletionList.php | 35 ---- src/Protocol/CompletionOptions.php | 24 --- src/Protocol/CompletionTriggerKind.php | 16 -- src/Protocol/ContentChangeEvent.php | 31 ---- src/Protocol/DependencyReference.php | 27 --- src/Protocol/Diagnostic.php | 63 ------- src/Protocol/DiagnosticSeverity.php | 26 --- src/Protocol/DocumentHighlight.php | 25 --- src/Protocol/DocumentHighlightKind.php | 24 --- .../DocumentOnTypeFormattingOptions.php | 23 --- src/Protocol/ErrorCode.php | 17 -- src/Protocol/FileChangeType.php | 24 --- src/Protocol/FileEvent.php | 33 ---- src/Protocol/FormattingOptions.php | 25 --- src/Protocol/Hover.php | 33 ---- src/Protocol/InitializeResult.php | 21 --- src/Protocol/Location.php | 43 ----- src/Protocol/MarkedString.php | 22 --- src/Protocol/MessageActionItem.php | 13 -- src/Protocol/MessageType.php | 29 ---- src/Protocol/PackageDescriptor.php | 25 --- src/Protocol/ParameterInformation.php | 39 ----- src/Protocol/Position.php | 65 ------- src/Protocol/Range.php | 59 ------- src/Protocol/ReferenceContext.php | 13 -- src/Protocol/ReferenceInformation.php | 36 ---- src/Protocol/ServerCapabilities.php | 132 -------------- src/Protocol/SignatureHelp.php | 46 ----- src/Protocol/SignatureHelpOptions.php | 16 -- src/Protocol/SignatureInformation.php | 49 ------ src/Protocol/SymbolDescriptor.php | 34 ---- src/Protocol/SymbolKind.php | 28 --- src/Protocol/SymbolLocationInformation.php | 32 ---- .../TextDocumentContentChangeEvent.php | 31 ---- src/Protocol/TextDocumentIdentifier.php | 21 --- src/Protocol/TextDocumentItem.php | 38 ---- src/Protocol/TextDocumentSyncKind.php | 25 --- src/Protocol/TextEdit.php | 31 ---- .../VersionedTextDocumentIdentifier.php | 13 -- src/Protocol/WorkspaceEdit.php | 16 -- src/ProtocolStreamReader.php | 2 +- src/ProtocolStreamWriter.php | 2 +- src/ProtocolWriter.php | 2 +- src/Server/TextDocument.php | 20 ++- src/Server/Workspace.php | 5 +- src/SignatureHelpProvider.php | 2 +- src/SignatureInformationFactory.php | 2 +- src/TreeAnalyzer.php | 5 +- tests/ClientHandlerTest.php | 2 +- tests/Diagnostics/InvalidThisUsageTest.php | 2 +- tests/LanguageServerTest.php | 4 +- tests/MockProtocolStream.php | 2 +- tests/PhpDocumentTest.php | 2 +- tests/ProtocolStreamReaderTest.php | 2 +- tests/ProtocolStreamWriterTest.php | 2 +- tests/Server/ServerTestCase.php | 2 +- tests/Server/TextDocument/CompletionTest.php | 2 +- .../Definition/GlobalFallbackTest.php | 2 +- .../TextDocument/Definition/GlobalTest.php | 2 +- .../Definition/NamespacedTest.php | 2 +- tests/Server/TextDocument/DidChangeTest.php | 2 +- tests/Server/TextDocument/DidCloseTest.php | 2 +- .../TextDocument/DocumentSymbolTest.php | 2 +- tests/Server/TextDocument/HoverTest.php | 2 +- tests/Server/TextDocument/ParseErrorsTest.php | 2 +- .../References/GlobalFallbackTest.php | 2 +- .../TextDocument/References/GlobalTest.php | 2 +- .../References/NamespacedTest.php | 2 +- .../Server/TextDocument/SignatureHelpTest.php | 2 +- .../Workspace/DidChangeWatchedFilesTest.php | 3 +- tests/Server/Workspace/SymbolTest.php | 2 +- tests/Validation/ValidationTest.php | 4 +- tests/Validation/cases/namespaces5.php | 2 +- .../cases/namespaces5.php.expected.json | 15 +- 98 files changed, 189 insertions(+), 1820 deletions(-) create mode 100644 src/Factory/CompletionItemFactory.php create mode 100644 src/Factory/LocationFactory.php create mode 100644 src/Factory/RangeFactory.php rename src/{Protocol/SymbolInformation.php => Factory/SymbolInformationFactory.php} (74%) rename src/{Protocol => }/Message.php (96%) delete mode 100644 src/Protocol/ClientCapabilities.php delete mode 100644 src/Protocol/CodeActionContext.php delete mode 100644 src/Protocol/CodeLens.php delete mode 100644 src/Protocol/CodeLensOptions.php delete mode 100644 src/Protocol/Command.php delete mode 100644 src/Protocol/CompletionContext.php delete mode 100644 src/Protocol/CompletionItem.php delete mode 100644 src/Protocol/CompletionItemKind.php delete mode 100644 src/Protocol/CompletionList.php delete mode 100644 src/Protocol/CompletionOptions.php delete mode 100644 src/Protocol/CompletionTriggerKind.php delete mode 100644 src/Protocol/ContentChangeEvent.php delete mode 100644 src/Protocol/DependencyReference.php delete mode 100644 src/Protocol/Diagnostic.php delete mode 100644 src/Protocol/DiagnosticSeverity.php delete mode 100644 src/Protocol/DocumentHighlight.php delete mode 100644 src/Protocol/DocumentHighlightKind.php delete mode 100644 src/Protocol/DocumentOnTypeFormattingOptions.php delete mode 100644 src/Protocol/ErrorCode.php delete mode 100644 src/Protocol/FileChangeType.php delete mode 100644 src/Protocol/FileEvent.php delete mode 100644 src/Protocol/FormattingOptions.php delete mode 100644 src/Protocol/Hover.php delete mode 100644 src/Protocol/InitializeResult.php delete mode 100644 src/Protocol/Location.php delete mode 100644 src/Protocol/MarkedString.php delete mode 100644 src/Protocol/MessageActionItem.php delete mode 100644 src/Protocol/MessageType.php delete mode 100644 src/Protocol/PackageDescriptor.php delete mode 100644 src/Protocol/ParameterInformation.php delete mode 100644 src/Protocol/Position.php delete mode 100644 src/Protocol/Range.php delete mode 100644 src/Protocol/ReferenceContext.php delete mode 100644 src/Protocol/ReferenceInformation.php delete mode 100644 src/Protocol/ServerCapabilities.php delete mode 100644 src/Protocol/SignatureHelp.php delete mode 100644 src/Protocol/SignatureHelpOptions.php delete mode 100644 src/Protocol/SignatureInformation.php delete mode 100644 src/Protocol/SymbolDescriptor.php delete mode 100644 src/Protocol/SymbolKind.php delete mode 100644 src/Protocol/SymbolLocationInformation.php delete mode 100644 src/Protocol/TextDocumentContentChangeEvent.php delete mode 100644 src/Protocol/TextDocumentIdentifier.php delete mode 100644 src/Protocol/TextDocumentItem.php delete mode 100644 src/Protocol/TextDocumentSyncKind.php delete mode 100644 src/Protocol/TextEdit.php delete mode 100644 src/Protocol/VersionedTextDocumentIdentifier.php delete mode 100644 src/Protocol/WorkspaceEdit.php diff --git a/composer.json b/composer.json index 085f189..ffa5971 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "php": "^7.0", "composer/xdebug-handler": "^1.0", "felixfbecker/advanced-json-rpc": "^3.0.0", + "felixfbecker/language-server-protocol": "^1.0.1", "jetbrains/phpstorm-stubs": "dev-master", "microsoft/tolerant-php-parser": "0.0.*", "netresearch/jsonmapper": "^1.0", diff --git a/src/Client/TextDocument.php b/src/Client/TextDocument.php index f163d60..7630438 100644 --- a/src/Client/TextDocument.php +++ b/src/Client/TextDocument.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer\Client; use LanguageServer\ClientHandler; -use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier}; +use LanguageServerProtocol\{TextDocumentItem, TextDocumentIdentifier}; use Sabre\Event\Promise; use JsonMapper; diff --git a/src/Client/Workspace.php b/src/Client/Workspace.php index 901e386..8c31f1f 100644 --- a/src/Client/Workspace.php +++ b/src/Client/Workspace.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer\Client; use LanguageServer\ClientHandler; -use LanguageServer\Protocol\TextDocumentIdentifier; +use LanguageServerProtocol\TextDocumentIdentifier; use Sabre\Event\Promise; use JsonMapper; diff --git a/src/ClientHandler.php b/src/ClientHandler.php index 9fe921b..c98cbc6 100644 --- a/src/ClientHandler.php +++ b/src/ClientHandler.php @@ -41,12 +41,12 @@ class ClientHandler { $id = $this->idGenerator->generate(); return $this->protocolWriter->write( - new Protocol\Message( + new Message( new AdvancedJsonRpc\Request($id, $method, (object)$params) ) )->then(function () use ($id) { $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) { // Received a response $this->protocolReader->removeListener('message', $listener); @@ -72,7 +72,7 @@ class ClientHandler public function notify(string $method, $params): Promise { return $this->protocolWriter->write( - new Protocol\Message( + new Message( new AdvancedJsonRpc\Notification($method, (object)$params) ) ); diff --git a/src/CompletionProvider.php b/src/CompletionProvider.php index d8fefa8..44cf5b8 100644 --- a/src/CompletionProvider.php +++ b/src/CompletionProvider.php @@ -4,7 +4,8 @@ declare(strict_types = 1); namespace LanguageServer; use LanguageServer\Index\ReadableIndex; -use LanguageServer\Protocol\{ +use LanguageServer\Factory\CompletionItemFactory; +use LanguageServerProtocol\{ TextEdit, Range, Position, @@ -246,7 +247,7 @@ class CompletionProvider foreach ($this->index->getDefinitions() as $fqn => $def) { foreach ($prefixes as $prefix) { if (substr($fqn, 0, strlen($prefix)) === $prefix && $def->isMember) { - $list->items[] = CompletionItem::fromDefinition($def); + $list->items[] = CompletionItemFactory::fromDefinition($def); } } } @@ -279,7 +280,7 @@ class CompletionProvider foreach ($this->index->getDefinitions() as $fqn => $def) { foreach ($prefixes as $prefix) { if (substr(strtolower($fqn), 0, strlen($prefix)) === strtolower($prefix) && $def->isMember) { - $list->items[] = CompletionItem::fromDefinition($def); + $list->items[] = CompletionItemFactory::fromDefinition($def); } } } @@ -337,7 +338,7 @@ class CompletionProvider foreach ($aliases as $alias => $fqn) { // Suggest symbols that have been `use`d and match the prefix if (substr($alias, 0, $prefixLen) === $prefix && ($def = $this->index->getDefinition($fqn))) { - $list->items[] = CompletionItem::fromDefinition($def); + $list->items[] = CompletionItemFactory::fromDefinition($def); } } } @@ -370,7 +371,7 @@ class CompletionProvider // Only suggest classes for `new` && (!isset($creation) || $def->canBeInstantiated) ) { - $item = CompletionItem::fromDefinition($def); + $item = CompletionItemFactory::fromDefinition($def); // Find the shortest name to reference the symbol if ($namespaceNode && ($alias = array_search($fqn, $aliases, true)) !== false) { // $alias is the name under which this definition is aliased in the current namespace diff --git a/src/ContentRetriever/ClientContentRetriever.php b/src/ContentRetriever/ClientContentRetriever.php index b88042c..d83aad1 100644 --- a/src/ContentRetriever/ClientContentRetriever.php +++ b/src/ContentRetriever/ClientContentRetriever.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer\ContentRetriever; use LanguageServer\LanguageClient; -use LanguageServer\Protocol\{TextDocumentIdentifier, TextDocumentItem}; +use LanguageServerProtocol\{TextDocumentIdentifier, TextDocumentItem}; use Sabre\Event\Promise; /** diff --git a/src/Definition.php b/src/Definition.php index 1600408..9ea27f9 100644 --- a/src/Definition.php +++ b/src/Definition.php @@ -5,7 +5,7 @@ namespace LanguageServer; use LanguageServer\Index\ReadableIndex; use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver}; -use LanguageServer\Protocol\SymbolInformation; +use LanguageServerProtocol\SymbolInformation; use Generator; /** diff --git a/src/DefinitionResolver.php b/src/DefinitionResolver.php index 990c196..3a4f378 100644 --- a/src/DefinitionResolver.php +++ b/src/DefinitionResolver.php @@ -4,7 +4,8 @@ declare(strict_types = 1); namespace LanguageServer; use LanguageServer\Index\ReadableIndex; -use LanguageServer\Protocol\SymbolInformation; +use LanguageServer\Factory\SymbolInformationFactory; +use LanguageServerProtocol\SymbolInformation; use Microsoft\PhpParser; use Microsoft\PhpParser\Node; use Microsoft\PhpParser\FunctionLike; @@ -36,7 +37,7 @@ class DefinitionResolver private $docBlockFactory; /** - * Creates SignatureInformation + * Creates SignatureInformation instances * * @var SignatureInformationFactory */ @@ -233,7 +234,7 @@ class DefinitionResolver } } - $def->symbolInformation = SymbolInformation::fromNode($node, $fqn); + $def->symbolInformation = SymbolInformationFactory::fromNode($node, $fqn); if ($def->symbolInformation !== null) { $def->type = $this->getTypeFromNode($node); diff --git a/src/Factory/CompletionItemFactory.php b/src/Factory/CompletionItemFactory.php new file mode 100644 index 0000000..ce00fa6 --- /dev/null +++ b/src/Factory/CompletionItemFactory.php @@ -0,0 +1,36 @@ +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; + } +} diff --git a/src/Factory/LocationFactory.php b/src/Factory/LocationFactory.php new file mode 100644 index 0000000..3ccc80b --- /dev/null +++ b/src/Factory/LocationFactory.php @@ -0,0 +1,32 @@ +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) + )); + } +} diff --git a/src/Factory/RangeFactory.php b/src/Factory/RangeFactory.php new file mode 100644 index 0000000..b438db5 --- /dev/null +++ b/src/Factory/RangeFactory.php @@ -0,0 +1,31 @@ +getStart(), + $node->getWidth(), + $node->getFileContents() + ); + + return new Range( + new Position($range->start->line, $range->start->character), + new Position($range->end->line, $range->end->character) + ); + } +} diff --git a/src/Protocol/SymbolInformation.php b/src/Factory/SymbolInformationFactory.php similarity index 74% rename from src/Protocol/SymbolInformation.php rename to src/Factory/SymbolInformationFactory.php index 499e417..b03d951 100644 --- a/src/Protocol/SymbolInformation.php +++ b/src/Factory/SymbolInformationFactory.php @@ -1,44 +1,16 @@ kind = SymbolKind::CLASS_; } else if ($node instanceof Node\Statement\TraitDeclaration) { @@ -98,7 +70,7 @@ class SymbolInformation $symbol->name = $node->getName(); } else if (isset($node->name)) { 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 { $symbol->name = ltrim((string)$node->name->getText($node->getFileContents()), "$"); } @@ -108,7 +80,7 @@ class SymbolInformation return null; } - $symbol->location = Location::fromNode($node); + $symbol->location = LocationFactory::fromNode($node); if ($fqn !== null) { $parts = preg_split('/(::|->|\\\\)/', $fqn); array_pop($parts); @@ -116,18 +88,4 @@ class SymbolInformation } 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; - } } diff --git a/src/Indexer.php b/src/Indexer.php index 85d1787..8b1fd9b 100644 --- a/src/Indexer.php +++ b/src/Indexer.php @@ -6,7 +6,7 @@ namespace LanguageServer; use LanguageServer\Cache\Cache; use LanguageServer\FilesFinder\FilesFinder; use LanguageServer\Index\{DependenciesIndex, Index}; -use LanguageServer\Protocol\MessageType; +use LanguageServerProtocol\MessageType; use Webmozart\PathUtil\Path; use Sabre\Event\Promise; use function Sabre\Event\coroutine; diff --git a/src/LanguageServer.php b/src/LanguageServer.php index 46281f5..05dd48a 100644 --- a/src/LanguageServer.php +++ b/src/LanguageServer.php @@ -3,15 +3,15 @@ declare(strict_types = 1); namespace LanguageServer; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ ServerCapabilities, ClientCapabilities, TextDocumentSyncKind, - Message, InitializeResult, CompletionOptions, SignatureHelpOptions }; +use LanguageServer\Message; use LanguageServer\FilesFinder\{FilesFinder, ClientFilesFinder, FileSystemFilesFinder}; use LanguageServer\ContentRetriever\{ContentRetriever, ClientContentRetriever, FileSystemContentRetriever}; use LanguageServer\Index\{DependenciesIndex, GlobalIndex, Index, ProjectIndex, StubsIndex}; diff --git a/src/Protocol/Message.php b/src/Message.php similarity index 96% rename from src/Protocol/Message.php rename to src/Message.php index 8df5d0e..fb51110 100644 --- a/src/Protocol/Message.php +++ b/src/Message.php @@ -1,9 +1,10 @@ triggerKind = $triggerKind; - $this->triggerCharacter = $triggerCharacter; - } -} diff --git a/src/Protocol/CompletionItem.php b/src/Protocol/CompletionItem.php deleted file mode 100644 index 64bc69d..0000000 --- a/src/Protocol/CompletionItem.php +++ /dev/null @@ -1,164 +0,0 @@ -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; - } -} diff --git a/src/Protocol/CompletionItemKind.php b/src/Protocol/CompletionItemKind.php deleted file mode 100644 index 046f8ef..0000000 --- a/src/Protocol/CompletionItemKind.php +++ /dev/null @@ -1,70 +0,0 @@ -items = $items; - $this->isIncomplete = $isIncomplete; - } -} diff --git a/src/Protocol/CompletionOptions.php b/src/Protocol/CompletionOptions.php deleted file mode 100644 index f668ca0..0000000 --- a/src/Protocol/CompletionOptions.php +++ /dev/null @@ -1,24 +0,0 @@ -attributes = $attributes ?? new \stdClass; - $this->hints = $hints; - } -} diff --git a/src/Protocol/Diagnostic.php b/src/Protocol/Diagnostic.php deleted file mode 100644 index 7bf9895..0000000 --- a/src/Protocol/Diagnostic.php +++ /dev/null @@ -1,63 +0,0 @@ -message = $message; - $this->range = $range; - $this->code = $code; - $this->severity = $severity; - $this->source = $source; - } -} diff --git a/src/Protocol/DiagnosticSeverity.php b/src/Protocol/DiagnosticSeverity.php deleted file mode 100644 index e91da8f..0000000 --- a/src/Protocol/DiagnosticSeverity.php +++ /dev/null @@ -1,26 +0,0 @@ -uri = $uri; - $this->type = $type; - } -} diff --git a/src/Protocol/FormattingOptions.php b/src/Protocol/FormattingOptions.php deleted file mode 100644 index b672ddf..0000000 --- a/src/Protocol/FormattingOptions.php +++ /dev/null @@ -1,25 +0,0 @@ -contents = $contents; - $this->range = $range; - } -} diff --git a/src/Protocol/InitializeResult.php b/src/Protocol/InitializeResult.php deleted file mode 100644 index 4a18e82..0000000 --- a/src/Protocol/InitializeResult.php +++ /dev/null @@ -1,21 +0,0 @@ -capabilities = $capabilities ?? new ServerCapabilities(); - } -} diff --git a/src/Protocol/Location.php b/src/Protocol/Location.php deleted file mode 100644 index 50fedfa..0000000 --- a/src/Protocol/Location.php +++ /dev/null @@ -1,43 +0,0 @@ -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; - } -} diff --git a/src/Protocol/MarkedString.php b/src/Protocol/MarkedString.php deleted file mode 100644 index 0799f14..0000000 --- a/src/Protocol/MarkedString.php +++ /dev/null @@ -1,22 +0,0 @@ -language = $language; - $this->value = $value; - } -} diff --git a/src/Protocol/MessageActionItem.php b/src/Protocol/MessageActionItem.php deleted file mode 100644 index 59dafe5..0000000 --- a/src/Protocol/MessageActionItem.php +++ /dev/null @@ -1,13 +0,0 @@ -name = $name; - } -} diff --git a/src/Protocol/ParameterInformation.php b/src/Protocol/ParameterInformation.php deleted file mode 100644 index fa9b7bf..0000000 --- a/src/Protocol/ParameterInformation.php +++ /dev/null @@ -1,39 +0,0 @@ -label = $label; - $this->documentation = $documentation; - } -} diff --git a/src/Protocol/Position.php b/src/Protocol/Position.php deleted file mode 100644 index f47afe2..0000000 --- a/src/Protocol/Position.php +++ /dev/null @@ -1,65 +0,0 @@ -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; - } -} diff --git a/src/Protocol/Range.php b/src/Protocol/Range.php deleted file mode 100644 index 1e19a5a..0000000 --- a/src/Protocol/Range.php +++ /dev/null @@ -1,59 +0,0 @@ -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; - } -} diff --git a/src/Protocol/ReferenceContext.php b/src/Protocol/ReferenceContext.php deleted file mode 100644 index bd546d5..0000000 --- a/src/Protocol/ReferenceContext.php +++ /dev/null @@ -1,13 +0,0 @@ -reference = $reference; - $this->symbol = $symbol; - } -} diff --git a/src/Protocol/ServerCapabilities.php b/src/Protocol/ServerCapabilities.php deleted file mode 100644 index 1893a51..0000000 --- a/src/Protocol/ServerCapabilities.php +++ /dev/null @@ -1,132 +0,0 @@ -signatures = $signatures; - $this->activeSignature = $activeSignature; - $this->activeParameter = $activeParameter; - } -} diff --git a/src/Protocol/SignatureHelpOptions.php b/src/Protocol/SignatureHelpOptions.php deleted file mode 100644 index 25b0e37..0000000 --- a/src/Protocol/SignatureHelpOptions.php +++ /dev/null @@ -1,16 +0,0 @@ -label = $label; - $this->parameters = $parameters; - $this->documentation = $documentation; - } -} diff --git a/src/Protocol/SymbolDescriptor.php b/src/Protocol/SymbolDescriptor.php deleted file mode 100644 index 4116864..0000000 --- a/src/Protocol/SymbolDescriptor.php +++ /dev/null @@ -1,34 +0,0 @@ -fqsen = $fqsen; - $this->package = $package; - } -} diff --git a/src/Protocol/SymbolKind.php b/src/Protocol/SymbolKind.php deleted file mode 100644 index e8a44e2..0000000 --- a/src/Protocol/SymbolKind.php +++ /dev/null @@ -1,28 +0,0 @@ -symbol = $symbol; - $this->location = $location; - } -} diff --git a/src/Protocol/TextDocumentContentChangeEvent.php b/src/Protocol/TextDocumentContentChangeEvent.php deleted file mode 100644 index 9cfa08b..0000000 --- a/src/Protocol/TextDocumentContentChangeEvent.php +++ /dev/null @@ -1,31 +0,0 @@ -uri = $uri; - } -} diff --git a/src/Protocol/TextDocumentItem.php b/src/Protocol/TextDocumentItem.php deleted file mode 100644 index 0c86664..0000000 --- a/src/Protocol/TextDocumentItem.php +++ /dev/null @@ -1,38 +0,0 @@ -range = $range; - $this->newText = $newText; - } -} diff --git a/src/Protocol/VersionedTextDocumentIdentifier.php b/src/Protocol/VersionedTextDocumentIdentifier.php deleted file mode 100644 index ba74e42..0000000 --- a/src/Protocol/VersionedTextDocumentIdentifier.php +++ /dev/null @@ -1,13 +0,0 @@ - */ 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 uri. * - * @param \LanguageServer\Protocol\TextDocumentItem $textDocument The document that was opened. + * @param \LanguageServerProtocol\TextDocumentItem $textDocument The document that was opened. * @return void */ 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. * - * @param \LanguageServer\Protocol\VersionedTextDocumentIdentifier $textDocument - * @param \LanguageServer\Protocol\TextDocumentContentChangeEvent[] $contentChanges + * @param \LanguageServerProtocol\VersionedTextDocumentIdentifier $textDocument + * @param \LanguageServerProtocol\TextDocumentContentChangeEvent[] $contentChanges * @return void */ 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 * 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 */ public function didClose(TextDocumentIdentifier $textDocument) @@ -208,7 +210,7 @@ class TextDocument if ($descendantNode instanceof Node\Expression\Variable && $descendantNode->getName() === $node->getName() ) { - $locations[] = Location::fromNode($descendantNode); + $locations[] = LocationFactory::fromNode($descendantNode); } } } else { @@ -233,7 +235,7 @@ class TextDocument $refs = $document->getReferenceNodesByFqn($fqn); if ($refs !== null) { foreach ($refs as $ref) { - $locations[] = Location::fromNode($ref); + $locations[] = LocationFactory::fromNode($ref); } } } @@ -332,7 +334,7 @@ class TextDocument } yield waitForEvent($this->index, 'definition-added'); } - $range = Range::fromNode($node); + $range = RangeFactory::fromNode($node); if ($def === null) { return new Hover([], $range); } diff --git a/src/Server/Workspace.php b/src/Server/Workspace.php index 548197b..fd93a9e 100644 --- a/src/Server/Workspace.php +++ b/src/Server/Workspace.php @@ -5,7 +5,8 @@ namespace LanguageServer\Server; use LanguageServer\{LanguageClient, PhpDocumentLoader}; use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index}; -use LanguageServer\Protocol\{ +use LanguageServer\Factory\LocationFactory; +use LanguageServerProtocol\{ FileChangeType, FileEvent, SymbolInformation, @@ -150,7 +151,7 @@ class Workspace $doc = yield $this->documentLoader->getOrLoad($uri); foreach ($doc->getReferenceNodesByFqn($fqn) as $node) { $refInfo = new ReferenceInformation; - $refInfo->reference = Location::fromNode($node); + $refInfo->reference = LocationFactory::fromNode($node); $refInfo->symbol = $query; $refInfos[] = $refInfo; } diff --git a/src/SignatureHelpProvider.php b/src/SignatureHelpProvider.php index 439be9c..43851b0 100644 --- a/src/SignatureHelpProvider.php +++ b/src/SignatureHelpProvider.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer; use LanguageServer\Index\ReadableIndex; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ Position, SignatureHelp, ParameterInformation diff --git a/src/SignatureInformationFactory.php b/src/SignatureInformationFactory.php index 6b8a1f0..86402b6 100644 --- a/src/SignatureInformationFactory.php +++ b/src/SignatureInformationFactory.php @@ -3,7 +3,7 @@ declare(strict_types = 1); namespace LanguageServer; -use LanguageServer\Protocol\{SignatureInformation, ParameterInformation}; +use LanguageServerProtocol\{SignatureInformation, ParameterInformation}; use Microsoft\PhpParser\FunctionLike; class SignatureInformationFactory diff --git a/src/TreeAnalyzer.php b/src/TreeAnalyzer.php index 03ad539..6b48470 100644 --- a/src/TreeAnalyzer.php +++ b/src/TreeAnalyzer.php @@ -3,7 +3,8 @@ declare(strict_types = 1); namespace LanguageServer; -use LanguageServer\Protocol\{Diagnostic, DiagnosticSeverity, Range, Position}; +use LanguageServer\Factory\RangeFactory; +use LanguageServerProtocol\{Diagnostic, DiagnosticSeverity, Range, Position}; use phpDocumentor\Reflection\DocBlockFactory; use Microsoft\PhpParser; use Microsoft\PhpParser\Node; @@ -100,7 +101,7 @@ class TreeAnalyzer if ($method && $method->isStatic()) { $this->diagnostics[] = new Diagnostic( "\$this can not be used in static methods.", - Range::fromNode($node), + RangeFactory::fromNode($node), null, DiagnosticSeverity::ERROR, 'php' diff --git a/tests/ClientHandlerTest.php b/tests/ClientHandlerTest.php index 214b018..19114d9 100644 --- a/tests/ClientHandlerTest.php +++ b/tests/ClientHandlerTest.php @@ -5,7 +5,7 @@ namespace LanguageServer\Tests; use PHPUnit\Framework\TestCase; use LanguageServer\ClientHandler; -use LanguageServer\Protocol\Message; +use LanguageServer\Message; use AdvancedJsonRpc; use Sabre\Event\Loop; diff --git a/tests/Diagnostics/InvalidThisUsageTest.php b/tests/Diagnostics/InvalidThisUsageTest.php index b7e8196..566c1c0 100644 --- a/tests/Diagnostics/InvalidThisUsageTest.php +++ b/tests/Diagnostics/InvalidThisUsageTest.php @@ -9,7 +9,7 @@ use LanguageServer\{ DefinitionResolver, TreeAnalyzer }; use LanguageServer\Index\{Index}; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ Diagnostic, DiagnosticSeverity, Position, Range }; use function LanguageServer\pathToUri; diff --git a/tests/LanguageServerTest.php b/tests/LanguageServerTest.php index 52963e6..10ca3f9 100644 --- a/tests/LanguageServerTest.php +++ b/tests/LanguageServerTest.php @@ -5,8 +5,8 @@ namespace LanguageServer\Tests; use PHPUnit\Framework\TestCase; use LanguageServer\LanguageServer; -use LanguageServer\Protocol\{ - Message, +use LanguageServer\Message; +use LanguageServerProtocol\{ ClientCapabilities, TextDocumentSyncKind, MessageType, diff --git a/tests/MockProtocolStream.php b/tests/MockProtocolStream.php index b2a489d..9287053 100644 --- a/tests/MockProtocolStream.php +++ b/tests/MockProtocolStream.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer\Tests; use LanguageServer\{ProtocolReader, ProtocolWriter}; -use LanguageServer\Protocol\Message; +use LanguageServer\Message; use Sabre\Event\{Loop, Emitter, Promise}; /** diff --git a/tests/PhpDocumentTest.php b/tests/PhpDocumentTest.php index ae1b5cd..710e651 100644 --- a/tests/PhpDocumentTest.php +++ b/tests/PhpDocumentTest.php @@ -9,7 +9,7 @@ use LanguageServer\{ use LanguageServer\Index\{ Index }; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ Position }; use Microsoft\PhpParser; diff --git a/tests/ProtocolStreamReaderTest.php b/tests/ProtocolStreamReaderTest.php index 69eea37..a0dcad5 100644 --- a/tests/ProtocolStreamReaderTest.php +++ b/tests/ProtocolStreamReaderTest.php @@ -5,7 +5,7 @@ namespace LanguageServer\Tests; use PHPUnit\Framework\TestCase; use LanguageServer\{LanguageServer, ProtocolStreamReader, ProtocolStreamWriter}; -use LanguageServer\Protocol\Message; +use LanguageServer\Message; use AdvancedJsonRpc\{Request as RequestBody, Response as ResponseBody}; use Sabre\Event\Loop; diff --git a/tests/ProtocolStreamWriterTest.php b/tests/ProtocolStreamWriterTest.php index b67bdcb..8ac94e7 100644 --- a/tests/ProtocolStreamWriterTest.php +++ b/tests/ProtocolStreamWriterTest.php @@ -5,7 +5,7 @@ namespace LanguageServer\Tests; use PHPUnit\Framework\TestCase; use LanguageServer\ProtocolStreamWriter; -use LanguageServer\Protocol\Message; +use LanguageServer\Message; use AdvancedJsonRpc\{Request as RequestBody}; use Sabre\Event\Loop; diff --git a/tests/Server/ServerTestCase.php b/tests/Server/ServerTestCase.php index 45d949f..880e1a0 100644 --- a/tests/Server/ServerTestCase.php +++ b/tests/Server/ServerTestCase.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\Index\{ProjectIndex, DependenciesIndex, Index}; use LanguageServer\ContentRetriever\FileSystemContentRetriever; -use LanguageServer\Protocol\{Position, Location, Range}; +use LanguageServerProtocol\{Position, Location, Range}; use function LanguageServer\pathToUri; abstract class ServerTestCase extends TestCase diff --git a/tests/Server/TextDocument/CompletionTest.php b/tests/Server/TextDocument/CompletionTest.php index 2b4e9ff..c64c8e6 100644 --- a/tests/Server/TextDocument/CompletionTest.php +++ b/tests/Server/TextDocument/CompletionTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; use LanguageServer\ContentRetriever\FileSystemContentRetriever; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ TextDocumentIdentifier, TextEdit, Range, diff --git a/tests/Server/TextDocument/Definition/GlobalFallbackTest.php b/tests/Server/TextDocument/Definition/GlobalFallbackTest.php index 4e45f9e..cca6d4d 100644 --- a/tests/Server/TextDocument/Definition/GlobalFallbackTest.php +++ b/tests/Server/TextDocument/Definition/GlobalFallbackTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; use LanguageServer\ContentRetriever\FileSystemContentRetriever; -use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Location}; +use LanguageServerProtocol\{TextDocumentIdentifier, Position, Range, Location}; class GlobalFallbackTest extends ServerTestCase { diff --git a/tests/Server/TextDocument/Definition/GlobalTest.php b/tests/Server/TextDocument/Definition/GlobalTest.php index 2a80873..fdfb3b2 100644 --- a/tests/Server/TextDocument/Definition/GlobalTest.php +++ b/tests/Server/TextDocument/Definition/GlobalTest.php @@ -4,7 +4,7 @@ declare(strict_types = 1); namespace LanguageServer\Tests\Server\TextDocument\Definition; use LanguageServer\Tests\Server\ServerTestCase; -use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Location, Range}; +use LanguageServerProtocol\{TextDocumentIdentifier, Position, Location, Range}; use function LanguageServer\pathToUri; class GlobalTest extends ServerTestCase diff --git a/tests/Server/TextDocument/Definition/NamespacedTest.php b/tests/Server/TextDocument/Definition/NamespacedTest.php index 395881b..0f9a582 100644 --- a/tests/Server/TextDocument/Definition/NamespacedTest.php +++ b/tests/Server/TextDocument/Definition/NamespacedTest.php @@ -3,7 +3,7 @@ declare(strict_types = 1); namespace LanguageServer\Tests\Server\TextDocument\Definition; -use LanguageServer\Protocol\{TextDocumentIdentifier, Location}; +use LanguageServerProtocol\{TextDocumentIdentifier, Location}; use function LanguageServer\pathToUri; class NamespacedTest extends GlobalTest diff --git a/tests/Server/TextDocument/DidChangeTest.php b/tests/Server/TextDocument/DidChangeTest.php index 4d26ed8..0f92ed7 100644 --- a/tests/Server/TextDocument/DidChangeTest.php +++ b/tests/Server/TextDocument/DidChangeTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\ContentRetriever\FileSystemContentRetriever; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ VersionedTextDocumentIdentifier, TextDocumentContentChangeEvent, Range, diff --git a/tests/Server/TextDocument/DidCloseTest.php b/tests/Server/TextDocument/DidCloseTest.php index 42daec5..22eb534 100644 --- a/tests/Server/TextDocument/DidCloseTest.php +++ b/tests/Server/TextDocument/DidCloseTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\ContentRetriever\FileSystemContentRetriever; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; -use LanguageServer\Protocol\{TextDocumentItem, TextDocumentIdentifier}; +use LanguageServerProtocol\{TextDocumentItem, TextDocumentIdentifier}; class DidCloseTest extends TestCase { diff --git a/tests/Server/TextDocument/DocumentSymbolTest.php b/tests/Server/TextDocument/DocumentSymbolTest.php index 155e4a2..205e8fe 100644 --- a/tests/Server/TextDocument/DocumentSymbolTest.php +++ b/tests/Server/TextDocument/DocumentSymbolTest.php @@ -6,7 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument; use LanguageServer\Tests\Server\ServerTestCase; use LanguageServer\Tests\MockProtocolStream; 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; class DocumentSymbolTest extends ServerTestCase diff --git a/tests/Server/TextDocument/HoverTest.php b/tests/Server/TextDocument/HoverTest.php index 2ba49e1..42b69c8 100644 --- a/tests/Server/TextDocument/HoverTest.php +++ b/tests/Server/TextDocument/HoverTest.php @@ -6,7 +6,7 @@ namespace LanguageServer\Tests\Server\TextDocument; use LanguageServer\Tests\MockProtocolStream; use LanguageServer\Tests\Server\ServerTestCase; use LanguageServer\{Server, LanguageClient, Project}; -use LanguageServer\Protocol\{TextDocumentIdentifier, Position, Range, Hover, MarkedString}; +use LanguageServerProtocol\{TextDocumentIdentifier, Position, Range, Hover, MarkedString}; use function LanguageServer\pathToUri; class HoverTest extends ServerTestCase diff --git a/tests/Server/TextDocument/ParseErrorsTest.php b/tests/Server/TextDocument/ParseErrorsTest.php index 4428523..09cdc98 100644 --- a/tests/Server/TextDocument/ParseErrorsTest.php +++ b/tests/Server/TextDocument/ParseErrorsTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; use LanguageServer\ContentRetriever\FileSystemContentRetriever; -use LanguageServer\Protocol\{TextDocumentItem, DiagnosticSeverity}; +use LanguageServerProtocol\{TextDocumentItem, DiagnosticSeverity}; use Sabre\Event\Promise; use JsonMapper; diff --git a/tests/Server/TextDocument/References/GlobalFallbackTest.php b/tests/Server/TextDocument/References/GlobalFallbackTest.php index abfefce..b1cbdac 100644 --- a/tests/Server/TextDocument/References/GlobalFallbackTest.php +++ b/tests/Server/TextDocument/References/GlobalFallbackTest.php @@ -10,7 +10,7 @@ use LanguageServer\ContentRetriever\FileSystemContentRetriever; use LanguageServer\Index\{ DependenciesIndex, Index, ProjectIndex }; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ Location, Position, Range, ReferenceContext, TextDocumentIdentifier }; use LanguageServer\Tests\MockProtocolStream; diff --git a/tests/Server/TextDocument/References/GlobalTest.php b/tests/Server/TextDocument/References/GlobalTest.php index 105dfef..d2550c8 100644 --- a/tests/Server/TextDocument/References/GlobalTest.php +++ b/tests/Server/TextDocument/References/GlobalTest.php @@ -3,7 +3,7 @@ declare(strict_types = 1); 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 function LanguageServer\pathToUri; diff --git a/tests/Server/TextDocument/References/NamespacedTest.php b/tests/Server/TextDocument/References/NamespacedTest.php index 1ee1ab4..b2bb9bb 100644 --- a/tests/Server/TextDocument/References/NamespacedTest.php +++ b/tests/Server/TextDocument/References/NamespacedTest.php @@ -3,7 +3,7 @@ declare(strict_types = 1); 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; class NamespacedTest extends GlobalTest diff --git a/tests/Server/TextDocument/SignatureHelpTest.php b/tests/Server/TextDocument/SignatureHelpTest.php index 2004aae..83dcb2c 100644 --- a/tests/Server/TextDocument/SignatureHelpTest.php +++ b/tests/Server/TextDocument/SignatureHelpTest.php @@ -10,7 +10,7 @@ use LanguageServer\{ }; use LanguageServer\Index\{Index, ProjectIndex, DependenciesIndex}; use LanguageServer\ContentRetriever\FileSystemContentRetriever; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ TextDocumentIdentifier, TextEdit, Range, diff --git a/tests/Server/Workspace/DidChangeWatchedFilesTest.php b/tests/Server/Workspace/DidChangeWatchedFilesTest.php index 1074c58..1f57acd 100644 --- a/tests/Server/Workspace/DidChangeWatchedFilesTest.php +++ b/tests/Server/Workspace/DidChangeWatchedFilesTest.php @@ -6,7 +6,8 @@ namespace LanguageServer\Tests\Server\Workspace; use LanguageServer\ContentRetriever\FileSystemContentRetriever; use LanguageServer\{DefinitionResolver, LanguageClient, PhpDocumentLoader, Server}; 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\Server\ServerTestCase; use LanguageServer\Server\Workspace; diff --git a/tests/Server/Workspace/SymbolTest.php b/tests/Server/Workspace/SymbolTest.php index 765841b..9dc5df1 100644 --- a/tests/Server/Workspace/SymbolTest.php +++ b/tests/Server/Workspace/SymbolTest.php @@ -6,7 +6,7 @@ namespace LanguageServer\Tests\Server\Workspace; use LanguageServer\Tests\MockProtocolStream; use LanguageServer\Tests\Server\ServerTestCase; use LanguageServer\{Server, Client, LanguageClient, Project, PhpDocument}; -use LanguageServer\Protocol\{ +use LanguageServerProtocol\{ TextDocumentItem, TextDocumentIdentifier, SymbolInformation, diff --git a/tests/Validation/ValidationTest.php b/tests/Validation/ValidationTest.php index 9057c9d..2c3efaf 100644 --- a/tests/Validation/ValidationTest.php +++ b/tests/Validation/ValidationTest.php @@ -13,7 +13,7 @@ use phpDocumentor\Reflection\DocBlock; use phpDocumentor\Reflection\DocBlockFactory; use PHPUnit\Framework\TestCase; use LanguageServer\ClientHandler; -use LanguageServer\Protocol\Message; +use LanguageServer\Message; use AdvancedJsonRpc; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; @@ -64,7 +64,7 @@ class ValidationTest extends TestCase try { $this->assertEquals($expectedValues['definitions'], $actualValues['definitions']); - $this->assertEquals((array)$expectedValues['references'], (array)$actualValues['references'], 'references don\'t match.'); + $this->assertEquals((array)$expectedValues['references'], (array)$actualValues['references'], sprintf('references match in "%s"', $outputFile)); } catch (\Throwable $e) { $outputFile = getExpectedValuesFile($testCaseFile); file_put_contents($outputFile, json_encode($actualValues, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); diff --git a/tests/Validation/cases/namespaces5.php b/tests/Validation/cases/namespaces5.php index 85ee4b5..d4a37b2 100644 --- a/tests/Validation/cases/namespaces5.php +++ b/tests/Validation/cases/namespaces5.php @@ -1,3 +1,3 @@