protected virtual string GetDescriptionForCompiledType(ICompiledTypeScope scope) { string s = GetFullTypeName(scope.CompiledType); ITypeScope[] instances = scope.GenericInstances; if (instances.Length > 0) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); int ind = s.IndexOf('<'); if (ind != -1) sb.Append(s.Substring(0,ind)); else sb.Append(s); sb.Append('<'); for (int i=0; i<instances.Length; i++) { sb.Append(GetSimpleDescriptionWithoutNamespace(instances[i])); //sb.Append(instances[i].Name); if (i < instances.Length - 1) sb.Append(','); } sb.Append('>'); s = sb.ToString(); } switch(scope.ElemKind) { case SymbolKind.Class : return (scope.IsFinal?"final ":"")+"class "+s; case SymbolKind.Interface : return "interface "+s; case SymbolKind.Enum : return "enum "+s; case SymbolKind.Delegate : return "delegate "+s; case SymbolKind.Struct : return "record "+s; case SymbolKind.Type : return "type "+s; } return s; }
protected override string GetSimpleDescriptionForCompiledType(ICompiledTypeScope scope) { string s = GetFullTypeName(scope.CompiledType); ITypeScope[] instances = scope.GenericInstances; if (instances.Length > 0) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); int ind = s.IndexOf('<'); if (ind != -1) sb.Append(s.Substring(0,ind)); else sb.Append(s); sb.Append('<'); for (int i=0; i<instances.Length; i++) { sb.Append(instances[i].Name); if (i < instances.Length - 1) sb.Append(','); } sb.Append('>'); s = sb.ToString(); } return s; }
public virtual string GetFullTypeName(ICompiledTypeScope scope, bool no_alias=true) { return GetFullTypeName(scope.CompiledType); }
public virtual string GetShortTypeName(ICompiledTypeScope scope) { return GetShortTypeName(scope.CompiledType); }
protected virtual string GetSimpleDescriptionForCompiledType(ICompiledTypeScope scope) { if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Func`")) { return getLambdaRepresentation(scope, true); } else if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Action`")) { return getLambdaRepresentation(scope, false); } else if (scope.CompiledType.Name != null && scope.CompiledType.Name.Contains("Predicate`1")) { return getLambdaRepresentation(scope, false); } else if (scope.CompiledType.Name != null && scope.CompiledType.Name == "IEnumerable`1") { ITypeScope[] instances = scope.GenericInstances; if (instances != null && instances.Length > 0) { return "sequence of " + GetSimpleDescriptionWithoutNamespace(instances[0]); } else return "sequence of T"; } else { string s = GetShortTypeName(scope.CompiledType); ITypeScope[] instances = scope.GenericInstances; if (instances != null && instances.Length > 0) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); int ind = s.IndexOf('<'); if (ind != -1) sb.Append(s.Substring(0, ind)); else sb.Append(s); sb.Append('<'); for (int i = 0; i < instances.Length; i++) { sb.Append(GetSimpleDescriptionWithoutNamespace(instances[i])); if (i < instances.Length - 1) sb.Append(','); } sb.Append('>'); s = sb.ToString(); } return s; } }
protected string getLambdaRepresentation(ICompiledTypeScope scope, bool has_return_value) { StringBuilder sb = new StringBuilder(); ITypeScope[] instances = scope.GenericInstances; List<string> parameters = new List<string>(); if (instances != null && instances.Length > 0) { foreach (ITypeScope ts in instances) parameters.Add(GetSimpleDescriptionWithoutNamespace(ts)); } /*else { foreach (Type t in scope.CompiledType.GetGenericArguments()) parameters.Add(t.Name); }*/ return getLambdaRepresentation(scope.CompiledType, has_return_value, parameters); }