/// <summary>
        /// Checks a method or method invocation to ensure that the closing bracket is
        /// on the same line as the last argument.
        /// </summary>
        /// <param name="element">The element containing the expression.</param>
        /// <param name="parameterList">The argument list.</param>
        /// <param name="openingBracket">The opening bracket.</param>
        /// <param name="closingBracketType">The type of the closing bracket.</param>
        /// <param name="arguments">The arguments to the method.</param>
        private void CheckMethodClosingBracket(
            Element element, CodeUnit parameterList, OpenBracketToken openingBracket, TokenType closingBracketType, IArgumentList arguments)
        {
            Param.AssertNotNull(element, "element");
            Param.AssertNotNull(parameterList, "parameterList");
            Param.AssertNotNull(openingBracket, "openingBracket");
            Param.Ignore(closingBracketType);
            Param.AssertNotNull(arguments, "arguments");

            // Find the closing bracket.
            CloseBracketToken closingBracket = null;

            Token next = parameterList.FindNextSiblingToken();

            if (next != null && next.Is(closingBracketType))
            {
                closingBracket = (CloseBracketToken)next;
            }

            if (closingBracket != null)
            {
                if (arguments.Count == 0)
                {
                    // The closing bracket must be on the same line as the opening bracket.
                    if (openingBracket.LineNumber != closingBracket.LineNumber)
                    {
                        // If the brackets are not on the same line, determine if this is because there are comments
                        // between the brackets.
                        int commentLineSpan = MeasureCommentLinesBetween(openingBracket, closingBracket, false);

                        if (openingBracket.LineNumber + commentLineSpan != closingBracket.LineNumber)
                        {
                            this.AddViolation(element, closingBracket.LineNumber, Rules.ClosingParenthesisMustBeOnLineOfOpeningParenthesis);
                        }
                    }
                }
                else
                {
                    // The closing bracket must be on the same line as the end of the last method argument.
                    int lastArgumentEndLine = arguments.Location(arguments.Count - 1).EndPoint.LineNumber;
                    if (lastArgumentEndLine != closingBracket.LineNumber)
                    {
                        int commentLineSpan = MeasureCommentLinesBetween(arguments.Argument(arguments.Count - 1).FindLastDescendentToken(), closingBracket, false);

                        if (lastArgumentEndLine + commentLineSpan != closingBracket.LineNumber)
                        {
                            this.AddViolation(element, closingBracket.LineNumber, Rules.ClosingParenthesisMustBeOnLineOfLastParameter);
                        }
                    }
                }
            }
        }
 public void TestMethodArrayParamWithSpace()
 => Verify(
     "M.N(string[ , , ] s)",
     methodDeclaration: MethodDeclaration(
         QualifiedName("M.N"),
         argumentList: ParameterList(
             Parameter(
                 ArrayType(Identifier("string"),
                           ArrayRankSpecifier(
                               OpenBracketToken.With(trailingTrivia: SpaceTrivia().ToImmutableArray()),
                               CloseBracketToken.With(trailingTrivia: SpaceTrivia().ToImmutableArray()),
                               CommaToken.With(trailingTrivia: SpaceTrivia().ToImmutableArray()),
                               CommaToken.With(trailingTrivia: SpaceTrivia().ToImmutableArray()))),
                 IdentifierToken("s")
                 )
             ))
     );
 /// <summary>
 /// argument_list = "[" [ argument *( "," argument ) ] "]"
 /// argument      = expression
 /// </summary>
 /// <param name="openBracket"></param>
 /// <param name="arguments"></param>
 /// <param name="closeBracket"></param>
 public ArmBracketedArgumentListAst(OpenBracketToken openBracket, IList <ArmExpressionAst> arguments, CloseBracketToken closeBracket)
 {
     this.OpenBracket  = openBracket ?? throw new ArgumentNullException(nameof(openBracket));
     this.ArgumentList = new ReadOnlyCollection <ArmExpressionAst>(
         arguments ?? throw new ArgumentNullException(nameof(arguments))
         );
     this.CloseBracket = closeBracket ?? throw new ArgumentNullException(nameof(closeBracket));
 }