- 
                Notifications
    
You must be signed in to change notification settings  - Fork 187
 
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 | ||
                
       | 
||
| { | ||
| 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