ember-language-server icon indicating copy to clipboard operation
ember-language-server copied to clipboard

"Go to definition" support for absolute paths

Open jackson-dean opened this issue 7 years ago • 7 comments

Using vscode, it seems "go to definition" only works for relative paths in .js files when executing it with the cursor over an import path string. It also seems there is no support yet for namespaced components which use the "::" syntax. Is there any plan to support namespaced/absolute paths in these scenarios? I would be very interested in helping add this support though i might need some guidance getting up to speed on how to run and debug the server from vscode. thanks!

jackson-dean avatar Jul 08 '18 16:07 jackson-dean

@jackson-dean you need to get vscode-ember package, and link it to local ember-language-server version.

vscode-ember has start-vscode script.

Most relevant Go-to component definitions examples in https://github.com/emberwatch/ember-language-server/pull/173 (https://marketplace.visualstudio.com/items?itemName=lifeart.vscode-ember-unstable)

  • Don't forget to compile ember-language-server code (ts -> js) before start-vscode

lifeart avatar Mar 17 '19 09:03 lifeart

@lifeart Thank you for working and making available Unstable Ember Language Server.

I think go to definition for absolute paths on JS modules could be one of the most important features to include.

All my JS modules are imported with the application name as the namespace root name.

import myModule from 'li/utils/my-module';

If I am not wrong, that is or was an Ember requirement.

Making this feature available will allow navigating easily across all the app JS modules.

ppcano avatar Mar 22 '19 17:03 ppcano

@ppcano it's definetly possible, all we need is - write kinda resolution logic for it.

1.) for absolute paths -- fo/bar/baz -> appName/app/foo/bar/baz -> node_modules/addon_name/app/foo/bar/baz (in-repo addon, node-modules addon, local import) 2.) for relative paths

if you have time for it, you can add resolution logic to https://github.com/lifeart/ember-meta-explorer/blob/master/src/utils/lookup-utils.ts

resolveScriptImport(appRoot, filePath, importDeclaration) resolveScriptImport('/home/my-ember', '/home/my-ember/app/utils/util.js', 'li/utils/my-module')

lifeart avatar Mar 22 '19 18:03 lifeart

@ppcano go-to definition for absolute imports commited to branch, could you test it?

lifeart avatar Mar 22 '19 20:03 lifeart

@lifeart I have tried but it does not look to be working.

I think I am using correctly your branch.

> clone ember-language-server 
cd ember-language-server
> move to  your branch
yarn install
yarn link
yarn compile

cd ..
> clone vscode-ember
cd vscode-ember
yarn install
yarn link "@emberwatch/ember-language-server"
yarn compile
./start-vscode.sh

Language server is working because component and helper autocompletion on handlebars works.

Please, let me know if I should try something else.

Note: I think the above instructions or another description explaining how to run locally the project may be useful to add on the Readme or Contribution section.

ppcano avatar Mar 24 '19 00:03 ppcano

For the js side of the resolution I discovered it can be done pretty easily using a proper jsconfig.json which uses the ts/js language server packaged with VSCode. Resolving namespaced component invocations would be very valuable though.

jackson-dean avatar May 31 '19 20:05 jackson-dean

@jackson-dean it's should work in unstable-language-server

lifeart avatar May 31 '19 20:05 lifeart