An alternative for Ballerina Shell type signature generation #28375
kdsuneraavinash
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
I think we should probably provide two separate methods for this. Maybe change the behaviour of the current |
Beta Was this translation helpful? Give feedback.
1 reply
-
After a further chat with @nadeeshaan @rasika and @kdsuneraavinash, decided not to go through with this change for now since the use cases for the shell are manageable with the current |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
For Ballerina Shell, currently is follows an approach where each code snippet is wrapped (with generated Ballerina code) before compiled. However, this wrapper includes a cast statement for previously defined var-dclns. (eg:
Type v = <Type> load("x")
So, the variable type should be "writable", in the sense that the variable name should be generatable to be a valid code segment.
However, the issue is with
var
types. If the variable is defined usingvar
, an approach is to get itsTypeSymbol
using semantic API and use thesignature()
method to generate the type signature. But if theTypeSymbol
is an imported type, this approach will not work, because currently, the type signature will return something of formatabc/pqr:1.0:Type
which is not a valid syntax that can be included in a code segment.So the current implementation of the shell has a
TypeSignatureTransformer
which does exactly what thesignature()
does, but converts theErrorTypeSymbols
andTypeReferenceTypeSymbols
so that they will use imported module names correctly. Is there a way to reduce this code duplication, because in the end,TypeSignatureTransformer
only needs to convert the said 2 types in a custom way, all others have to follow the same logic assignature()
?There is also a PR to use the
signature()
but replace imported names from the generated string, but I'm not sure that is the best approach. #28301Any thoughts or ideas would be great.
Beta Was this translation helpful? Give feedback.
All reactions