arrow-meta
arrow-meta copied to clipboard
Scopes for AST elements for the Quote System
We need to come up with a list of the entire set of AST elements and declarations that we want the user to be able to destructure with templates. Right now, we only have scopes for templates for classOrObject, func, property and type aliases.
The sole purpose of scopes is to provide template destructuring capabilities and all methods in their API should be related to rendering properties but not conditional logic or other type of operations that belong in the PSI and that we don’t have to worry about maintaining.
Every element of the KtElement hierarchy is worth restructuring with a template, which needs a Scope type. We want to make it easy to build nodes for the AST as quotes. Ideally, we should have one file per quote and that includes the public function and its scope.
List of AST elements completed
- [x] KtBinaryOperation #90
- [x] KtForExpression #120
- [x] KtLoopExpression #111
- [x] KtWhileExpression #121
- [x] KtLambdaExpression #122
- [x] KtFunctionLiteral #123
- [x] KtWhenEntry https://github.com/arrow-kt/arrow-meta/pull/139
- [x] KtWhenCondition https://github.com/arrow-kt/arrow-meta/pull/145
- [x] KtFinallySection https://github.com/arrow-kt/arrow-meta/pull/156
- [x] KtBlockExpression https://github.com/arrow-kt/arrow-meta/pull/154
- [x] KtCatchClause https://github.com/arrow-kt/arrow-meta/pull/152
- [x] KtIfExpression https://github.com/arrow-kt/arrow-meta/pull/135
- [x] KtWhenExpression https://github.com/arrow-kt/arrow-meta/pull/136
- [x] KtTryExpression https://github.com/arrow-kt/arrow-meta/pull/151
- [x] KtFinallySection https://github.com/arrow-kt/arrow-meta/pull/156
- [x] KtThrowExpression https://github.com/arrow-kt/arrow-meta/pull/162
- [x] KtIsExpression https://github.com/arrow-kt/arrow-meta/pull/164
- [x] KtReturnExpression https://github.com/arrow-kt/arrow-meta/pull/165
- [x] KtAnnotatedExpression https://github.com/arrow-kt/arrow-meta/pull/167
- [x] KtTypeElement #127
- [x] KtDestructuringDeclaration #176
- [x] KtValueArgument #183
- [x] KtParameterList https://github.com/arrow-kt/arrow-meta/pull/188
- [x] KtTypeReference #132
- [x] KtObjectDeclaration #133
- [x] KtImportDirective #182
- [x] KtModifierList https://github.com/arrow-kt/arrow-meta/pull/186
- [x] KtDotQualifiedExpression #298
- [x] KtThisExpression #325
- [x] KtClassBody https://github.com/arrow-kt/arrow-meta/pull/326
- [x] KtPackageDirective https://github.com/arrow-kt/arrow-meta/pull/336
- [ ] KtPropertyDelegate
- [ ] KtScript
- [ ] KtSimpleNameExpression
- [ ] KtEnumEntry
- [ ] KtDeclaration
- [ ] KtCallableReferenceExpression
- [ ] KtPrimaryConstructor
- [ ] KtStringTemplateExpression
- [ ] KtConstructorDelegationCall
- [ ] KtSuperTypeEntry
- [ ] KtSuperTypeCallEntry
- [ ] KtInitializerList
TODO Scopes for AST Elements
- ~~KtTypeElement~~
- KtFile
- KtBodyExpression
- ~~KtFunctionLiteral~~
- KtDestructuringDeclaration
- ~~KtTypeReference~~
- KtModifierList
- KtParameterList
Creating a PR for AST elements
There's a lot of elements, so we're in need of a system to keep track of all these PRs:
- Link your PR to the corresponding issue.
- We'll add the AST element you're writing and link the corresponding issue in the List of Elements section
- Label every PR & Issue with
AST-scope:
- On your PR, please copy and paste this markdown checklist below so that we can make sure we're doing the same thing for all AST elements!
### Checklist for [element]
- [ ] Added/replaced the inverse element in ElementScope
- [ ] Destructure and make available all methods related to rendering properties, but no logic
- [ ] Add documentation for element, including an example using all properties
- [ ] Testing added for validation to ensure all properties can be used as a commutative identity
Asides from the binary oper #90 one I'm working on, would it make sense to work with AST elements top-down? By that, I mean we start with block, call expression and so on
@raulraja made an excellent point about the system we create and thought it would make sense to add it to this ticket, from a discussion on the BinaryOper PR
I think the name for this quote and all other quotes should be
whatever the Psi element name is.
I think we should replace:
func -> namedFunction
bynaryOper -> binaryExpression
there are other function matches we can do like lambdas
and there are other binary expressions that are not operators for example any function flagged as infix