VS 代码 - JSON 架构缓存
VS Code - JSON Schema cache
我刚刚升级到 TypeScript 1.5(不再是测试版),在这样做的过程中,我想利用 VS Code 中的 json 模式助手。
配置 tsconfig.json 时,唯一的模块选项是 commonjs
和 amd
,这意味着缺少 umd
和 system
,基于此:http://json.schemastore.org/tsconfig
我的问题是如何让 VS Code 刷新它的模式缓存?
仅供参考,我尝试覆盖设置中的 URL 并将其改回并重新启动 VS Code
My questions is how do I get VS Code to refresh it's cache of the schema?
该架构实际上被硬编码在一个名为 jsonWorker.js
的文件中(我的文件路径是 C:\Users\basaratsyed\AppData\Local\Code\app-0.1.2\resources\app\client\vs\languages\json\jsonWorker.js
),该文件已缩小。这是原子美化https://atom.io/packages/atom-beautify的相关代码美化:
this.addPreloadedFileSchema("http://json.schemastore.org/tsconfig", {
title: n.localize("vs_languages_json_jsonSchemaService", 110),
$schema: "http://json-schema.org/draft-04/schema#",
type: "object",
default: {
compilerOptions: {
target: "ES5",
module: "commonjs"
}
},
properties: {
compilerOptions: {
type: "object",
description: n.localize("vs_languages_json_jsonSchemaService", 111),
properties: {
charset: {
description: n.localize("vs_languages_json_jsonSchemaService", 112),
type: "string"
},
declaration: {
description: n.localize("vs_languages_json_jsonSchemaService", 113),
type: "boolean"
},
diagnostics: {
description: n.localize("vs_languages_json_jsonSchemaService", 114),
type: "boolean"
},
emitBOM: {
description: n.localize("vs_languages_json_jsonSchemaService", 115),
type: "boolean"
},
inlineSourceMap: {
description: n.localize("vs_languages_json_jsonSchemaService", 116),
type: "number"
},
inlineSources: {
description: n.localize("vs_languages_json_jsonSchemaService", 117),
type: "number"
},
listFiles: {
description: n.localize("vs_languages_json_jsonSchemaService", 118),
type: "boolean"
},
locale: {
description: n.localize("vs_languages_json_jsonSchemaService", 119),
type: "string"
},
mapRoot: {
description: n.localize("vs_languages_json_jsonSchemaService", 120),
type: "string",
format: "uri"
},
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd"]
},
newLine: {
description: n.localize("vs_languages_json_jsonSchemaService", 122),
type: "boolean"
},
noEmit: {
description: n.localize("vs_languages_json_jsonSchemaService", 123),
type: "boolean"
},
noEmitOnError: {
description: n.localize("vs_languages_json_jsonSchemaService", 124),
type: "boolean"
},
noEmitHelpers: {
description: n.localize("vs_languages_json_jsonSchemaService", 125),
type: "boolean"
},
noImplicitAny: {
description: n.localize("vs_languages_json_jsonSchemaService", 126),
type: "boolean"
},
noLib: {
description: n.localize("vs_languages_json_jsonSchemaService", 127),
type: "boolean"
},
noResolve: {
type: "boolean"
},
out: {
description: n.localize("vs_languages_json_jsonSchemaService", 128),
type: "string",
format: "uri"
},
outDir: {
description: n.localize("vs_languages_json_jsonSchemaService", 129),
type: "string",
format: "uri"
},
preserveConstEnums: {
description: n.localize("vs_languages_json_jsonSchemaService", 130),
type: "boolean"
},
removeComments: {
description: n.localize("vs_languages_json_jsonSchemaService", 131),
type: "boolean"
},
rootDir: {
description: n.localize("vs_languages_json_jsonSchemaService", 132),
type: "boolean"
},
sourceMap: {
description: n.localize("vs_languages_json_jsonSchemaService", 133),
type: "boolean"
},
sourceRoot: {
description: n.localize("vs_languages_json_jsonSchemaService", 134),
type: "string",
format: "uri"
},
suppressImplicitAnyIndexErrors: {
description: n.localize("vs_languages_json_jsonSchemaService", 135),
type: "boolean"
},
target: {
description: n.localize("vs_languages_json_jsonSchemaService", 136),
enum: ["ES3", "ES5", "ES6", "es3", "es5", "es6"],
default: "ES3"
}
}
},
files: {
type: "array",
description: n.localize("vs_languages_json_jsonSchemaService", 137),
items: {
type: "string",
format: "uri"
}
}
}
})
并且更专注于:
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd"]
},
如果你改变它
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd", "umd", "system"]
},
然后重启 vs code 就可以了
请注意,在您美化 js 文件后,VS Code 仍然可以正常工作 ;)
- 我没有找到清除此类缓存的官方解决方案...但我认为命令 "Reload Window" 可以。
- "Changes to the schema file are not reflected" 是一个错误 https://github.com/Microsoft/vscode/issues/13897 ,已修复。但据我所知,它要求模式文件的名称以“.json”结尾,任何其他扩展名(例如我的情况下的“.schema”),甚至明确关联到 json 在设置中,不会触发刷新事件以使您的更改立即生效。
加载模式之前可以触发一个新命令:
JSON clear schema cache command
A new command JSON: Clear schema cache
clears the cache of previously
downloaded schemas.
await vscode.commands.executeCommand('json.clearCache');
我刚刚升级到 TypeScript 1.5(不再是测试版),在这样做的过程中,我想利用 VS Code 中的 json 模式助手。
配置 tsconfig.json 时,唯一的模块选项是 commonjs
和 amd
,这意味着缺少 umd
和 system
,基于此:http://json.schemastore.org/tsconfig
我的问题是如何让 VS Code 刷新它的模式缓存?
仅供参考,我尝试覆盖设置中的 URL 并将其改回并重新启动 VS Code
My questions is how do I get VS Code to refresh it's cache of the schema?
该架构实际上被硬编码在一个名为 jsonWorker.js
的文件中(我的文件路径是 C:\Users\basaratsyed\AppData\Local\Code\app-0.1.2\resources\app\client\vs\languages\json\jsonWorker.js
),该文件已缩小。这是原子美化https://atom.io/packages/atom-beautify的相关代码美化:
this.addPreloadedFileSchema("http://json.schemastore.org/tsconfig", {
title: n.localize("vs_languages_json_jsonSchemaService", 110),
$schema: "http://json-schema.org/draft-04/schema#",
type: "object",
default: {
compilerOptions: {
target: "ES5",
module: "commonjs"
}
},
properties: {
compilerOptions: {
type: "object",
description: n.localize("vs_languages_json_jsonSchemaService", 111),
properties: {
charset: {
description: n.localize("vs_languages_json_jsonSchemaService", 112),
type: "string"
},
declaration: {
description: n.localize("vs_languages_json_jsonSchemaService", 113),
type: "boolean"
},
diagnostics: {
description: n.localize("vs_languages_json_jsonSchemaService", 114),
type: "boolean"
},
emitBOM: {
description: n.localize("vs_languages_json_jsonSchemaService", 115),
type: "boolean"
},
inlineSourceMap: {
description: n.localize("vs_languages_json_jsonSchemaService", 116),
type: "number"
},
inlineSources: {
description: n.localize("vs_languages_json_jsonSchemaService", 117),
type: "number"
},
listFiles: {
description: n.localize("vs_languages_json_jsonSchemaService", 118),
type: "boolean"
},
locale: {
description: n.localize("vs_languages_json_jsonSchemaService", 119),
type: "string"
},
mapRoot: {
description: n.localize("vs_languages_json_jsonSchemaService", 120),
type: "string",
format: "uri"
},
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd"]
},
newLine: {
description: n.localize("vs_languages_json_jsonSchemaService", 122),
type: "boolean"
},
noEmit: {
description: n.localize("vs_languages_json_jsonSchemaService", 123),
type: "boolean"
},
noEmitOnError: {
description: n.localize("vs_languages_json_jsonSchemaService", 124),
type: "boolean"
},
noEmitHelpers: {
description: n.localize("vs_languages_json_jsonSchemaService", 125),
type: "boolean"
},
noImplicitAny: {
description: n.localize("vs_languages_json_jsonSchemaService", 126),
type: "boolean"
},
noLib: {
description: n.localize("vs_languages_json_jsonSchemaService", 127),
type: "boolean"
},
noResolve: {
type: "boolean"
},
out: {
description: n.localize("vs_languages_json_jsonSchemaService", 128),
type: "string",
format: "uri"
},
outDir: {
description: n.localize("vs_languages_json_jsonSchemaService", 129),
type: "string",
format: "uri"
},
preserveConstEnums: {
description: n.localize("vs_languages_json_jsonSchemaService", 130),
type: "boolean"
},
removeComments: {
description: n.localize("vs_languages_json_jsonSchemaService", 131),
type: "boolean"
},
rootDir: {
description: n.localize("vs_languages_json_jsonSchemaService", 132),
type: "boolean"
},
sourceMap: {
description: n.localize("vs_languages_json_jsonSchemaService", 133),
type: "boolean"
},
sourceRoot: {
description: n.localize("vs_languages_json_jsonSchemaService", 134),
type: "string",
format: "uri"
},
suppressImplicitAnyIndexErrors: {
description: n.localize("vs_languages_json_jsonSchemaService", 135),
type: "boolean"
},
target: {
description: n.localize("vs_languages_json_jsonSchemaService", 136),
enum: ["ES3", "ES5", "ES6", "es3", "es5", "es6"],
default: "ES3"
}
}
},
files: {
type: "array",
description: n.localize("vs_languages_json_jsonSchemaService", 137),
items: {
type: "string",
format: "uri"
}
}
}
})
并且更专注于:
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd"]
},
如果你改变它
module: {
description: n.localize("vs_languages_json_jsonSchemaService", 121),
enum: ["commonjs", "amd", "umd", "system"]
},
然后重启 vs code 就可以了
请注意,在您美化 js 文件后,VS Code 仍然可以正常工作 ;)
- 我没有找到清除此类缓存的官方解决方案...但我认为命令 "Reload Window" 可以。
- "Changes to the schema file are not reflected" 是一个错误 https://github.com/Microsoft/vscode/issues/13897 ,已修复。但据我所知,它要求模式文件的名称以“.json”结尾,任何其他扩展名(例如我的情况下的“.schema”),甚至明确关联到 json 在设置中,不会触发刷新事件以使您的更改立即生效。
加载模式之前可以触发一个新命令:
JSON clear schema cache command
A new command
JSON: Clear schema cache
clears the cache of previously downloaded schemas.
await vscode.commands.executeCommand('json.clearCache');