diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index b9c9847ea..640db83f2 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -313,7 +313,7 @@ namespace CodeCompletion meths = entry_scope.GetExtensionMethods(name, tright); foreach (ProcScope meth in meths) lst.Add(meth); - ProcScope ps = select_method(lst.ToArray(), tleft, tright, null, false, _bin_expr.left, _bin_expr.right); + ProcScope ps = select_method(lst.ToArray(), tleft, tright, null, false, null, _bin_expr.left, _bin_expr.right); if (ps != null) returned_scope = ps.return_type; else @@ -3174,13 +3174,19 @@ namespace CodeCompletion private SymScope[] selected_methods = null; private bool disable_lambda_compilation = false; - private ProcScope select_method(SymScope[] meths, TypeScope tleft, TypeScope tright, TypeScope obj, bool obj_instanced, params expression[] args) + private ProcScope select_method(SymScope[] meths, TypeScope tleft, TypeScope tright, TypeScope obj, bool obj_instanced, List arg_types, params expression[] args) { - List arg_types = new List(); + if (arg_types == null) + arg_types = new List(); List arg_types2 = new List(); SymScope[] saved_selected_methods = selected_methods; selected_methods = meths; - if (tleft != null || tright != null) + if (arg_types.Count > 0) + { + foreach (TypeScope ts in arg_types) + arg_types2.Add(ts); + } + else if (tleft != null || tright != null) { if (tleft != null) { @@ -3309,8 +3315,11 @@ namespace CodeCompletion { parameters.AddRange(_method_call.parameters.expressions); } - List lambda_types = new List(); - ProcScope ps = select_method(names, null, null, obj, obj_instanced, parameters.ToArray()); + List lambda_types = new List(); + List param_types = new List(); + ProcScope ps = select_method(names, null, null, obj, obj_instanced, param_types, parameters.ToArray()); + bool has_lambda = false; + if (_method_call.parameters != null && ps != null) for (int i = 0; i < _method_call.parameters.expressions.Count; i++) { @@ -3325,8 +3334,12 @@ namespace CodeCompletion e.visit(this); disable_lambda_compilation = tmp_disable_lambda_compilation; awaitedProcType = tmp_awaitedProcType; + has_lambda = true; + param_types[obj == null ? i : i + 1] = returned_scope; } } + if (has_lambda) + ps = select_method(names, null, null, obj, obj_instanced, param_types, parameters.ToArray()); returned_scopes.Clear(); if (ps != null) @@ -5367,6 +5380,7 @@ namespace CodeCompletion } SymScope tmp = cur_scope; cur_scope = ps; + TypeScope saved_return_type = ps.return_type; if (!disable_lambda_compilation) { if (awaitedProcType != null) @@ -5380,7 +5394,10 @@ namespace CodeCompletion statement_list sl = _function_lambda_definition.proc_body as statement_list; if (sl != null && sl.list.Count == 1 && sl.list[0] is assign && (sl.list[0] as assign).to is ident && ((sl.list[0] as assign).to as ident).name.ToLower() == "result") + { (sl.list[0] as assign).from.visit(this); + ps.return_type = returned_scope as TypeScope; + } else _function_lambda_definition.proc_body.visit(this); } @@ -5388,7 +5405,7 @@ namespace CodeCompletion cur_scope = tmp; if (_function_lambda_definition.usedkeyword == 2) ps.return_type = null; - else + else if (saved_return_type == ps.return_type) ps.return_type = new UnknownScope(new SymInfo("",SymbolKind.Class,""));// returned_scope as TypeScope; returned_scope = new ProcType(ps); } @@ -5545,6 +5562,16 @@ namespace CodeCompletion else visit(ttr.name); } + + public override void visit(diapason_expr_new _diapason_expr_new) + { + _diapason_expr_new.left.visit(this); + TypeScope ts = TypeTable.get_compiled_type(new SymInfo("IEnumerable`1", SymbolKind.Type, "System.Collections.Generic.IEnumerable`1"), typeof(IEnumerable<>)); + TypeScope elem_ts = returned_scope as TypeScope; + if (elem_ts != null) + ts = ts.GetInstance(new List() { elem_ts }); + returned_scope = ts; + } } } diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index c7caf9ba9..a0d8404ac 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -1994,5 +1994,17 @@ namespace CodeCompletion mc.dereferencing_value = new dot_node(new ident("Tuple"), new ident("Create")); mc.visit(this); } + + public override void visit(diapason_expr_new _diapason_expr_new) + { + _diapason_expr_new.left.visit(this); + TypeScope ts = TypeTable.get_compiled_type(new SymInfo("IEnumerable`1", SymbolKind.Type, "System.Collections.Generic.IEnumerable`1"), typeof(IEnumerable<>)); + TypeScope elem_ts = null; + if (returned_scope is ElementScope) + elem_ts = (returned_scope as ElementScope).sc as TypeScope; + if (elem_ts != null) + ts = ts.GetInstance(new List() { elem_ts }); + returned_scope = new ElementScope(ts); + } } } diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 66216d454..f0b02fd0f 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -2331,6 +2331,17 @@ namespace CodeCompletion if (this.template_parameters.Contains(inst_ts.name)) { exact = false; + if (ts.IsDelegate) + { + for (int j=0; j= 1 && Text[i - 1] == '.') + if (ch == '.' && i >= 1 && Text[i - 1] == '.' && tokens.Count == 0) end = true; else if (ch == '?' && i + 1 < Text.Length && Text[i + 1] != '.') end = true; diff --git a/TestSuite/intellisense_tests/dotdot1.pas b/TestSuite/intellisense_tests/dotdot1.pas new file mode 100644 index 000000000..17f40524b --- /dev/null +++ b/TestSuite/intellisense_tests/dotdot1.pas @@ -0,0 +1,4 @@ +begin + var s{@var s: sequence of integer;@} := 1..4; + var s2{@var s2: sequence of char;@} := '1'..'4'; +end. \ No newline at end of file