mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
* Add support for more SsmsMin property dialogs and the Generate Script Wizard. Also fixed bug with ExtHostObjectExplorerNode getParent function * Localize package.json entries * Fix localization tokens * Address PR comments * Fix regex and getParent
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
'use strict';
|
|
|
|
import * as vscode from 'vscode';
|
|
|
|
export interface IPackageInfo {
|
|
name: string;
|
|
version: string;
|
|
aiKey: string;
|
|
}
|
|
|
|
export function getPackageInfo(packageJson: any): IPackageInfo {
|
|
if (packageJson) {
|
|
return {
|
|
name: packageJson.name,
|
|
version: packageJson.version,
|
|
aiKey: packageJson.aiKey
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the configuration for a extensionName
|
|
* @param extensionName The string name of the extension to get the configuration for
|
|
* @param resource The optional URI, as a URI object or a string, to use to get resource-scoped configurations
|
|
*/
|
|
export function getConfiguration(extensionName?: string, resource?: vscode.Uri | string): vscode.WorkspaceConfiguration {
|
|
if (typeof resource === 'string') {
|
|
try {
|
|
resource = this.parseUri(resource);
|
|
} catch (e) {
|
|
resource = undefined;
|
|
}
|
|
} else if (!resource) {
|
|
// Fix to avoid adding lots of errors to debug console. Expects a valid resource or null, not undefined
|
|
resource = null;
|
|
}
|
|
return vscode.workspace.getConfiguration(extensionName, resource as vscode.Uri);
|
|
}
|
|
|
|
/**
|
|
* Escapes all single-quotes (') by prefixing them with another single quote ('')
|
|
* ' => ''
|
|
* @param value The string to escape
|
|
*/
|
|
export function doubleEscapeSingleQuotes(value: string): string {
|
|
return value.replace(/'/g, '\'\'');
|
|
}
|
|
|
|
/**
|
|
* Escape all double-quotes (") by prefixing them with a \
|
|
* " => \"
|
|
* @param value The string to escape
|
|
*/
|
|
export function backEscapeDoubleQuotes(value: string): string {
|
|
return value.replace(/"/g, '\\"');
|
|
} |