本文整理汇总了TypeScript中first-mate.GrammarRegistry.grammarForScopeName方法的典型用法代码示例。如果您正苦于以下问题:TypeScript GrammarRegistry.grammarForScopeName方法的具体用法?TypeScript GrammarRegistry.grammarForScopeName怎么用?TypeScript GrammarRegistry.grammarForScopeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类first-mate.GrammarRegistry
的用法示例。
在下文中一共展示了GrammarRegistry.grammarForScopeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const tokenizeLineResult = grammar.tokenizeLine("Test String", null, false);
tokenizeLineResult.line;
tokenizeLineResult.tags;
tokenizeLineResult.tokens;
grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack);
grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack, false);
// Grammar Registry ===========================================================
// Event Subscription
subscription = registry.onDidAddGrammar(grammar => grammar.name);
subscription = registry.onDidUpdateGrammar(grammar => grammar.name);
// Managing Grammars
grammars = registry.getGrammars();
let potentialGrammar = registry.grammarForScopeName("scope.test");
if (potentialGrammar) grammar = potentialGrammar;
subscription = registry.addGrammar(grammar);
potentialGrammar = registry.removeGrammarForScopeName("scope.test");
grammar = registry.readGrammarSync("/test/path");
registry.readGrammar("/test/path", (error, grammar) => {
if (grammar) {
grammar.name;
} else {
if (error) error.name;
}
});