mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Fix #32235. Functional style formatter. Color range is all float number and remove fromHex, fromHSL methods.
This commit is contained in:
@@ -551,6 +551,7 @@ export function createApiFactory(
|
||||
CancellationTokenSource: CancellationTokenSource,
|
||||
CodeLens: extHostTypes.CodeLens,
|
||||
Color: extHostTypes.Color,
|
||||
ColorFormat: extHostTypes.ColorFormat,
|
||||
ColorRange: extHostTypes.ColorRange,
|
||||
EndOfLine: extHostTypes.EndOfLine,
|
||||
CompletionItem: extHostTypes.CompletionItem,
|
||||
|
||||
@@ -232,7 +232,6 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
|
||||
$registerSuggestSupport(handle: number, selector: vscode.DocumentSelector, triggerCharacters: string[], supportsResolveDetails: boolean): TPromise<any>;
|
||||
$registerSignatureHelpProvider(handle: number, selector: vscode.DocumentSelector, triggerCharacter: string[]): TPromise<any>;
|
||||
$registerDocumentLinkProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any>;
|
||||
$registerColorFormats(formats: IRawColorFormatMap): TPromise<any>;
|
||||
$registerDocumentColorProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any>;
|
||||
$setLanguageConfiguration(handle: number, languageId: string, configuration: vscode.LanguageConfiguration): TPromise<any>;
|
||||
}
|
||||
@@ -501,13 +500,9 @@ export interface ExtHostHeapServiceShape {
|
||||
}
|
||||
export interface IRawColorInfo {
|
||||
color: [number, number, number, number];
|
||||
availableFormats: (number | [number, number])[];
|
||||
range: IRange;
|
||||
}
|
||||
|
||||
export type IRawColorFormatMap = [number, string][];
|
||||
|
||||
|
||||
export interface IExtHostSuggestion extends modes.ISuggestion {
|
||||
_id: number;
|
||||
_parentId: number;
|
||||
@@ -541,8 +536,9 @@ export interface ExtHostLanguageFeaturesShape {
|
||||
$releaseCompletionItems(handle: number, id: number): void;
|
||||
$provideSignatureHelp(handle: number, resource: URI, position: IPosition): TPromise<modes.SignatureHelp>;
|
||||
$provideDocumentLinks(handle: number, resource: URI): TPromise<modes.ILink[]>;
|
||||
$provideDocumentColors(handle: number, resource: URI): TPromise<IRawColorInfo[]>;
|
||||
$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>;
|
||||
}
|
||||
|
||||
export interface ExtHostQuickOpenShape {
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHos
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { IWorkspaceSymbolProvider } from 'vs/workbench/parts/search/common/search';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { MainContext, MainThreadTelemetryShape, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, ObjectIdentifier, IRawColorInfo, IRawColorFormatMap, IMainContext, IExtHostSuggestResult, IExtHostSuggestion } from './extHost.protocol';
|
||||
import { MainContext, MainThreadTelemetryShape, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, ObjectIdentifier, IRawColorInfo, IMainContext, IExtHostSuggestResult, IExtHostSuggestion } from './extHost.protocol';
|
||||
import { regExpLeadsToEndlessLoop } from 'vs/base/common/strings';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
@@ -704,8 +704,6 @@ class LinkProviderAdapter {
|
||||
|
||||
class ColorProviderAdapter {
|
||||
|
||||
private static _colorFormatHandlePool: number = 0;
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadLanguageFeaturesShape,
|
||||
private _documents: ExtHostDocuments,
|
||||
@@ -720,39 +718,20 @@ class ColorProviderAdapter {
|
||||
return [];
|
||||
}
|
||||
|
||||
const newRawColorFormats: IRawColorFormatMap = [];
|
||||
const getFormatId = (format: string) => {
|
||||
let id = this._colorFormatCache.get(format);
|
||||
|
||||
if (typeof id !== 'number') {
|
||||
id = ColorProviderAdapter._colorFormatHandlePool++;
|
||||
this._colorFormatCache.set(format, id);
|
||||
newRawColorFormats.push([id, format]);
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
|
||||
const colorInfos: IRawColorInfo[] = colors.map(ci => {
|
||||
const availableFormats = ci.availableFormats.map(format => {
|
||||
if (typeof format === 'string') {
|
||||
return getFormatId(format);
|
||||
} else {
|
||||
return [getFormatId(format.opaque), getFormatId(format.transparent)] as [number, number];
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
color: [ci.color.red, ci.color.green, ci.color.blue, ci.color.alpha] as [number, number, number, number],
|
||||
availableFormats: availableFormats,
|
||||
range: TypeConverters.fromRange(ci.range)
|
||||
};
|
||||
});
|
||||
|
||||
this._proxy.$registerColorFormats(newRawColorFormats);
|
||||
return colorInfos;
|
||||
});
|
||||
}
|
||||
|
||||
resolveColor(color: modes.IColor, colorFormat: modes.ColorFormat): TPromise<string> {
|
||||
return asWinJsPromise(token => this._provider.resolveColor(color, colorFormat));
|
||||
}
|
||||
}
|
||||
|
||||
type Adapter = OutlineAdapter | CodeLensAdapter | DefinitionAdapter | HoverAdapter
|
||||
@@ -1063,6 +1042,10 @@ 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> {
|
||||
return this._withAdapter(handle, ColorProviderAdapter, adapter => adapter.resolveColor(color, colorFormat));
|
||||
}
|
||||
|
||||
// --- configuration
|
||||
|
||||
setLanguageConfiguration(languageId: string, configuration: vscode.LanguageConfiguration): vscode.Disposable {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { Color as BaseColor, HSLA } from 'vs/base/common/color';
|
||||
import { illegalArgument } from 'vs/base/common/errors';
|
||||
import * as vscode from 'vscode';
|
||||
import { isMarkdownString } from 'vs/base/common/htmlContent';
|
||||
@@ -1052,20 +1051,6 @@ export class Color {
|
||||
this.blue = blue;
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
static fromHSLA(hue: number, saturation: number, luminance: number, alpha: number): Color {
|
||||
const color = new BaseColor(new HSLA(hue, saturation, luminance, alpha)).rgba;
|
||||
return new Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
static fromHex(hex: string): Color | null {
|
||||
let baseColor = BaseColor.Format.CSS.parseHex(hex);
|
||||
if (baseColor) {
|
||||
const rgba = baseColor.rgba;
|
||||
return new Color(rgba.r, rgba.g, rgba.b, rgba.a);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export type IColorFormat = string | { opaque: string, transparent: string };
|
||||
@@ -1075,24 +1060,24 @@ export class ColorRange {
|
||||
|
||||
color: Color;
|
||||
|
||||
availableFormats: IColorFormat[];
|
||||
|
||||
constructor(range: Range, color: Color, availableFormats: IColorFormat[]) {
|
||||
constructor(range: Range, color: Color) {
|
||||
if (color && !(color instanceof Color)) {
|
||||
throw illegalArgument('color');
|
||||
}
|
||||
if (availableFormats && !Array.isArray(availableFormats)) {
|
||||
throw illegalArgument('availableFormats');
|
||||
}
|
||||
if (!Range.isRange(range) || range.isEmpty) {
|
||||
throw illegalArgument('range');
|
||||
}
|
||||
this.range = range;
|
||||
this.color = color;
|
||||
this.availableFormats = availableFormats;
|
||||
}
|
||||
}
|
||||
|
||||
export enum ColorFormat {
|
||||
RGB = 0,
|
||||
HEX = 1,
|
||||
HSL = 2
|
||||
}
|
||||
|
||||
export enum TaskRevealKind {
|
||||
Always = 1,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user