Interface ICodeMining
- All Known Implementing Classes:
AbstractCodeMining, DocumentFooterCodeMining, LineContentCodeMining, LineEndCodeMining, LineHeaderCodeMining, UnifiedDiffCodeMiningProvider.FoldedRegionCodeMining, UnifiedDiffCodeMiningProvider.UnifiedDiffFooterCodeMining, UnifiedDiffCodeMiningProvider.UnifiedDiffLineHeaderCodeMining
- Since:
- 3.13
-
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose the mining.draw(GC gc, StyledText textWidget, Color color, int x, int y) Draw the code mining.Returns the action to execute when mining is clicked and null otherwise.getLabel()Returns the label may be set early in the class lifecycle, or upon completion of the future provided byresolve(ITextViewer, IProgressMonitor)operation.default Consumer<MouseEvent> Returns a consumer which is called when mouse is hovered over the code mining.default Consumer<MouseEvent> Returns a consumer which is called when mouse is moved inside the code mining.default Consumer<MouseEvent> Returns a consumer which is called when mouse is moved out of code mining.default StringReturns the placeholder label, which is displayed whilegetLabel()returnsnulland the mining is not yet resolved.Returns the line position where code mining must be displayed in the line spacing area.Returns the owner provider which has created this mining.booleanReturns whether the content mining is resolved.resolve(ITextViewer viewer, IProgressMonitor monitor) Returns the future to resolve the content of mining, orCompletableFuture.completedFuture(Object)if no such resolution is necessary (in which case {#isResolved()} is expected to returntrue).
-
Method Details
-
getPosition
Position getPosition()Returns the line position where code mining must be displayed in the line spacing area.- Returns:
- the line position where code mining must be displayed in the line spacing area.
-
getProvider
ICodeMiningProvider getProvider()Returns the owner provider which has created this mining.- Returns:
- the owner provider which has created this mining.
-
getLabel
String getLabel()Returns the label may be set early in the class lifecycle, or upon completion of the future provided byresolve(ITextViewer, IProgressMonitor)operation.The returned label can have several values:
nullwhen mining is not resolvednullwhen mining is resolved means that mining was resolved with an error and it will not be displayed.- empty when mining is resolved means that mining will not be displayed
- non empty when mining must be displayed
- Returns:
- the label may be set early in the class lifecycle, or upon completion of the future
provided by
resolve(ITextViewer, IProgressMonitor)operation.
-
getPlaceholderLabel
Returns the placeholder label, which is displayed whilegetLabel()returnsnulland the mining is not yet resolved.If the placeholder label is
nullor empty, no placeholder is displayed.A placeholder label can be used to prevent editor jumping for code minings with expensive
resolve(ITextViewer, IProgressMonitor)implementations, especially for LineHeaderCodeMinings. To actually prevent editor jumping, the placeholder should have the same number of lines as the resolved label. If the mining resolves to anullor empty label, the placeholder disappears and the lines it occupied are removed again.This method may be called from any thread, including the UI thread, possibly several times. Implementations must not block the calling thread and should return a pre-computed value.
When implemented to return a non-empty value, the code mining implementation must adhere to the following contract for
getLabel():getLabel()must returnnulluntil the label is computed. The placeholder is only used whilegetLabel()returnsnulland the mining is not resolved. If a non-nulllabel is set before resolving, the placeholder is never displayed.- The label must be set during resolution, i.e. after
resolve(ITextViewer, IProgressMonitor)is invoked and before the future returned by it completes. - If resolution fails or is cancelled, the label should remain
null. The mining is then treated as resolved with an error, seegetLabel().
- Returns:
- the placeholder label, may be
nullor empty. - Since:
- 3.33
-
resolve
Returns the future to resolve the content of mining, orCompletableFuture.completedFuture(Object)if no such resolution is necessary (in which case {#isResolved()} is expected to returntrue).If
getPlaceholderLabel()returns a non-empty value, then the value ofgetLabel()must be set after this method is invoked but before the future returned by it completes.- Parameters:
viewer- the viewer, can be nullmonitor- the monitor.- Returns:
- the future to resolve the content of mining, or
CompletableFuture.completedFuture(Object)if no such resolution is necessary (in which case {#isResolved()} is expected to returntrue).
-
isResolved
boolean isResolved()Returns whether the content mining is resolved. If it is not resolved, {resolve(ITextViewer, IProgressMonitor)} will be invoked later, triggering the future to resolve content.- Returns:
- whether the content mining is resolved. If it is not resolved,
{
resolve(ITextViewer, IProgressMonitor)} will be invoked later, triggering the future to resolve content.
-
draw
Draw the code mining.- Parameters:
gc- the graphics contexttextWidget- the text widget to draw oncolor- the color of the linex- the x position of the annotationy- the y position of the annotation- Returns:
- the size of the draw of mining.
-
getAction
Consumer<MouseEvent> getAction()Returns the action to execute when mining is clicked and null otherwise.- Returns:
- the action to execute when mining is clicked and null otherwise.
-
getMouseHover
Returns a consumer which is called when mouse is hovered over the code mining. If set, the implementor needs to take care of setting the cursor if wanted.- Since:
- 3.27
-
getMouseOut
Returns a consumer which is called when mouse is moved out of code mining. If set, the implementor needs to take care of resetting the cursor.- Since:
- 3.27
-
getMouseMove
Returns a consumer which is called when mouse is moved inside the code mining.- Since:
- 3.27
-
dispose
void dispose()Dispose the mining. Typically shuts down or cancels all related asynchronous operations.
-