public class DumbServiceImpl extends DumbService implements Disposable, ModificationTracker
DumbService.DumbModeListener
Disposable.Parent
DUMB_MODE
EVER_CHANGED, NEVER_CHANGED
Constructor and Description |
---|
DumbServiceImpl(Project project) |
Modifier and Type | Method and Description |
---|---|
void |
cancelAllTasksAndWait()
Cancels all tasks and wait when their execution is finished.
|
void |
cancelTask(DumbModeTask task)
Cancels the given task.
|
void |
completeJustSubmittedTasks()
Runs the "just submitted" tasks under a modal dialog.
|
void |
dispose()
Usually not invoked directly, see class javadoc.
|
java.lang.Throwable |
getDumbModeStartTrace() |
static DumbServiceImpl |
getInstance(Project project) |
long |
getModificationCount() |
ModificationTracker |
getModificationTracker()
The tracker is advanced each time we enter/exit from dumb mode.
|
Project |
getProject() |
boolean |
isAlternativeResolveEnabled() |
boolean |
isDumb()
To avoid race conditions use it only in EDT thread or inside read-action.
|
boolean |
isSuspendedDumbMode()
Checks whether
DumbService.isDumb() is true for the current project and if it's currently suspended by user or a DumbService.suspendIndexingAndRun(java.lang.String, java.lang.Runnable) call. |
void |
queueTask(DumbModeTask task)
Queues a task to be executed in "dumb mode", where access to indexes is forbidden.
|
void |
runWhenSmart(java.lang.Runnable runnable)
Executes the runnable as soon as possible on AWT Event Dispatch when:
project is initialized
and there's no dumb mode in progress
This may also happen immediately if these conditions are already met.
Note that it's not guaranteed that the dumb mode won't start again during this runnable execution, it should manage that situation explicitly.
|
void |
setAlternativeResolveEnabled(boolean enabled)
Enables or disables alternative resolve strategies for the current thread.
|
void |
setDumb(boolean dumb) |
boolean |
showDumbModeDialog(java.util.List<java.lang.String> actionNames)
Show modal progress about indexing blocking those actions until it is cancelled or indexing stops.
|
void |
showDumbModeNotification(java.lang.String message)
Show a notification when given action is not available during dumb mode.
|
void |
smartInvokeLater(java.lang.Runnable runnable)
Invoke the runnable later on EventDispatchThread AND when IDE isn't in dumb mode.
|
void |
smartInvokeLater(java.lang.Runnable runnable,
ModalityState modalityState)
Invoke the runnable later on EventDispatchThread with the given modality state AND when IDE isn't in dumb mode.
|
void |
suspendIndexingAndRun(java.lang.String activityName,
java.lang.Runnable activity)
Runs a heavy activity and suspends indexing (if any) for this time.
|
void |
unsafeRunWhenSmart(java.lang.Runnable runnable) |
void |
waitForSmartMode()
Pause the current thread until dumb mode ends and then continue execution.
|
javax.swing.JComponent |
wrapGently(javax.swing.JComponent dumbUnawareContent,
Disposable parentDisposable)
Replaces given component temporarily with "Not available until indices are built" label during dumb mode.
|
javax.swing.JComponent |
wrapWithSpoiler(javax.swing.JComponent dumbAwareContent,
java.lang.Runnable updateRunnable,
Disposable parentDisposable)
Adds a "Results might be incomplete while indexing." decorator to a given component during dumb mode.
|
allowStartingDumbModeInside, computeWithAlternativeResolveEnabled, filterByDumbAwareness, filterByDumbAwareness, getDumbAwareExtensions, getDumbAwareExtensions, isDumb, isDumbAware, makeDumbAware, repeatUntilPassesInSmartMode, runReadActionInSmartMode, runReadActionInSmartMode, runWithAlternativeResolveEnabled, tryRunReadActionInSmartMode, withAlternativeResolveEnabled
public DumbServiceImpl(Project project)
public static DumbServiceImpl getInstance(Project project)
public void cancelTask(DumbModeTask task)
DumbService
ProgressIndicator
is canceled, so the next ProgressManager.checkCanceled()
call
will throw ProcessCanceledException
.cancelTask
in class DumbService
public void dispose()
Disposable
dispose
in interface Disposable
public Project getProject()
getProject
in class DumbService
public boolean isAlternativeResolveEnabled()
isAlternativeResolveEnabled
in class DumbService
DumbService.setAlternativeResolveEnabled(boolean)
public void suspendIndexingAndRun(java.lang.String activityName, java.lang.Runnable activity)
DumbService
suspendIndexingAndRun
in class DumbService
activityName
- the text (a noun phrase) to display as a reason for the indexing being pausedpublic boolean isSuspendedDumbMode()
DumbService
DumbService.isDumb()
is true for the current project and if it's currently suspended by user or a DumbService.suspendIndexingAndRun(java.lang.String, java.lang.Runnable)
call.
This should be called inside read action. The momentary system state is returned: there are no guarantees that the result won't change
in the next line of the calling code.isSuspendedDumbMode
in class DumbService
public void setAlternativeResolveEnabled(boolean enabled)
DumbService
Normally reference resolution uses indexes, and hence is not available in dumb mode. In some cases, alternative ways of performing resolve are available, although much slower. It's impractical to always use these ways because it'll lead to overloaded CPU (especially given there's also indexing in progress). But for some explicit user actions (e.g., explicit Goto Declaration) turning on these slower methods is beneficial.
NOTE: even with alternative resolution enabled, methods like resolve(), findClass() etc may still throw
IndexNotReadyException
. So alternative resolve is not a panacea, it might help provide navigation in some cases
but not in all.
A typical usage would involve try-finally
, where the alternative resolution is first enabled, then an action is performed,
and then alternative resolution is turned off in the finally
block.
setAlternativeResolveEnabled
in class DumbService
public ModificationTracker getModificationTracker()
DumbService
getModificationTracker
in class DumbService
public boolean isDumb()
DumbService
DumbService
isDumb
in class DumbService
public void setDumb(boolean dumb)
public void runWhenSmart(java.lang.Runnable runnable)
DumbService
runWhenSmart
in class DumbService
public void unsafeRunWhenSmart(java.lang.Runnable runnable)
unsafeRunWhenSmart
in class DumbService
public void queueTask(DumbModeTask task)
DumbService
DumbService.completeJustSubmittedTasks()
is called in the same dispatch thread activity.
Tasks can specify custom "equality" policy via their constructor. Calling this method has no effect if an "equal" task is already enqueued (but not yet running).
queueTask
in class DumbService
public void showDumbModeNotification(java.lang.String message)
DumbService
showDumbModeNotification
in class DumbService
public boolean showDumbModeDialog(java.util.List<java.lang.String> actionNames)
DumbService
showDumbModeDialog
in class DumbService
public void cancelAllTasksAndWait()
DumbService
cancelAllTasksAndWait
in class DumbService
public void waitForSmartMode()
DumbService
DumbService.runWhenSmart(Runnable)
or DumbService.runReadActionInSmartMode(Runnable)
insteadwaitForSmartMode
in class DumbService
public javax.swing.JComponent wrapGently(javax.swing.JComponent dumbUnawareContent, Disposable parentDisposable)
DumbService
wrapGently
in class DumbService
public javax.swing.JComponent wrapWithSpoiler(javax.swing.JComponent dumbAwareContent, java.lang.Runnable updateRunnable, Disposable parentDisposable)
DumbService
wrapWithSpoiler
in class DumbService
dumbAwareContent
- - a component to wrapupdateRunnable
- - an action to execute when dumb mode state changed or user explicitly request reload panelpublic void smartInvokeLater(java.lang.Runnable runnable)
DumbService
smartInvokeLater
in class DumbService
public void smartInvokeLater(java.lang.Runnable runnable, ModalityState modalityState)
DumbService
smartInvokeLater
in class DumbService
public void completeJustSubmittedTasks()
DumbService
This functionality can be useful in refactorings (invoked in "smart mode"), when after VFS or root changes (which could start "dumb mode") some reference resolve is required (which again requires "smart mode").
Should be invoked on dispatch thread. It's the caller's responsibility to invoke this method only when the model is in internally consistent state, so that background threads with read actions don't see half-baked PSI/VFS/etc.
completeJustSubmittedTasks
in class DumbService
public long getModificationCount()
getModificationCount
in interface ModificationTracker
public java.lang.Throwable getDumbModeStartTrace()