diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-11-01 19:38:19 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-11-01 19:38:19 +0400 |
commit | fc54ca49eda7af3e9c119256a3b583d03816e103 (patch) | |
tree | e38df967a524380971dd5f427c3dc8f34ed8e13c /main/src/addins/CSharpBinding | |
parent | b76a847951d2123975c6b402ec4d4b78914fb85a (diff) |
Fixed "Bug 1747 - [New Resolver] Code completion issues when declaring
a generic dictionary" (reopened).
Diffstat (limited to 'main/src/addins/CSharpBinding')
3 files changed, 66 insertions, 9 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/ConstructorParameterDataProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/ConstructorParameterDataProvider.cs index 7e8e840d3f..6d2d365e79 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/ConstructorParameterDataProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/ConstructorParameterDataProvider.cs @@ -25,18 +25,26 @@ // THE SOFTWARE. using System; using ICSharpCode.NRefactory.TypeSystem; +using MonoDevelop.TypeSystem; namespace MonoDevelop.CSharp.Completion { public class ConstructorParameterDataProvider : MethodParameterDataProvider { + IType type; + public ConstructorParameterDataProvider (CSharpCompletionTextEditorExtension ext, IType type) : base (ext) { + this.type = type; foreach (var method in type.GetConstructors (ext.ctx, m => m.IsPublic)) { methods.Add (method); } - - + } + + protected override string GetPrefix (IMethod method) + { + var flags = OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.IncludeGenerics; + return ambience.GetString (ext.ctx, type, flags) + "."; } } } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MethodParameterDataProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MethodParameterDataProvider.cs index 3320dc3848..4deb4e298c 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MethodParameterDataProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/MethodParameterDataProvider.cs @@ -192,6 +192,11 @@ namespace MonoDevelop.CSharp.Completion #region IParameterDataProvider implementation + protected virtual string GetPrefix (IMethod method) + { + var flags = OutputFlags.ClassBrowserEntries | OutputFlags.IncludeMarkup | OutputFlags.IncludeGenerics; + return ambience.GetString (ext.ctx, method.ReturnType, flags) + " "; + } public string GetMethodMarkup (int overload, string[] parameterMarkup, int currentParameter) { @@ -201,11 +206,11 @@ namespace MonoDevelop.CSharp.Completion var m = methods [overload]; - string name = m.Name; //(this.delegateName ?? (methods [overload].IsConstructor ? ambience.GetString (methods [overload].DeclaringType, flags) : methods [overload].Name)); + string name = m.EntityType == EntityType.Constructor || m.EntityType == EntityType.Destructor ? m.DeclaringType.Name : m.Name; var parameters = new StringBuilder (); int curLen = 0; - string prefix = !m.IsConstructor ? ambience.GetString (ext.ctx, m.ReturnType, flags) + " " : ""; - + string prefix = GetPrefix (m); + foreach (string parameter in parameterMarkup) { if (parameters.Length > 0) parameters.Append (", "); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs index c9962a5693..16d54f2dc7 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpAmbience.cs @@ -370,10 +370,49 @@ namespace MonoDevelop.CSharp return sb.ToString (); } - protected override string GetTypeString (ITypeDefinition type, OutputSettings settings) + protected override string GetTypeString (IType t, OutputSettings settings) { + ITypeDefinition type = t.GetDefinition (); if (type == null) return ""; + + if (type.Namespace == "System" && type.TypeParameterCount == 0) { + switch (type.Name) { + case "Object": + return "object"; + case "Boolean": + return "bool"; + case "Char": + return "char"; + case "SByte": + return "sbyte"; + case "Byte": + return "byte"; + case "Int16": + return "short"; + case "UInt16": + return "ushort"; + case "Int32": + return "int"; + case "UInt32": + return "uint"; + case "Int64": + return "long"; + case "UInt64": + return "ulong"; + case "Single": + return "float"; + case "Double": + return "double"; + case "Decimal": + return "decimal"; + case "String": + return "string"; + case "Void": + return "void"; + } + } + // output anonymous type if (type.IsSynthetic && type.Name == "$Anonymous$") return GetTypeReferenceString (type, settings); @@ -411,13 +450,18 @@ namespace MonoDevelop.CSharp if (i > 0) result.Append (settings.Markup (settings.HideGenericParameterNames ? "," : ", ")); if (!settings.HideGenericParameterNames) { - result.Append (NetToCSharpTypeName (type.TypeParameters [i].FullName)); + if (t is ParameterizedType) { + result.Append (GetString (((ParameterizedType)t).TypeArguments [i], settings)); + + } else { + result.Append (NetToCSharpTypeName (type.TypeParameters [i].FullName)); + } } } result.Append (settings.Markup (">")); } - if (type.IsDelegate () && settings.ReformatDelegates) { + if (t.Kind == TypeKind.Delegate && settings.ReformatDelegates) { // var policy = GetPolicy (settings); // if (policy.BeforeMethodCallParentheses) // result.Append (settings.Markup (" ")); @@ -497,7 +541,7 @@ namespace MonoDevelop.CSharp protected override string GetMethodString (IMethod method, OutputSettings settings) { - return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.Name))), true); + return InternalGetMethodString (method, settings, settings.EmitName (method, Format (FilterName (method.EntityType == EntityType.Constructor || method.EntityType == EntityType.Destructor ? method.DeclaringType.Name : method.Name))), true); } protected override string GetConstructorString (IMethod method, OutputSettings settings) |