break-stuff / cem-plugin-jet-brains-ide-integration

A custom elements manifest analyzer plugin to generate configuration files for web component integration with JetBrains IDEs
MIT License
11 stars 0 forks source link

Support for source #5

Open SavoInfostream opened 11 months ago

SavoInfostream commented 11 months ago

I am wondering if it's possible to add support for "source" property for custom-elements, like this:

          "source": {
            "symbol": "FlagInputComponent",
            "module": "webComponents/flagInput.ts"
          }

which would allow to go to declaration class from html. It would be useful, no?

break-stuff commented 11 months ago

Ah, interesting. I didn't realize this is part of the web-types.json spec. I think that should be possible. We would likely need to add a config to specify the output path since that info isn't in the CEM.

SavoInfostream commented 11 months ago

Isn't that the same path on 3rd line?

{
      "kind": "javascript-module",
      "path": "webComponents/flagInput.ts",
      "declarations": [
        {
          "kind": "class",
          "description": "",
          "name": "FlagInputComponent",
          "members": [
            {
              "kind": "field",
              "name": "prop",
              "type": {
                "text": "string"
              },
              "privacy": "private",
              "description": "What property binds to this input.",
              "attribute": "prop"
            },
            {
              "kind": "field",
              "name": "text",
              "type": {
                "text": "string"
              },
              "privacy": "private",
              "attribute": "text"
            },
            {
              "kind": "field",
              "name": "shortcut",
              "type": {
                "text": "[string, boolean]"
              },
              "privacy": "private",
              "attribute": "shortcut"
            },
            {
              "kind": "field",
              "name": "savo",
              "type": {
                "text": "(a: InputChangeEvent) => any"
              },
              "privacy": "public",
              "attribute": "savo"
            },
            {
              "kind": "method",
              "name": "render",
              "privacy": "private"
            }
          ],
          "events": [
            {
              "type": {
                "text": "InputChangeEvent"
              },
              "description": "some description for typed-event",
              "name": "savo"
            }
          ],
          "attributes": [
            {
              "name": "prop",
              "type": {
                "text": "string"
              },
              "description": "What property binds to this input.",
              "fieldName": "prop"
            },
            {
              "name": "text",
              "type": {
                "text": "string"
              },
              "fieldName": "text"
            },
            {
              "name": "shortcut",
              "type": {
                "text": "[string, boolean]"
              },
              "fieldName": "shortcut"
            },
            {
              "name": "savo",
              "type": {
                "text": "(a: InputChangeEvent) => any"
              },
              "fieldName": "savo"
            }
          ],
          "superclass": {
            "name": "HTMLElement"
          },
          "tagName": "flag-input",
          "customElement": true
        }
      ],
      "exports": [
        {
          "kind": "custom-element-definition",
          "name": "flag-input",
          "declaration": {
            "name": "FlagInputComponent",
            "module": "webComponents/flagInput.ts"
          }
        }
      ]
    }
break-stuff commented 11 months ago

Not usually. The CEM captures the source of the component, but that's not typically included in deployed package.

SavoInfostream commented 11 months ago

Hmm, this UI library does deploy the source: Adobe Spectrum. cem

It seems to be essential to deploy it like this for component libraries.

break-stuff commented 11 months ago

They are actually updating the value in the CEM before they deploy.

https://github.com/adobe/spectrum-web-components/blob/main/custom-elements-manifest.config.js#L33

SavoInfostream commented 11 months ago

Well, yeah but you get the navigation to .dts which is the same as for any other symbol in jetbrains. So, any plans for this feature atm?

break-stuff commented 11 months ago

I'll have to think about how we could implement this and provide a way for teams to ensure it points to the right resource.