當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript uri.from函數代碼示例

本文整理匯總了TypeScript中vs/base/common/uri.from函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript from函數的具體用法?TypeScript from怎麽用?TypeScript from使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了from函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('URI#toString, don\'t encode port', () => {
		var value = URI.parse('http://localhost:8080/far');
		assert.equal(value.toString(), 'http://localhost:8080/far');

		value = URI.from({ scheme: 'http', authority: 'löcalhost:8080', path: '/far', query: undefined, fragment: undefined });
		assert.equal(value.toString(), 'http://l%C3%B6calhost:8080/far');
	});
開發者ID:AjuanM,項目名稱:vscode,代碼行數:7,代碼來源:uri.test.ts

示例2: migrateStorageToMultiRootWorkspace

export function migrateStorageToMultiRootWorkspace(fromWorkspaceId: string, toWorkspace: IWorkspaceIdentifier, storage: IStorage): string {
	const parsed = parseStorage(storage);

	const newWorkspaceId = URI.from({ path: toWorkspace.id, scheme: 'root' }).toString();

	// Find in which location the workspace storage is to be migrated from
	let storageForWorkspace: StorageObject;
	if (parsed.multiRoot.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.multiRoot.get(fromWorkspaceId);
	} else if (parsed.empty.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.empty.get(fromWorkspaceId);
	} else if (parsed.folder.has(fromWorkspaceId)) {
		storageForWorkspace = parsed.folder.get(fromWorkspaceId);
	}

	// Migrate existing storage to new workspace id
	if (storageForWorkspace) {
		Object.keys(storageForWorkspace).forEach(key => {
			if (key === StorageService.WORKSPACE_IDENTIFIER) {
				return; // make sure to never migrate the workspace identifier
			}

			storage.setItem(`${StorageService.WORKSPACE_PREFIX}${newWorkspaceId}/${key}`, storageForWorkspace[key]);
		});
	}

	return newWorkspaceId;
}
開發者ID:AlexxNica,項目名稱:sqlopsstudio,代碼行數:28,代碼來源:migration.ts

示例3: test

	test('getBackupResource should get the correct backup path for untitled files', () => {
		// Format should be: <backupHome>/<workspaceHash>/<scheme>/<filePath>
		const backupResource = Uri.from({ scheme: 'untitled', path: 'Untitled-1' });
		const workspaceHash = crypto.createHash('md5').update(workspaceResource.fsPath).digest('hex');
		const expectedPath = Uri.file(path.join(backupHome, workspaceHash, 'untitled', backupResource.fsPath)).fsPath;
		assert.equal(service.getBackupResource(backupResource).fsPath, expectedPath);
	});
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例4: test

	test('dirname', () => {
		const f = URI.file('/some/file/test.txt');
		const d = dirname(f);
		assert.equal(d.fsPath, normalize('/some/file', true));

		// does not explode (https://github.com/Microsoft/vscode/issues/41987)
		dirname(URI.from({ scheme: 'file', authority: '/users/someone/portal.h' }));
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:8,代碼來源:resources.test.ts

示例5: test

	test('get encoded debug data', () => {
		const checkData = (uri: uri, expectedName, expectedPath, expectedSourceReference, expectedSessionId) => {
			let { name, path, sourceReference, sessionId } = Source.getEncodedDebugData(uri);
			assert.equal(name, expectedName);
			assert.equal(path, expectedPath);
			assert.equal(sourceReference, expectedSourceReference);
			assert.equal(sessionId, expectedSessionId);
		};

		checkData(uri.file('a/b/c/d'), 'd', normalize('/a/b/c/d', true), undefined, undefined);
		checkData(uri.from({ scheme: 'file', path: '/my/path/test.js', query: 'ref=1&session=2' }), 'test.js', normalize('/my/path/test.js', true), undefined, undefined);

		checkData(uri.from({ scheme: 'http', authority: 'www.msft.com', path: '/my/path' }), 'path', 'http://www.msft.com/my/path', undefined, undefined);
		checkData(uri.from({ scheme: 'debug', authority: 'www.msft.com', path: '/my/path', query: 'ref=100' }), 'path', '/my/path', 100, undefined);
		checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d.js', query: 'session=100' }), 'd.js', 'a/b/c/d.js', undefined, 100);
		checkData(uri.from({ scheme: 'debug', path: 'a/b/c/d/foo.txt', query: 'session=100&ref=10' }), 'foo.txt', 'a/b/c/d/foo.txt', 10, 100);
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:17,代碼來源:debugSource.test.ts

示例6: test

	test('http#toString, encode=FALSE', () => {
		assert.equal(URI.from({ scheme: 'http', authority: 'a-test-site.com', path: '/', query: 'test=true' }).toString(true), 'http://a-test-site.com/?test=true');
		assert.equal(URI.from({ scheme: 'http', authority: 'a-test-site.com', path: '/', query: '', fragment: 'test=true' }).toString(true), 'http://a-test-site.com/#test=true');
		assert.equal(URI.from({}).with({ scheme: 'http', path: '/api/files/test.me', query: 't=1234' }).toString(true), 'http:/api/files/test.me?t=1234');

		var value = URI.parse('file://shares/pröjects/c%23/#l12');
		assert.equal(value.authority, 'shares');
		assert.equal(value.path, '/pröjects/c#/');
		assert.equal(value.fragment, 'l12');
		assert.equal(value.toString(), 'file://shares/pr%C3%B6jects/c%23/#l12');
		assert.equal(value.toString(true), 'file://shares/pröjects/c%23/#l12');

		var uri2 = URI.parse(value.toString(true));
		var uri3 = URI.parse(value.toString());
		assert.equal(uri2.authority, uri3.authority);
		assert.equal(uri2.path, uri3.path);
		assert.equal(uri2.query, uri3.query);
		assert.equal(uri2.fragment, uri3.fragment);
	});
開發者ID:armanio123,項目名稱:vscode,代碼行數:19,代碼來源:uri.test.ts

示例7: test

	test('Migrate Storage (empty => multi root)', () => {
		const workspaceToMigrateFrom = URI.from({ path: '1500007676869', scheme: 'empty' }).toString();
		createService(workspaceToMigrateFrom);

		const workspaceToMigrateTo = URI.from({ path: '2500007676869', scheme: 'root' }).toString();

		migrateStorageToMultiRootWorkspace(workspaceToMigrateFrom, { id: '2500007676869', configPath: null }, storage);

		const s2 = new StorageService(storage, storage, workspaceToMigrateTo);
		const parsed = parseStorage(storage);

		assert.equal(parsed.empty.size, 1);
		assert.equal(parsed.folder.size, 0);
		assert.equal(parsed.multiRoot.size, 1);

		const migratedStorage = parsed.multiRoot.get(workspaceToMigrateTo);
		assert.equal(Object.keys(migratedStorage).length, 4);
		assert.equal(migratedStorage['key1'], s2.get('key1', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key2.something'], s2.get('key2.something', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key3/special'], s2.get('key3/special', StorageScope.WORKSPACE));
		assert.equal(migratedStorage['key4 space'], s2.get('key4 space', StorageScope.WORKSPACE));
	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:22,代碼來源:migration.test.ts

示例8: createMockModelService

export function createMockModelService(): IModelService {
	let contextService = new BaseWorkspaceContextService({
		resource: URI.from({ scheme: 'inmemory', authority: 'model', path: '/' }),
		id: null,
		name: null,
		uid: null,
		mtime: null
	}, {});

	let eventService = new EventService();

	let configurationService = new MockConfigurationService(contextService, eventService);

	return new MockModelService(null, configurationService, null);
}
開發者ID:AjuanM,項目名稱:vscode,代碼行數:15,代碼來源:servicesTestUtils.ts

示例9: test

	test('URI#toString, user information in authority', () => {
		var value = URI.parse('http://foo:bar@localhost/far');
		assert.equal(value.toString(), 'http://foo:bar@localhost/far');

		value = URI.parse('http://foo@localhost/far');
		assert.equal(value.toString(), 'http://foo@localhost/far');

		value = URI.parse('http://foo:bAr@localhost:8080/far');
		assert.equal(value.toString(), 'http://foo:bAr@localhost:8080/far');

		value = URI.parse('http://foo@localhost:8080/far');
		assert.equal(value.toString(), 'http://foo@localhost:8080/far');

		value = URI.from({ scheme: 'http', authority: 'föö:bör@löcalhost:8080', path: '/far', query: undefined, fragment: undefined });
		assert.equal(value.toString(), 'http://f%C3%B6%C3%B6:b%C3%B6r@l%C3%B6calhost:8080/far');
	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:16,代碼來源:uri.test.ts


注:本文中的vs/base/common/uri.from函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。