Skip to content
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

Open
DanTup opened this issue Feb 9, 2018 · 5 comments
Open

Support package-provided code snippets #32103

DanTup opened this issue Feb 9, 2018 · 5 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@DanTup
Copy link
Collaborator

DanTup commented Feb 9, 2018

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.

@bwilkerson
Copy link
Member

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?

@alexander-doroshko
Copy link

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.

@DanTup
Copy link
Collaborator Author

DanTup commented Feb 9, 2018

I was going to suggest the completion API too, but that doesn't support anything like LinkedEditGroups which I think would be needed for editing in multiple places together?

@kevmoo
Copy link
Member

kevmoo commented Feb 14, 2018

@zoechi – a reason for your 👎 ?

@kevmoo kevmoo added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Feb 14, 2018
@zoechi
Copy link
Contributor

zoechi commented Feb 15, 2018

sorry! I meant to 👍

@bwilkerson bwilkerson added the type-enhancement A request for a change that isn't a bug label Sep 2, 2018
@srawlins srawlins added the P3 A lower priority bug or feature request label Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants