cedar-policy / vscode-cedar

Cedar policy language extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=cedar-policy.vscode-cedar
Apache License 2.0
15 stars 3 forks source link

Plugin should work for schema without a policies file #8

Closed john-h-kastner-aws closed 4 months ago

john-h-kastner-aws commented 6 months ago

Category

Cedar validation features

Describe the feature you'd like to request

While looking at issue #6 I wanted to play with a schema using the plugin, but initially couldn't get the plugin to do anything with the schema. Turns out it will only process the schema if it find a *.cedar file also. I don't think anything it does with the schema uses the cedar policy files, so it should be easy to do all the schema processing anyways.

Describe alternatives you've considered

As a workaround, creating an empty policy file gets things working, and the problem goes away entirely once you've started writing policies.

Additional context

No response

Is this something that you'd be interested in working on?

hakanson commented 6 months ago

I'm looking into this and suspect it is based on extension activation events. Are you opening the schema as file and not part of a workspace?

https://github.com/cedar-policy/vscode-cedar/blob/9c7048bedcbf153a45478c75a4412e4a70b2f0ea/package.json#L30-L36

john-h-kastner-aws commented 6 months ago

Are you opening the schema as file and not part of a workspace?

That could be it. I can't reproduce this in a workspace, and I can't think of anything else I might have been doing. I guess I opened it in a workspace when I tried adding a *.cedar file and came to the wrong conclusion.

hakanson commented 6 months ago

Max reported a similar issue where "Open With > Visual Studio Code.app" on an individual file doesn't work as expected, even when the extension is activated. I'm looking at how to best support these related use cases as I had other logic that assumed a workspace.

hakanson commented 4 months ago

Fixed some behaviors require a workspace in v0.6.0.

Note: The extension automatically activates when a Cedar language file (.cedar) file is opened, or when any Cedar schema (JSON) file is opened as part of a workspace. Since JSON language files are so common, a design decision was to not automatically activate in this case. To trigger activation in this case, "Activate Cedar extension" was added to the Command Palette.