Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

Commit e844366

Browse files
committed
feat: add extension decorations API
1 parent 936264d commit e844366

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/extension/api.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Subscription } from 'rxjs'
2+
import { TextDocumentIdentifier } from 'vscode-languageserver-types'
23
import { Context } from '../environment/context/context'
34
import { MessageConnection } from '../jsonrpc2/connection'
4-
import { InitializeParams, Settings } from '../protocol'
5+
import { InitializeParams, Settings, TextDocumentDecoration } from '../protocol'
56
import { URI } from '../types/textDocument'
67

78
/**
@@ -159,6 +160,14 @@ export interface Windows extends Observable<Window[]> {
159160
* @returns The user's input, or null if the user (or the client) canceled the input request.
160161
*/
161162
showInputBox(message: string, defaultValue?: string): Promise<string | null>
163+
164+
/**
165+
* Sets the decorations for the given document. All previous decorations for the document are cleared.
166+
*
167+
* @param resource The document to decorate.
168+
* @param decorations The decorations to apply to the document.
169+
*/
170+
setDecorations(resource: TextDocumentIdentifier, decorations: TextDocumentDecoration[]): void
162171
}
163172

164173
/**

src/extension/features/windows.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { BehaviorSubject } from 'rxjs'
2-
import { DidCloseTextDocumentNotification, DidOpenTextDocumentNotification, ShowInputRequest } from '../../protocol'
2+
import { TextDocumentIdentifier } from 'vscode-languageserver-types'
3+
import {
4+
DidCloseTextDocumentNotification,
5+
DidOpenTextDocumentNotification,
6+
ShowInputRequest,
7+
TextDocumentDecoration,
8+
TextDocumentPublishDecorationsNotification,
9+
TextDocumentPublishDecorationsParams,
10+
} from '../../protocol'
311
import { CXP, Observable, Window, Windows } from '../api'
412

513
class ExtWindows extends BehaviorSubject<Window[]> implements Windows, Observable<Window[]> {
@@ -39,6 +47,13 @@ class ExtWindows extends BehaviorSubject<Window[]> implements Windows, Observabl
3947
return this.ext.rawConnection.sendRequest(ShowInputRequest.type, { message, defaultValue })
4048
}
4149

50+
public setDecorations(resource: TextDocumentIdentifier, decorations: TextDocumentDecoration[]): void {
51+
return this.ext.rawConnection.sendNotification(TextDocumentPublishDecorationsNotification.type, {
52+
textDocument: resource,
53+
decorations,
54+
} as TextDocumentPublishDecorationsParams)
55+
}
56+
4257
public readonly [Symbol.observable] = () => this
4358
}
4459

0 commit comments

Comments
 (0)