From dec79ad2f3f9dfea0839a4c4d2434b4fe3a4b07f Mon Sep 17 00:00:00 2001 From: Softonik Date: Wed, 14 Feb 2024 15:47:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=86=D0=B5=D0=BD=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D0=B9:=20=D0=92=D1=8B=D0=B7=D0=BE=D0=B2=20=D0=B2=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BC=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B4=D0=BE=D0=B2=20=D0=B4=D0=B8=D0=BD=D0=B0=D0=BC=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/expr.go | 15 ++++--------- pkg/service/features/app.feature | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) 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(); +} ``` Сценарий: Структура с вызовом методов со входящими и выходящими параметрами