EAP - ShowIntentionsPass.getActionsToShow(hostEditor, hostFile) returning inconsistent results

Answered

This issue started happening since EAP 2019.1 Beta3 build 191.6183.20 released on March 13.

We are using the method inside a test which basically sets the caret on the red highlighted "Issue" and opens the Alt-Enter menu, then retrieves the suggested fixes.

Groovy code:

// context is instance of ActionContext
context.app.runReadAction {
def intentions = ShowIntentionsPass.getActionsToShow(context.editor, context.psiFile)
}

Sometimes it will correctly return all fixes....sometimes only the "Remove explicit type". This appears to be random.

 

Ive debugged through the code and I noticed:

1. ShowIntentionsPass.getActionsToShow() calls ShowIntentionsPass.getAvailableFixes()

2. ShowIntentionsPass.getAvailableFixes() calls DaemonCodeAnalyzerImpl.processHighlightsNearOffset() - the inconsistency seems to be coming from this method

 

What could be causing the inconsistent results? 

1 comment
Comment actions Permalink

Maybe the highlighting is not finished yet. Depending of the test type you can `com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase#highlightErrors` to start highlighting and wait for it to complete or call `com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx#isErrorAnalyzingFinished` to check if it's finished

0

Please sign in to leave a comment.