This is wrong. The variableDeclarator children include the commas as well as the declarators. What you want is nonSeparatorCount and nonSeparatorAt here.