public class DumbServiceImpl extends DumbService implements Disposable, ModificationTracker
DumbService.DumbModeListenerDisposable.ParentDUMB_MODEEVER_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, withAlternativeResolveEnabledpublic DumbServiceImpl(Project project)
public static DumbServiceImpl getInstance(Project project)
public void cancelTask(DumbModeTask task)
DumbServiceProgressIndicator is canceled, so the next ProgressManager.checkCanceled() call
will throw ProcessCanceledException.cancelTask in class DumbServicepublic void dispose()
Disposabledispose in interface Disposablepublic Project getProject()
getProject in class DumbServicepublic boolean isAlternativeResolveEnabled()
isAlternativeResolveEnabled in class DumbServiceDumbService.setAlternativeResolveEnabled(boolean)public void suspendIndexingAndRun(java.lang.String activityName,
java.lang.Runnable activity)
DumbServicesuspendIndexingAndRun in class DumbServiceactivityName - the text (a noun phrase) to display as a reason for the indexing being pausedpublic boolean isSuspendedDumbMode()
DumbServiceDumbService.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 DumbServicepublic void setAlternativeResolveEnabled(boolean enabled)
DumbServiceNormally 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 DumbServicepublic ModificationTracker getModificationTracker()
DumbServicegetModificationTracker in class DumbServicepublic boolean isDumb()
DumbServiceDumbServiceisDumb in class DumbServicepublic void setDumb(boolean dumb)
public void runWhenSmart(java.lang.Runnable runnable)
DumbServicerunWhenSmart in class DumbServicepublic void unsafeRunWhenSmart(java.lang.Runnable runnable)
unsafeRunWhenSmart in class DumbServicepublic void queueTask(DumbModeTask task)
DumbServiceDumbService.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 DumbServicepublic void showDumbModeNotification(java.lang.String message)
DumbServiceshowDumbModeNotification in class DumbServicepublic boolean showDumbModeDialog(java.util.List<java.lang.String> actionNames)
DumbServiceshowDumbModeDialog in class DumbServicepublic void cancelAllTasksAndWait()
DumbServicecancelAllTasksAndWait in class DumbServicepublic void waitForSmartMode()
DumbServiceDumbService.runWhenSmart(Runnable) or DumbService.runReadActionInSmartMode(Runnable) insteadwaitForSmartMode in class DumbServicepublic javax.swing.JComponent wrapGently(javax.swing.JComponent dumbUnawareContent,
Disposable parentDisposable)
DumbServicewrapGently in class DumbServicepublic javax.swing.JComponent wrapWithSpoiler(javax.swing.JComponent dumbAwareContent,
java.lang.Runnable updateRunnable,
Disposable parentDisposable)
DumbServicewrapWithSpoiler in class DumbServicedumbAwareContent - - 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)
DumbServicesmartInvokeLater in class DumbServicepublic void smartInvokeLater(java.lang.Runnable runnable,
ModalityState modalityState)
DumbServicesmartInvokeLater in class DumbServicepublic void completeJustSubmittedTasks()
DumbServiceThis 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 DumbServicepublic long getModificationCount()
getModificationCount in interface ModificationTrackerpublic java.lang.Throwable getDumbModeStartTrace()