本文整理匯總了TypeScript中vscode.Uri.parse方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Uri.parse方法的具體用法?TypeScript Uri.parse怎麽用?TypeScript Uri.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.Uri
的用法示例。
在下文中一共展示了Uri.parse方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
client.onRequest(NoSassLintLibraryRequest.type, (params) => {
const uri: Uri = Uri.parse(params.source.uri);
const workspaceFolder = workspace.getWorkspaceFolder(uri);
const packageManager = workspace.getConfiguration("sasslint", uri).get("packageManager", "npm");
client.info(getInstallFailureMessage(uri, workspaceFolder, packageManager));
return {};
});
示例2: test
test('editor, onDidChangeTextEditorViewColumn (move editor group)', () => {
let actualEvents: TextEditorViewColumnChangeEvent[] = [];
let registration1 = workspace.registerTextDocumentContentProvider('bikes', {
provideTextDocumentContent() {
return 'mountainbiking,roadcycling';
}
});
return Promise.all([
workspace.openTextDocument(Uri.parse('bikes://testing/one')).then(doc => window.showTextDocument(doc, ViewColumn.One)),
workspace.openTextDocument(Uri.parse('bikes://testing/two')).then(doc => window.showTextDocument(doc, ViewColumn.Two))
]).then(editors => {
let [, two] = editors;
two.show();
return new Promise(resolve => {
let registration2 = window.onDidChangeTextEditorViewColumn(event => {
actualEvents.push(event);
if (actualEvents.length === 2) {
registration2.dispose();
resolve();
}
});
// move active editor group left
return commands.executeCommand('workbench.action.moveActiveEditorGroupLeft');
}).then(() => {
assert.equal(actualEvents.length, 2);
for (const event of actualEvents) {
assert.equal(event.viewColumn, event.textEditor.viewColumn);
}
registration1.dispose();
});
});
});
示例3: init
async function init(context: ExtensionContext, disposables: Disposable[]): Promise<void> {
const { name, version, aiKey } = require(context.asAbsolutePath('./package.json')) as { name: string, version: string, aiKey: string };
const telemetryReporter: TelemetryReporter = new TelemetryReporter(name, version, aiKey);
disposables.push(telemetryReporter);
const outputChannel = window.createOutputChannel('Git');
disposables.push(outputChannel);
const config = workspace.getConfiguration('git');
const enabled = config.get<boolean>('enabled') === true;
const workspaceRootPath = workspace.rootPath;
const pathHint = workspace.getConfiguration('git').get<string>('path');
const info = await findGit(pathHint);
const askpass = new Askpass();
const env = await askpass.getEnv();
const git = new Git({ gitPath: info.path, version: info.version, env });
if (!workspaceRootPath || !enabled) {
const commandCenter = new CommandCenter(git, undefined, outputChannel, telemetryReporter);
disposables.push(commandCenter);
return;
}
const model = new Model(git, workspaceRootPath);
outputChannel.appendLine(localize('using git', "Using git {0} from {1}", info.version, info.path));
git.onOutput(str => outputChannel.append(str), null, disposables);
const commandCenter = new CommandCenter(git, model, outputChannel, telemetryReporter);
const statusBarCommands = new StatusBarCommands(model);
const provider = new GitSCMProvider(model, commandCenter, statusBarCommands);
const contentProvider = new GitContentProvider(model);
const autoFetcher = new AutoFetcher(model);
const mergeDecorator = new MergeDecorator(model);
disposables.push(
commandCenter,
provider,
contentProvider,
autoFetcher,
mergeDecorator,
model
);
if (/^[01]/.test(info.version)) {
const update = localize('updateGit', "Update Git");
const choice = await window.showWarningMessage(localize('git20', "You seem to have git {0} installed. Code works best with git >= 2", info.version), update);
if (choice === update) {
commands.executeCommand('vscode.open', Uri.parse('https://git-scm.com/'));
}
}
}
示例4:
let csvCommand = commands.registerCommand('csv.preview', () => {
let file = window.activeTextEditor.document.fileName;
if (file.startsWith("/")) {
file = file.substring(1);
}
previewUri = Uri.parse(`csv-preview://preview/${file}`);
return commands.executeCommand('vscode.previewHtml', previewUri, ViewColumn.One).then((success) => {
}, (reason) => {
window.showErrorMessage(reason);
});
});
示例5: test
test('openTextDocument, untitled is dirty', function(done) {
if (process.platform === 'win32') {
return done(); // TODO@Joh this test fails on windows
}
workspace.openTextDocument(Uri.parse('untitled://' + join(workspace.rootPath, './newfile.txt'))).then(doc => {
assert.equal(doc.uri.scheme, 'untitled');
assert.ok(doc.isDirty);
done();
});
});
示例6:
vscode.window.showQuickPick(items, options).then(function (selection) {
if (typeof selection === "undefined") {
return;
}
global.methodForDescription = selection;
syntaxHelper.update(previewUri);
vscode.commands.executeCommand("vscode.previewHtml", vscode.Uri.parse(previewUriString), vscode.ViewColumn.Two).then((success) => {
}, (reason) => {
vscode.window.showErrorMessage(reason);
});
});
示例7: test
test('api-command: vscode.diff', function () {
let registration = workspace.registerTextDocumentContentProvider('sc', {
provideTextDocumentContent(uri) {
return `content of URI <b>${uri.toString()}</b>#${Math.random()}`;
}
});
let a = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'DIFF').then(value => {
assert.ok(value === void 0);
registration.dispose();
});
let b = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b')).then(value => {
assert.ok(value === void 0);
registration.dispose();
});
let c = commands.executeCommand('vscode.diff', Uri.parse('sc:a'), Uri.parse('sc:b'), 'Title', { selection: new Range(new Position(1, 1), new Position(1, 2)) }).then(value => {
assert.ok(value === void 0);
registration.dispose();
});
let d = commands.executeCommand('vscode.diff').then(() => assert.ok(false), () => assert.ok(true));
let e = commands.executeCommand('vscode.diff', 1, 2, 3).then(() => assert.ok(false), () => assert.ok(true));
return Promise.all([a, b, c, d, e]);
});
示例8: openScript
async function openScript(pathOrUri: string) {
let uri: vscode.Uri;
if (pathOrUri.startsWith('debug:')) {
uri = vscode.Uri.parse(pathOrUri);
} else {
uri = vscode.Uri.file(pathOrUri);
}
const doc = await vscode.workspace.openTextDocument(uri);
vscode.window.showTextDocument(doc);
}
示例9: async
async (params: WorkspaceRubyEnvironmentParams): Promise<WorkspaceRubyEnvironmentResult> => {
const environments: WorkspaceRubyEnvironmentResult = {};
for (const uri of params.folders) {
const workspaceFolder: WorkspaceFolder = workspace.getWorkspaceFolder(Uri.parse(uri));
if (workspaceFolder && workspaceFolder.uri.fsPath) {
environments[uri] = await loadEnv(workspaceFolder.uri.fsPath);
}
}
return environments;
}
示例10: showOpenFileDialog
export async function showOpenFileDialog(): Promise<string> {
const defaultFolder = workspace.workspaceFolders ? workspace.workspaceFolders[0].uri.fsPath : '';
const folder = await (await window.showSaveDialog({
defaultUri: Uri.parse(defaultFolder),
saveLabel: 'Select mnemonic storage',
}));
if (!folder) {
throw new CancellationEvent();
}
return folder.fsPath;
}