Skip to content
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

Custom file extensions not being indexed in Theia? #1233

Closed
ghost opened this issue Jun 16, 2020 · 10 comments
Closed

Custom file extensions not being indexed in Theia? #1233

ghost opened this issue Jun 16, 2020 · 10 comments

Comments

@ghost
Copy link

ghost commented Jun 16, 2020

Describe the bug
For some reason using the following config I can't seem to get custom file extensions to be indexed:

{
 "files.associations": {
    "*.inc": "php",
    "*.php": "php"
  }
}

To Reproduce

  • Create both an index.php and a include.inc file in your workspace root with some php code.
  • Start indexing
  • Functions defined in the include.inc file that are called in the index.php file will not be found.

Expected behavior
Setting the files.associations array should allow the indexing of non-standard file extensions.

Not sure how to debug
I have been trying to resolve this issue for a couple of days now. But I'm not sure how to validate which files have been indexed. The only way I can see that they were not indexed is after I open an .inc file it will be indexed.

Platform and version

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic
  "vscode-intelephense": "1.4.1"
@ghost
Copy link
Author

ghost commented Jun 16, 2020

No @jfcherng , the files.associations will be merged with intelephense.files.associations:

function mergeAssociations(intelephenseAssociations: string[]) {
let vscodeConfig = workspace.getConfiguration('files');
if(!vscodeConfig) {
return intelephenseAssociations;
}
let vscodeAssociations = vscodeConfig.get('associations') || {};
let associationsSet = new Set<string>(intelephenseAssociations);
for (let [key, val] of Object.entries(vscodeAssociations)) {
if (val === 'php') {
associationsSet.add(key);
}
}
return Array.from(associationsSet);
}

@bmewburn
Copy link
Owner

@verbruggenalex are you using short tags?

@ghost
Copy link
Author

ghost commented Jun 16, 2020

@bmewburn no. Only full php opening tags (Drupal development .inc, .module, files...)

For me it seems that neither files.associations and intelephense.files.associations settings have any effect on the indexing command process. Whenever I change intelephense.files.associations to only have ".inc" it still only indexes ".php" files for me.

But when opening files in Theia it does seem to index the individual "*.inc" files that are opened.

I'll see if I can make you a light docker image that you can check out to reproduce the issue.

@ghost
Copy link
Author

ghost commented Jun 16, 2020

If you want to have a look @bmewburn :

git clone git@github.com:verbruggenalex/theia-php-intelephense-indexing.git
cd theia-php-intelephense-indexing
docker-compose up -d
  • Visit http://localhost:3000
  • Start indexing (does not index include.inc)
  • Open index.php
  • See that the function is not found.
  • Open include.inc (indexes include.inc)
  • Now the function in index.php will be found.

@ghost
Copy link
Author

ghost commented Jun 17, 2020

Hi @bmewburn,

I'm not really familiar with writing vscode plugins yet. But to me it seems that intelephense is not passing any pattern to the documentSelector within the clientOptions for the LanguageClient:

documentSelector: [
{ language: PHP_LANGUAGE_ID, scheme: 'file' },
{ language: PHP_LANGUAGE_ID, scheme: 'untitled' }

DocumentFilter API: https://code.visualstudio.com/api/references/vscode-api#DocumentFilter

But I think that adding a pattern without language or scheme is required to have the custom exension files indexed. And this could possibly register non php files that have a custom file extension as a php file.

Anywayz, this looks like a known issue also

I hope we can find a solution for this as it is blocking intelephense usage for a lot of frameworks that rely on non standard file extension names.

@bmewburn
Copy link
Owner

bmewburn commented Jun 17, 2020

@verbruggenalex is the issue just related to theia? In vscode adding *.inc to files.associations works fine for me. Could your issue be the same as this eclipse-theia/theia#5945 ? There seems to be something about the middleware layer that theia doesnt like https://github.com/bmewburn/vscode-intelephense/blob/master/src/middleware.ts

@ghost
Copy link
Author

ghost commented Jun 19, 2020

Sorry to bother you again @bmewburn . But do you have any good resource on how I can compile the code in this repository? Running yarn seems to compile intelephense.js but not extension.js.

@bmewburn
Copy link
Owner

@verbruggenalex npm install && npm run production will build it. Then you can run a debug session in vscode (maybe theia too?) with the Launch Extension debug task. To build a vsix - vsce package.

@ghost
Copy link
Author

ghost commented Jun 24, 2020

Thanks @bmewburn. I was able to successfully build the extension. But when trying to run it in the docker Theia instance the extension fails to activate.

Activating extension PHP Intelephense failed: The language client requires VS Code version ^1.42.0 but received version 1.2.0.

I'm not really sure why Theia is using its own package for running vscode extensions. But it may be why it doesn't run exactly the same on Theia.

I'm afraid my knowledge in NPM is not sufficient to try and help on this issue. So I'm going to put this on hold for myself. I hope someone can pick this issue up. Solving it will enable full usage of Intelephense for popular services like GitPod or custom docker build images based on Theia:

@ghost ghost changed the title Custom file extensions not being indexed? Custom file extensions not being indexed in Theia? Jun 24, 2020
@ghost
Copy link
Author

ghost commented Sep 8, 2020

I'm closing this issue because with the latest version of Intelephense (v1.5.4) I'm not experiencing the problem any longer.

Thank you for the support @bmewburn. I will be enjoying your plugin a lot! If anyone is interested in the Docker image I created for developing PHP applications you can find it here: https://github.com/verbruggenalex/docker-theia-php

I'm deleting the other repository that was used for debugging this issue.

@ghost ghost closed this as completed Sep 8, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant