已关闭
[Bug修复] 修复Decorator转换后的AST节点源码位置信息丢失问题 #9651
ElevenDuan创建于 3月26日关闭于 3月31日
openharmony_ci
3月26日 评论:
3月26日 评论:
感谢提交Issue!关于Issue的交互操作,请访问OpenHarmony社区支持命令清单。如果有问题,请联系 [@xucheng46](https://gitcode.com/xucheng46) [@gavin1012_hw](https://gitcode.com/gavin1012_hw) [@trubachevilya](https://gitcode.com/trubachevilya) [@vpukhov](https://gitcode.com/vpukhov) [@chernykhsergey](https://gitcode.com/chernykhsergey) [@zhuoli](https://gitcode.com/zhuoli) 。如果需要调整订阅PR、Issue的变更状态,请访问链接。
Thanks for submitting the issue. For more commands, please visit OpenHarmony Command List. If you have any questions, please refer to committer gitcode for help. If you need to change the subscription of a Pull Request or Issue, please visit the link.


3月26日 添加了label:waiting_for_assign
3月26日 关联了pull request:Fix decorator AST node source location
3月26日 修改了issue 的描述
3月26日 修改了issue 的描述
3月31日 关闭了 issue
3月31日 issue状态由 待办的 改变为 已完成
5月27日 issue类型由 任务 改变为 缺陷
问题描述
在处理TypeScript装饰器(Decorator)转换时,生成的AST节点缺少正确的源码位置信息(source location/range),这会导致:
修复内容
本次修改主要在
es2panda/parser/transformer/transformer.cpp和transformer.h中,为所有decorator相关的AST节点添加了正确的源码范围设置:主要修改点:
函数签名更新 - 为以下函数增加
originalNode参数:CreateReferenceIdentifier()- 添加ir::AstNode *originalNode参数CreateDecoratorTarget()- 添加const ir::AstNode *originalNode参数CreateClassPrototype()- 添加const ir::AstNode *originalNode参数CreateGetOwnPropertyDescriptorCall()- 添加const ir::AstNode *originalNode参数CreateDefinePropertyCall()- 添加const ir::AstNode *originalNode参数添加源码范围设置:
SetRangeRecursively()设置范围具体修改位置:
VisitClassDeclaration()- 为类装饰器的变量声明和赋值表达式设置范围CreateVariableDeclarationForDecorators()- 为方法装饰器和参数装饰器的变量声明设置范围CreateParamDecorators()- 为参数装饰器调用设置范围CreatePropertyDecorators()- 为属性装饰器调用设置范围CreateMethodDecorators()- 为方法装饰器调用设置范围CreateClassDecorators()- 为类装饰器调用设置范围影响范围
es2panda/parser/transformer/transformer.hes2panda/parser/transformer/transformer.cpp测试
修改后的测试用例预期输出已更新:
test-class-decorator-1-transformed-expected.txttest-class-decorator-2-transformed-expected.txttest-decorator-1-transformed-expected.txt关联信息