java: cannot access com.intellij.openapi.actionSystem.DataKey

Answered

I recently upgraded my IntelliJ version from 2018.3 to 2020.3. I now get an error when trying to run code involving data keys:

Editor editor = event.getData(CommonDataKeys.EDITOR);
String highlightedText = editor.getSelectionModel().getSelectedText();
ConsoleViewImpl console = ((ConsoleViewImpl) event.getData(LangDataKeys.CONSOLE_VIEW));

Both of the above code snippets give the following error:

java: cannot access com.intellij.openapi.actionSystem.DataKey
class file for com.intellij.openapi.actionSystem.DataKey not found

This code works fine in 2018.3 but not in 2020.3 and I have been unable to work out why, any help is appreciated. 

3 comments
Comment actions Permalink

Most likely the JAR file(s) of your IJ Platform in Gradle cache are corrupted; and/or try full re-import of your Gradle project.

Class com.intellij.openapi.actionSystem.DataKey definitely exists.

0
Comment actions Permalink

Still the same problem. I have downgraded to IntelliJ 2020.2 and it works as expected on there.

0

Please sign in to leave a comment.