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


TypeScript vscode-uri.file函數代碼示例

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


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

示例1: test

	test('CSS url() Path Completion - Unquoted url', function () {
		let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
		let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];

		assertCompletions('html { background-image: url(./|)', {
			items: [
				{ label: 'about.html', resultText: 'html { background-image: url(./about.html)' }
			]
		}, testUri, folders);

		assertCompletions('html { background-image: url(./a|)', {
			items: [
				{ label: 'about.html', resultText: 'html { background-image: url(./about.html)' }
			]
		}, testUri, folders);

		assertCompletions('html { background-image: url(../|src/)', {
			items: [
				{ label: 'about/', resultText: 'html { background-image: url(../about/)' }
			]
		}, testUri, folders);

		assertCompletions('html { background-image: url(../s|rc/)', {
			items: [
				{ label: 'about/', resultText: 'html { background-image: url(../about/)' }
			]
		}, testUri, folders);
	});
開發者ID:developers23,項目名稱:vscode,代碼行數:28,代碼來源:completion.test.ts

示例2: test

	test('CSS Path completion', function () {
		let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
		let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];

		assertCompletions('html { background-image: url("./|")', {
			items: [
				{ label: 'about.html', resultText: 'html { background-image: url("./about.html")' }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('../|')`, {
			items: [
				{ label: 'about/', resultText: `html { background-image: url('../about/')` },
				{ label: 'index.html', resultText: `html { background-image: url('../index.html')` },
				{ label: 'src/', resultText: `html { background-image: url('../src/')` }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('../src/a|')`, {
			items: [
				{ label: 'feature.js', resultText: `html { background-image: url('../src/feature.js')` },
				{ label: 'data/', resultText: `html { background-image: url('../src/data/')` },
				{ label: 'test.js', resultText: `html { background-image: url('../src/test.js')` }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('../src/data/f|.asar')`, {
			items: [
				{ label: 'foo.asar', resultText: `html { background-image: url('../src/data/foo.asar')` }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('|')`, {
			items: [
				{ label: 'about.css', resultText: `html { background-image: url('about.css')` },
				{ label: 'about.html', resultText: `html { background-image: url('about.html')` },
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('/|')`, {
			items: [
				{ label: 'pathCompletionFixtures/', resultText: `html { background-image: url('/pathCompletionFixtures/')` }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url('/pathCompletionFixtures/|')`, {
			items: [
				{ label: 'about/', resultText: `html { background-image: url('/pathCompletionFixtures/about/')` },
				{ label: 'index.html', resultText: `html { background-image: url('/pathCompletionFixtures/index.html')` },
				{ label: 'src/', resultText: `html { background-image: url('/pathCompletionFixtures/src/')` }
			]
		}, testUri, folders);

		assertCompletions(`html { background-image: url("/|")`, {
			items: [
				{ label: 'pathCompletionFixtures/', resultText: `html { background-image: url("/pathCompletionFixtures/")` }
			]
		}, testUri, folders);
	});
開發者ID:costincaraivan,項目名稱:vscode,代碼行數:59,代碼來源:completion.test.ts

示例3: test

	test('Completion should ignore files/folders starting with dot', function () {
		let testUri = Uri.file(path.resolve(__dirname, '../../test/pathCompletionFixtures/about/about.css')).toString();
		let folders = [{ name: 'x', uri: Uri.file(path.resolve(__dirname, '../../test')).toString() }];

		assertCompletions('html { background-image: url("../|")', {
			count: 4
		}, testUri, folders);

	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:9,代碼來源:completion.test.ts

示例4: it

 it('should support RenameFile edit', async () => {
   let file = path.join(__dirname, 'foo')
   await workspace.createFile(file, { ignoreIfExists: true, overwrite: true })
   let newFile = path.join(__dirname, 'bar')
   let uri = URI.file(file).toString()
   let workspaceEdit: WorkspaceEdit = {
     documentChanges: [RenameFile.create(uri, URI.file(newFile).toString())]
   }
   let res = await workspace.applyEdit(workspaceEdit)
   expect(res).toBe(true)
   await workspace.deleteFile(newFile, { ignoreIfNotExists: true })
 })
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:12,代碼來源:workspace.test.ts

示例5: modifyConfiguration

 private async modifyConfiguration(target: ConfigurationTarget, key: string, value?: any): Promise<void> {
   let { nvim, workspace } = this
   let file = workspace.getConfigFile(target)
   if (!file) return
   let formattingOptions = await workspace.getFormatOptions()
   let content = await workspace.readFile(Uri.file(file).toString())
   value = value == null ? undefined : value
   let edits = modify(content, [key], value, { formattingOptions })
   content = applyEdits(content, edits)
   fs.writeFileSync(file, content, 'utf8')
   let doc = workspace.getDocument(Uri.file(file).toString())
   if (doc) nvim.command('checktime', true)
   return
 }
開發者ID:demelev,項目名稱:coc.nvim,代碼行數:14,代碼來源:shape.ts

示例6: getSourceDoc

 definitions.forEach(d => {
   const definitionTargetDoc = getSourceDoc(d.fileName, program);
   definitionResults.push({
     uri: Uri.file(d.fileName).toString(),
     range: convertRange(definitionTargetDoc, d.textSpan)
   });
 });
開發者ID:tiravata,項目名稱:vetur,代碼行數:7,代碼來源:javascript.ts

示例7: getUri

export function getUri(fullpath: string, id: number, buftype: string): string {
  if (!fullpath) return `untitled:${id}`
  if (path.isAbsolute(fullpath)) return Uri.file(fullpath).toString()
  if (isuri.isValid(fullpath)) return Uri.parse(fullpath).toString()
  if (buftype != '') return `${buftype}:${id}`
  return `unknown:${id}`
}
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:7,代碼來源:index.ts

示例8: test

  test(testName, async() => {
    const {synchronizer, baseDir, clientConnection, converter} =
        createFileSynchronizer();
    const indexPath = path.join(baseDir, 'index.html');
    const indexUri = URI.file(indexPath).toString();

    // We read the file from disk before it is opened.
    fs.writeFileSync(indexPath, 'Filesystem content');
    assert.deepEqual(
        await synchronizer.urlLoader.load(
            converter.getAnalyzerUrl({uri: 'index.html'})!),
        'Filesystem content');

    // Open the document
    const openParams: DidOpenTextDocumentParams = {
      textDocument: {
        languageId: 'html',
        text: 'Initial text document content',
        uri: indexUri,
        version: 0
      }
    };
    clientConnection.sendNotification(
        DidOpenTextDocumentNotification.type, openParams);
    let change = await synchronizer.fileChanges.next;
    assert.deepEqual(change, [{type: FileChangeType.Changed, uri: indexUri}]);
    assert.deepEqual(
        await synchronizer.urlLoader.load(
            converter.getAnalyzerUrl({uri: 'index.html'})!),
        'Initial text document content');

    // Change the file in memory
    const changeParams: DidChangeTextDocumentParams = {
      textDocument: {uri: indexUri, version: 1},
      contentChanges: [{
        range: {start: {line: 0, character: 0}, end: {line: 0, character: 100}},
        text: 'Changed text document content'
      }]
    };
    clientConnection.sendNotification(
        DidChangeTextDocumentNotification.type, changeParams);
    change = await synchronizer.fileChanges.next;
    assert.deepEqual(change, [{type: FileChangeType.Changed, uri: indexUri}]);
    assert.deepEqual(
        await synchronizer.urlLoader.load(
            converter.getAnalyzerUrl({uri: 'index.html'})!),
        'Changed text document content');

    // Close without saving
    const closeParams:
        DidCloseTextDocumentParams = {textDocument: {uri: indexUri}};
    clientConnection.sendNotification(
        DidCloseTextDocumentNotification.type, closeParams);
    change = await synchronizer.fileChanges.next;
    assert.deepEqual(change, [{type: FileChangeType.Changed, uri: indexUri}]);
    assert.deepEqual(
        await synchronizer.urlLoader.load(
            converter.getAnalyzerUrl({uri: 'index.html'})!),
        'Filesystem content');
  });
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:60,代碼來源:file-synchronizer_test.ts


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