JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
278 stars 25 forks source link

Go to declaration without a symbol #76

Open geecu opened 7 months ago

geecu commented 7 months ago

I'm working on a (proprietary) library that allows developers to define vue components by putting their templates in HTML files - just the HTML contents, without the <template> tag. These HTML files are passed to a webpack loader that wraps them in a <template> tag before passing them to the vue-loader.

web-types is a great fit for this usecase and it works great for autocompletion: besides autocompleting the tag name, the loader also looks for props.propName in the HTML and defines the props on the fly, so web-types autocompletes the props too. But I can't get "Go to declaration" to work - it seems that the two ways that web-types support (file or module) both require a symbol.

I've set up a sample repository: https://github.com/geecu/web-types-source . The component is defined here: https://github.com/geecu/web-types-source/blob/main/src/components/hero.html and used here: https://github.com/geecu/web-types-source/blob/main/src/templates/index.html .

On the branch class ( https://github.com/geecu/web-types-source/tree/class ) I've added a <script> tag to the component that defines a class ( https://github.com/geecu/web-types-source/blob/class/src/components/hero.html#L2 ) - with this Go to declaration works, but it's a hassle to ask developers to add this to every component.

I've also setup a branch with a sample for custom-elements-manifest https://github.com/geecu/web-types-source/tree/custom-elements , using the example provided at https://github.com/webcomponents/custom-elements-manifest . Go to declaration doesn't work for my-element neither: https://github.com/geecu/web-types-source/blob/custom-elements/src/templates/index.html .

PS: I'm using PhpStorm 2023.3 ( Build #PS-233.11799.232, built on December 1, 2023 )

piotrtomiak commented 6 months ago

@geecu - I see, it looks like there is a bug in the go-to declaration, where it allows only to navigate to JavaScript symbols. I'll look into fixing that for 2024.1 - please follow https://youtrack.jetbrains.com/issue/WEB-64747. To be able to interact with all of the Vue plugin support, please consider adding components into vue-components kind. More information in the documentation here: https://plugins.jetbrains.com/docs/intellij/websymbols-web-types.html#vue.