How to use CommentProvider
if language was create using createServicesForGrammar
?
#1453
-
Hi there, I'm currently trying to create a sample grammar for a test case that has JSDoc using it('should handle grammar with one greedy rule', async () => {
const grammar = `
grammar Test
/** Rule */
entry Rule: 'rule' num=INT;
/** INT */
terminal INT: /\\d+/;
`;
const services = await createServicesForGrammar({ grammar });
services.Grammar.rules.forEach((rule) => {
expect(services.documentation.CommentProvider.getComment(rule)).toBeDefined();
});
}); The above code fails because the Is this expected? It's working fine if I created the language using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @Yokozuna59, you're asking the language specific service for comments on the grammar language. You need to ask the grammar service explicitly if you want to get comments for grammars. Similarly, the language specific comment provider only works for the language in question, i.e. the Note that the |
Beta Was this translation helpful? Give feedback.
You would use the
createLangiumGrammarServices()
method to get the grammar services and with that the grammar comment provider: