Browse Source

[Completion] Fixed type 'overloads'.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
4e8b01df03
  1. 17
      ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs

17
ICSharpCode.NRefactory.CSharp/Completion/CompletionDataWrapper.cs

@ -80,22 +80,25 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
result.Add (Factory.CreateLiteralCompletionData (alias)); result.Add (Factory.CreateLiteralCompletionData (alias));
} }
Dictionary<string, ICompletionData> usedTypes = new Dictionary<string, ICompletionData> ();
HashSet<string> usedTypes = new HashSet<string> ();
public ICompletionData AddType(IType type, string shortType) public ICompletionData AddType(IType type, string shortType)
{ {
if (type == null || string.IsNullOrEmpty(shortType) || usedTypes.Contains(shortType)) if (type == null || string.IsNullOrEmpty(shortType))
return null; return null;
if (type.Name == "Void" && type.Namespace == "System") if (type.Name == "Void" && type.Namespace == "System")
return null; return null;
var def = type.GetDefinition (); var def = type.GetDefinition();
if (def != null && def.ParentAssembly != completion.ctx.CurrentAssembly && !def.IsBrowsable ()) if (def != null && def.ParentAssembly != completion.ctx.CurrentAssembly && !def.IsBrowsable())
return null; return null;
ICompletionData usedType;
usedTypes.Add(shortType); if (usedTypes.TryGetValue (shortType, out usedType)) {
usedType.AddOverload (Factory.CreateTypeCompletionData(type, shortType));
return usedType;
}
var iCompletionData = Factory.CreateTypeCompletionData(type, shortType); var iCompletionData = Factory.CreateTypeCompletionData(type, shortType);
usedTypes[shortType] = iCompletionData;
result.Add(iCompletionData); result.Add(iCompletionData);
return iCompletionData; return iCompletionData;
} }

Loading…
Cancel
Save