eclipse-langium/langium

Pass JSDoc from parser rule to the generated interface

Opened this issue · 1 comments

It would be great if the JSDoc comments above parser rules in grammar files are forwarded to the respective generated AST interface to improve IntelliSense when using that AST node type.
For example, if I write

/** A human being who has a name */
Person:
    'person' name=ID;

I would like generated/ast.ts to have:

/** A human being who has a name */
export interface Person extends AstNode {
    name: string;
}

It would also be nice if this can be extended to properties as well.

I tried to implement this myself using the CommentProvider, but I got stuck while trying to integrate it in collectInferredTypes

for (const rule of parserRules) {
allTypes.push(...getRuleTypes(context, rule));
}
const interfaces = calculateInterfaces(allTypes);

I am not sure how to associate the comment on the rule with the interface returned by calculateInterfaces