public List <SyntaxToken> FormatInterfaceBase(InterfaceSyntax syntax) { List <SyntaxToken> tokens = new List <SyntaxToken>(); // Create the list of types and interfaces List <TypeRef> baseTypesAndInterfaces = new List <TypeRef>(); baseTypesAndInterfaces.AddRange(syntax.GetInterfaces()); if (baseTypesAndInterfaces.Count > 0) { tokens.Add(new SyntaxToken("Implements", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); for (int i = 0; i < baseTypesAndInterfaces.Count; i++) { if (i != 0) { tokens.Add(new SyntaxToken(", ", SyntaxTokens.Text)); } tokens.Add(FormatTypeName(baseTypesAndInterfaces[i])); } } return(tokens); }
public override SyntaxNode VisitInterface(InterfaceSyntax node) { if ((this.NodeInSpan(node)) && (node.Members != null) && (node.Members.Count > 0) && (!node.ContainsDiagnostics)) { node = node.WithMembers(this.Sort(node.Members)); } return(base.VisitInterface(node)); }
/// <summary> /// /// </summary> /// <param name="syntax"></param> /// <returns></returns> /// <remarks> /// <code> /// interface-declaration: /// attributes(opt) interface-modifiers(opt) interface identifier interface-base(opt) /// </code> /// </remarks> public SyntaxTokenCollection Format(InterfaceSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(Constants.KeywordInterface); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); tokens.Add(Constants.Space); tokens.AddRange(FormatInterfaceBase(syntax)); return(tokens); }
public SyntaxTokenCollection Format(InterfaceSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken("Interface", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); List <SyntaxToken> baseTokens = FormatInterfaceBase(syntax); if (baseTokens.Count > 0) { tokens.Add(new SyntaxToken(" _\n\t", SyntaxTokens.Text)); tokens.AddRange(baseTokens); } return(tokens); }
/// <summary> /// Formats the interface base decleration for a c# interface. /// </summary> /// <param name="syntax">The syntax to format.</param> /// <returns>A string representing the interface-base for the interface.</returns> /// <remarks> /// <code> /// interface-base: /// ; interface-type-list /// </code> /// </remarks> public List <SyntaxToken> FormatInterfaceBase(InterfaceSyntax syntax) { List <SyntaxToken> tokens = new List <SyntaxToken>(); // Create the list of types and interfaces List <SyntaxToken> baseTypesAndInterfaces = new List <SyntaxToken>(); baseTypesAndInterfaces.AddRange(FormatTypeName(syntax.GetInterfaces())); if (baseTypesAndInterfaces.Count > 0) { tokens.Add(new SyntaxToken(": ", SyntaxTokens.Text)); for (int i = 0; i < baseTypesAndInterfaces.Count; i++) { if (i != 0) { tokens.Add(new SyntaxToken(", ", SyntaxTokens.Text)); } tokens.Add(baseTypesAndInterfaces[i]); } } return(tokens); }
public VBInterfaceFormatter(InterfaceSyntax syntax) { _syntax = syntax; }
public List <SyntaxToken> FormatVisibility(InterfaceSyntax syntax) { return(FormatVisibility(syntax.GetVisibility())); }
public CSharpInterfaceFormatter(InterfaceSyntax syntax) { _syntax = syntax; }