public interface Application extends ComponentManager
The thread model defines three types of locks which provide access the PSI and other IDE data structures:
The compatibility matrix for these locks is reflected below.
| R | IW | W | |
|---|---|---|---|
| R | + | + | - | 
| IW | + | - | - | 
| W | - | - | - | 
 Obtaining locks manually is not recommended. The recommended way to obtain read and write locks is to run so-called
 "read actions" and "write actions" via runReadAction(java.lang.Runnable) and runWriteAction(java.lang.Runnable), respectively.
 
 The recommended way to obtain Write Intent lock is to schedule execution on so-called "write thread" (i.e. thread with Write Intent lock)
 via invokeLaterOnWriteThread(java.lang.Runnable), WriteThread or AppUIExecutor.onWriteThread(com.intellij.openapi.application.ModalityState) asynchronous API.
 
Multiple read actions can run at the same time without locking each other.
 If there are read actions running at this moment runWriteAction is blocked until they are completed.
 
See also General Threading Rules.
Disposable.Parent| Modifier and Type | Method and Description | 
|---|---|
| AccessToken | acquireReadActionLock()Deprecated. 
 Use  runReadAction(Runnable)instead | 
| AccessToken | acquireWriteActionLock(java.lang.Class<?> marker)Deprecated. 
 | 
| boolean | acquireWriteIntentLockIfNeeded()Private API to use in instrumented code. | 
| void | addApplicationListener(ApplicationListener listener)Deprecated. 
 Use  addApplicationListener(ApplicationListener, Disposable)instead
 Adds anApplicationListener. | 
| void | addApplicationListener(ApplicationListener listener,
                      Disposable parent)Adds an  ApplicationListener. | 
| void | assertIsDispatchThread()Asserts whether the method is being called from the event dispatch thread. | 
| void | assertIsWriteThread()Asserts whether the method is being called from under the Write Intent lock | 
| void | assertReadAccessAllowed()Asserts whether the read access is allowed. | 
| void | assertWriteAccessAllowed()Asserts whether the write access is allowed. | 
| <T> java.util.concurrent.Future<T> | executeOnPooledThread(java.util.concurrent.Callable<T> action)Requests pooled thread to execute the action. | 
| java.util.concurrent.Future<?> | executeOnPooledThread(java.lang.Runnable action)Requests pooled thread to execute the action. | 
| void | exit()Exits the application, showing the exit confirmation prompt if it is enabled. | 
| default void | exit(boolean force,
    boolean exitConfirmed,
    boolean restart) | 
| ModalityState | getAnyModalityState()Please use  ModalityState.any()instead, and only if you absolutely must, after carefully reading its documentation. | 
| ModalityState | getCurrentModalityState()Please use  ModalityState.current()instead. | 
| ModalityState | getDefaultModalityState()Please use  ModalityState.defaultModalityState()instead. | 
| long | getIdleTime()Returns the time in milliseconds during which IDE received no input events. | 
| ModalityInvokator | getInvokator() | 
| ModalityState | getModalityStateForComponent(java.awt.Component c)Please use  ModalityState.stateForComponent(Component)instead. | 
| ModalityState | getNoneModalityState()Please use  ModalityState.NON_MODALinstead. | 
| long | getStartTime()Returns the time of IDE start, in milliseconds since midnight, January 1, 1970 UTC. | 
| boolean | hasWriteAction(java.lang.Class<?> actionClass)Returns  trueif there is currently executing write action of the specified class. | 
| void | invokeAndWait(java.lang.Runnable runnable) | 
| void | invokeAndWait(java.lang.Runnable runnable,
             ModalityState modalityState)Causes  runnable.run()to be executed synchronously on the
 AWT event dispatching thread under Write Intent lock, when the IDE is in the specified modality
 state (or a state with less modal dialogs open). | 
| void | invokeLater(java.lang.Runnable runnable)Causes  runnable.run()to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, withModalityState.defaultModalityState()modality state. | 
| void | invokeLater(java.lang.Runnable runnable,
           Condition<?> expired)Causes  runnable.run()to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock - unless the expiration condition is fulfilled. | 
| void | invokeLater(java.lang.Runnable runnable,
           ModalityState state)Causes  runnable.run()to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, when IDE is in the specified modality
 state (or a state with less modal dialogs open). | 
| void | invokeLater(java.lang.Runnable runnable,
           ModalityState state,
           Condition<?> expired)Causes  runnable.run()to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, when IDE is in the specified modality
 state(or a state with less modal dialogs open) - unless the expiration condition is fulfilled. | 
| void | invokeLaterOnWriteThread(java.lang.Runnable action)Causes  runnableto be executed asynchronously under Write Intent lock on some thread,
 withModalityState.defaultModalityState()modality state. | 
| void | invokeLaterOnWriteThread(java.lang.Runnable action,
                        ModalityState modal)Causes  runnableto be executed asynchronously under Write Intent lock on some thread,
 when IDE is in the specified modality state (or a state with less modal dialogs open). | 
| void | invokeLaterOnWriteThread(java.lang.Runnable action,
                        ModalityState modal,
                        Condition<?> expired)Causes  runnableto be executed asynchronously under Write Intent lock on some thread,
 when IDE is in the specified modality state (or a state with less modal dialogs open)
 - unless the expiration condition is fulfilled. | 
| boolean | isActive()Checks if the application is active. | 
| boolean | isCommandLine()Checks if IDE is running as a command line applet or in unit test mode. | 
| boolean | isDispatchThread()Checks if the current thread is the Swing dispatch thread and has IW lock acquired. | 
| default boolean | isDisposeInProgress()Deprecated. 
 | 
| boolean | isEAP() | 
| boolean | isHeadlessEnvironment()Checks if IDE is running as a command line applet or in unit test mode. | 
| boolean | isInternal()Checks if IDE is running in Internal Mode to enable additional features for plugin development. | 
| boolean | isReadAccessAllowed()Checks if the read access is currently allowed. | 
| boolean | isRestartCapable()Checks if IDE is capable of restarting itself on the current platform and with the current execution mode. | 
| boolean | isUnitTestMode()Checks if IDE is currently running unit tests. | 
| boolean | isWriteAccessAllowed()Checks if the write access is currently allowed. | 
| boolean | isWriteThread()Checks if the current thread has IW lock acquired, which grants read access and the ability to run write actions. | 
| void | releaseWriteIntentLockIfNeeded(boolean needed)Private API to use in instrumented code. | 
| void | removeApplicationListener(ApplicationListener listener)Deprecated. 
 Instead, just call  Disposer.dispose(disposable);on disposable you've passed toaddApplicationListener(ApplicationListener, Disposable)Removes anApplicationListener. | 
| void | restart()Exits and restarts IDE. | 
| void | runIntendedWriteActionOnCurrentThread(java.lang.Runnable action)Runs the specified action under Write Intent lock. | 
| <T> T | runReadAction(Computable<T> computation)Runs the specified computation in a read action. | 
| void | runReadAction(java.lang.Runnable action)Runs the specified read action. | 
| <T,E extends java.lang.Throwable> | runReadAction(ThrowableComputable<T,E> computation)Runs the specified computation in a read action. | 
| <T,E extends java.lang.Throwable> | runUnlockingIntendedWrite(ThrowableComputable<T,E> action)Runs the specified action, releasing Write Intent lock if it is acquired at the moment of the call. | 
| <T> T | runWriteAction(Computable<T> computation)Runs the specified computation in a write action. | 
| void | runWriteAction(java.lang.Runnable action)Runs the specified write action. | 
| <T,E extends java.lang.Throwable> | runWriteAction(ThrowableComputable<T,E> computation)Runs the specified computation in a write action. | 
| void | saveAll()Saves all open documents and projects. | 
| void | saveSettings()Saves application settings. | 
createError, createError, getComponent, getComponent, getComponent, getComponentInstancesOfType, getComponentInstancesOfType, getComponents, getDisposed, getExtensionArea, getExtensions, getMessageBus, getPicoContainer, getService, getService, getServiceIfCreated, hasComponent, instantiateClass, instantiateClassWithConstructorInjection, instantiateExtensionWithPicoContainerOnlyIfNeeded, isDisposed, isDisposedOrDisposeInProgress, logErrorgetUserData, putUserDatadisposeboolean acquireWriteIntentLockIfNeeded()
Acquires IW lock if it's not acquired by the current thread.
true if IW lock was acquired, or false if it is held by the current thread already.void releaseWriteIntentLockIfNeeded(boolean needed)
 Releases IW lock if the parameter is true.
needed - whether IW lock should be released or notvoid invokeLaterOnWriteThread(java.lang.Runnable action)
runnable to be executed asynchronously under Write Intent lock on some thread,
 with ModalityState.defaultModalityState() modality state.action - the runnable to execute.void invokeLaterOnWriteThread(java.lang.Runnable action,
                              ModalityState modal)
runnable to be executed asynchronously under Write Intent lock on some thread,
 when IDE is in the specified modality state (or a state with less modal dialogs open).action - the runnable to execute.modal - the state in which action will be executedvoid invokeLaterOnWriteThread(java.lang.Runnable action,
                              ModalityState modal,
                              Condition<?> expired)
runnable to be executed asynchronously under Write Intent lock on some thread,
 when IDE is in the specified modality state (or a state with less modal dialogs open)
 - unless the expiration condition is fulfilled.action - the runnable to execute.modal - the state in which action will be executedexpired - condition to check before execution.<T,E extends java.lang.Throwable> T runUnlockingIntendedWrite(ThrowableComputable<T,E> action) throws E extends java.lang.Throwable
This method is used to implement higher-level API, please do not use it directly.
E extends java.lang.Throwablevoid runIntendedWriteActionOnCurrentThread(java.lang.Runnable action)
 This method is used to implement higher-level API, please do not use it directly.
 Use invokeLaterOnWriteThread(java.lang.Runnable), WriteThread or AppUIExecutor.onWriteThread() to
 run code under Write Intent lock asynchronously.
action - the action to runvoid runReadAction(java.lang.Runnable action)
 See also ReadAction.run(com.intellij.openapi.application.Result<T>) for a more lambda-friendly version.
action - the action to run.<T> T runReadAction(Computable<T> computation)
 See also ReadAction.compute(com.intellij.openapi.util.ThrowableComputable<T, E>) for a more lambda-friendly version.
computation - the computation to perform.<T,E extends java.lang.Throwable> T runReadAction(ThrowableComputable<T,E> computation) throws E extends java.lang.Throwable
 See also ReadAction.compute(com.intellij.openapi.util.ThrowableComputable<T, E>) for a more lambda-friendly version.
computation - the computation to perform.E - re-frown from ThrowableComputableE extends java.lang.Throwablevoid runWriteAction(java.lang.Runnable action)
 See also WriteAction.run(com.intellij.util.ThrowableRunnable<E>) for a more lambda-friendly version.
action - the action to run<T> T runWriteAction(Computable<T> computation)
 See also WriteAction.compute(com.intellij.openapi.util.ThrowableComputable<T, E>) for a more lambda-friendly version.
computation - the computation to run<T,E extends java.lang.Throwable> T runWriteAction(ThrowableComputable<T,E> computation) throws E extends java.lang.Throwable
 See also WriteAction.compute(com.intellij.openapi.util.ThrowableComputable<T, E>) for a more lambda-friendly version.
computation - the computation to runE - re-frown from ThrowableComputableE extends java.lang.Throwableboolean hasWriteAction(java.lang.Class<?> actionClass)
true if there is currently executing write action of the specified class.actionClass - the class of the write action to return.true if the action is running, or false if no action of the specified class is currently executing.void assertReadAccessAllowed()
void assertWriteAccessAllowed()
void assertIsDispatchThread()
void assertIsWriteThread()
@Deprecated void addApplicationListener(ApplicationListener listener)
addApplicationListener(ApplicationListener, Disposable) instead
 Adds an ApplicationListener.listener - the listener to addvoid addApplicationListener(ApplicationListener listener, Disposable parent)
ApplicationListener.listener - the listener to addparent - the parent disposable which dispose will trigger this listener removal@Deprecated void removeApplicationListener(ApplicationListener listener)
Disposer.dispose(disposable); on disposable you've passed to addApplicationListener(ApplicationListener, Disposable)
 Removes an ApplicationListener.listener - the listener to removevoid saveAll()
void saveSettings()
void exit()
default void exit(boolean force,
                  boolean exitConfirmed,
                  boolean restart)
boolean isWriteAccessAllowed()
true if the write access is currently allowed, false otherwise.assertWriteAccessAllowed(), 
runWriteAction(Runnable)boolean isReadAccessAllowed()
true if the read access is currently allowed, false otherwise.assertReadAccessAllowed(), 
runReadAction(Runnable)boolean isDispatchThread()
true if the current thread is the Swing dispatch thread with IW lock, false otherwise.isWriteThread()boolean isWriteThread()
true if the current thread has IW lock acquired, false otherwise.ModalityInvokator getInvokator()
void invokeLater(java.lang.Runnable runnable)
runnable.run() to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, with ModalityState.defaultModalityState() modality state.
 This will happen after all pending AWT events have been processed.
 
 Please use this method instead of SwingUtilities.invokeLater(Runnable) or UIUtil methods
 for the reasons described in ModalityState documentation.
runnable - the runnable to execute.void invokeLater(java.lang.Runnable runnable,
                 Condition<?> expired)
runnable.run() to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock - unless the expiration condition is fulfilled.
 This will happen after all pending AWT events have been processed and in ModalityState.defaultModalityState() modality state
 (or a state with less modal dialogs open).
 
 Please use this method instead of SwingUtilities.invokeLater(Runnable) or UIUtil methods
 for the reasons described in ModalityState documentation.
runnable - the runnable to execute.expired - condition to check before execution.void invokeLater(java.lang.Runnable runnable,
                 ModalityState state)
runnable.run() to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, when IDE is in the specified modality
 state (or a state with less modal dialogs open).
 
 Please use this method instead of SwingUtilities.invokeLater(Runnable) or UIUtil methods
 for the reasons described in ModalityState documentation.
runnable - the runnable to execute.state - the state in which the runnable will be executed.void invokeLater(java.lang.Runnable runnable,
                 ModalityState state,
                 Condition<?> expired)
runnable.run() to be executed asynchronously on the
 AWT event dispatching thread under Write Intent lock, when IDE is in the specified modality
 state(or a state with less modal dialogs open) - unless the expiration condition is fulfilled.
 This will happen after all pending AWT events have been processed.
 
 Please use this method instead of SwingUtilities.invokeLater(Runnable) or UIUtil methods
 for the reasons described in ModalityState documentation.
runnable - the runnable to execute.state - the state in which the runnable will be executed.expired - condition to check before execution.void invokeAndWait(java.lang.Runnable runnable,
                   ModalityState modalityState)
            throws ProcessCanceledException
Causes runnable.run() to be executed synchronously on the
 AWT event dispatching thread under Write Intent lock, when the IDE is in the specified modality
 state (or a state with less modal dialogs open). This call blocks until all pending AWT events have been processed and (then)
 runnable.run() returns.
If current thread is an event dispatch thread then runnable.run()
 is executed immediately regardless of the modality state.
 Please use this method instead of SwingUtilities.invokeAndWait(Runnable) or UIUtil methods
 for the reasons described in ModalityState documentation.
runnable - the runnable to execute.modalityState - the state in which the runnable will be executed.ProcessCanceledException - when the current thread is interruptedvoid invokeAndWait(java.lang.Runnable runnable)
            throws ProcessCanceledException
ProcessCanceledExceptionModalityState getCurrentModalityState()
ModalityState.current() instead.ModalityState getModalityStateForComponent(java.awt.Component c)
ModalityState.stateForComponent(Component) instead.ModalityState getDefaultModalityState()
ModalityState.defaultModalityState() instead.ModalityState getNoneModalityState()
ModalityState.NON_MODAL instead.ModalityState getAnyModalityState()
ModalityState.any() instead, and only if you absolutely must, after carefully reading its documentation.long getStartTime()
long getIdleTime()
boolean isUnitTestMode()
invokeLater in tests, you can call PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()NonBlockingReadActionImpl.waitForAsyncTaskCompletion()Future/Promise/etc callbacks and call PlatformTestUtil.waitFor*Messages.setTestDialog(...)UiInterceptorstrue if IDE is running unit tests, false otherwiseboolean isHeadlessEnvironment()
true if IDE is running in UI-less mode, false otherwiseboolean isCommandLine()
true if IDE is running in command line  mode, false otherwisejava.util.concurrent.Future<?> executeOnPooledThread(java.lang.Runnable action)
This pool is an
action - to be executed<T> java.util.concurrent.Future<T> executeOnPooledThread(java.util.concurrent.Callable<T> action)
This pool is an
action - to be executed@Deprecated default boolean isDisposeInProgress()
ComponentManager.isDisposed().boolean isRestartCapable()
true if IDE can restart itself, false otherwise.void restart()
boolean isActive()
true if one of application windows is focused, false otherwise@Deprecated AccessToken acquireReadActionLock()
runReadAction(Runnable) instead@Deprecated AccessToken acquireWriteActionLock(java.lang.Class<?> marker)
runWriteAction(java.lang.Runnable), WriteAction.run(ThrowableRunnable) or WriteAction.compute(ThrowableComputable) insteadboolean isInternal()
boolean isEAP()