Asynchronous and delay completion contributor

Answered

We have developed a plug-in that can perform code completion. It needs to request the back-end server and then return the corresponding code completion, so it will take some time. The code example I use is as follows, but this will cause the interface to freeze and cannot be entered normally. How should this be? to solve it? I thought of two places that need to be optimized. First, it should be judged when inputting. If the user stops for 1 second without inputting, then go to the backend to request the code completion item. The second is to display the default code completion normally, and then another thread Go to request the backend, and then fill it after the request is completed, but I don't know how to implement it, and I hope to get your help.

thanks

1
4 comments

Because I don't know much about plug-in development, I hope you can give some examples at the end and answer in a little more detail. Thank you very much,

0

Please see item “Q: My completion contributor has to get its results from far away (e.g., blocking I/O or internet). How do I do that?” in com.intellij.codeInsight.completion.CompletionContributor javadoc.

1

First of all, thank you very much for your help, which is very useful to me. I have used runWithCheckCanceled, but another problem is that every time I enter a character, my code will complete and I will request the backend, which has caused great pressure on the backend service. Can I limit the request conditions. For example, do I want the cursor to stay for one second and then request the backend for code completion, or do I want to use fixed shortcut keys? How to realize it? Do you have a good idea? Thank you.

0

I'm sorry but I can't point you to working solutions in this area

0

Please sign in to leave a comment.