Hi there,
I just noticed in the 252-EAP-SNAPSHOT that CommonDataKeys.LANGUAGE
is null. I don’t see any comment on that in the API and Compatibility section, I guess it is a bug.
Here is the implementation I have:
class ExecuteSPARQLQueryAction : DumbAwareAction() {
override fun actionPerformed(e: AnActionEvent) {
...
}
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
override fun update(e: AnActionEvent) {
val project = e.getData(CommonDataKeys.PROJECT)
val editor = e.getData(CommonDataKeys.EDITOR)
val virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE)
val language = e.getData(CommonDataKeys.LANGUAGE)
if (project == null || editor == null || virtualFile == null || language != SPARQLLanguage) {
e.presentation.isEnabledAndVisible = false
} else {
if (virtualFile.getUserData(SPARQLFile.SELECTED_ENDPOINT_ID_KEY) == null) {
e.presentation.isVisible = true
e.presentation.isEnabled = false
} else {
e.presentation.isEnabledAndVisible = true
}
}
}
}
The behaviour:
- open a SPARQL file,
- click inside of the file,
update(AnActionEvent)
is called regularly, but in ~80% caseslanguage
variable is null.
I don’t see anything special about these ~80%, therefore I cannot understand why suddenly CommonDataKeys.LANGUAGE
is null in the current EAP version.
Any thoughts?
Regards,
Maksim