1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Merge pull request #7887 from ging-dev/lsp-fixes

improve LSP
This commit is contained in:
orklah 2022-04-26 22:23:00 +02:00 committed by GitHub
commit 038947eb08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 27 deletions

View File

@ -142,11 +142,6 @@ class LanguageServer extends Dispatcher
return;
}
/** @psalm-suppress UndefinedPropertyFetch */
if ($msg->body->method === 'textDocument/signatureHelp') {
$this->doAnalysis();
}
$result = null;
$error = null;
try {

View File

@ -6,7 +6,6 @@ namespace Psalm\Internal\LanguageServer\Server;
use Amp\Promise;
use Amp\Success;
use InvalidArgumentException;
use LanguageServerProtocol\CompletionList;
use LanguageServerProtocol\Hover;
use LanguageServerProtocol\Location;
@ -27,7 +26,6 @@ use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\LanguageServer\LanguageServer;
use UnexpectedValueException;
use function array_combine;
use function array_values;
use function count;
use function error_log;
@ -92,8 +90,9 @@ class TextDocument
* The document save notification is sent from the client to the server when the document was saved in the client
*
* @param TextDocumentItem $textDocument the document that was opened
* @param ?string $text the content when saved
*/
public function didSave(TextDocumentItem $textDocument): void
public function didSave(TextDocumentItem $textDocument, ?string $text): void
{
$file_path = LanguageServer::uriToPath($textDocument->uri);
@ -103,7 +102,7 @@ class TextDocument
// reopen file
$this->codebase->removeTemporaryFileChanges($file_path);
$this->codebase->file_provider->setOpenContents($file_path, $textDocument->text);
$this->codebase->file_provider->setOpenContents($file_path, (string) $text);
$this->server->queueFileAnalysis($file_path, $textDocument->uri);
}
@ -122,10 +121,6 @@ class TextDocument
return;
}
if ($this->project_analyzer->onchange_line_limit === 0) {
return;
}
if (count($contentChanges) === 1 && $contentChanges[0]->range === null) {
$new_content = $contentChanges[0]->text;
} else {
@ -266,8 +261,6 @@ class TextDocument
*/
public function completion(TextDocumentIdentifier $textDocument, Position $position): Promise
{
$this->server->doAnalysis();
$file_path = LanguageServer::uriToPath($textDocument->uri);
if (!$this->codebase->config->isInProjectDirs($file_path)) {
return new Success([]);
@ -361,18 +354,6 @@ class TextDocument
return new Success(null);
}
$all_file_paths_to_analyze = [$file_path];
$this->codebase->analyzer->addFilesToAnalyze(
array_combine($all_file_paths_to_analyze, $all_file_paths_to_analyze)
);
try {
$this->codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false);
} catch (UnexpectedValueException | InvalidArgumentException $e) {
error_log('codeAction errored on file ' . $file_path. ', Reason: '.$e->getMessage());
return new Success(null);
}
$issues = $this->server->getCurrentIssues();
if (empty($issues[$file_path])) {