From 4e8b01df03acc7a75933016ed28df90d24dc1e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Wed, 5 Sep 2012 09:45:30 +0200 Subject: [PATCH] [Completion] Fixed type 'overloads'. --- .../Completion/CompletionDataWrapper.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs b/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs index 5455faa85a..38d7f84a89 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs @@ -80,22 +80,25 @@ namespace ICSharpCode.NRefactory.CSharp.Completion result.Add (Factory.CreateLiteralCompletionData (alias)); } - - HashSet usedTypes = new HashSet (); + Dictionary usedTypes = new Dictionary (); public ICompletionData AddType(IType type, string shortType) { - if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) + if (type == null || string.IsNullOrEmpty(shortType)) return null; if (type.Name == "Void" && type.Namespace == "System") return null; - var def = type.GetDefinition (); - if (def != null && def.ParentAssembly != completion.ctx.CurrentAssembly && !def.IsBrowsable ()) + var def = type.GetDefinition(); + if (def != null && def.ParentAssembly != completion.ctx.CurrentAssembly && !def.IsBrowsable()) return null; - - usedTypes.Add(shortType); + ICompletionData usedType; + if (usedTypes.TryGetValue (shortType, out usedType)) { + usedType.AddOverload (Factory.CreateTypeCompletionData(type, shortType)); + return usedType; + } var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); + usedTypes[shortType] = iCompletionData; result.Add(iCompletionData); return iCompletionData; }