提交 d24404ee 编写于 作者: M Martin Aeschlimann

Do not use exceptions for missing grammars. Fixes #52692

上级 1f79465e
......@@ -25,6 +25,7 @@ import { Color } from 'vs/base/common/color';
import { INotificationService } from 'vs/platform/notification/common/notification';
import URI from 'vs/base/common/uri';
import { IFileService } from 'vs/platform/files/common/files';
import { ILogService } from 'vs/platform/log/common/log';
export class TMScopeRegistry {
......@@ -139,6 +140,7 @@ export class TextMateService implements ITextMateService {
private _modeService: IModeService;
private _themeService: IWorkbenchThemeService;
private _fileService: IFileService;
private _logService: ILogService;
private _scopeRegistry: TMScopeRegistry;
private _injections: { [scopeName: string]: string[]; };
private _injectedEmbeddedLanguages: { [scopeName: string]: IEmbeddedLanguagesMap[]; };
......@@ -155,13 +157,15 @@ export class TextMateService implements ITextMateService {
@IModeService modeService: IModeService,
@IWorkbenchThemeService themeService: IWorkbenchThemeService,
@IFileService fileService: IFileService,
@INotificationService notificationService: INotificationService
@INotificationService notificationService: INotificationService,
@ILogService logService: ILogService
) {
this._styleElement = dom.createStyleSheet();
this._styleElement.className = 'vscode-tokens-styles';
this._modeService = modeService;
this._themeService = themeService;
this._fileService = fileService;
this._logService = logService;
this._scopeRegistry = new TMScopeRegistry();
this.onDidEncounterLanguage = this._scopeRegistry.onDidEncounterLanguage;
this._injections = {};
......@@ -212,10 +216,14 @@ export class TextMateService implements ITextMateService {
loadGrammar: (scopeName: string) => {
const location = this._scopeRegistry.getGrammarLocation(scopeName);
if (!location) {
this._logService.info(`No grammar found for scope ${scopeName}`);
return null;
}
return this._fileService.resolveContent(location).then(content => {
return parseRawGrammar(content.value, location.path);
}, e => {
this._logService.error(`Unable to load and parse grammar for scope ${scopeName} from ${location}`, e);
return null;
});
},
getInjections: (scopeName: string) => {
......
......@@ -1798,7 +1798,7 @@ fast-levenshtein@~2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
fast-plist@0.1.2, fast-plist@^0.1.2:
fast-plist@0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/fast-plist/-/fast-plist-0.1.2.tgz#a45aff345196006d406ca6cdcd05f69051ef35b8"
......@@ -6250,11 +6250,10 @@ vscode-ripgrep@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-1.0.1.tgz#eff2f2b2a49921ac0acd3ff8dfecaaeebf0184cf"
vscode-textmate@^4.0.0-next.2:
version "4.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.0.0-next.2.tgz#03b6c1feb7d297cb70e24cc1166ce2d5c619e440"
vscode-textmate@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.0.1.tgz#6c36f28e9059ce12bc34907f7a33ea43166b26a8"
dependencies:
fast-plist "^0.1.2"
oniguruma "^7.0.0"
vscode-xterm@3.5.0-beta17:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册