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

Investigate PHP VS Code extensions #12796

Closed
tsmaeder opened this issue Feb 28, 2019 · 1 comment
Closed

Investigate PHP VS Code extensions #12796

tsmaeder opened this issue Feb 28, 2019 · 1 comment

Comments

@tsmaeder
Copy link
Contributor

There seem to be two PHP LS plugins that are widely used

@vrubezhny
Copy link
Contributor

vrubezhny commented Mar 15, 2019

IMHO, the intelephense extension is a much better choice as it is more tolerant to 'as-you-type' errors and has better and punctual error reporting (show more or less actual error in its proper place). But it's not possible to use it "as is and right now" for the following reasons:

  • it requires VS Code v. >= 1.31.0, while we declare it to be 1.27.2 in plugin-ext-vscode. (I'm not sure on all the consequences, but the intelephenseextension was satisfied when I applied the following simple fix that just changes the declared VS Code version to be1.31.0`:
$ git diff packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
diff --git a/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts b/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
index 1e017b9f..55381bf9 100644
--- a/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
+++ b/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts
@@ -72,7 +72,7 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF
     };
 
     // override the version for vscode to be a VSCode version
-    (<any>vscode).version = '1.27.2';
+    (<any>vscode).version = '1.31.0';
 
     pluginsApiImpl.set(plugin.model.id, vscode);
     plugins.push(plugin);
  • It requires a defined object (even an empty one is valid) to be returned when it requests for the associations preference in section files, otherwise, the following code (that is invoked when it's being activated):
vscode_1.workspace.getConfiguration('files').get('associations');

results into the following exception and failure:

PLUGIN_HOST(22186): initializing(/home/jeremy/projects/che/source/theia-ide/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)
PLUGIN_HOST(22186): PluginManagerExtImpl/loadPlugin(/tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension)

root INFO [nsfw-watcher: 22228] Started watching: /home/jeremy/projects/che/theia-runtime-workspace/.theia/phptest.php
root ERROR [hosted-plugin: 22186] (node:22186) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at workspaceFilesIncludeGlob (/tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension.js:125:31)
    at /tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension.js:74:72
    at Generator.next (<anonymous>)
    at /tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension.js:10:71
    at new Promise (<anonymous>)
    at __awaiter (/tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension.js:6:12)
    at activate (/tmp/vscode-unpacked/bmewburn.vscode-intelephense-client-1.0.8.vsix/extension/out/src/extension.js:29:12)
    at PluginManagerExtImpl.startPlugin (/home/jeremy/projects/che/source/theia-ide/theia/packages/plugin-ext/lib/plugin/plugin-manager.js:172:73)
    at PluginManagerExtImpl.$init (/home/jeremy/projects/che/source/theia-ide/theia/packages/plugin-ext/lib/plugin/plugin-manager.js:126:26)

root ERROR [hosted-plugin: 22186] (node:22186) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:22186) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

In order to run the intelephense I've workarounded this issue with the following change, but for sure it can't be used in production:

$ git diff packages/plugin-ext/src/plugin/preference-registry.ts
diff --git a/packages/plugin-ext/src/plugin/preference-registry.ts b/packages/plugin-ext/src/plugin/preference-registry.ts
index fa74a71b..cb943256 100644
--- a/packages/plugin-ext/src/plugin/preference-registry.ts
+++ b/packages/plugin-ext/src/plugin/preference-registry.ts
@@ -100,7 +100,7 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
             get: <T>(key: string, defaultValue?: T) => {
                 const result = lookUp(preferences, key);
                 if (typeof result === 'undefined') {
-                    return defaultValue;
+                    return defaultValue ? defaultValue : {};
                 } else {
                     let clonedConfig: any = undefined;
                     const cloneOnWriteProxy = (target: any, accessor: string): any => {

The Baker's extension has few disadvantages - it doesn't tolerate typos/errors made in code, showing wrong/inappropriate error messages in such cases. Also, its error messages are not enough informative. But it can be started with no additional changes/fixes once the Grammars for PHP are contributed to Theia.

As a User I'd like to use the extension from intelephense.

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

2 participants