IntelliJ Platform Plugin SDK
 
IntelliJ Platform Explorer

Trusted Project

Edit pageLast modified: 04 April 2023

When a project is opened in the IDE for the first time, the user will be asked whether they trust the project or not. If the user chooses to preview the project in the safe mode, no potentially dangerous feature can be executed automatically or unexpectedly.

A plugin can check whether the project is trusted via the Kotlin extension method Project.isTrusted() or from Java via static method TrustedProjects.isTrusted(Project).

A project opened in the safe mode can become trusted afterward: either the user can click on the Trust Project link in the notification panel shown on top of the editor, or the state can be changed programmatically, for instance, if the user invokes a dangerous action, and that action proposes to switch to the Trusted mode.

Therefore, a plugin can subscribe to changes of the trusted state via application-level listener TrustStateListener to switch on a feature that was disabled in the safe mode. To do it the plugin should implement TrustStateListener.onProjectTrusted(). Or better, use one of TrustedProjects.whenProjectTrusted() helper methods accepting a lambda, one for Kotlin and another for Java.