-
Notifications
You must be signed in to change notification settings - Fork 47
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
Feature: AST annotations #234
Feature: AST annotations #234
Conversation
- any statement can receive multiple annotations - annotations can have arguments - annotations have a method to obtain JS-friendly types
simply marvellous. I will put this to good use. Thanks @elsassph |
src/parser/Parser.ts
Outdated
@@ -246,6 +252,11 @@ export class Parser { | |||
) { | |||
let dec = this.declaration(); | |||
if (dec) { | |||
//attach annotations to statements | |||
if (this.pendingAnnotations.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be this.pendingAnnotations.length > 0
?
@@ -2503,11 +2540,11 @@ function createReferences(): References { | |||
export interface References { | |||
assignmentStatements: AssignmentStatement[]; | |||
classStatements: ClassStatement[]; | |||
namespaceStatements: NamespaceStatement[]; | |||
functionStatements: FunctionStatement[]; | |||
functionExpressions: FunctionExpression[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're ordering these alphabetically, might as well swap functionStatements
and functionExpressions
too.
@elsassph this looks great. As soon as you address this comment I'll be ready to merge. |
Annotations are metadata expressions attached to AST statements.
sub
,while
...),annotation.getArguments()
); basic types, arrays and roAssocArrays are converted.Limitation:
Example:
A plugin can explore the AST and look at the annotations: