Replies: 3 comments 3 replies
-
Introduced 3 new SyntaxTree nodes for resource method call action
Since we have already allowed resource methods in object types in the parser and logged the error in @lochana-chathura @sameerajayasoma @hasithaa Kindly have a look at this |
Beta Was this translation helpful? Give feedback.
-
Implemented an inner class named BLangResourceMethodInvocation inside BLangInvocation to represent the resource method call action. /**
* @since 2201.2.0
*/
public static class BLangResourceMethodInvocation extends BLangInvocation implements ActionNode {
public boolean invokedInsideTransaction = false;
public List<BLangExpression> resourceAccessPathSegments;
public BLangExpression resourceAccessRestSegment;
@Override
public void accept(BLangNodeVisitor visitor) {
visitor.visit(this);
}
@Override
public <T> void accept(BLangNodeAnalyzer<T> analyzer, T props) {
analyzer.visit(this, props);
}
@Override
public <T, R> R apply(BLangNodeTransformer<T, R> modifier, T props) {
return modifier.transform(this, props);
}
} |
Beta Was this translation helpful? Give feedback.
-
Update on Removed /**
* @since 2201.2.0
*/
public static class BLangResourceMethodInvocation extends BLangInvocation implements ActionNode {
public boolean invokedInsideTransaction = false;
public List<BLangExpression> resourceAccessPathSegments;
@Override
public void accept(BLangNodeVisitor visitor) {
visitor.visit(this);
}
@Override
public <T> void accept(BLangNodeAnalyzer<T> analyzer, T props) {
analyzer.visit(this, props);
}
@Override
public <T, R> R apply(BLangNodeTransformer<T, R> modifier, T props) {
return modifier.transform(this, props);
}
} |
Beta Was this translation helpful? Give feedback.
-
Currently, resource methods are only allowed for service objects, with this feature resource methods will be permitted in client objects.
Syntax to call resource methods on clients (which will syntactically be an action)
Syntax change
Simplest form of resource method call action would be
Parts of the path can come from an expression rather than being compile-time known, by using square brackets (as in a mapping constructor):
The static type of
userId
must beint|string|float|boolean|decimal
Parameters can be specified:
Parameters can be named as usual:
The last segment of a path can be a spread:
... expression
: must be a subtype ofint|string|float|boolean|decimal[]
A method other than get can be specified using dot like this:
The method-name defaults to get if not specified. A missing arg-list is equivalent to an empty (); arguments get defaulted as usual.
New STNode needs to be introduced STResourceMethodCallActionNode
Probably Need to introduce a new BLangNode BLangResourceMethodInvocation
The client object constructor or client class needs to be able to define resource methods.
No syntax change is needed since resource methods are already allowed in object-cons and class-def for services.
Need to allow resource functions in a client class or object cons from the semantic analyzer.
The client object type needs to be able to include resource methods.
Syntax change
object-type-descriptor :=
object-type-quals object {
object-member-descriptor*
}
object-member-descriptor :=
object-field-descriptor
| method-decl
| remote-method-decl
| resource-method-decl
| object-type-inclusion
Constraints (we do not add resource methods to clients with full generality)
hierarchical client resource objects are not supported, i.e. resource methods of client objects are not allowed to return client objects.
there is no query concept: a single action will perform a single resource method call
Please add your thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions