tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
485 stars 38 forks source link

Handle component re-exports #39

Closed unlocomqx closed 5 years ago

unlocomqx commented 5 years ago

This is a way to handle aliased re-exports from project files as well as from node_modules (related to #37 #6)

image

Todo:

image

It's a bit messy, if you'd like to take what's useful, it will be fine The hardest part is to find which API to use as there's not enough documentation


Resolves #6 Resolves #37

tomblachut commented 5 years ago

The hardest part is to find which API to use as there's not enough documentation

Yeah definitely it's like walking in the dark for me. You need to bump into a bunch of wrong APIs before arriving at correct solution.

I'll check the code later, thx!

unlocomqx commented 5 years ago

Method breakpoints in interfaces helped me a lot with this one

Regarding the dicovery of re-exports, I standardized component info using JsModuleNameInfo and added the svelte file manually in https://github.com/tomblachut/svelte-intellij/blob/7cd40038f440498a48c75d813a570972eb699c63/src/main/java/dev/blachut/svelte/lang/codeInsight/ComponentImporter.kt#L131

tomblachut commented 5 years ago

I've tested it as original branch and merged with master and in both cases only marking imports as used and navigation to definition works. Completions aren't added, unresolved component inspection works only for default exports.

I can merge this but wanted to clarify because you said otherwise in the descriptions. Regression maybe?

unlocomqx commented 5 years ago

I couldn't reproduce on original branch, it still works as expected

image

image

Here's how I re-export the Child component export {default as Child} from "./Child.svelte";

I will rebase and see how it goes

unlocomqx commented 5 years ago

Found a regression, image

I will look into it

tomblachut commented 5 years ago

Thx. Keep in mind I've swapped HTML with SvelteHTML. I've actually checked it there are some obvious checks but didn't find anything

unlocomqx commented 5 years ago

I fixed the direct import regression. I didn't find a potential issue with SvelteHTML in my code. PS: If you know of a way to make a svelte component be treated as an implicit ES6 module, it would be great (maybe something for future dev)

tomblachut commented 5 years ago

Still no luck with completions and missing imports inspection for components from node modules. I'm running https://github.com/EmilTholin/svelte-routing/tree/master/example

image

I even tried with IDEA and WebStorm - results are the same.

I'm gonna merge this anyway because I wanted to release something - it's been over a month since 0.8.0. I need to fix some HTML inspections first though.

We should catch up on Discord some day about ES6 module issue.

unlocomqx commented 5 years ago

I was able to reproduce using svelte-routing example I had to mark node_modules as "Not Excluded" to get it working screenshot_5

Can you try it? node_modules was initially marked as "library root" which I thought would be sufficient but it wasn't

tomblachut commented 5 years ago

Ah yes! It's working now.

Anyway we can't expect anybody to do it 😅It will bloat completions for every other library. Node modules integration will need more work (and research first ughhh).

For the time being, thanks for fixing #6 and #37

unlocomqx commented 5 years ago

Thank you for merging, If I find out anything about node_modules, I'll let you know

Cheers