import { DecorationOptions , TextDocument , TextEditor , TextEditorDecorationType } from 'vscode' ; import { IDisposable } from '../util/types' ; import { IDecorationSetter } from './decorationSetter' ; export interface IDecorationProvider extends IDisposable { /**
     * The `TextEditorDecorationType` provided by this `IDecorationProvider`.
     */ readonly decorationType : TextEditorDecorationType ; attach ( textEditors ) : void ; detach ( ) : void ; /**
     * (Re-)create `TextEditor` decorations.
     */ updateDecorations ( ) : void ; } /**
 * A `DocumentDecorationProvider` belongs to a specific `TextDocument` and provides decorations to multiple
 * `TextEditor`s showing that document.
 */ export abstract class DocumentDecorationProvider implements IDecorationProvider { private textEditors : ReadonlyArray < TextEditor > = [ ] ; inheritdoc abstract decorationType : TextEditorDecorationType ; constructor ( protected readonly document , private readonly decorationSetter ) { } param textEditors attach ( textEditors ) { this . detach ( ) ; this . textEditors = textEditors . filter ( ( t ) => t . document . uri . toString ( ) === this . document . uri . toString ( ) ) ; this . updateDecorations ( ) ; } /**
     * Remove decorations from currently tracked `TextEditor`s and reset tracked editors.
     */ detach ( ) { this . setDecorations ( [ ] ) ; this . textEditors = [ ] ; } /**
     * (Re-)create `TextEditor` decorations. You can use `setDecorations` in the concrete `DocumentDecorationProvider`
     * implementation to update all currently tracked text editors with the new decorations.
     */ abstract updateDecorations ( ) ; param decorationOptions protected setDecorations ( decorationOptions ) { for ( const editor of this . textEditors ) { this . decorationSetter . set ( editor , this . decorationType , decorationOptions ) ; } } dispose ( ) { this . detach ( ) ; } }