InlayParameterHintsProvider: manual inlay refresh
已回答
Hi,
I've implemented InlayParameterHintsProvider.java and added my impl class to the plugin's plugin.xml :
<codeInsight.parameterNameHints language="Gherkin" implementationClass="com.MyInlays"/>
This works fine and the inlays are rendering; however, the impl class is called everytime I edit the file in the editor. This is a problem as I'm expecting slow performance when retrieving the inlay text, and the pause here causes the editor to become unresponsive.
Is there a way to execute this processing manually when a user wants to refresh the inlays, rather than on each edit to the file?
Thanks
请先登录再写评论。
You can implement your own caching for slow text retrieval in a background thread. In the inlay class retrieve the data from the cache.
When the data is not in the cache you will need to trigger data retrieval, then when it is retrieved, trigger refresh of editor repainting so that the inlay is updated.
Thanks Vladimir Schneider, I'm intending to get the text from a server via a web service. Given that the data could change on the server, maintaining the cache would be complicated. I would need to continuously check that the cache contains the up to date info.
It's a valid solution. But if there was an easy way to execute the inlays manually I think it would be a much simpler solution.
You did mention that you want to have the inlay updates done via user action. In this case you can simplify the cache by updating it on user action.
In the end the cache for inlay data will be needed. When you update the cache is under your control and one way is on user action. Another is on a timed basis, every x minutes or so. Since it would be done in the background then it would not cause EDT thread hangups.