mirror of
https://github.com/danog/psalm.git
synced 2025-01-23 06:11:25 +01:00
add experimental in memory option
This commit is contained in:
parent
f908b9ad85
commit
3271b1b8f3
@ -3,6 +3,7 @@
|
||||
namespace Psalm\Internal\Cli;
|
||||
|
||||
use LanguageServerProtocol\MessageType;
|
||||
use Psalm\Config;
|
||||
use Psalm\Internal\CliUtils;
|
||||
use Psalm\Internal\ErrorHandler;
|
||||
use Psalm\Internal\Fork\PsalmRestarter;
|
||||
@ -87,6 +88,7 @@ final class LanguageServer
|
||||
'enable-provide-signature-help::',
|
||||
'enable-provide-definition::',
|
||||
'show-diagnostic-warnings::',
|
||||
'in-memory::',
|
||||
'disable-xdebug::',
|
||||
'on-change-debounce-ms::',
|
||||
'use-extended-diagnostic-codes',
|
||||
@ -216,6 +218,9 @@ final class LanguageServer
|
||||
--disable-xdebug[=BOOL]
|
||||
Disable xdebug for performance reasons. Enable for debugging
|
||||
|
||||
--in-memory[=BOOL]
|
||||
Use in-memory mode. Default is false. Experimental.
|
||||
|
||||
--verbose
|
||||
Will send log messages to the client with information.
|
||||
|
||||
@ -275,12 +280,12 @@ final class LanguageServer
|
||||
'blackfire',
|
||||
]);
|
||||
|
||||
$diableXdebug = !isset($options['disable-xdebug'])
|
||||
$disableXdebug = !isset($options['disable-xdebug'])
|
||||
|| !is_string($options['disable-xdebug'])
|
||||
|| strtolower($options['disable-xdebug']) !== 'false';
|
||||
|
||||
// If Xdebug is enabled, restart without it based on cli
|
||||
if ($diableXdebug) {
|
||||
if ($disableXdebug) {
|
||||
$ini_handler->check();
|
||||
}
|
||||
|
||||
@ -310,8 +315,19 @@ final class LanguageServer
|
||||
|
||||
$config->setServerMode();
|
||||
|
||||
//Theres no cache in LSP land
|
||||
$config->cache_directory = null;
|
||||
$inMemory = isset($options['in-memory']) &&
|
||||
is_string($options['in-memory']) &&
|
||||
strtolower($options['in-memory']) === 'true';
|
||||
|
||||
if ($inMemory) {
|
||||
$config->cache_directory = null;
|
||||
} else {
|
||||
$cache_directory = $config->getCacheDirectory();
|
||||
|
||||
if ($cache_directory !== null) {
|
||||
Config::removeCacheDirectory($cache_directory);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['use-baseline']) && is_string($options['use-baseline'])) {
|
||||
$clientConfiguration->baseline = $options['use-baseline'];
|
||||
@ -378,6 +394,6 @@ final class LanguageServer
|
||||
$clientConfiguration->TCPServerAddress = $options['tcp'] ?? null;
|
||||
$clientConfiguration->TCPServerMode = isset($options['tcp-server']);
|
||||
|
||||
LanguageServerLanguageServer::run($config, $clientConfiguration);
|
||||
LanguageServerLanguageServer::run($config, $clientConfiguration, $current_dir, $inMemory);
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +40,20 @@ use Psalm\Config;
|
||||
use Psalm\ErrorBaseline;
|
||||
use Psalm\Internal\Analyzer\IssueData;
|
||||
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
||||
use Psalm\Internal\LanguageServer\Provider\ClassLikeStorageCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\FileReferenceCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\FileStorageCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\ParserCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\ProjectCacheProvider;
|
||||
use Psalm\Internal\Composer;
|
||||
use Psalm\Internal\LanguageServer\Provider\ClassLikeStorageCacheProvider as InMemoryClassLikeStorageCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\FileReferenceCacheProvider as InMemoryFileReferenceCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\FileStorageCacheProvider as InMemoryFileStorageCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\ParserCacheProvider as InMemoryParserCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Provider\ProjectCacheProvider as InMemoryProjectCacheProvider;
|
||||
use Psalm\Internal\LanguageServer\Server\TextDocument as ServerTextDocument;
|
||||
use Psalm\Internal\LanguageServer\Server\Workspace as ServerWorkspace;
|
||||
use Psalm\Internal\Provider\ClassLikeStorageCacheProvider;
|
||||
use Psalm\Internal\Provider\FileProvider;
|
||||
use Psalm\Internal\Provider\FileReferenceCacheProvider;
|
||||
use Psalm\Internal\Provider\FileStorageCacheProvider;
|
||||
use Psalm\Internal\Provider\ParserCacheProvider;
|
||||
use Psalm\Internal\Provider\ProjectCacheProvider;
|
||||
use Psalm\Internal\Provider\Providers;
|
||||
use Psalm\IssueBuffer;
|
||||
use Throwable;
|
||||
@ -240,18 +246,33 @@ class LanguageServer extends Dispatcher
|
||||
/**
|
||||
* Start the Server
|
||||
*/
|
||||
public static function run(Config $config, ClientConfiguration $clientConfiguration): void
|
||||
{
|
||||
public static function run(
|
||||
Config $config,
|
||||
ClientConfiguration $clientConfiguration,
|
||||
string $base_dir,
|
||||
bool $inMemory = false
|
||||
): void {
|
||||
$progress = new Progress();
|
||||
|
||||
$providers = new Providers(
|
||||
new FileProvider,
|
||||
new ParserCacheProvider,
|
||||
new FileStorageCacheProvider,
|
||||
new ClassLikeStorageCacheProvider,
|
||||
new FileReferenceCacheProvider($config),
|
||||
new ProjectCacheProvider,
|
||||
);
|
||||
if ($inMemory) {
|
||||
$providers = new Providers(
|
||||
new FileProvider,
|
||||
new InMemoryParserCacheProvider,
|
||||
new InMemoryFileStorageCacheProvider,
|
||||
new InMemoryClassLikeStorageCacheProvider,
|
||||
new InMemoryFileReferenceCacheProvider($config),
|
||||
new InMemoryProjectCacheProvider,
|
||||
);
|
||||
} else {
|
||||
$providers = new Providers(
|
||||
new FileProvider,
|
||||
new ParserCacheProvider($config),
|
||||
new FileStorageCacheProvider($config),
|
||||
new ClassLikeStorageCacheProvider($config),
|
||||
new FileReferenceCacheProvider($config),
|
||||
new ProjectCacheProvider(Composer::getLockFilePath($base_dir)),
|
||||
);
|
||||
}
|
||||
|
||||
$codebase = new Codebase(
|
||||
$config,
|
||||
|
Loading…
x
Reference in New Issue
Block a user