This commit is contained in:
Ivan Bondarev 2022-10-30 12:22:57 +01:00
parent 930c1a6074
commit f4689e58d0

View file

@ -474,12 +474,16 @@ namespace PascalABCCompiler.Parsers
else if (ctn.Name.Contains("Tuple`"))
return get_tuple_string(ctn);
}
if (ctn.Name.Contains("`"))
int gen_pos = ctn.Name.IndexOf("`");
if (gen_pos != -1 || ctn.IsGenericType)
{
int len = ctn.GetGenericArguments().Length;
Type[] gen_ps = ctn.GetGenericArguments();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(ctn.Namespace + "." + ctn.Name.Substring(0, ctn.Name.IndexOf('`')));
if (gen_pos != -1)
sb.Append(ctn.Namespace + "." + ctn.Name.Substring(0, gen_pos));
else
sb.Append(ctn.Namespace + "." + ctn.Name);
sb.Append('<');
for (int i = 0; i < len; i++)
{
@ -619,10 +623,14 @@ namespace PascalABCCompiler.Parsers
line = get_line_nr(sb);
col = 1;
}
sb.Append(" ");
int ind = t.Name.IndexOf('`');
if (ind != -1)
if (ind != -1 || t.IsGenericType)
{
if (ind != -1)
sb.Append(prepare_member_name(t.Name.Substring(0, ind)));
else
sb.Append(t.Name);
sb.Append('<');
Type[] gen_args = t.GetGenericArguments();
for (int i = 0; i < gen_args.Length; i++)
@ -671,7 +679,7 @@ namespace PascalABCCompiler.Parsers
FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (fields.Length > 0)
{
sb.AppendLine("{$region " + StringResources.Get("CODE_COMPLETION_FIELDS") + "}");
sb.AppendLine(" {$region " + StringResources.Get("CODE_COMPLETION_FIELDS") + "}");
for (int i = 0; i < fields.Length; i++)
{
if (fields[i].DeclaringType == t && !fields[i].IsPrivate && !fields[i].IsAssembly)
@ -698,13 +706,13 @@ namespace PascalABCCompiler.Parsers
sb.AppendLine(); ln++;
}
}
sb.AppendLine("{$endregion}");
sb.AppendLine(" {$endregion}");
sb.AppendLine();
}
EventInfo[] events = t.GetEvents(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (events.Length > 0)
{
sb.AppendLine("{$region " + StringResources.Get("CODE_COMPLETION_EVENTS") + "}");
sb.AppendLine(" {$region " + StringResources.Get("CODE_COMPLETION_EVENTS") + "}");
for (int i = 0; i < events.Length; i++)
{
if (events[i].DeclaringType != t)
@ -734,13 +742,13 @@ namespace PascalABCCompiler.Parsers
sb.AppendLine(); ln++;
}
}
sb.AppendLine("{$endregion}");
sb.AppendLine(" {$endregion}");
sb.AppendLine();
}
PropertyInfo[] props = t.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (props.Length > 0)
{
sb.AppendLine("{$region " + StringResources.Get("CODE_COMPLETION_PROPERTIES") + "}");
sb.AppendLine(" {$region " + StringResources.Get("CODE_COMPLETION_PROPERTIES") + "}");
for (int i = 0; i < props.Length; i++)
{
if (props[i].DeclaringType != t)
@ -764,19 +772,19 @@ namespace PascalABCCompiler.Parsers
col = 3;
}
sb.Append(" ");
sb.Append(GetDescriptionForCompiledProperty(props[i]));
sb.Append(GetDescriptionForCompiledProperty(props[i]).Replace("; readonly"," read"));
sb.AppendLine(); ln++;
sb.AppendLine(); ln++;
}
}
sb.AppendLine("{$endregion}");
sb.AppendLine(" {$endregion}");
sb.AppendLine();
}
ConstructorInfo[] constrs = t.GetConstructors(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (constrs.Length > 0)
{
sb.AppendLine("{$region " + StringResources.Get("CODE_COMPLETION_CONSTRUCTORS") + "}");
sb.AppendLine(" {$region " + StringResources.Get("CODE_COMPLETION_CONSTRUCTORS") + "}");
for (int i = 0; i < constrs.Length; i++)
{
if (constrs[i].DeclaringType == t && !constrs[i].IsPrivate && !constrs[i].IsAssembly)
@ -802,13 +810,13 @@ namespace PascalABCCompiler.Parsers
sb.AppendLine(); ln++;
}
}
sb.AppendLine("{$endregion}");
sb.AppendLine(" {$endregion}");
sb.AppendLine();
}
MethodInfo[] meths = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (meths.Length > 0)
{
sb.AppendLine("{$region " + StringResources.Get("CODE_COMPLETION_METHODS") + "}");
sb.AppendLine(" {$region " + StringResources.Get("CODE_COMPLETION_METHODS") + "}");
for (int i = 0; i < meths.Length; i++)
{
if (meths[i].DeclaringType == t && !meths[i].IsPrivate && !meths[i].IsAssembly && !meths[i].Name.StartsWith("get_") && !meths[i].Name.StartsWith("set_") && !meths[i].Name.StartsWith("add_") && !meths[i].Name.StartsWith("remove_"))
@ -834,11 +842,11 @@ namespace PascalABCCompiler.Parsers
sb.AppendLine(); ln++;
}
}
sb.AppendLine("{$endregion}");
sb.AppendLine(" {$endregion}");
sb.AppendLine();
}
sb.AppendLine("end;");
sb.AppendLine(" end;");
sb.AppendLine();
sb.AppendLine("end.");
return sb.ToString();