diff --git a/pkg/service/expr.go b/pkg/service/expr.go index 3a6860c..7653986 100644 --- a/pkg/service/expr.go +++ b/pkg/service/expr.go @@ -105,21 +105,14 @@ func handleSelectorExpr(s *ast.SelectorExpr) (code string) { switch x := s.X.(type) { case *ast.Ident: - if isInMethod { - if x.Name == currentReceiverName { - code += "this" - } else { - code += handleIdentExpr(x) - } - code += "->" + if isInMethod && x.Name == currentReceiverName { + code += "this" } else { code += handleIdentExpr(x) - code += "->" } - case *ast.SelectorExpr: - code += "this" code += "->" - code += handleIdentExpr(x.Sel) + case *ast.SelectorExpr: + code += handleSelectorExpr(x) code += "->" } code += handleIdentExpr(s.Sel) diff --git a/pkg/service/features/app.feature b/pkg/service/features/app.feature index 0c7dd4c..52c3681 100644 --- a/pkg/service/features/app.feature +++ b/pkg/service/features/app.feature @@ -260,6 +260,44 @@ public: void device::doSomething() { this->remote->doSomethingElse(); } +``` + + Сценарий: Вызов вложенных методов динамически созданного объекта + * Исходник: +``` +package test + +type device struct { +} + +func (d *device) doSomething() { + n := NewOther() + n.G.x() + n.G.x.x2.x3() +} +func main() { + n := NewOther() + n.G.x() + n.G.x.x2.x3() +} +``` + * Результат: +``` +class device { +public: + void doSomething(); +}; +void main(); +void device::doSomething() { +auto n=NewOther(); +n->G->x(); +n->G->x->x2->x3(); +} +void main() { +auto n=NewOther(); +n->G->x(); +n->G->x->x2->x3(); +} ``` Сценарий: Структура с вызовом методов со входящими и выходящими параметрами