protected virtual string GetDescriptionForCompiledMethod(ICompiledMethodScope scope) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (scope.IsExtension) sb.Append("(" + StringResources.Get("CODE_COMPLETION_EXTENSION") + ") "); if (scope.IsStatic && !scope.IsGlobal) sb.Append("class "); if (scope.ReturnType == null) sb.Append("procedure "); else sb.Append("function "); Dictionary<string, string> generic_param_args = null; Dictionary<string, int> class_generic_table = new Dictionary<string, int>(); ParameterInfo[] pis = scope.CompiledMethod.GetParameters(); Type[] tt = scope.CompiledMethod.GetGenericArguments(); int gen_ind = 0; if (!scope.IsExtension) { sb.Append(GetShortTypeName(scope.CompiledMethod.DeclaringType)); int ind = 0; foreach (Type gen_arg in scope.CompiledMethod.DeclaringType.GetGenericArguments()) { if (gen_arg.IsGenericParameter) { if (generic_param_args == null) generic_param_args = new Dictionary<string, string>(); if (scope.GenericArgs != null && scope.GenericArgs.Count > ind) generic_param_args.Add(gen_arg.Name, scope.GenericArgs[ind]); } ind++; } } else { gen_ind = 1; generic_param_args = new Dictionary<string, string>(); for (int i = 0; i < pis.Length; i++) { if (i == 0 && scope.IsExtension) { Type[] class_generic_args = pis[i].ParameterType.GetGenericArguments(); for (int j = 0; j < class_generic_args.Length; j++) { if (!class_generic_table.ContainsKey(class_generic_args[i].Name)) class_generic_table.Add(class_generic_args[i].Name, j); if (scope.GenericArgs != null && scope.GenericArgs.Count > j) generic_param_args.Add(class_generic_args[i].Name, scope.GenericArgs[j]); } break; } } sb.Append(GetShortTypeName(scope.CompiledMethod.GetParameters()[0].ParameterType)); } if (scope.Name != "Invoke") { sb.Append("."); sb.Append(scope.Name); } if (scope.CompiledMethod.GetGenericArguments().Length > 0) { sb.Append('<'); for (int i = gen_ind; i < tt.Length; i++) { if (class_generic_table.ContainsKey(tt[i].Name)) { int ind = class_generic_table[tt[i].Name]; if (scope.GenericArgs != null && scope.GenericArgs.Count > ind) { sb.Append(scope.GenericArgs[ind]); generic_param_args.Add(tt[i].Name, scope.GenericArgs[ind]); } } else sb.Append(tt[i].Name); if (i < tt.Length - 1) sb.Append(','); } sb.Append('>'); } sb.Append('('); for (int i = 0; i < pis.Length; i++) { if (i == 0 && scope.IsExtension) continue; if (pis[i].ParameterType.IsByRef) sb.Append("var "); else if (is_params(pis[i])) sb.Append("params "); sb.Append(pis[i].Name); sb.Append(": "); string inst_type = null; if (!pis[i].ParameterType.IsByRef) { if (scope.GenericArgs != null) { inst_type = get_type_instance(pis[i].ParameterType, scope.GenericArgs, generic_param_args); } if (inst_type == null) sb.Append(GetShortTypeName(pis[i].ParameterType, false)); else sb.Append(inst_type); } else { Type t = pis[i].ParameterType.GetElementType(); if (scope.GenericArgs != null) { inst_type = get_type_instance(t, scope.GenericArgs, generic_param_args); } if (inst_type == null) sb.Append(GetShortTypeName(t, false)); else sb.Append(inst_type); } if (i < pis.Length - 1) sb.Append("; "); } sb.Append(')'); string ret_inst_type = null; if (scope.ReturnType != null) { if (scope.GenericArgs != null) { ret_inst_type = get_type_instance(scope.CompiledMethod.ReturnType, scope.GenericArgs, generic_param_args); } if (ret_inst_type == null) sb.Append(": " + GetFullTypeName((scope.ReturnType as ICompiledTypeScope).CompiledType, false)); else sb.Append(": " + ret_inst_type); } //if (scope.CompiledMethod.IsStatic) sb.Append("; static"); if (scope.CompiledMethod.IsVirtual) sb.Append("; virtual"); else if (scope.CompiledMethod.IsAbstract) sb.Append("; abstract"); //else if (scope.CompiledMethod.IsHideBySig) sb.Append("; reintroduce"); sb.Append(';'); return sb.ToString(); }
public virtual string GetShortTypeName(ICompiledMethodScope scope) { return GetShortTypeName(scope.CompiledMethod); }
protected override string GetDescriptionForCompiledMethod(ICompiledMethodScope scope) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(get_access_modifier(scope.AccessModifier)); if (scope.CompiledMethod.IsStatic) sb.Append("Shared "); else if (scope.CompiledMethod.IsVirtual) sb.Append("Overridable "); else if (scope.CompiledMethod.IsAbstract) sb.Append("MustOverride "); if (scope.ReturnType == null) sb.Append("Sub "); else sb.Append("Function "); //sb.Append(GetShortTypeName(scope.CompiledMethod.DeclaringType)); //sb.Append("."); sb.Append(scope.CompiledMethod.Name); sb.Append('('); ParameterInfo[] pis = scope.CompiledMethod.GetParameters(); for (int i = 0; i < pis.Length; i++) { if (pis[i].ParameterType.IsByRef) sb.Append("ByRef "); sb.Append(pis[i].Name); sb.Append(" As "); if (!pis[i].ParameterType.IsByRef) sb.Append(GetFullTypeName(pis[i].ParameterType)); else sb.Append(GetFullTypeName(pis[i].ParameterType.GetElementType())); if (i < pis.Length - 1) sb.Append(", "); } sb.Append(')'); if (scope.ReturnType != null) { sb.Append(" As " + GetSimpleDescription(scope.ReturnType)); } //else if (scope.CompiledMethod.IsHideBySig) sb.Append("; reintroduce"); return sb.ToString(); }