mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
#30856: Register schema for workspace configuration file
- Both saved & unsaved - which supports intellisense in the files
This commit is contained in:
parent
ee2de18277
commit
7c7ae7a66f
|
@ -39,6 +39,14 @@
|
|||
"fileMatch": "%APP_SETTINGS_HOME%/settings.json",
|
||||
"url": "vscode://schemas/settings"
|
||||
},
|
||||
{
|
||||
"fileMatch": "%APP_WORKSPACES_HOME%/*/workspace.json",
|
||||
"url": "vscode://schemas/workspaceConfig"
|
||||
},
|
||||
{
|
||||
"fileMatch": "**/*.code-workspace",
|
||||
"url": "vscode://schemas/workspaceConfig"
|
||||
},
|
||||
{
|
||||
"fileMatch": "%APP_SETTINGS_HOME%/locale.json",
|
||||
"url": "vscode://schemas/locale"
|
||||
|
|
|
@ -125,6 +125,7 @@ function getSchemaAssociation(context: ExtensionContext): ISchemaAssociations {
|
|||
}
|
||||
if (fileMatch[0] === '%') {
|
||||
fileMatch = fileMatch.replace(/%APP_SETTINGS_HOME%/, '/User');
|
||||
fileMatch = fileMatch.replace(/%APP_WORKSPACES_HOME%/, '/Workspaces');
|
||||
} else if (fileMatch.charAt(0) !== '/' && !fileMatch.match(/\w+:\/\//)) {
|
||||
fileMatch = '/' + fileMatch;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ export interface IDefaultConfigurationExtension {
|
|||
defaults: { [key: string]: {} };
|
||||
}
|
||||
|
||||
const schemaId = 'vscode://schemas/settings';
|
||||
export const schemaId = 'vscode://schemas/settings';
|
||||
export const editorConfigurationSchemaId = 'vscode://schemas/settings/editor';
|
||||
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import * as collections from 'vs/base/common/collections';
|
|||
import { Disposable, toDisposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { readFile, stat } from 'vs/base/node/pfs';
|
||||
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
import * as extfs from 'vs/base/node/extfs';
|
||||
import { IWorkspaceContextService, IWorkspace, Workspace, ILegacyWorkspace, LegacyWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { FileChangeType, FileChangesEvent } from 'vs/platform/files/common/files';
|
||||
|
@ -30,7 +31,7 @@ import { ConfigurationService as GlobalConfigurationService } from 'vs/platform/
|
|||
import * as nls from 'vs/nls';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import { IConfigurationNode, IConfigurationRegistry, Extensions, editorConfigurationSchemaId, IDefaultConfigurationExtension, validateProperty, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IConfigurationNode, IConfigurationRegistry, Extensions, editorConfigurationSchemaId, IDefaultConfigurationExtension, validateProperty, ConfigurationScope, schemaId } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { createHash } from 'crypto';
|
||||
import { getWorkspaceLabel, IWorkspacesService } from "vs/platform/workspaces/common/workspaces";
|
||||
|
||||
|
@ -418,6 +419,7 @@ export class WorkspaceServiceImpl extends WorkspaceService {
|
|||
}
|
||||
|
||||
private initializeMulitFolderWorkspace(): TPromise<void> {
|
||||
this.registerWorkspaceConfigSchema();
|
||||
return this.workspaceConfiguration.load(this.workspaceConfigPath)
|
||||
.then(() => {
|
||||
const workspaceConfigurationModel = this.workspaceConfiguration.workspaceConfigurationModel;
|
||||
|
@ -432,6 +434,43 @@ export class WorkspaceServiceImpl extends WorkspaceService {
|
|||
});
|
||||
}
|
||||
|
||||
private registerWorkspaceConfigSchema(): void {
|
||||
const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
if (!contributionRegistry.getSchemaContributions().schemas['vscode://schemas/workspaceConfig']) {
|
||||
contributionRegistry.registerSchema('vscode://schemas/workspaceConfig', {
|
||||
default: {
|
||||
id: 'SOME_UNIQUE_ID',
|
||||
folders: [
|
||||
'file:///'
|
||||
],
|
||||
settings: {
|
||||
}
|
||||
},
|
||||
required: ['id', 'folders'],
|
||||
properties: {
|
||||
'id': {
|
||||
type: 'string',
|
||||
description: nls.localize('workspaceConfig.id', "Unique workspace id"),
|
||||
minLength: 1
|
||||
},
|
||||
'folders': {
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
'settings': {
|
||||
type: 'object',
|
||||
default: {},
|
||||
description: nls.localize('workspaceSettings.description', "Configure workspace settings"),
|
||||
$ref: schemaId
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private initializeSingleFolderWorkspace(): TPromise<void> {
|
||||
return stat(this.folderPath.fsPath)
|
||||
.then(workspaceStat => {
|
||||
|
|
Loading…
Reference in a new issue