color api: docs

This commit is contained in:
Joao Moreno
2017-08-11 11:31:00 +02:00
parent 43160efc08
commit 0f5272afe9
5 changed files with 125 additions and 14 deletions

View File

@@ -5,7 +5,7 @@
'use strict';
import * as parse from 'parse-color';
import { window, workspace, DecorationOptions, DecorationRenderOptions, Disposable, Range, TextDocument, DocumentColorProvider, Color, ColorFormat, ColorInfo } from 'vscode';
import { window, workspace, DecorationOptions, DecorationRenderOptions, Disposable, Range, TextDocument, DocumentColorProvider, Color, ColorFormat, ColorRange } from 'vscode';
const MAX_DECORATORS = 500;
@@ -158,7 +158,7 @@ export class ColorProvider implements DocumentColorProvider {
constructor(private decoratorProvider: (uri: string) => Thenable<Range[]>) { }
async provideDocumentColors(document: TextDocument): Promise<ColorInfo[]> {
async provideDocumentColors(document: TextDocument): Promise<ColorRange[]> {
const ranges = await this.decoratorProvider(document.uri.toString());
const result = [];
for (let range of ranges) {
@@ -175,7 +175,7 @@ export class ColorProvider implements DocumentColorProvider {
}
if (color) {
const format = detectFormat(value);
result.push(new ColorInfo(range, color, format, [CSSColorFormats.Hex, CSSColorFormats.RGB, CSSColorFormats.HSL]));
result.push(new ColorRange(range, color, format, [CSSColorFormats.Hex, CSSColorFormats.RGB, CSSColorFormats.HSL]));
}
}
return result;