-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support package-provided code snippets #32103
Comments
No, it's not a crazy idea. We've talked about it in the past but haven't had time to follow through. What we need to do is identify the IDE support we're talking about (for some reasonable sampling of IDEs), and what those clients would need from server. That will allow us to design an API for accessing the information and figure out how packages could specify them. (We already have a special directory in packages used to hold plugins, so that seems like a reasonable place for additional information.) @alexander-doroshko Would the IntelliJ support benefit from something like this? |
Yup, IntelliJ IDEA has a concept of Live Templates, that's exactly what is shown on the GIF in that tweet. But the engine is not ready for dynamically added context-aware templates. So I think the simplest and the most effective way of implementing features like this (from the IDE point of view) would be Code Completion. Zero (or close to zero) work is required on IDE end in this case. |
I was going to suggest the completion API too, but that doesn't support anything like |
@zoechi – a reason for your 👎 ? |
sorry! I meant to 👍 |
I saw this tweet today about using live templates (code snippets?) for json_serializable:
https://twitter.com/koorankka/status/961726046176448522
It reminded me of when I tried out built_value(?) and I had to copy paste a bunch of code from the docs and customise it. IDE snippets would've been really useful. As a user I can add snippets to my IDE but it seems like package authors being able to include them in their package might be a better idea - they'd be project-aware (don't appear when I'm editing a project that doesn't import that package) and all users of a package would get them for free.
Does this sound like a crazy idea?
It'd require to be a standard location/format for snippets in a package and the analyzer would need to be able to hand them up to IDEs (IDEs may need to convert them to their own format but possibly they could go into the existing completion API to reduce the work there) but it seems like good functionality IMO. Just this week I added Flutter snippets to Dart Code - fortunately Dart Code knows what's a Flutter project so this was easy to show conditionally, but for the average package (like built_value) this wouldn't be the case.
The text was updated successfully, but these errors were encountered: