本文整理匯總了TypeScript中vs/base/common/uri.file函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript file函數的具體用法?TypeScript file怎麽用?TypeScript file使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了file函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: onError
service.resolveFile(uri.file(testDir)).done(parent => {
const folderResource = uri.file(path.join(parent.resource.fsPath, 'conway.js'));
return service.createFolder(folderResource).then(f => {
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
return service.copyFile(resource, f.resource, true).then(copied => {
assert.equal(fs.existsSync(copied.resource.fsPath), true);
assert.ok(fs.statSync(copied.resource.fsPath).isFile);
assert.ok(createEvent);
assert.ok(deleteEvent);
assert.ok(copyEvent);
assert.equal(copyEvent.resource.fsPath, resource.fsPath);
assert.equal(copyEvent.target.resource.fsPath, copied.resource.fsPath);
assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath);
toDispose.dispose();
done();
});
});
}, error => onError(error, done));
示例2: test
test('importFile - overwrite folder with file', function () {
let createEvent: FileOperationEvent;
let importEvent: FileOperationEvent;
let deleteEvent: FileOperationEvent;
const toDispose = service.onAfterOperation(e => {
if (e.operation === FileOperation.CREATE) {
createEvent = e;
} else if (e.operation === FileOperation.DELETE) {
deleteEvent = e;
} else if (e.operation === FileOperation.IMPORT) {
importEvent = e;
}
});
return service.resolveFile(uri.file(testDir)).then(parent => {
const folderResource = uri.file(path.join(parent.resource.fsPath, 'conway.js'));
return service.createFolder(folderResource).then(f => {
const resource = uri.file(path.join(testDir, 'deep', 'conway.js'));
return service.importFile(resource, uri.file(testDir)).then(res => {
assert.equal(fs.existsSync(res.stat.resource.fsPath), true);
assert.ok(fs.readdirSync(testDir).some(f => f === 'conway.js'));
assert.ok(fs.statSync(res.stat.resource.fsPath).isFile);
assert.ok(createEvent);
assert.ok(deleteEvent);
assert.ok(importEvent);
assert.equal(importEvent.resource.fsPath, resource.fsPath);
assert.equal(importEvent.target.resource.fsPath, res.stat.resource.fsPath);
assert.equal(deleteEvent.resource.fsPath, folderResource.fsPath);
toDispose.dispose();
});
});
});
});
示例3: TestConfigurationService
return pfs.copy(_sourceDir, _testDir).then(() => {
const encodingOverride: IEncodingOverride[] = [];
encodingOverride.push({
extension: 'js',
encoding: 'utf16le'
});
const configurationService = new TestConfigurationService();
configurationService.setUserConfiguration('files', { encoding: 'windows1252' });
const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
textResourceConfigurationService,
configurationService,
new TestLifecycleService(),
new TestStorageService(),
new TestNotificationService(),
{
encodingOverride,
disableWatcher: true
});
return _service.resolveContent(uri.file(path.join(testDir, 'index.html'))).then(c => {
assert.equal(c.encoding, 'windows1252');
return _service.resolveContent(uri.file(path.join(testDir, 'deep', 'conway.js'))).then(c => {
assert.equal(c.encoding, 'utf16le');
// teardown
_service.dispose();
});
});
});
示例4: test
test('updateContent - encoding preserved (UTF 16 LE, ITextSnapShot)', function (done: () => void) {
const encoding = 'utf16le';
const resource = uri.file(path.join(testDir, 'some_utf16le.css'));
service.resolveContent(resource).done(c => {
assert.equal(c.encoding, encoding);
const model = TextModel.createFromString('Some updates');
return service.updateContent(c.resource, model.createSnapshot(), { encoding: encoding }).then(c => {
return encodingLib.detectEncodingByBOM(c.resource.fsPath).then((enc) => {
assert.equal(enc, encodingLib.UTF16le);
return service.resolveContent(resource).then(c => {
assert.equal(c.encoding, encoding);
model.dispose();
done();
});
});
});
}, error => onError(error, done));
});
示例5: test
test('nearestReference', function () {
const model = new ReferencesModel([{
uri: URI.file('/out/obj/can'),
range: new Range(1, 1, 1, 1)
}, {
uri: URI.file('/out/obj/can2'),
range: new Range(1, 1, 1, 1)
}, {
uri: URI.file('/src/can'),
range: new Range(1, 1, 1, 1)
}]);
let ref = model.nearestReference(URI.file('/src/can'), new Position(1, 1));
assert.equal(ref.uri.path, '/src/can');
ref = model.nearestReference(URI.file('/src/someOtherFileInSrc'), new Position(1, 1));
assert.equal(ref.uri.path, '/src/can');
ref = model.nearestReference(URI.file('/out/someOtherFile'), new Position(1, 1));
assert.equal(ref.uri.path, '/out/obj/can');
ref = model.nearestReference(URI.file('/out/obj/can2222'), new Position(1, 1));
assert.equal(ref.uri.path, '/out/obj/can2');
});
示例6: test
test('isEqualOrParent', () => {
let fileURI = isWindows ? URI.file('c:\\foo\\bar') : URI.file('/foo/bar');
let fileURI2 = isWindows ? URI.file('c:\\foo') : URI.file('/foo');
let fileURI2b = isWindows ? URI.file('C:\\Foo\\') : URI.file('/Foo/');
assert.equal(isEqualOrParent(fileURI, fileURI, true), true, '1');
assert.equal(isEqualOrParent(fileURI, fileURI, false), true, '2');
assert.equal(isEqualOrParent(fileURI, fileURI2, true), true, '3');
assert.equal(isEqualOrParent(fileURI, fileURI2, false), true, '4');
assert.equal(isEqualOrParent(fileURI, fileURI2b, true), true, '5');
assert.equal(isEqualOrParent(fileURI, fileURI2b, false), false, '6');
assert.equal(isEqualOrParent(fileURI2, fileURI, false), false, '7');
assert.equal(isEqualOrParent(fileURI2b, fileURI2, true), true, '8');
let fileURI3 = URI.parse('foo://server:453/foo/bar/goo');
let fileURI4 = URI.parse('foo://server:453/foo/');
let fileURI5 = URI.parse('foo://server:453/foo');
assert.equal(isEqualOrParent(fileURI3, fileURI3, true), true, '11');
assert.equal(isEqualOrParent(fileURI3, fileURI3, false), true, '12');
assert.equal(isEqualOrParent(fileURI3, fileURI4, true), true, '13');
assert.equal(isEqualOrParent(fileURI3, fileURI4, false), true, '14');
assert.equal(isEqualOrParent(fileURI3, fileURI, true), false, '15');
assert.equal(isEqualOrParent(fileURI5, fileURI5, true), true, '16');
});
示例7:
return service.resolveFile(uri.file(path.join(testDir, 'deep', 'conway.js'))).then(source => {
return service.importFile(source.resource, uri.file(testDir)).then(res => { // CONWAY.js => conway.js
assert.equal(fs.existsSync(res.stat.resource.fsPath), true);
assert.ok(fs.readdirSync(testDir).some(f => f === 'conway.js'));
});
});
示例8: test
test('OutputWorker - Link detection', function () {
let patternsSlash = OutputLinkComputer.createPatterns(
URI.file('C:/Users/someone/AppData/Local/Temp/_monacodata_9888/workspaces/mankala')
);
let patternsBackSlash = OutputLinkComputer.createPatterns(
URI.file('C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala')
);
let contextService = new TestContextService();
let line = toOSPath('Foo bar');
let result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 0);
result = OutputLinkComputer.detectLinks(line, 1, patternsBackSlash, contextService);
assert.equal(result.length, 0);
// Example: at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString());
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 84);
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts in');
result = OutputLinkComputer.detectLinks(line, 1, patternsBackSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString());
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 84);
// Example: at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336 in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 88);
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336 in');
result = OutputLinkComputer.detectLinks(line, 1, patternsBackSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 88);
// Example: at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336:9
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336:9 in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336,9');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 90);
result = OutputLinkComputer.detectLinks(line, 1, patternsBackSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336,9');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 90);
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336:9 in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336,9');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 90);
result = OutputLinkComputer.detectLinks(line, 1, patternsBackSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336,9');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 90);
// Example: at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts>dir
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts>dir in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString());
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 84);
// Example: at [C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336:9]
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts:336:9] in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString() + '#336,9');
assert.equal(result[0].range.startColumn, 5);
assert.equal(result[0].range.endColumn, 90);
// Example: at [C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts]
line = toOSPath(' at C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts] in');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
assert.equal(result[0].url, contextService.toResource('/Game.ts').toString());
// Example: C:\Users\someone\AppData\Local\Temp\_monacodata_9888\workspaces\express\server.js on line 8
line = toOSPath('C:\\Users\\someone\\AppData\\Local\\Temp\\_monacodata_9888\\workspaces\\mankala\\Game.ts on line 8');
result = OutputLinkComputer.detectLinks(line, 1, patternsSlash, contextService);
assert.equal(result.length, 1);
//.........這裏部分代碼省略.........