private static void FormatParameters( ISymbol symbol, ImmutableArray <SymbolDisplayPart> .Builder parts, string indentChars) { int parenthesesDepth = 0; int bracesDepth = 0; int bracketsDepth = 0; int angleBracketsDepth = 0; int i = 0; int index = FindParameterListStart(symbol, parts); Debug.Assert(index != -1); if (index == -1) { return; } parts.Insert(index + 1, SymbolDisplayPartFactory.Indentation(indentChars)); parts.Insert(index + 1, SymbolDisplayPartFactory.LineBreak()); i++; while (i < parts.Count) { SymbolDisplayPart part = parts[i]; if (part.Kind == SymbolDisplayPartKind.Punctuation) { switch (part.ToString()) { case ",": { if (((angleBracketsDepth == 0 && parenthesesDepth == 1 && bracesDepth == 0 && bracketsDepth == 0) || (angleBracketsDepth == 0 && parenthesesDepth == 0 && bracesDepth == 0 && bracketsDepth == 1)) && i < parts.Count - 1) { SymbolDisplayPart nextPart = parts[i + 1]; if (nextPart.Kind == SymbolDisplayPartKind.Space) { parts[i + 1] = SymbolDisplayPartFactory.LineBreak(); parts.Insert(i + 2, SymbolDisplayPartFactory.Indentation(indentChars)); } } break; } case "(": { parenthesesDepth++; break; } case ")": { Debug.Assert(parenthesesDepth >= 0); parenthesesDepth--; if (parenthesesDepth == 0 && symbol.IsKind(SymbolKind.Method, SymbolKind.NamedType)) { return; } break; } case "[": { bracketsDepth++; break; } case "]": { Debug.Assert(bracketsDepth >= 0); bracketsDepth--; if (bracketsDepth == 0 && symbol.Kind == SymbolKind.Property) { return; } break; } case "{": { bracesDepth++; break; } case "}": { Debug.Assert(bracesDepth >= 0); bracesDepth--; break; } case "<": { angleBracketsDepth++; break; } case ">": { Debug.Assert(angleBracketsDepth >= 0); angleBracketsDepth--; break; } } } i++; } }
private static void AddIndentation(this ImmutableArray <SymbolDisplayPart> .Builder builder) { builder.Add(SymbolDisplayPartFactory.Indentation()); }