本文整理汇总了TypeScript中vs/platform/workspace/common/workspace.toWorkspaceFolders函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toWorkspaceFolders函数的具体用法?TypeScript toWorkspaceFolders怎么用?TypeScript toWorkspaceFolders使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toWorkspaceFolders函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: testWorkspace
export function testWorkspace(resource: URI): Workspace {
return new Workspace(
resource.toString(),
resource.fsPath,
toWorkspaceFolders([{ path: resource.fsPath }])
);
}
示例2: onError
extfs.copy(sourceDir, testDir, (error) => {
if (error) {
return onError(error, done);
}
service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true });
done();
});
示例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('UTF 8 BOMs', function () {
// setup
const _id = uuid.generateUuid();
const _testDir = path.join(parentDir, _id);
const _sourceDir = require.toUrl('./fixtures/service');
const resource = uri.file(path.join(testDir, 'index.html'));
const _service = new FileService(new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), {
disableWatcher: true
});
return pfs.copy(_sourceDir, _testDir).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
const model = TextModel.createFromString('Hello Bom');
// Update content: UTF_8 => UTF_8_BOM
return _service.updateContent(resource, model.createSnapshot(), { encoding: encodingLib.UTF8_with_bom }).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);
// Update content: PRESERVE BOM when using UTF-8
model.setValue('Please stay Bom');
return _service.updateContent(resource, model.createSnapshot(), { encoding: encodingLib.UTF8 }).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);
// Update content: REMOVE BOM
model.setValue('Go away Bom');
return _service.updateContent(resource, model.createSnapshot(), { encoding: encodingLib.UTF8, overwriteEncoding: true }).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
// Update content: BOM comes not back
model.setValue('Do not come back Bom');
return _service.updateContent(resource, model.createSnapshot(), { encoding: encodingLib.UTF8 }).then(() => {
return pfs.readFile(resource.fsPath).then(data => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
model.dispose();
_service.dispose();
});
});
});
});
});
});
});
});
});
});
});
示例5: FileService
return pfs.copy(sourceDir, testDir).then(() => {
service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), { disableWatcher: true });
});
示例6: constructor
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
super(workspaceBackupPath, fileService);
}
示例7: toWorkspaceFolders
workspaceResolver: workspace => { return workspace === testWorkspace ? { id: testWorkspace.id, configPath: workspace.configPath, folders: toWorkspaceFolders([{ path: path.join(fixturesFolder, 'vscode_workspace_1_folder') }, { path: path.join(fixturesFolder, 'vscode_workspace_2_folder') }]) } : null; },
示例8: getPathFromAmdModule
import * as path from 'vs/base/common/path';
import { findBestWindowOrFolderForFile, ISimpleWindow, IBestWindowOrFolderOptions } from 'vs/code/node/windowsFinder';
import { OpenContext } from 'vs/platform/windows/common/windows';
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import { URI } from 'vs/base/common/uri';
import { getPathFromAmdModule } from 'vs/base/common/amd';
const fixturesFolder = getPathFromAmdModule(require, './fixtures');
const testWorkspace: IWorkspaceIdentifier = {
id: Date.now().toString(),
configPath: URI.file(path.join(fixturesFolder, 'workspaces.json'))
};
const testWorkspaceFolders = toWorkspaceFolders([{ path: path.join(fixturesFolder, 'vscode_workspace_1_folder') }, { path: path.join(fixturesFolder, 'vscode_workspace_2_folder') }], testWorkspace.configPath);
function options(custom?: Partial<IBestWindowOrFolderOptions<ISimpleWindow>>): IBestWindowOrFolderOptions<ISimpleWindow> {
return {
windows: [],
newWindow: false,
context: OpenContext.CLI,
codeSettingsFolder: '_vscode',
localWorkspaceResolver: workspace => { return workspace === testWorkspace ? { id: testWorkspace.id, configPath: workspace.configPath, folders: testWorkspaceFolders } : null; },
...custom
};
}
const vscodeFolderWindow: ISimpleWindow = { lastFocusTime: 1, openedFolderUri: URI.file(path.join(fixturesFolder, 'vscode_folder')) };
const lastActiveWindow: ISimpleWindow = { lastFocusTime: 3, openedFolderUri: undefined };
const noVscodeFolderWindow: ISimpleWindow = { lastFocusTime: 2, openedFolderUri: URI.file(path.join(fixturesFolder, 'no_vscode_folder')) };
示例9: test
test('UTF 8 BOMs', function (done: () => void) {
// setup
const _id = uuid.generateUuid();
const _testDir = path.join(parentDir, _id);
const _sourceDir = require.toUrl('./fixtures/service');
const resource = uri.file(path.join(testDir, 'index.html'));
const _service = new FileService(new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))), new TestTextResourceConfigurationService(), new TestConfigurationService(), {
disableWatcher: true
});
extfs.copy(_sourceDir, _testDir, () => {
fs.readFile(resource.fsPath, (error, data) => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
// Update content: UTF_8 => UTF_8_BOM
_service.updateContent(resource, 'Hello Bom', { encoding: encodingLib.UTF8_with_bom }).done(() => {
fs.readFile(resource.fsPath, (error, data) => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);
// Update content: PRESERVE BOM when using UTF-8
_service.updateContent(resource, 'Please stay Bom', { encoding: encodingLib.UTF8 }).done(() => {
fs.readFile(resource.fsPath, (error, data) => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), encodingLib.UTF8);
// Update content: REMOVE BOM
_service.updateContent(resource, 'Go away Bom', { encoding: encodingLib.UTF8, overwriteEncoding: true }).done(() => {
fs.readFile(resource.fsPath, (error, data) => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
// Update content: BOM comes not back
_service.updateContent(resource, 'Do not come back Bom', { encoding: encodingLib.UTF8 }).done(() => {
fs.readFile(resource.fsPath, (error, data) => {
assert.equal(encodingLib.detectEncodingByBOMFromBuffer(data, 512), null);
_service.dispose();
done();
});
});
});
});
});
});
});
});
});
});
});
示例10: TestConfigurationService
extfs.copy(_sourceDir, _testDir, () => {
const encodingOverride: IEncodingOverride[] = [];
encodingOverride.push({
resource: uri.file(path.join(testDir, 'deep')),
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 }]))), textResourceConfigurationService, configurationService, {
encodingOverride,
disableWatcher: true
});
_service.resolveContent(uri.file(path.join(testDir, 'index.html'))).done(c => {
assert.equal(c.encoding, 'windows1252');
return _service.resolveContent(uri.file(path.join(testDir, 'deep', 'conway.js'))).done(c => {
assert.equal(c.encoding, 'utf16le');
// teardown
_service.dispose();
done();
});
});
});