提交 0ec0abe7 编写于 作者: J Johannes Rieken

better fix for #60188

上级 f255d103
......@@ -31,7 +31,7 @@ import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/comm
import { isFalsyOrEmpty } from 'vs/base/common/arrays';
import { IRange, Range } from 'vs/editor/common/core/range';
namespace ext {
namespace snippetExt {
export interface ISnippetsExtensionPoint {
language: string;
......@@ -110,11 +110,7 @@ namespace ext {
}
};
export let snippetExtensions: ReadonlyArray<IExtensionPointUser<ISnippetsExtensionPoint[]>> = [];
ExtensionsRegistry.registerExtensionPoint<ext.ISnippetsExtensionPoint[]>('snippets', [languagesExtPoint], ext.snippetsContribution).setHandler(extensions => {
snippetExtensions = snippetExtensions.concat(extensions);
});
export const point = ExtensionsRegistry.registerExtensionPoint<snippetExt.ISnippetsExtensionPoint[]>('snippets', [languagesExtPoint], snippetExt.snippetsContribution);
}
function watch(service: IFileService, resource: URI, callback: (type: FileChangeType, resource: URI) => any): IDisposable {
......@@ -203,43 +199,45 @@ class SnippetsService implements ISnippetsService {
// --- loading, watching
private _initExtensionSnippets(): void {
for (const extension of ext.snippetExtensions) {
for (const contribution of extension.value) {
const validContribution = ext.toValidSnippet(extension, contribution, this._modeService);
if (!validContribution) {
continue;
}
if (this._files.has(validContribution.location.toString())) {
this._files.get(validContribution.location.toString()).defaultScopes.push(validContribution.language);
} else {
const file = new SnippetFile(SnippetSource.Extension, validContribution.location, validContribution.language ? [validContribution.language] : undefined, extension.description, this._fileService);
this._files.set(file.location.toString(), file);
snippetExt.point.setHandler(extensions => {
for (const extension of extensions) {
for (const contribution of extension.value) {
const validContribution = snippetExt.toValidSnippet(extension, contribution, this._modeService);
if (!validContribution) {
continue;
}
if (this._environmentService.isExtensionDevelopment) {
file.load().then(file => {
// warn about bad tabstop/variable usage
if (file.data.some(snippet => snippet.isBogous)) {
if (this._files.has(validContribution.location.toString())) {
this._files.get(validContribution.location.toString()).defaultScopes.push(validContribution.language);
} else {
const file = new SnippetFile(SnippetSource.Extension, validContribution.location, validContribution.language ? [validContribution.language] : undefined, extension.description, this._fileService);
this._files.set(file.location.toString(), file);
if (this._environmentService.isExtensionDevelopment) {
file.load().then(file => {
// warn about bad tabstop/variable usage
if (file.data.some(snippet => snippet.isBogous)) {
extension.collector.warn(localize(
'badVariableUse',
"One or more snippets from the extension '{0}' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)",
extension.description.name
));
}
}, err => {
// generic error
extension.collector.warn(localize(
'badVariableUse',
"One or more snippets from the extension '{0}' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)",
extension.description.name
'badFile',
"The snippet file \"{0}\" could not be read.",
file.location.toString()
));
}
}, err => {
// generic error
extension.collector.warn(localize(
'badFile',
"The snippet file \"{0}\" could not be read.",
file.location.toString()
));
});
}
});
}
}
}
}
}
});
}
private _initWorkspaceSnippets(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册