Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass JSDoc from parser rule to the generated interface #1673

Open
aabounegm opened this issue Sep 11, 2024 · 1 comment
Open

Pass JSDoc from parser rule to the generated interface #1673

aabounegm opened this issue Sep 11, 2024 · 1 comment

Comments

@aabounegm
Copy link
Member

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.

@aabounegm
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant