public class LightEditDumbService extends DumbServiceImpl
DumbService.DumbModeListener
Disposable.Parent
DUMB_MODE
EVER_CHANGED, NEVER_CHANGED
Constructor and Description |
---|
LightEditDumbService(Project project) |
Modifier and Type | Method and Description |
---|---|
void |
cancelTask(DumbModeTask task)
Cancels the given task.
|
void |
completeJustSubmittedTasks()
Runs the "just submitted" tasks under a modal dialog.
|
long |
getModificationCount() |
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 |
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.
|
cancelAllTasksAndWait, dispose, getDumbModeStartTrace, getInstance, getModificationTracker, getProject, setDumb, showDumbModeDialog, showDumbModeNotification
allowStartingDumbModeInside, computeWithAlternativeResolveEnabled, filterByDumbAwareness, filterByDumbAwareness, getDumbAwareExtensions, getDumbAwareExtensions, isDumb, isDumbAware, makeDumbAware, repeatUntilPassesInSmartMode, runReadActionInSmartMode, runReadActionInSmartMode, runWithAlternativeResolveEnabled, tryRunReadActionInSmartMode, withAlternativeResolveEnabled
public LightEditDumbService(Project project)
public boolean isDumb()
DumbService
DumbService
isDumb
in class DumbServiceImpl
public void runWhenSmart(java.lang.Runnable runnable)
DumbService
runWhenSmart
in class DumbServiceImpl
public void waitForSmartMode()
DumbService
DumbService.runWhenSmart(Runnable)
or DumbService.runReadActionInSmartMode(Runnable)
insteadwaitForSmartMode
in class DumbServiceImpl
public void smartInvokeLater(java.lang.Runnable runnable)
DumbService
smartInvokeLater
in class DumbServiceImpl
public void smartInvokeLater(java.lang.Runnable runnable, ModalityState modalityState)
DumbService
smartInvokeLater
in class DumbServiceImpl
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 DumbServiceImpl
public void cancelTask(DumbModeTask task)
DumbService
ProgressIndicator
is canceled, so the next ProgressManager.checkCanceled()
call
will throw ProcessCanceledException
.cancelTask
in class DumbServiceImpl
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 DumbServiceImpl
public javax.swing.JComponent wrapGently(javax.swing.JComponent dumbUnawareContent, Disposable parentDisposable)
DumbService
wrapGently
in class DumbServiceImpl
public javax.swing.JComponent wrapWithSpoiler(javax.swing.JComponent dumbAwareContent, java.lang.Runnable updateRunnable, Disposable parentDisposable)
DumbService
wrapWithSpoiler
in class DumbServiceImpl
dumbAwareContent
- - a component to wrapupdateRunnable
- - an action to execute when dumb mode state changed or user explicitly request reload panelpublic 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 DumbServiceImpl
public boolean isAlternativeResolveEnabled()
isAlternativeResolveEnabled
in class DumbServiceImpl
DumbService.setAlternativeResolveEnabled(boolean)
public void suspendIndexingAndRun(java.lang.String activityName, java.lang.Runnable activity)
DumbService
suspendIndexingAndRun
in class DumbServiceImpl
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 DumbServiceImpl
public void unsafeRunWhenSmart(java.lang.Runnable runnable)
unsafeRunWhenSmart
in class DumbServiceImpl
public long getModificationCount()
getModificationCount
in interface ModificationTracker
getModificationCount
in class DumbServiceImpl