Skip to content

How to use CommentProvider if language was create using createServicesForGrammar? #1453

Answered by msujew
Yokozuna59 asked this question in Q&A
Discussion options

You must be logged in to vote

You would use the createLangiumGrammarServices() method to get the grammar services and with that the grammar comment provider:

import { createLangiumGrammarServices } from 'langium/grammar';
const grammarServices = createLangiumGrammarServices(EmptyFileSystem);
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(grammarServices.documentation.CommentProvider.getComment(rule)).toBeDefined();
    });
});

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Yokozuna59
Comment options

@msujew
Comment options

Answer selected by Yokozuna59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants