From 10ac29f6bcf5323e6c106d2116d8cd33f54d4d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 19 Feb 2017 14:55:34 +0100 Subject: [PATCH] intellisense: type inference for delegates --- CodeCompletion/DomSyntaxTreeVisitor.cs | 93 ++++++++++++--------- TestSuite/intellisense_tests/delegates1.pas | 8 ++ 2 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 TestSuite/intellisense_tests/delegates1.pas diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 6240c4ed1..17606d33e 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -314,15 +314,15 @@ namespace CodeCompletion public override void visit(ident _ident) { - if (!search_all) - { - returned_scope = cur_scope.FindName(_ident.name); - if (returned_scope == null) - { - //cnst_val.prim_val = _ident.name; - cnst_val.prim_val = null; - return; - } + if (!search_all) + { + returned_scope = cur_scope.FindName(_ident.name); + if (returned_scope == null) + { + //cnst_val.prim_val = _ident.name; + cnst_val.prim_val = null; + return; + } if (returned_scope is ElementScope) { cnst_val.prim_val = (returned_scope as ElementScope).cnst_val; @@ -331,41 +331,52 @@ namespace CodeCompletion } else if (returned_scope is ProcScope) - { - if ((returned_scope as ProcScope).parameters.Count == 0) + { + if ((returned_scope as ProcScope).parameters.Count == 0) + { + if ((returned_scope as ProcScope).return_type != null) returned_scope = (returned_scope as ProcScope).return_type; else - { - returned_scopes = cur_scope.FindOverloadNames(_ident.name); - returned_scope = returned_scopes.Find(x => x is ProcScope && (x as ProcScope).parameters.Count == 0); - if (returned_scope == null) - returned_scope = returned_scopes[0]; - } + returned_scope = new ProcType(returned_scope as ProcScope); } - else if (returned_scope is TypeScope) + else + { + returned_scopes = cur_scope.FindOverloadNames(_ident.name); + returned_scope = returned_scopes.Find(x => x is ProcScope && (x as ProcScope).parameters.Count == 0); + if (returned_scope == null) + { + returned_scope = returned_scopes[0]; + if (returned_scope is ProcScope && (returned_scope as ProcScope).return_type == null ) + returned_scope = new ProcType(returned_scope as ProcScope); + } + else if (returned_scopes.Count > 0 && returned_scopes[0] is ProcScope && (returned_scopes[0] as ProcScope).return_type == null) + returned_scope = new ProcType(returned_scopes[0] as ProcScope); + } + } + else if (returned_scope is TypeScope) + is_type = true; + } + else + { + returned_scopes = cur_scope.FindOverloadNames(_ident.name); + for (int i = 0; i < returned_scopes.Count; i++) + { + if (returned_scopes[i] is ElementScope) + { + cnst_val.prim_val = (returned_scopes[i] as ElementScope).cnst_val; + returned_scope = (returned_scopes[i] as ElementScope).sc; + returned_scopes[i] = returned_scope; + return; + } + else + if (returned_scopes[i] is TypeScope) + { is_type = true; - } - else - { - returned_scopes = cur_scope.FindOverloadNames(_ident.name); - for (int i=0; i