Align signatures with other providers.
This commit is contained in:
parent
f0ecb26ace
commit
3753e0e1d2
|
@ -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) {
|
||||
case ColorFormat.RGB:
|
||||
if (color.alpha === 1) {
|
||||
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`;
|
||||
} 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:
|
||||
if (color.alpha === 1) {
|
||||
|
|
|
@ -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) {
|
||||
case ColorFormat.RGB:
|
||||
if (color.alpha === 1) {
|
||||
return `rgb(${Math.round(color.red * 255)}, ${Math.round(color.green * 255)}, ${Math.round(color.blue * 255)})`;
|
||||
} 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:
|
||||
if (color.alpha === 1) {
|
||||
|
|
|
@ -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) {
|
||||
return `#${_toTwoDigitHex(Math.round(color.red * 255))}${_toTwoDigitHex(Math.round(color.green * 255))}${_toTwoDigitHex(Math.round(color.blue * 255))}`;
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ export class RGBFormatter implements IColorFormatter {
|
|||
if (rgb.a === 1) {
|
||||
return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
|
||||
} else {
|
||||
return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`;
|
||||
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${rgb.a})`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -155,7 +155,7 @@ declare module 'vscode' {
|
|||
/**
|
||||
* Provide the string representation for a color.
|
||||
*/
|
||||
resolveColor(color: Color, colorFormat: ColorFormat): ProviderResult<string>;
|
||||
resolveDocumentColor(color: Color, colorFormat: ColorFormat): ProviderResult<string>;
|
||||
}
|
||||
|
||||
export namespace languages {
|
||||
|
|
|
@ -306,7 +306,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
|||
});
|
||||
},
|
||||
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 {
|
|||
$provideDocumentLinks(handle: number, resource: URI): TPromise<modes.ILink[]>;
|
||||
$resolveDocumentLink(handle: number, link: modes.ILink): TPromise<modes.ILink>;
|
||||
$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 {
|
||||
|
|
|
@ -730,7 +730,7 @@ class ColorProviderAdapter {
|
|||
}
|
||||
|
||||
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 {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue