diff --git a/pkg/service/expr.go b/pkg/service/expr.go index 0371eb5..2d93910 100644 --- a/pkg/service/expr.go +++ b/pkg/service/expr.go @@ -87,8 +87,13 @@ func handleSelectorExpr(expr ast.Expr) string { code := "" switch x := s.X.(type) { case *ast.Ident: - if isInMethod && x.Name == currentReceiverName { - code += "this->" + if isInMethod { + if x.Name == currentReceiverName { + code += "this" + } else { + code += handleIdentExpr(x) + } + code += "->" } else { code += handleIdentExpr(x) code += "." diff --git a/pkg/service/features/app.feature b/pkg/service/features/app.feature index 2b60f65..3643f42 100644 --- a/pkg/service/features/app.feature +++ b/pkg/service/features/app.feature @@ -161,3 +161,38 @@ this->x=1; this->x=this->y; } ``` + + Сценарий: Структура с вызовом метода и свойства другого объекта + * Исходник: +``` +package test + +type device struct { + x int +} + +func (d *device) doSomething() { + dev2.doSomethingElse() +} +func (d *device) doSomethingElse() { + dev2.x = 1 + d.x = dev2.x +} +``` + * Результат: +``` +class device { +public: + int x; + void doSomething(); + void doSomethingElse(); +}; +void device::doSomething() { +dev2->doSomethingElse(); +} +void device::doSomethingElse() { +dev2->x=1; +this->x=dev2->x; +} +``` +