Exception when getting PsiElement
I created a class by extending AnAction.
And parse anActionEvent to other class which is not extened by any class and assign to its local variable in constructor as below,
public Abc(AnActionEvent actionEvent) {
this.action = actionEvent;
}
Then I tried to execute below line,
this.psiElement = this.action.getData(CommonDataKeys.PSI_ELEMENT);
functionality is working but below error come in error IDE error console,
cannot share data context between Swing events; initial event count = 6171; current event count = 6177
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:132)
at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:363)
at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:75)
can anyone help me to resolve this error.
Please sign in to leave a comment.
Most likely your code shows a dialog before accessing data context, and this is prohibited.
I am not using dialog but this error comes when the action perform by shortcut key. key configured as below,
<action id="ABC"
class="test.AbcAction"
description="ccc">
<keyboard-shortcut keymap="\$default" first-keystroke="ctrl shift g"/>
<add-to-group group-id="Abc.ToolBarMenu"/>
</action>
if use menu bar command no error comes.
You can debug this by putting a breakpoint into IdeEventQueue, into the line where "myEventCount++", after your action is invoked, and see who's dispatching AWT events.