提交 3753e0e1 编写于 作者: R rebornix

Align signatures with other providers.

上级 f0ecb26a
...@@ -70,13 +70,13 @@ export function activate(context: ExtensionContext) { ...@@ -70,13 +70,13 @@ export function activate(context: ExtensionContext) {
}); });
}); });
}, },
resolveColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string { resolveDocumentColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string {
switch (colorFormat) { switch (colorFormat) {
case ColorFormat.RGB: case ColorFormat.RGB:
if (color.alpha === 1) { if (color.alpha === 1) {
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`; return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`;
} else { } else {
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)}, ${color.alpha})`; return `rgba(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)}, ${color.alpha})`;
} }
case ColorFormat.HEX: case ColorFormat.HEX:
if (color.alpha === 1) { if (color.alpha === 1) {
......
...@@ -87,13 +87,13 @@ export function activate(context: ExtensionContext) { ...@@ -87,13 +87,13 @@ export function activate(context: ExtensionContext) {
}); });
}); });
}, },
resolveColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string { resolveDocumentColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string {
switch (colorFormat) { switch (colorFormat) {
case ColorFormat.RGB: case ColorFormat.RGB:
if (color.alpha === 1) { if (color.alpha === 1) {
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`; return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`;
} else { } else {
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)}, ${color.alpha})`; return `rgba(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)}, ${color.alpha})`;
} }
case ColorFormat.HEX: case ColorFormat.HEX:
if (color.alpha === 1) { if (color.alpha === 1) {
......
...@@ -132,7 +132,7 @@ export function activate(context: ExtensionContext) { ...@@ -132,7 +132,7 @@ export function activate(context: ExtensionContext) {
}); });
}); });
}, },
resolveColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string { resolveDocumentColor(color: Color, colorFormat: ColorFormat): Thenable<string> | string {
if (color.alpha === 1) { if (color.alpha === 1) {
return `#${_toTwoDigitHex(Math.round(color.red * 255))}${_toTwoDigitHex(Math.round(color.green * 255))}${_toTwoDigitHex(Math.round(color.blue * 255))}`; return `#${_toTwoDigitHex(Math.round(color.red * 255))}${_toTwoDigitHex(Math.round(color.green * 255))}${_toTwoDigitHex(Math.round(color.blue * 255))}`;
} else { } else {
......
...@@ -19,7 +19,7 @@ export class RGBFormatter implements IColorFormatter { ...@@ -19,7 +19,7 @@ export class RGBFormatter implements IColorFormatter {
if (rgb.a === 1) { if (rgb.a === 1) {
return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`; return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
} else { } else {
return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`; return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`;
} }
} }
} }
......
...@@ -155,7 +155,7 @@ declare module 'vscode' { ...@@ -155,7 +155,7 @@ declare module 'vscode' {
/** /**
* Provide the string representation for a color. * Provide the string representation for a color.
*/ */
resolveColor(color: Color, colorFormat: ColorFormat): ProviderResult<string>; resolveDocumentColor(color: Color, colorFormat: ColorFormat): ProviderResult<string>;
} }
export namespace languages { export namespace languages {
......
...@@ -306,7 +306,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha ...@@ -306,7 +306,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
}); });
}, },
resolveColor: (color, format, token) => { resolveColor: (color, format, token) => {
return wireCancellationToken(token, proxy.$resolveColor(handle, color, format)); return wireCancellationToken(token, proxy.$resolveDocumentColor(handle, color, format));
} }
}); });
......
...@@ -538,7 +538,7 @@ export interface ExtHostLanguageFeaturesShape { ...@@ -538,7 +538,7 @@ export interface ExtHostLanguageFeaturesShape {
$provideDocumentLinks(handle: number, resource: URI): TPromise<modes.ILink[]>; $provideDocumentLinks(handle: number, resource: URI): TPromise<modes.ILink[]>;
$resolveDocumentLink(handle: number, link: modes.ILink): TPromise<modes.ILink>; $resolveDocumentLink(handle: number, link: modes.ILink): TPromise<modes.ILink>;
$provideDocumentColors(handle: number, resource: URI): TPromise<IRawColorInfo[]>; $provideDocumentColors(handle: number, resource: URI): TPromise<IRawColorInfo[]>;
$resolveColor(handle: number, color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string>; $resolveDocumentColor(handle: number, color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string>;
} }
export interface ExtHostQuickOpenShape { export interface ExtHostQuickOpenShape {
......
...@@ -730,7 +730,7 @@ class ColorProviderAdapter { ...@@ -730,7 +730,7 @@ class ColorProviderAdapter {
} }
resolveColor(color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string> { resolveColor(color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string> {
return asWinJsPromise(token => this._provider.resolveColor(color, colorFormat)); return asWinJsPromise(token => this._provider.resolveDocumentColor(color, colorFormat));
} }
} }
...@@ -1042,7 +1042,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape { ...@@ -1042,7 +1042,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColors(resource)); return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColors(resource));
} }
$resolveColor(handle: number, color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string> { $resolveDocumentColor(handle: number, color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string> {
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.resolveColor(color, colorFormat)); return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.resolveColor(color, colorFormat));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册