tomblachut / svelte-intellij

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

enable JS injections in attribute values #36

Closed unlocomqx closed 5 years ago

unlocomqx commented 5 years ago

A basic js injection image

It requires more work and is buggy inside a svelte tag like #if and so on

I was debugging the multiHostInjector but couldn't find out why it doesn't allow highlighting and code insight (so I gave up)

With this approach, highlighting and code insight works (mostly) fine I think it's a good path to follow

I can improve it using referencesSearch if necessary

tomblachut commented 5 years ago

Hello again 👋 I really appreciate your work

doesn't allow highlighting

As far as I understand, intellij has layered design. You can enable dumb mode or something in the UI and injections could stop working. They also tend to disappear from time to time when ide is recomputing them. What I did with already handled injections is I used layered highlighting lexer which works "instantly". Injections later provide the same highlight plus more so they can be though of as progressive enhancement.

Multi host injector was chosen by me because I wanted to connect little islands of JS with each other and I've read it is a fine idea, but the longer I use it the more I see it's not really configurable. I'm open to diffrrent approaches but I think it's important not to use both injectors at the same time - it's even more confusing

unlocomqx commented 5 years ago

Thank you, great work on the multi-injector I changed this one to injecting JS in attribute values only Consider it as prototyping for now because I don't know if there's a better way to do it and it doesn't work as well with unquoted attribute values + doesn't support escaped quotes image

unlocomqx commented 5 years ago

My bad, I didn't notice that the highlighting inside interpolations already works because I was testing window and alert and so on We can still use this for attribute values and attribute names though