Skip to content

Commit 736ff0b

Browse files
committed
[json] move schema associations to extensions
1 parent 8982434 commit 736ff0b

6 files changed

Lines changed: 209 additions & 44 deletions

File tree

extensions/csharp/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"language": "csharp",
1515
"scopeName": "source.cs",
1616
"path": "./syntaxes/csharp.json"
17+
}],
18+
"jsonValidation": [{
19+
"fileMatch": "project.json",
20+
"url": "http://json.schemastore.org/project"
1721
}]
1822
}
1923
}

extensions/javascript/package.json

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,86 @@
22
"name": "javascript",
33
"version": "0.1.0",
44
"publisher": "vscode",
5-
"engines": { "vscode": "*" },
5+
"engines": {
6+
"vscode": "*"
7+
},
68
"contributes": {
7-
"languages": [{
8-
"id": "javascriptreact",
9-
"aliases": ["JavaScript React","jsx"],
10-
"extensions": [".jsx"],
11-
"configuration": "./javascript.configuration.json"
12-
},{
13-
"id": "javascript",
14-
"aliases": ["JavaScript", "javascript", "js"],
15-
"extensions": [".js", ".es6"],
16-
"filenames": ["jakefile"],
17-
"firstLine": "^#!.*\\bnode",
18-
"mimetypes": ["text/javascript"]
19-
}],
20-
"grammars": [{
21-
"language": "javascriptreact",
22-
"scopeName": "source.jsx",
23-
"path": "./syntaxes/JavaScriptReact.tmLanguage"
24-
},{
25-
"language": "javascript",
26-
"scopeName": "source.js",
27-
"path": "./syntaxes/JavaScript.tmLanguage"
28-
},{
29-
// referenced by other grammars
30-
"scopeName": "source.js.regexp",
31-
"path": "./syntaxes/Regular Expressions (JavaScript).tmLanguage"
32-
}],
33-
"snippets": [{
34-
"language": "javascript",
35-
"path": "./snippets/javascript.json"
36-
}]
9+
"languages": [
10+
{
11+
"id": "javascriptreact",
12+
"aliases": [
13+
"JavaScript React",
14+
"jsx"
15+
],
16+
"extensions": [
17+
".jsx"
18+
],
19+
"configuration": "./javascript.configuration.json"
20+
},
21+
{
22+
"id": "javascript",
23+
"aliases": [
24+
"JavaScript",
25+
"javascript",
26+
"js"
27+
],
28+
"extensions": [
29+
".js",
30+
".es6"
31+
],
32+
"filenames": [
33+
"jakefile"
34+
],
35+
"firstLine": "^#!.*\\bnode",
36+
"mimetypes": [
37+
"text/javascript"
38+
]
39+
}
40+
],
41+
"grammars": [
42+
{
43+
"language": "javascriptreact",
44+
"scopeName": "source.jsx",
45+
"path": "./syntaxes/JavaScriptReact.tmLanguage"
46+
},
47+
{
48+
"language": "javascript",
49+
"scopeName": "source.js",
50+
"path": "./syntaxes/JavaScript.tmLanguage"
51+
},
52+
{
53+
// referenced by other grammars
54+
"scopeName": "source.js.regexp",
55+
"path": "./syntaxes/Regular Expressions (JavaScript).tmLanguage"
56+
}
57+
],
58+
"snippets": [
59+
{
60+
"language": "javascript",
61+
"path": "./snippets/javascript.json"
62+
}
63+
],
64+
"jsonValidation": [
65+
{
66+
"fileMatch": "package.json",
67+
"url": "http://json.schemastore.org/project"
68+
},
69+
{
70+
"fileMatch": "bower.json",
71+
"url": "http://json.schemastore.org/bower"
72+
},
73+
{
74+
"fileMatch": ".bower.json",
75+
"url": "http://json.schemastore.org/bower"
76+
},
77+
{
78+
"fileMatch": ".bowerrc",
79+
"url": "http://json.schemastore.org/bowerrc"
80+
},
81+
{
82+
"fileMatch": "jsconfig.json",
83+
"url": "./schemas/jsconfig.schema.json"
84+
}
85+
]
3786
}
3887
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"title": "JSON schema for the JavaScript configuration file",
3+
"type": "object",
4+
"default": {
5+
"compilerOptions": {
6+
"target": "ES5"
7+
}
8+
},
9+
"properties": {
10+
"compilerOptions": {
11+
"type": "object",
12+
"description": "Instructs the JavaScript language service how to validate .js files",
13+
"properties": {
14+
"charset": {
15+
"description": "The character set of the input files",
16+
"type": "string"
17+
},
18+
"diagnostics": {
19+
"description": "Show diagnostic information.",
20+
"type": "boolean"
21+
},
22+
"locale": {
23+
"description": "The locale to use to show error messages, e.g. en-us.",
24+
"type": "string"
25+
},
26+
"mapRoot": {
27+
"description": "Specifies the location where debugger should locate map files instead of generated locations",
28+
"type": "string",
29+
"format": "uri"
30+
},
31+
"module": {
32+
"description": "Module code generation to resolve against: 'commonjs', 'amd', 'system', or 'umd'.",
33+
"enum": [
34+
"commonjs",
35+
"amd",
36+
"system",
37+
"umd"
38+
]
39+
},
40+
"noLib": {
41+
"description": "Do not include the default library file (lib.d.ts).",
42+
"type": "boolean"
43+
},
44+
"target": {
45+
"description": "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental).",
46+
"enum": [
47+
"ES3",
48+
"ES5",
49+
"ES6",
50+
"es3",
51+
"es5",
52+
"es6"
53+
],
54+
"default": "ES3"
55+
},
56+
"experimentalDecorators": {
57+
"description": "Enables experimental support for ES7 decorators.",
58+
"type": "boolean"
59+
}
60+
}
61+
},
62+
"files": {
63+
"type": "array",
64+
"description": "If no 'files' property is present in a jsconfig.json, the language service defaults to including all files the containing directory and subdirectories. When a 'files' property is specified, only those files are included.",
65+
"items": {
66+
"type": "string",
67+
"format": "uri"
68+
}
69+
},
70+
"exclude": {
71+
"type": "array",
72+
"description": "List files and folders that should not be included. This property is not honored when the 'files' property is present.",
73+
"items": {
74+
"type": "string",
75+
"format": "uri"
76+
}
77+
}
78+
}
79+
}

extensions/json/package.json

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,41 @@
22
"name": "json",
33
"version": "0.1.0",
44
"publisher": "vscode",
5-
"engines": { "vscode": "*" },
5+
"engines": {
6+
"vscode": "*"
7+
},
68
"contributes": {
7-
"languages": [{
8-
"id": "json",
9-
"aliases": ["JSON", "json"],
10-
"extensions": [".json", ".bowerrc", ".jshintrc", ".jscsrc", ".eslintrc"],
11-
"mimetypes": ["application/json"]
12-
}],
13-
"grammars": [{
14-
"language": "json",
15-
"scopeName": "source.json",
16-
"path": "./syntaxes/JSON.tmLanguage"
17-
}]
9+
"languages": [
10+
{
11+
"id": "json",
12+
"aliases": [
13+
"JSON",
14+
"json"
15+
],
16+
"extensions": [
17+
".json",
18+
".bowerrc",
19+
".jshintrc",
20+
".jscsrc",
21+
".eslintrc"
22+
],
23+
"mimetypes": [
24+
"application/json"
25+
]
26+
}
27+
],
28+
"grammars": [
29+
{
30+
"language": "json",
31+
"scopeName": "source.json",
32+
"path": "./syntaxes/JSON.tmLanguage"
33+
}
34+
],
35+
"jsonValidation": [
36+
{
37+
"fileMatch": "*.schema.json",
38+
"url": "http://json-schema.org/draft-04/schema#"
39+
}
40+
]
1841
}
1942
}

extensions/typescript/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
"language": "typescriptreact",
102102
"path": "./snippets/typescriptreact.json"
103103
}
104+
],
105+
"jsonValidation": [
106+
{
107+
"fileMatch": "tsconfig.json",
108+
"url": "http://json.schemastore.org/tsconfig"
109+
}
104110
]
105111
}
106112
}

src/vs/platform/jsonschemas/common/jsonValidationExtensionPoint.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ export class JSONValidationExtensionPoint {
7171
collector.error(nls.localize('invalid.url.schema', "'configuration.jsonValidation.url' must start with 'http:', 'https:' or './' to reference schemas located in the extension"));
7272
return;
7373
}
74-
schemaRegistry.addSchemaFileAssociation(extension.fileMatch, uri);
74+
var fileMatch = extension.fileMatch;
75+
if (!strings.startsWith(extension.fileMatch, '/')) {
76+
fileMatch = '/' + fileMatch;
77+
}
78+
schemaRegistry.addSchemaFileAssociation(fileMatch, uri);
7579
});
7680
}
7781
});

0 commit comments

Comments
 (0)