mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
provideColorPresentations should have document in paramaters.
This commit is contained in:
parent
ce20acd130
commit
084849c2fa
|
@ -70,7 +70,7 @@ export function activate(context: ExtensionContext) {
|
|||
});
|
||||
});
|
||||
},
|
||||
provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
let result: ColorPresentation[] = [];
|
||||
let color = colorInfo.color;
|
||||
let label;
|
||||
|
|
|
@ -87,7 +87,7 @@ export function activate(context: ExtensionContext) {
|
|||
});
|
||||
});
|
||||
},
|
||||
provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
let result: ColorPresentation[] = [];
|
||||
let color = colorInfo.color;
|
||||
let label;
|
||||
|
|
|
@ -132,7 +132,7 @@ export function activate(context: ExtensionContext) {
|
|||
});
|
||||
});
|
||||
},
|
||||
provideColorPresentations(colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
provideColorPresentations(document: TextDocument, colorInfo: ColorInformation): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
let result: ColorPresentation[] = [];
|
||||
let color = colorInfo.color;
|
||||
let label;
|
||||
|
|
|
@ -728,7 +728,7 @@ export interface DocumentColorProvider {
|
|||
/**
|
||||
* Provide the string representations for a color.
|
||||
*/
|
||||
provideColorPresentations(colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable<IColorPresentation[]>;
|
||||
provideColorPresentations(model: editorCommon.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable<IColorPresentation[]>;
|
||||
}
|
||||
|
||||
export interface IResourceEdit {
|
||||
|
|
|
@ -27,6 +27,6 @@ export function getColors(model: IReadOnlyModel): TPromise<IColorData[]> {
|
|||
return TPromise.join(promises).then(() => colors);
|
||||
}
|
||||
|
||||
export function getColorPresentations(colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise<IColorPresentation[]> {
|
||||
return asWinJsPromise(token => provider.provideColorPresentations(colorInfo, token));
|
||||
export function getColorPresentations(model: IReadOnlyModel, colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise<IColorPresentation[]> {
|
||||
return asWinJsPromise(token => provider.provideColorPresentations(model, colorInfo, token));
|
||||
}
|
||||
|
|
|
@ -325,7 +325,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
|||
const model = new ColorPickerModel(color, [], 0);
|
||||
const widget = new ColorPickerWidget(fragment, model, this._editor.getConfiguration().pixelRatio);
|
||||
|
||||
getColorPresentations(colorInfo, msg.provider).then(colorPresentations => {
|
||||
getColorPresentations(editorModel, colorInfo, msg.provider).then(colorPresentations => {
|
||||
model.colorPresentations = colorPresentations;
|
||||
const originalText = this._editor.getModel().getValueInRange(msg.range);
|
||||
model.guessColorPresentation(color, originalText);
|
||||
|
@ -360,7 +360,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
|
|||
};
|
||||
|
||||
const updateColorPresentations = (color: Color) => {
|
||||
return getColorPresentations({
|
||||
return getColorPresentations(editorModel, {
|
||||
range: range,
|
||||
color: {
|
||||
red: color.rgba.r / 255,
|
||||
|
|
2
src/vs/monaco.d.ts
vendored
2
src/vs/monaco.d.ts
vendored
|
@ -4904,7 +4904,7 @@ declare module monaco.languages {
|
|||
/**
|
||||
* Provide the string representations for a color.
|
||||
*/
|
||||
provideColorPresentations(colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable<IColorPresentation[]>;
|
||||
provideColorPresentations(model: editor.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable<IColorPresentation[]>;
|
||||
}
|
||||
|
||||
export interface IResourceEdit {
|
||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -222,7 +222,7 @@ declare module 'vscode' {
|
|||
/**
|
||||
* Provide representations for a color.
|
||||
*/
|
||||
provideColorPresentations(colorInfo: ColorInformation, token: CancellationToken): ProviderResult<ColorPresentation[]>;
|
||||
provideColorPresentations(document: TextDocument, colorInfo: ColorInformation, token: CancellationToken): ProviderResult<ColorPresentation[]>;
|
||||
}
|
||||
|
||||
export namespace languages {
|
||||
|
|
|
@ -306,8 +306,8 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
|||
});
|
||||
},
|
||||
|
||||
provideColorPresentations: (colorInfo, token) => {
|
||||
return wireCancellationToken(token, proxy.$provideColorPresentations(handle, {
|
||||
provideColorPresentations: (model, colorInfo, token) => {
|
||||
return wireCancellationToken(token, proxy.$provideColorPresentations(handle, model.uri, {
|
||||
color: [colorInfo.color.red, colorInfo.color.green, colorInfo.color.blue, colorInfo.color.alpha],
|
||||
range: colorInfo.range
|
||||
}));
|
||||
|
|
|
@ -559,7 +559,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[]>;
|
||||
$provideColorPresentations(handle: number, colorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]>;
|
||||
$provideColorPresentations(handle: number, resource: URI, colorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]>;
|
||||
}
|
||||
|
||||
export interface ExtHostQuickOpenShape {
|
||||
|
|
|
@ -729,7 +729,7 @@ class ColorProviderAdapter {
|
|||
});
|
||||
}
|
||||
|
||||
provideColorPresentations(rawColorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
provideColorPresentations(resource: URI, rawColorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
let colorInfo: vscode.ColorInformation = {
|
||||
range: TypeConverters.toRange(rawColorInfo.range),
|
||||
color: {
|
||||
|
@ -739,7 +739,8 @@ class ColorProviderAdapter {
|
|||
alpha: rawColorInfo.color[3]
|
||||
}
|
||||
};
|
||||
return asWinJsPromise(token => this._provider.provideColorPresentations(colorInfo, token)).then(value => {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
return asWinJsPromise(token => this._provider.provideColorPresentations(doc, colorInfo, token)).then(value => {
|
||||
return value.map(v => TypeConverters.ColorPresentation.from(v));
|
||||
});
|
||||
}
|
||||
|
@ -1053,8 +1054,8 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
|
|||
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColors(resource));
|
||||
}
|
||||
|
||||
$provideColorPresentations(handle: number, colorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColorPresentations(colorInfo));
|
||||
$provideColorPresentations(handle: number, resource: URI, colorInfo: IRawColorInfo): TPromise<modes.IColorPresentation[]> {
|
||||
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.provideColorPresentations(resource, colorInfo));
|
||||
}
|
||||
|
||||
// --- configuration
|
||||
|
|
Loading…
Reference in a new issue