mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
trailing commas only for setting files
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"dependencies": {
|
||||
"jsonc-parser": "^2.1.1",
|
||||
"request-light": "^0.2.4",
|
||||
"vscode-json-languageservice": "^3.3.2",
|
||||
"vscode-json-languageservice": "^3.3.3",
|
||||
"vscode-languageserver": "^5.3.0-next.8",
|
||||
"vscode-nls": "^4.1.1",
|
||||
"vscode-uri": "^2.0.3"
|
||||
|
||||
@@ -312,7 +312,7 @@ function validateTextDocument(textDocument: TextDocument, callback?: (diagnostic
|
||||
const jsonDocument = getJSONDocument(textDocument);
|
||||
const version = textDocument.version;
|
||||
|
||||
const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' };
|
||||
const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'warning' } : { comments: 'error', trailingCommas: 'error' };
|
||||
languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
|
||||
setTimeout(() => {
|
||||
const currDocument = documents.get(textDocument.uri);
|
||||
|
||||
@@ -73,10 +73,10 @@ request-light@^0.2.4:
|
||||
https-proxy-agent "^2.2.1"
|
||||
vscode-nls "^4.0.0"
|
||||
|
||||
vscode-json-languageservice@^3.3.2:
|
||||
version "3.3.2"
|
||||
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.2.tgz#2b241b73ead75b001bf90ee5107b1b0a4e47737c"
|
||||
integrity sha512-+TXVA8KsIzPOZIBV4lI8S/460XihqL26N9hyH7wMOCbEA06W/zfmlZhHSmSJ/Nun9Q/CGLJYZKw4xn+vcuI62A==
|
||||
vscode-json-languageservice@^3.3.3:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.3.tgz#f7e512a2cd5e82fecbebf507d6fceaea47661297"
|
||||
integrity sha512-5vL3OXTUuQpn6+tGd47dopio+7WwbtIZ07zfYMzAUX8eVWPZjfEsLeSWmQk5Xw+vwgu+j5zC4koz5UofLDGGRA==
|
||||
dependencies:
|
||||
jsonc-parser "^2.1.1"
|
||||
vscode-languageserver-types "^3.15.0-next.2"
|
||||
|
||||
@@ -50,8 +50,7 @@
|
||||
".babelrc",
|
||||
".jsonc",
|
||||
".eslintrc",
|
||||
".eslintrc.json",
|
||||
"tslint.json"
|
||||
".eslintrc.json"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export interface IJSONSchema {
|
||||
markdownDescription?: string; // VSCode extension
|
||||
doNotSuggest?: boolean; // VSCode extension
|
||||
allowComments?: boolean; // VSCode extension
|
||||
allowsTrailingCommas?: boolean; // VSCode extension
|
||||
}
|
||||
|
||||
export interface IJSONSchemaMap {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -170,7 +170,7 @@ class ConfigurationRegistry implements IConfigurationRegistry {
|
||||
properties: {}
|
||||
};
|
||||
this.configurationContributors = [this.defaultOverridesConfigurationNode];
|
||||
this.editorConfigurationSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown editor configuration setting' };
|
||||
this.editorConfigurationSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown editor configuration setting', allowsTrailingCommas: true, allowComments: true };
|
||||
this.configurationProperties = {};
|
||||
this.excludedConfigurationProperties = {};
|
||||
this.computeOverridePropertyPattern();
|
||||
|
||||
@@ -238,6 +238,7 @@ function validateProperties(configuration: IConfigurationNode, extension: IExten
|
||||
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
jsonRegistry.registerSchema('vscode://schemas/workspaceConfig', {
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
default: {
|
||||
folders: [
|
||||
{
|
||||
|
||||
@@ -358,6 +358,7 @@ export class LanguageConfigurationFileHandler {
|
||||
const schemaId = 'vscode://schemas/language-configuration';
|
||||
const schema: IJSONSchema = {
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
default: {
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
|
||||
@@ -137,6 +137,8 @@ export const launchSchema: IJSONSchema = {
|
||||
id: launchSchemaId,
|
||||
type: 'object',
|
||||
title: nls.localize('app.launch.json.title', "Launch"),
|
||||
allowsTrailingCommas: true,
|
||||
allowComments: true,
|
||||
required: [],
|
||||
default: { version: '0.2.0', configurations: [], compounds: [] },
|
||||
properties: {
|
||||
|
||||
@@ -11,6 +11,7 @@ export const ExtensionsConfigurationSchemaId = 'vscode://schemas/extensions';
|
||||
export const ExtensionsConfigurationSchema: IJSONSchema = {
|
||||
id: ExtensionsConfigurationSchemaId,
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
type: 'object',
|
||||
title: localize('app.extensions.json.title', "Extensions"),
|
||||
additionalProperties: false,
|
||||
@@ -50,4 +51,4 @@ export const ExtensionsConfigurationInitialContent: string = [
|
||||
'\t\t',
|
||||
'\t]',
|
||||
'}'
|
||||
].join('\n');
|
||||
].join('\n');
|
||||
|
||||
@@ -232,6 +232,7 @@ function registerLocaleDefinitionSchema(languages: string[]): void {
|
||||
jsonRegistry.registerSchema(localeDefinitionFileSchemaId, {
|
||||
id: localeDefinitionFileSchemaId,
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
description: 'Locale Definition file',
|
||||
type: 'object',
|
||||
default: {
|
||||
|
||||
@@ -28,6 +28,7 @@ const languageScopeSchemaId = 'vscode://schemas/snippets';
|
||||
const languageScopeSchema: IJSONSchema = {
|
||||
id: languageScopeSchemaId,
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
defaultSnippets: [{
|
||||
label: nls.localize('snippetSchema.json.default', "Empty snippet"),
|
||||
body: { '${1:snippetName}': { 'prefix': '${2:prefix}', 'body': '${3:snippet}', 'description': '${4:description}' } }
|
||||
@@ -63,6 +64,7 @@ const globalSchemaId = 'vscode://schemas/global-snippets';
|
||||
const globalSchema: IJSONSchema = {
|
||||
id: globalSchemaId,
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
defaultSnippets: [{
|
||||
label: nls.localize('snippetSchema.json.default', "Empty snippet"),
|
||||
body: { '${1:snippetName}': { 'scope': '${2:scope}', 'prefix': '${3:prefix}', 'body': '${4:snippet}', 'description': '${5:description}' } }
|
||||
|
||||
@@ -260,6 +260,8 @@ let schema: IJSONSchema = {
|
||||
id: schemaId,
|
||||
description: 'Task definition file',
|
||||
type: 'object',
|
||||
allowsTrailingCommas: true,
|
||||
allowComments: true,
|
||||
default: {
|
||||
version: '2.0.0',
|
||||
tasks: [
|
||||
|
||||
@@ -507,17 +507,17 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
|
||||
private registerConfigurationSchemas(): void {
|
||||
if (this.workspace) {
|
||||
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
const allSettingsSchema: IJSONSchema = { properties: allSettings.properties, patternProperties: allSettings.patternProperties, additionalProperties: true };
|
||||
const userSettingsSchema: IJSONSchema = this.remoteUserConfiguration ? { properties: { ...applicationSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true } : allSettingsSchema;
|
||||
const machineSettingsSchema: IJSONSchema = { properties: { ...machineSettings.properties, ...machineOverridableSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true };
|
||||
const workspaceSettingsSchema: IJSONSchema = { properties: { ...machineOverridableSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true };
|
||||
const allSettingsSchema: IJSONSchema = { properties: allSettings.properties, patternProperties: allSettings.patternProperties, additionalProperties: true, allowsTrailingCommas: true, allowComments: true };
|
||||
const userSettingsSchema: IJSONSchema = this.remoteUserConfiguration ? { properties: { ...applicationSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true, allowsTrailingCommas: true, allowComments: true } : allSettingsSchema;
|
||||
const machineSettingsSchema: IJSONSchema = { properties: { ...machineSettings.properties, ...machineOverridableSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true, allowsTrailingCommas: true, allowComments: true };
|
||||
const workspaceSettingsSchema: IJSONSchema = { properties: { ...machineOverridableSettings.properties, ...windowSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true, allowsTrailingCommas: true, allowComments: true };
|
||||
|
||||
jsonRegistry.registerSchema(defaultSettingsSchemaId, allSettingsSchema);
|
||||
jsonRegistry.registerSchema(userSettingsSchemaId, userSettingsSchema);
|
||||
jsonRegistry.registerSchema(machineSettingsSchemaId, machineSettingsSchema);
|
||||
|
||||
if (WorkbenchState.WORKSPACE === this.getWorkbenchState()) {
|
||||
const folderSettingsSchema: IJSONSchema = { properties: { ...machineOverridableSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true };
|
||||
const folderSettingsSchema: IJSONSchema = { properties: { ...machineOverridableSettings.properties, ...resourceSettings.properties }, patternProperties: allSettings.patternProperties, additionalProperties: true, allowsTrailingCommas: true, allowComments: true };
|
||||
jsonRegistry.registerSchema(workspaceSettingsSchemaId, workspaceSettingsSchema);
|
||||
jsonRegistry.registerSchema(folderSettingsSchemaId, folderSettingsSchema);
|
||||
} else {
|
||||
|
||||
@@ -602,10 +602,12 @@ let commandsSchemas: IJSONSchema[] = [];
|
||||
let commandsEnum: string[] = [];
|
||||
let commandsEnumDescriptions: (string | undefined)[] = [];
|
||||
let schema: IJSONSchema = {
|
||||
'id': schemaId,
|
||||
'type': 'array',
|
||||
'title': nls.localize('keybindings.json.title', "Keybindings configuration"),
|
||||
'definitions': {
|
||||
id: schemaId,
|
||||
type: 'array',
|
||||
title: nls.localize('keybindings.json.title', "Keybindings configuration"),
|
||||
allowsTrailingCommas: true,
|
||||
allowComments: true,
|
||||
definitions: {
|
||||
'editorGroupsSchema': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
@@ -623,7 +625,7 @@ let schema: IJSONSchema = {
|
||||
}
|
||||
}
|
||||
},
|
||||
'items': {
|
||||
items: {
|
||||
'required': ['key'],
|
||||
'type': 'object',
|
||||
'defaultSnippets': [{ 'body': { 'key': '$1', 'command': '$2', 'when': '$3' } }],
|
||||
|
||||
@@ -192,6 +192,7 @@ export const colorThemeSchemaId = 'vscode://schemas/color-theme';
|
||||
const colorThemeSchema: IJSONSchema = {
|
||||
type: 'object',
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
properties: {
|
||||
colors: {
|
||||
description: nls.localize('schema.workbenchColors', 'Colors in the workbench'),
|
||||
|
||||
@@ -12,6 +12,7 @@ const schemaId = 'vscode://schemas/icon-theme';
|
||||
const schema: IJSONSchema = {
|
||||
type: 'object',
|
||||
allowComments: true,
|
||||
allowsTrailingCommas: true,
|
||||
definitions: {
|
||||
folderExpanded: {
|
||||
type: 'string',
|
||||
@@ -221,4 +222,4 @@ const schema: IJSONSchema = {
|
||||
export function registerFileIconThemeSchemas() {
|
||||
let schemaRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
|
||||
schemaRegistry.registerSchema(schemaId, schema);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user