Skip to content

Commit

Permalink
Merge pull request #7247 from tm1000/bugfix/7246
Browse files Browse the repository at this point in the history
Fixes #7246, wrap getTypeContextAtPosition in try/catch
  • Loading branch information
orklah committed Jan 1, 2022
2 parents 51ba96c + 409910c commit 8dc1a31
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Psalm/Internal/LanguageServer/Server/TextDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,16 @@ public function completion(TextDocumentIdentifier $textDocument, Position $posit
return new Success([]);
}

$type_context = $this->codebase->getTypeContextAtPosition($file_path, $position);
try {
$type_context = $this->codebase->getTypeContextAtPosition($file_path, $position);
} catch (UnexpectedValueException $e) {
error_log('completion errored at ' . $position->line . ':' . $position->character.
', Reason: '.$e->getMessage());
return new Success([]);
}

if (!$completion_data && !$type_context) {
error_log('completion not found at ' . $position->line . ':' . $position->character);

return new Success([]);
}

Expand Down

0 comments on commit 8dc1a31

Please sign in to comment.