-
Notifications
You must be signed in to change notification settings - Fork 1
Fix typings and add interfaces #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd01418
d3e9bac
dce0661
00db701
16e481d
b5d1bcb
83c51ed
81f797b
8af89da
21bfecb
2821c58
f2504bc
5965287
0b776fc
1365c46
824ce9b
6534893
07def7e
be9d972
2b0ce9a
6f77cc5
c2711eb
ea401c8
b693795
279d3b4
9ff0857
a3a2b90
c246fe2
4c4e361
a832c7e
e6db661
c224f7b
dce869c
3bebd6b
90f9351
d611ee7
3e9d9a4
73b3fbb
19dd940
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,14 +4,29 @@ import isWsl from "is-wsl"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {IPackageJson} from "package-json-type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {readJsonFile} from "./utils"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {ExtensionMetaData, ExtensionPaths, ExtensionMetaDataValue} from "./interfaces/extensionMetaData"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export class ExtensionData { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This extension details in the form of a key:value Map object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Extension data in the form of a key:value Map object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @type {Map<string, string>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @type {Map<keyof ExtensionMetaData, ExtensionMetaDataValue>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private extensionData = new Map<string, string>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private extensionData = new Map<keyof ExtensionMetaData, ExtensionMetaDataValue>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Extension discovery paths in the form of a key:value Map object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @type {Map<keyof ExtensionPaths, string>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private extensionDiscoveryPaths = new Map<keyof ExtensionPaths, string>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The absolute path of the requested extension. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @type {string} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly extensionPath: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The package.json data for this extension. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -20,93 +35,125 @@ export class ExtensionData { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private packageJsonData: IPackageJson; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public constructor() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public constructor(extensionPath: string | null = null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set the path if provided, otherwise default to this extension's path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For this extension's path, we use `__dirname` and go up two levels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // (from "out/src" to the extension root). This path is also used to locate all other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // user-installed extensions later for the `userExtensionsPath` discovery path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionPath = extensionPath ?? path.join(__dirname, "../../"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.packageJsonData = this.getExtensionPackageJsonData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.setExtensionData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only proceed with extension data setup if packageJsonData is NOT null. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (this.packageJsonData !== null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.setExtensionData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.setExtensionDiscoveryPaths(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Get the names, id, and version of this extension from package.json. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @returns {IPackageJson} The package.json data for this extension, with extra custom keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @returns {IPackageJson | null} The package.json data for this extension, with extra custom keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private getExtensionPackageJsonData(): IPackageJson { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const extensionPath = path.join(__dirname, "../../"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJSON: IPackageJson = readJsonFile(path.join(extensionPath, "package.json")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set the id (publisher.name) into the packageJSON object as a new `id` key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| packageJSON.id = `${packageJSON.publisher}.${packageJSON.name}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| packageJSON.extensionPath = extensionPath; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The configuration settings namespace is a shortened version of the extension name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // We just need to replace "automatic" with "auto" in the name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const settingsNamespace: string = packageJSON.name.replace("automatic", "auto"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set the namespace to the packageJSON `configuration` object as a new `namespace` key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| packageJSON.contributes.configuration.namespace = settingsNamespace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return packageJSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private getExtensionPackageJsonData(): IPackageJson | null { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Get the package.json file path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJSONPath = path.join(this.extensionPath, "package.json"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return readJsonFile<IPackageJson>(packageJSONPath, false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Set the extension data into the extensionData Map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private setExtensionData() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set all entries in the extensionData Map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Object.entries(this.createExtensionData()).forEach(([key, value]) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set(key, value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Create the extension ID (publisher.name). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const id = `${this.packageJsonData.publisher}.${this.packageJsonData.name}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set each key-value pair directly into the Map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("id", id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("name", this.packageJsonData.name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only set the namespace if it dealing with this extension. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (this.packageJsonData.name === "automatic-comment-blocks") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The configuration settings namespace is a shortened version of the extension name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // We just need to replace "automatic" with "auto" in the name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const settingsNamespace: string = this.packageJsonData.name.replace("automatic", "auto"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("namespace", settingsNamespace); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("displayName", this.packageJsonData.displayName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("version", this.packageJsonData.version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("extensionPath", this.extensionPath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionData.set("packageJSON", this.packageJsonData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Create the extension data object for the extensionData Map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * It also helps for type inference intellisense in the get method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @returns The extension data object with keys and values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Set the extension discovery paths into the extensionDiscoveryPaths Map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private createExtensionData() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private setExtensionDiscoveryPaths() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The path to the user extensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const userExtensionsPath = isWsl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? path.join(vscode.env.appRoot, "../../", "extensions") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : path.join(this.packageJsonData.extensionPath, "../"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set the keys and values for the Map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The keys will also be used for type inference in VSCode intellisense. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: this.packageJsonData.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: this.packageJsonData.contributes.configuration.namespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| displayName: this.packageJsonData.displayName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: this.packageJsonData.version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| userExtensionsPath: userExtensionsPath, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The path to the built-in extensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This env variable changes when on WSL to it's WSL-built-in extensions path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| builtInExtensionsPath: path.join(vscode.env.appRoot, "extensions"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only set these if running in WSL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(isWsl && { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WindowsUserExtensionsPathFromWsl: path.dirname(process.env.VSCODE_WSL_EXT_LOCATION!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| WindowsBuiltInExtensionsPathFromWsl: path.join(process.env.VSCODE_CWD!, "resources/app/extensions"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } as const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // On Windows/Linux/Mac: ~/.vscode[-server|remote]/extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // On WSL: ~/.vscode-[server|remote]/extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const userExtensionsPath = isWsl ? path.join(vscode.env.appRoot, "../../", "extensions") : path.join(this.extensionPath, "../"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionDiscoveryPaths.set("userExtensionsPath", userExtensionsPath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The path to the built-in extensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // This env variable changes when on WSL to it's WSL-built-in extensions path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionDiscoveryPaths.set("builtInExtensionsPath", path.join(vscode.env.appRoot, "extensions")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only set these if running in WSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isWsl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionDiscoveryPaths.set("WindowsUserExtensionsPathFromWsl", path.dirname(process.env.VSCODE_WSL_EXT_LOCATION!)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionDiscoveryPaths.set("WindowsBuiltInExtensionsPathFromWsl", path.join(process.env.VSCODE_CWD!, "resources/app/extensions")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+110
to
+111
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.extensionDiscoveryPaths.set("WindowsUserExtensionsPathFromWsl", path.dirname(process.env.VSCODE_WSL_EXT_LOCATION!)); | |
| this.extensionDiscoveryPaths.set("WindowsBuiltInExtensionsPathFromWsl", path.join(process.env.VSCODE_CWD!, "resources/app/extensions")); | |
| const wslExtLocation = process.env.VSCODE_WSL_EXT_LOCATION; | |
| if (wslExtLocation) { | |
| this.extensionDiscoveryPaths.set("WindowsUserExtensionsPathFromWsl", path.dirname(wslExtLocation)); | |
| } | |
| const vscodeCwd = process.env.VSCODE_CWD; | |
| if (vscodeCwd) { | |
| this.extensionDiscoveryPaths.set("WindowsBuiltInExtensionsPathFromWsl", path.join(vscodeCwd, "resources/app/extensions")); | |
| } |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the non-null assertion operator (!) on process.env.VSCODE_CWD assumes this environment variable is always defined when running in WSL. If this environment variable is not set, it will result in path.join(undefined, ...), which could cause unexpected behavior.
Consider adding a check to ensure the environment variable exists before using it, or provide a fallback value.
| this.extensionDiscoveryPaths.set("WindowsUserExtensionsPathFromWsl", path.dirname(process.env.VSCODE_WSL_EXT_LOCATION!)); | |
| this.extensionDiscoveryPaths.set("WindowsBuiltInExtensionsPathFromWsl", path.join(process.env.VSCODE_CWD!, "resources/app/extensions")); | |
| const wslExtLocation = process.env.VSCODE_WSL_EXT_LOCATION; | |
| const vscodeCwd = process.env.VSCODE_CWD; | |
| if (wslExtLocation) { | |
| this.extensionDiscoveryPaths.set( | |
| "WindowsUserExtensionsPathFromWsl", | |
| path.dirname(wslExtLocation) | |
| ); | |
| } | |
| if (vscodeCwd) { | |
| this.extensionDiscoveryPaths.set( | |
| "WindowsBuiltInExtensionsPathFromWsl", | |
| path.join(vscodeCwd, "resources/app/extensions") | |
| ); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * Define the single-line comment styles. | ||
| */ | ||
| export type SingleLineCommentStyle = "//" | "#" | ";"; | ||
|
|
||
| /** | ||
| * Define the extra single-line comment styles, like `///`, etc. | ||
| */ | ||
| export type ExtraSingleLineCommentStyles = "##" | ";;" | "///" | "//!"; | ||
|
|
||
| /** | ||
| * Line Comments | ||
| * | ||
| * Taken directly from VScode's commit in June 2025 that changed the line comment config. | ||
| * https://github.com/microsoft/vscode/commit/d9145a291dcef0bad3ace81a3d55727ca294c122#diff-0dfa7db579eface8250affb76bc88717725a121401d4d8598bc36b92b0b6ef62 | ||
| * | ||
| * The @types/vscode package does not yet have these changes. | ||
| * So until they're added, we define them manually. | ||
| */ | ||
|
|
||
| /** | ||
| * The line comment token, like `// this is a comment`. | ||
| * Can be a string, an object with comment and optional noIndent properties, or null. | ||
| */ | ||
| export type LineComment = string | LineCommentConfig | null; | ||
|
|
||
| /** | ||
| * Configuration for line comments. | ||
| */ | ||
| export interface LineCommentConfig { | ||
| /** | ||
| * The line comment token, like `//` | ||
| */ | ||
| comment: string; | ||
|
|
||
| /** | ||
| * Whether the comment token should not be indented and placed at the first column. | ||
| * Defaults to false. | ||
| */ | ||
| noIndent?: boolean; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import {IPackageJson} from "package-json-type"; | ||
|
|
||
| // Utility types for cleaner Map typing | ||
| export type ExtensionMetaDataValue = ExtensionMetaData[keyof ExtensionMetaData]; | ||
|
|
||
| /** | ||
| * Extension metadata for a VSCode extension | ||
| */ | ||
| export interface ExtensionMetaData { | ||
| /** | ||
| * The unique ID in the form of `publisher.name`. | ||
| */ | ||
| id: string; | ||
|
|
||
| /** | ||
| * The name. | ||
| * Directly from package.json "name" key. | ||
| */ | ||
| name: string; | ||
|
|
||
| /** | ||
| * The namespace for this extension's configuration settings, | ||
| * which is a slightly shorter version of the name. | ||
| */ | ||
| namespace?: string; | ||
|
|
||
| /** | ||
| * The display name. | ||
| * Directly from package.json "displayName" key. | ||
| */ | ||
| displayName: string; | ||
|
|
||
| /** | ||
| * The version. | ||
| * Directly from package.json "version" key. | ||
| */ | ||
| version: string; | ||
|
|
||
| /** | ||
| * The absolute path to the extension. | ||
| */ | ||
| extensionPath: string; | ||
|
|
||
| /** | ||
| * The full package.json data | ||
| */ | ||
| packageJSON: IPackageJson; | ||
| } | ||
|
|
||
| /** | ||
| * Extension discovery paths configuration for this extension | ||
| */ | ||
| export interface ExtensionPaths { | ||
| /** | ||
| * The path to the user extensions. | ||
| */ | ||
| userExtensionsPath: string; | ||
|
|
||
| /** | ||
| * The path to the built-in extensions. | ||
| */ | ||
| builtInExtensionsPath: string; | ||
|
|
||
| /** | ||
| * The Windows path to the user extensions when running in WSL. | ||
| * | ||
| * Only set when running in WSL. | ||
| */ | ||
| WindowsUserExtensionsPathFromWsl?: string; | ||
|
|
||
| /** | ||
| * The Windows path to the built-in extensions when running in WSL. | ||
| * | ||
| * Only set when running in WSL. | ||
| */ | ||
| WindowsBuiltInExtensionsPathFromWsl?: string; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export interface Settings { | ||
| singleLineBlockOnEnter: boolean; | ||
| disabledLanguages: string[]; | ||
| slashStyleBlocks: string[]; | ||
| hashStyleBlocks: string[]; | ||
| semicolonStyleBlocks: string[]; | ||
| multiLineStyleBlocks: string[]; | ||
| overrideDefaultLanguageMultiLineComments: Record<string, string>; | ||
| bladeOverrideComments: boolean; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
namespaceproperty may beundefinedwhen retrieved from the ExtensionData, as it's optional in theExtensionMetaDatainterface and only set for the "automatic-comment-blocks" extension (see line 79 in extensionData.ts). Using it directly in string templates without checking for undefined could result in "undefined" being interpolated into the strings.Consider adding a null check or using a fallback value when
namespaceis undefined.