Problems with FileEditorProvider implemetation
Answered
Hello!
I have a class, that implements the FileEditorProvider and DumbAware interfaces.
For some reason, method accept() of FileEditorProvider interface is requested for infinite times, when the plugin user opens the file, which must be handled by this editor.
Can the trouble spot be in Cyrillic file name?
Thank you.
Please sign in to leave a comment.
Please show snippet of your accept() method
Problem occurs only with property6 file name.
Please investigate then
and
The return value of
i logged with custom build. In that case it was always true.
can not occur problems, because its wrapped with try-catch block.
Could you please clarify
method accept() of FileEditorProvider interface is requested for infinite times
Do you mean you get StackOverflowError? Does problem still occur when removing DumbAware?
No.
As i understand, for each project file Intellij IDEA call accept() method of my implementation of FileEditorProvider. If accept() return true, this implementation will be used to handle file.
So there are couple of cases (I don't know them exactly), when Intellij IDEA call accept(), get "true" as result value and then call accept() method again. And do it for an infinite number of times.
Please show stacktraces where you think this is a problem. Is this a performance problem for your implementation?
There are no stacktraces problem, because problem occurs immediately after file selection in project file tree. And accept() method is only one method was called.
Yes, it is problem for me, because content of this file i get from server, that has some response ping. When user select file, he get something like infinite indexation:
I did not try to remove DumbAware interface. Can problem be occured by it?
I doubt removing DumbAware would help in your case.
com.intellij.openapi.fileEditor.FileEditorProvider#accept is expected to be fast and return immediately. Unfortunately there is no other API that would allow for use-cases like yours.
Please try to cache results in some way locally or persist status of file locally via com.intellij.openapi.vfs.newvfs.FileAttribute
So, you mean, that regular accept() method calling is provided by open API and it is normal work?
Thank you any way!
Yes, accept() is called (mostly) from com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl#getProviders.
I've updated the Javadoc of accept-method to clarify requirement.
Thank you!