# Interface ICodeMining

All Known Implementing Classes:
  `AbstractCodeMining, DocumentFooterCodeMining, LineContentCodeMining, LineEndCodeMining, LineHeaderCodeMining`

public interface ICodeMining
A code mining represents a content (ex: label, icons) that should be shown along with source text, like the number of references, a way to run tests (with run/debug icons), etc. A code mining is unresolved when no content (ex: label, icons) is associated to it. For performance reasons the creation of a code mining and resolving should be done to two stages.

Since:
  3.13

## Method Summary

Modifier and Type
Method
Description
`void`
`dispose()`
Dispose the mining.
`Point`
`draw(GC gc, StyledText textWidget, Color color, int x, int y)`
Draw the code mining.
`Consumer<MouseEvent>`
`getAction()`
Returns the action to execute when mining is clicked and null otherwise.
`String`
`getLabel()`
Returns the label may be set early in the class lifecycle, or upon completion of the future provided by `resolve(ITextViewer, IProgressMonitor)` operation.
`default Consumer<MouseEvent>`
`getMouseHover()`
Returns a consumer which is called when mouse is hovered over the code mining.
`default Consumer<MouseEvent>`
`getMouseMove()`
Returns a consumer which is called when mouse is moved inside the code mining.
`default Consumer<MouseEvent>`
`getMouseOut()`
Returns a consumer which is called when mouse is moved out of code mining.
`Position`
`getPosition()`
Returns the line position where code mining must be displayed in the line spacing area.
`ICodeMiningProvider`
`getProvider()`
Returns the owner provider which has created this mining.
`boolean`
`isResolved()`
Returns whether the content mining is resolved.
`CompletableFuture<Void>`
`resolve(ITextViewer viewer, IProgressMonitor 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 return `true`).

## 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 by `resolve(ITextViewer, IProgressMonitor)` operation.

The returned label can have several values:

- `null` when mining is not resolved
- `null` when 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.

### resolve

CompletableFuture<Void> resolve(ITextViewer viewer, IProgressMonitor 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 return `true`).

Parameters:
  `viewer` - the viewer, can be null
  `monitor` - 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 return `true`).

### 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

Point draw(GC gc, StyledText textWidget, Color color, int x, int y)
Draw the code mining.

Parameters:
  `gc` - the graphics context
  `textWidget` - the text widget to draw on
  `color` - the color of the line
  `x` - the x position of the annotation
  `y` - 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

default Consumer<MouseEvent> 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

default Consumer<MouseEvent> 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

default Consumer<MouseEvent> 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.