diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index c5b1dbeb1..dbc221caa 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -41,7 +41,7 @@ namespace CodeCompletion private List pending_is_pattern_vars = new List(); private static Compiler compiler; public static bool use_semantic_for_intellisense; - + private Dictionary method_call_cache = new Dictionary(); public SemanticOptions semantic_options = new SemanticOptions(); public DomSyntaxTreeVisitor(DomConverter converter) @@ -57,6 +57,7 @@ namespace CodeCompletion public void Convert(compilation_unit cu) { + method_call_cache.Clear(); try { cu.visit(this); @@ -3591,6 +3592,11 @@ namespace CodeCompletion public override void visit(method_call _method_call) { + if (method_call_cache.ContainsKey(_method_call)) + { + returned_scope = method_call_cache[_method_call]; + return; + } search_all = true; returned_scope = null; _method_call.dereferencing_value.visit(this); @@ -3603,6 +3609,7 @@ namespace CodeCompletion if (names.Length > 0 && names[0] is TypeScope) { returned_scope = names[0]; + method_call_cache.Add(_method_call, returned_scope); return; } foreach (SymScope ss in names) @@ -3717,6 +3724,7 @@ namespace CodeCompletion returned_scope = ss; } } + method_call_cache.Add(_method_call, returned_scope); cnst_val.prim_val = null; } diff --git a/CodeCompletion/ExpressionVisitor.cs b/CodeCompletion/ExpressionVisitor.cs index cf8642102..6f4e5aa23 100644 --- a/CodeCompletion/ExpressionVisitor.cs +++ b/CodeCompletion/ExpressionVisitor.cs @@ -30,6 +30,7 @@ namespace CodeCompletion internal bool mouse_hover = false; private DomSyntaxTreeVisitor stv = null; private SymScope[] selected_methods = null; + private Dictionary method_call_cache = new Dictionary(); public ExpressionVisitor(SymScope entry_scope, DomSyntaxTreeVisitor stv) { @@ -1144,6 +1145,11 @@ namespace CodeCompletion public override void visit(method_call _method_call) { returned_scopes.Clear(); + if (method_call_cache.ContainsKey(_method_call)) + { + returned_scope = method_call_cache[_method_call]; + return; + } search_all = true; _method_call.dereferencing_value.visit(this); search_all = false; @@ -1151,11 +1157,13 @@ namespace CodeCompletion if (names.Length > 0 && names[0] is ElementScope && (names[0] as ElementScope).sc is TypeScope && ((names[0] as ElementScope).sc as TypeScope).IsDelegate) { returned_scope = names[0]; + method_call_cache[_method_call] = returned_scope; return; } if (names.Length > 0 && names[0] is TypeScope) { returned_scope = new ElementScope(names[0]); + method_call_cache[_method_call] = returned_scope; return; } TypeScope obj = null; @@ -1252,6 +1260,7 @@ namespace CodeCompletion } else ret_tn = null;*/ } + method_call_cache[_method_call] = returned_scope; } public override void visit(pascal_set_constant _pascal_set_constant)