本文整理匯總了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);
});
示例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);
});
示例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);
});
示例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 })
})
示例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
}
示例6: getSourceDoc
definitions.forEach(d => {
const definitionTargetDoc = getSourceDoc(d.fileName, program);
definitionResults.push({
uri: Uri.file(d.fileName).toString(),
range: convertRange(definitionTargetDoc, d.textSpan)
});
});
示例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}`
}
示例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');
});