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


TypeScript URI.parse方法代碼示例

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


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

示例1: test

	test('dirname', () => {
		if (isWindows) {
			assert.equal(dirname(URI.file('c:\\some\\file\\test.txt')).toString(), 'file:///c:/some/file');
			assert.equal(dirname(URI.file('c:\\some\\file')).toString(), 'file:///c:/some');
			assert.equal(dirname(URI.file('c:\\some\\file\\')).toString(), 'file:///c:/some');
			assert.equal(dirname(URI.file('c:\\some')).toString(), 'file:///c:/');
			assert.equal(dirname(URI.file('C:\\some')).toString(), 'file:///c:/');
		} else {
			assert.equal(dirname(URI.file('/some/file/test.txt')).toString(), 'file:///some/file');
			assert.equal(dirname(URI.file('/some/file/')).toString(), 'file:///some');
			assert.equal(dirname(URI.file('/some/file')).toString(), 'file:///some');
		}
		assert.equal(dirname(URI.parse('foo://a/some/file/test.txt')).toString(), 'foo://a/some/file');
		assert.equal(dirname(URI.parse('foo://a/some/file/')).toString(), 'foo://a/some');
		assert.equal(dirname(URI.parse('foo://a/some/file')).toString(), 'foo://a/some');
		assert.equal(dirname(URI.parse('foo://a/some')).toString(), 'foo://a/');

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

示例2: test

	test('WorkspaceEdit - two edits for one resource', function () {
		let edit = new types.WorkspaceEdit();
		let uri = URI.parse('foo:bar');
		edit.insert(uri, new types.Position(0, 0), 'Hello');
		edit.insert(uri, new types.Position(0, 0), 'Foo');

		assert.equal(edit._allEntries().length, 2);
		let [first, second] = edit._allEntries();
		assert.equal((first as [URI, types.TextEdit[]])[1][0].newText, 'Hello');
		assert.equal((second as [URI, types.TextEdit[]])[1][0].newText, 'Foo');
	});
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例3: test

	test('diagnostics collection, tuples and undefined (small array), #15585', function () {

		const collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
		let uri = URI.parse('sc:hightower');
		let uri2 = URI.parse('sc:nomad');
		let diag = new Diagnostic(new Range(0, 0, 0, 1), 'ffff');

		collection.set([
			[uri, [diag, diag, diag]],
			[uri, undefined],
			[uri, [diag]],

			[uri2, [diag, diag]],
			[uri2, undefined],
			[uri2, [diag]],
		]);

		assert.equal(collection.get(uri).length, 1);
		assert.equal(collection.get(uri2).length, 1);
	});
開發者ID:ramesius,項目名稱:vscode,代碼行數:20,代碼來源:extHostDiagnostics.test.ts

示例4: test

	test('only uri, outside workspace', function () {

		let model = new EditorBreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, workspaceService, configService);
		let elements = model.getElements();

		assert.equal(elements.length, 2);
		let [one, two] = elements as FileElement[];
		assert.equal(one.kind, FileKind.FOLDER);
		assert.equal(two.kind, FileKind.FILE);
		assert.equal(one.uri.toString(), 'foo:/outside');
		assert.equal(two.uri.toString(), 'foo:/outside/file.ts');
	});
開發者ID:developers23,項目名稱:vscode,代碼行數:12,代碼來源:breadcrumbModel.test.ts

示例5: test

	test('with, identity', () => {
		let uri = URI.parse('foo:bar/path');

		let uri2 = uri.with(null);
		assert.ok(uri === uri2);
		uri2 = uri.with(undefined);
		assert.ok(uri === uri2);
		uri2 = uri.with({});
		assert.ok(uri === uri2);
		uri2 = uri.with({ scheme: 'foo', path: 'bar/path' });
		assert.ok(uri === uri2);
	});
開發者ID:ramesius,項目名稱:vscode,代碼行數:12,代碼來源:uri.test.ts

示例6: test

	test('isEqual', () => {
		let fileURI = isWindows ? URI.file('c:\\foo\\bar') : URI.file('/foo/bar');
		let fileURI2 = isWindows ? URI.file('C:\\foo\\Bar') : URI.file('/foo/Bar');
		assert.equal(isEqual(fileURI, fileURI, true), true);
		assert.equal(isEqual(fileURI, fileURI, false), true);
		assert.equal(isEqual(fileURI, fileURI, hasToIgnoreCase(fileURI)), true);
		assert.equal(isEqual(fileURI, fileURI2, true), true);
		assert.equal(isEqual(fileURI, fileURI2, false), false);

		let fileURI3 = URI.parse('foo://server:453/foo/bar');
		let fileURI4 = URI.parse('foo://server:453/foo/Bar');
		assert.equal(isEqual(fileURI3, fileURI3, true), true);
		assert.equal(isEqual(fileURI3, fileURI3, false), true);
		assert.equal(isEqual(fileURI3, fileURI3, hasToIgnoreCase(fileURI3)), true);
		assert.equal(isEqual(fileURI3, fileURI4, true), true);
		assert.equal(isEqual(fileURI3, fileURI4, false), false);

		assert.equal(isEqual(fileURI, fileURI3, true), false);

		assert.equal(isEqual(URI.parse('foo://server'), URI.parse('foo://server/')), true);
	});
開發者ID:eamodio,項目名稱:vscode,代碼行數:21,代碼來源:resources.test.ts

示例7: test

	test('score, filter', function () {
		assert.equal(score('farboo', model.uri, model.language, true), 10);
		assert.equal(score({ language: 'farboo' }, model.uri, model.language, true), 10);
		assert.equal(score({ language: 'farboo', scheme: 'file' }, model.uri, model.language, true), 10);
		assert.equal(score({ language: 'farboo', scheme: 'http' }, model.uri, model.language, true), 0);

		assert.equal(score({ pattern: '**/*.fb' }, model.uri, model.language, true), 10);
		assert.equal(score({ pattern: '**/*.fb', scheme: 'file' }, model.uri, model.language, true), 10);
		assert.equal(score({ pattern: '**/*.fb' }, URI.parse('foo:bar'), model.language, true), 0);
		assert.equal(score({ pattern: '**/*.fb', scheme: 'foo' }, URI.parse('foo:bar'), model.language, true), 0);

		let doc = {
			uri: URI.parse('git:/my/file.js'),
			langId: 'javascript'
		};
		assert.equal(score('javascript', doc.uri, doc.langId, true), 10); // 0;
		assert.equal(score({ language: 'javascript', scheme: 'git' }, doc.uri, doc.langId, true), 10); // 10;
		assert.equal(score('*', doc.uri, doc.langId, true), 5); // 5
		assert.equal(score('fooLang', doc.uri, doc.langId, true), 0); // 0
		assert.equal(score(['fooLang', '*'], doc.uri, doc.langId, true), 5); // 5
	});
開發者ID:PKRoma,項目名稱:vscode,代碼行數:21,代碼來源:languageSelector.test.ts

示例8: test

	test('Data Source', function () {
		let ds = instantiation.createInstance(SearchDataSource);
		let result: SearchResult = instantiation.createInstance(SearchResult, null);
		result.query = {
			type: QueryType.Text,
			contentPattern: { pattern: 'foo' },
			folderQueries: [{
				folder: uri.parse('file://c:/')
			}]
		};

		const ranges = {
			startLineNumber: 1,
			startColumn: 0,
			endLineNumber: 1,
			endColumn: 1
		};
		result.add([{
			resource: uri.parse('file:///c:/foo'),
			results: [{
				preview: {
					text: 'bar',
					matches: ranges
				},
				ranges
			}]
		}]);

		let fileMatch = result.matches()[0];
		let lineMatch = fileMatch.matches()[0];

		assert.equal(ds.getId(null, result), 'root');
		assert.equal(ds.getId(null, fileMatch), 'file:///c%3A/foo');
		assert.equal(ds.getId(null, lineMatch), 'file:///c%3A/foo>[2,1 -> 2,2]b');

		assert(!ds.hasChildren(null, 'foo'));
		assert(ds.hasChildren(null, result));
		assert(ds.hasChildren(null, fileMatch));
		assert(!ds.hasChildren(null, lineMatch));
	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:40,代碼來源:searchViewlet.test.ts

示例9: open

	private open(data: OpenCommandPipeArgs, res: http.ServerResponse) {
		let { fileURIs, folderURIs, forceNewWindow, diffMode, addMode, forceReuseWindow, waitMarkerFilePath } = data;
		const urisToOpen: IURIToOpen[] = [];
		if (Array.isArray(folderURIs)) {
			for (const s of folderURIs) {
				try {
					urisToOpen.push({ folderUri: URI.parse(s) });
					if (!addMode && !forceReuseWindow) {
						forceNewWindow = true;
					}
				} catch (e) {
					// ignore
				}
			}
		}
		if (Array.isArray(fileURIs)) {
			for (const s of fileURIs) {
				try {
					if (hasWorkspaceFileExtension(s)) {
						urisToOpen.push({ workspaceUri: URI.parse(s) });
						if (!forceReuseWindow) {
							forceNewWindow = true;
						}
					} else {
						urisToOpen.push({ fileUri: URI.parse(s) });
					}
				} catch (e) {
					// ignore
				}
			}
		}
		if (urisToOpen.length) {
			const waitMarkerFileURI = waitMarkerFilePath ? URI.file(waitMarkerFilePath) : undefined;
			const windowOpenArgs: IOpenSettings = { forceNewWindow, diffMode, addMode, forceReuseWindow, waitMarkerFileURI };
			this._commands.executeCommand('_files.windowOpen', urisToOpen, windowOpenArgs);
		}
		res.writeHead(200);
		res.end();
	}
開發者ID:PKRoma,項目名稱:vscode,代碼行數:39,代碼來源:extHostCLIServer.ts


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