/// <summary> /// Foramts the class base portion of a class decleration. /// </summary> /// <param name="syntax">The syntax details for the class.</param> /// <returns>The string representing the class base.</returns> public List <SyntaxToken> FormatClassBase(ClassSyntax syntax) { List <SyntaxToken> tokens = new List <SyntaxToken>(); bool hasBaseType = false; // Create the list of types and interfaces List <SyntaxToken> baseTypesAndInterfaces = new List <SyntaxToken>(); if (syntax.Class.InheritsFrom != null && syntax.Class.InheritsFrom.GetFullyQualifiedName() != "System.Object") { tokens.Add(new SyntaxToken(" : ", SyntaxTokens.Text)); tokens.AddRange(FormatTypeDetails(syntax.GetBaseClass())); hasBaseType = true; } Signatures.TypeDetails[] details = syntax.GetInterfaces(); for (int i = 0; i < details.Length; i++) { if (!hasBaseType && i == 0) { tokens.Add(new SyntaxToken(": ", SyntaxTokens.Text)); } else if (hasBaseType && i == 0 || i != 0) { tokens.Add(new SyntaxToken($",\n\t", SyntaxTokens.Text)); } tokens.AddRange(FormatTypeDetails(details[i])); } return(tokens); }
public List <SyntaxToken> FormatClassBase(ClassSyntax syntax) { List <SyntaxToken> tokens = new List <SyntaxToken>(); bool hasBaseType = false; // Create the list of types and interfaces if (syntax.Class.InheritsFrom != null && syntax.Class.InheritsFrom.GetFullyQualifiedName() != "System.Object") { hasBaseType = true; } if (hasBaseType) { tokens.Add(new SyntaxToken("Derives", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); tokens.AddRange(FormatTypeDetails(syntax.GetBaseClass())); } Signatures.TypeDetails[] interfaces = syntax.GetInterfaces(); for (int i = 0; i < interfaces.Length; i++) { if (i == 0) { tokens.Add(new SyntaxToken(" _\n\t", SyntaxTokens.Text)); tokens.Add(new SyntaxToken("Implements", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); } else if (hasBaseType && i == 0 || i != 0) { tokens.Add(new SyntaxToken(", _\n\t\t", SyntaxTokens.Text)); } tokens.AddRange(FormatTypeDetails(interfaces[i])); } return(tokens); }