-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcommon.ts
88 lines (82 loc) · 2.43 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
export interface FormatRequest {
/** The file path to format. */
filePath: string;
/** File text to format. */
fileText: string;
/** Byte range to format. Note this is BYTE range and NOT character range. */
bytesRange?: readonly [number, number];
/** Configuration to set for a single format. */
overrideConfig?: Record<string, unknown>;
}
export interface Host {
setInstance(wasmInstance: WebAssembly.Instance): void;
setHostFormatter(formatWithHost: ((request: FormatRequest) => string) | undefined): void;
createImportObject(): WebAssembly.Imports;
}
/** Formats code. */
export interface Formatter {
/**
* Sets the configuration.
* @param globalConfig - Global configuration for use across plugins.
* @param pluginConfig - Plugin specific configuration.
*/
setConfig(
globalConfig: GlobalConfiguration,
pluginConfig: Record<string, unknown>,
): void;
/**
* Gets the configuration diagnostics.
*/
getConfigDiagnostics(): ConfigurationDiagnostic[];
/**
* Gets the resolved configuration.
* @returns An object containing the resolved configuration.
*/
getResolvedConfig(): Record<string, unknown>;
/**
* Gets the plugin info.
*/
getPluginInfo(): PluginInfo;
/**
* Gets what files the plugin matches based on the current configuration.
*/
getFileMatchingInfo(): FileMatchingInfo;
/**
* Gets the license text of the plugin.
*/
getLicenseText(): string;
/**
* Formats the specified file text.
* @param request - Data to format.
* @param formatWithHost - Host formatter.
* @returns The formatted text.
* @throws If there is an error formatting.
*/
formatText(request: FormatRequest, formatWithHost?: (request: FormatRequest) => string): string;
}
/** Configuration specified for use across plugins. */
export interface GlobalConfiguration {
lineWidth?: number;
indentWidth?: number;
useTabs?: boolean;
newLineKind?: "auto" | "lf" | "crlf" | "system";
}
/** A diagnostic indicating a problem with the specified configuration. */
export interface ConfigurationDiagnostic {
propertyName: string;
message: string;
}
/** Information about a plugin. */
export interface PluginInfo {
name: string;
version: string;
configKey: string;
helpUrl: string;
configSchemaUrl: string;
updateUrl?: string;
}
/** Information about how the current config matches files. */
export interface FileMatchingInfo {
fileExtensions: string[];
fileNames: string[];
}