From 2d6dc82dda5d94d230505dd366d4ecb5e85409dc 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, 7 Jan 2018 17:27:56 +0100 Subject: [PATCH] bug fix #631 --- CodeCompletion/DomSyntaxTreeVisitor.cs | 8 ++-- CodeCompletion/ExpressionVisitor.cs | 5 +++ CodeCompletion/SymTable.cs | 2 + .../intellisense_tests/extensionmethods5.pas | 37 +++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 TestSuite/intellisense_tests/extensionmethods5.pas diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 86512dcb4..6c1ea2f19 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -1005,7 +1005,7 @@ namespace CodeCompletion ps = new ProcScope(meth_name, topScope); ps.head_loc = loc; bool ext = false; - if (topScope is CompiledScope || topScope is ArrayScope || topScope is TypeSynonim && ((topScope as TypeSynonim).actType is CompiledScope || (topScope as TypeSynonim).actType is ArrayScope || (topScope as TypeSynonim).actType is DiapasonScope)) + if (topScope is CompiledScope || topScope is ArrayScope || topScope is TypeSynonim /*&& ((topScope as TypeSynonim).actType is CompiledScope || (topScope as TypeSynonim).actType is ArrayScope || (topScope as TypeSynonim).actType is DiapasonScope)*/) ext = true; else if (!(topScope is TypeSynonim) && !(topScope is PointerScope) && !(topScope is SetScope) && !(topScope is FileScope)) ext = true; @@ -1019,7 +1019,7 @@ namespace CodeCompletion if (topScope is TypeSynonim) ts = (ts as TypeSynonim).actType; this.entry_scope.AddExtensionMethod(meth_name, ps, ts); - topScope.AddExtensionMethod(meth_name, ps, ts); + ts.AddExtensionMethod(meth_name, ps, ts); } } //while (ps != null && ps.already_defined) ps = ps.nextProc; @@ -1307,7 +1307,7 @@ namespace CodeCompletion ps.head_loc = loc; bool ext = false; - if (topScope is CompiledScope || topScope is ArrayScope || topScope is TypeSynonim && ((topScope as TypeSynonim).actType is CompiledScope || (topScope as TypeSynonim).actType is ArrayScope || (topScope as TypeSynonim).actType is DiapasonScope)) + if (topScope is CompiledScope || topScope is ArrayScope || topScope is TypeSynonim /*&& ((topScope as TypeSynonim).actType is CompiledScope || (topScope as TypeSynonim).actType is ArrayScope || (topScope as TypeSynonim).actType is DiapasonScope)*/) ext = true; else if (!(topScope is TypeSynonim) && !(topScope is PointerScope) && !(topScope is SetScope) && !(topScope is FileScope)) ext = true; @@ -1321,7 +1321,7 @@ namespace CodeCompletion if (topScope is TypeSynonim) ts = (ts as TypeSynonim).actType; this.entry_scope.AddExtensionMethod(meth_name, ps, ts); - topScope.AddExtensionMethod(meth_name, ps, ts); + ts.AddExtensionMethod(meth_name, ps, ts); } } else diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index 44f759e2a..434e6466a 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -931,6 +931,11 @@ namespace CodeCompletion { for (int i = 0; i < good_procs.Count; i++) { + if (good_procs[i].parameters.Count == 0) + { + ind = i; + break; + } TypeScope param_type = good_procs[i].parameters[0].sc as TypeScope; if (param_type.original_type != null) param_type = param_type.original_type; diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index fe0043eba..2ef6cb36e 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -367,6 +367,8 @@ namespace CodeCompletion public List GetExtensionMethods(TypeScope ts) { + if (ts is TypeSynonim) + return GetExtensionMethods((ts as TypeSynonim).actType); List lst = new List(); List meths = null; TypeScope tmp_ts = ts; diff --git a/TestSuite/intellisense_tests/extensionmethods5.pas b/TestSuite/intellisense_tests/extensionmethods5.pas new file mode 100644 index 000000000..529872cf0 --- /dev/null +++ b/TestSuite/intellisense_tests/extensionmethods5.pas @@ -0,0 +1,37 @@ +type TClass = class +procedure Test2; +end; + +type TClass2 = TClass; + +procedure TClass2.Test; +begin + +end; + +function TClass2.Test3: integer; +begin + +end; + +procedure TClass.Test2; +begin + +end; + +type myarr = array of integer; + +procedure MyProc(self: myarr); extensionmethod; +begin + +end; + +begin + var o: TClass2; + var o2: TClass; + o.Test{@(расширение) procedure TClass2.Test();@}(); + o2.Test{@(расширение) procedure TClass2.Test();@}(); + o.Test3{@(расширение) function TClass2.Test3(): integer;@}(); + var arr1 := new integer[10]; + arr1.MyProc{@(расширение) procedure myarr.MyProc();@}(); +end. \ No newline at end of file