-
Notifications
You must be signed in to change notification settings - Fork 185
Allow configurable file extension for indexing #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
cdb5b56
5f096c4
7dc4477
f7175bc
9433694
39cfbda
3c33e7f
d2e5048
b9d0d1b
9067b44
1e319c7
58c82e6
44a942e
940eb97
5b1b6bf
707c97f
1e73d08
1f90b4e
ca225ff
c4568bf
5308e7a
a06057b
23a40f0
f4f1067
9cc2736
09fbec2
a5417cd
e317e8c
a1c3845
a1e5654
a81bed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,11 +167,12 @@ public function __construct(ProtocolReader $reader, ProtocolWriter $writer) | |
* @param ClientCapabilities $capabilities The capabilities provided by the client (editor) | ||
* @param string|null $rootPath The rootPath of the workspace. Is null if no folder is open. | ||
* @param int|null $processId The process Id of the parent process that started the server. Is null if the process has not been started by another process. If the parent process is not alive then the server should exit (see exit notification) its process. | ||
* @param mixed $initializationOptions The options send from client to initialize the server | ||
* @return Promise <InitializeResult> | ||
*/ | ||
public function initialize(ClientCapabilities $capabilities, string $rootPath = null, int $processId = null): Promise | ||
public function initialize(ClientCapabilities $capabilities, string $rootPath = null, int $processId = null, $initializationOptions = null): Promise | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know vscode sends the settings as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Microsoft has a list with all methods and params: https://github.com/Microsoft/language-server-protocol/blob/master/versions/protocol-2-x.md#initialize You only have to pass them from vscode as a property of ClientOptions According to the Docs it can have any type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't force every client to do this. This needs to happen through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual options are taken from the configuration and are just passed with the initialize method. felixfbecker/vscode-php-intellisense@59e6f2c So you want to move the indexing to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tricky. A client might never send There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would open a new issue to discuss this part because it affects the indexing for many option combinations. And maybe delay it until we have implemented some of them. For now it is okay, when the user has to reload to reindex with the changed options. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would want at least an implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But feel free to discuss in an issue |
||
{ | ||
return coroutine(function () use ($capabilities, $rootPath, $processId) { | ||
return coroutine(function () use ($capabilities, $rootPath, $processId, $initializationOptions) { | ||
|
||
if ($capabilities->xfilesProvider) { | ||
$this->filesFinder = new ClientFilesFinder($this->client); | ||
|
@@ -190,6 +191,7 @@ public function initialize(ClientCapabilities $capabilities, string $rootPath = | |
$this->projectIndex = new ProjectIndex($sourceIndex, $dependenciesIndex, $this->composerJson); | ||
$stubsIndex = StubsIndex::read(); | ||
$this->globalIndex = new GlobalIndex($stubsIndex, $this->projectIndex); | ||
$options = new Options($initializationOptions); | ||
|
||
// The DefinitionResolver should look in stubs, the project source and dependencies | ||
$this->definitionResolver = new DefinitionResolver($this->globalIndex); | ||
|
@@ -235,7 +237,8 @@ public function initialize(ClientCapabilities $capabilities, string $rootPath = | |
$sourceIndex, | ||
$this->documentLoader, | ||
$this->composerLock, | ||
$this->composerJson | ||
$this->composerJson, | ||
$options | ||
); | ||
$indexer->index()->otherwise('\\LanguageServer\\crash'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace LanguageServer; | ||
|
||
class Options | ||
{ | ||
/** | ||
* Filetypes the indexer should process | ||
* | ||
* @var array | ||
*/ | ||
public $fileTypes = [".php"]; | ||
|
||
/** | ||
* @param \stdClass|null $options | ||
*/ | ||
public function __construct(\stdClass $options = null) | ||
{ | ||
// Do nothing when the $options parameter is not an object | ||
if (!is_object($options)) { | ||
return; | ||
} | ||
|
||
$this->fileTypes = $options->fileTypes ?? $this->normalizeFileTypes($this->fileTypes); | ||
} | ||
|
||
private function normalizeFileTypes(array $fileTypes): array | ||
{ | ||
return array_map(function (string $fileType) { | ||
if (substr($fileType, 0, 1) !== '.') { | ||
$fileType = '.' . $fileType; | ||
} | ||
|
||
return $fileType; | ||
}, $fileTypes); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong type