public void testLinenoSwitch() { AstRoot root = parse( "\nswitch (a) {\n" + " case\n" + " 1:\n" + " b++;\n" + " case 2:\n" + " default:\n" + " b--;\n" + " }\n"); SwitchStatement switchStmt = (SwitchStatement) root.getFirstChild(); AstNode switchVar = switchStmt.getExpression(); List<SwitchCase> cases = switchStmt.getCases(); SwitchCase firstCase = cases.get(0); AstNode caseArg = firstCase.getExpression(); List<AstNode> caseBody = firstCase.getStatements(); ExpressionStatement exprStmt = (ExpressionStatement) caseBody.get(0); UnaryExpression incrExpr = (UnaryExpression) exprStmt.getExpression(); AstNode incrVar = incrExpr.getOperand(); SwitchCase secondCase = cases.get(1); AstNode defaultCase = cases.get(2); AstNode returnStmt = (AstNode) switchStmt.getNext(); assertEquals(1, switchStmt.getLineno()); assertEquals(1, switchVar.getLineno()); assertEquals(2, firstCase.getLineno()); assertEquals(3, caseArg.getLineno()); assertEquals(4, exprStmt.getLineno()); assertEquals(4, incrExpr.getLineno()); assertEquals(4, incrVar.getLineno()); assertEquals(5, secondCase.getLineno()); assertEquals(6, defaultCase.getLineno()); }