Rust: Step correctly over method arguments

Previously the math was wrong and the first argument (with `i` being `0`) had two edges out of it.
This commit is contained in:
Simon Friis Vindum
2024-10-17 16:32:35 +02:00
parent b2032fc6fd
commit 272d12fee1
3 changed files with 6 additions and 10 deletions

View File

@@ -524,10 +524,7 @@ class MatchExprTree extends PostOrderTree instanceof MatchExpr {
class MethodCallExprTree extends StandardPostOrderTree, MethodCallExpr {
override AstNode getChildNode(int i) {
i = 0 and
result = this.getReceiver()
or
result = this.getArgList().getArg(i + 1)
if i = 0 then result = this.getReceiver() else result = this.getArgList().getArg(i - 1)
}
}

View File

@@ -19,10 +19,9 @@ edges
| test.rs:10:13:10:19 | map | test.rs:11:9:11:28 | ExprStmt | match |
| test.rs:10:23:10:34 | PathExpr | test.rs:10:23:10:36 | CallExpr | |
| test.rs:10:23:10:36 | CallExpr | test.rs:10:13:10:19 | map | |
| test.rs:11:9:11:11 | map | test.rs:11:9:11:27 | MethodCallExpr | |
| test.rs:11:9:11:11 | map | test.rs:11:20:11:21 | 37 | |
| test.rs:11:9:11:27 | MethodCallExpr | test.rs:9:22:12:5 | BlockExpr | |
| test.rs:11:9:11:28 | ExprStmt | test.rs:11:20:11:21 | 37 | |
| test.rs:11:20:11:21 | 37 | test.rs:11:9:11:11 | map | |
| test.rs:11:9:11:28 | ExprStmt | test.rs:11:9:11:11 | map | |
| test.rs:11:20:11:21 | 37 | test.rs:11:24:11:26 | "a" | |
| test.rs:11:24:11:26 | "a" | test.rs:11:9:11:27 | MethodCallExpr | |
| test.rs:17:5:33:5 | enter test_break_and_continue | test.rs:17:32:17:32 | n | |

View File

@@ -707,10 +707,10 @@ edges
| variables.rs:332:5:332:17 | ExprStmt | variables.rs:332:5:332:13 | PathExpr | |
| variables.rs:332:15:332:15 | a | variables.rs:332:5:332:16 | CallExpr | |
| variables.rs:333:5:333:27 | MethodCallExpr | variables.rs:334:5:334:17 | ExprStmt | |
| variables.rs:333:5:333:28 | ExprStmt | variables.rs:333:25:333:26 | 10 | |
| variables.rs:333:6:333:11 | RefExpr | variables.rs:333:5:333:27 | MethodCallExpr | |
| variables.rs:333:5:333:28 | ExprStmt | variables.rs:333:11:333:11 | a | |
| variables.rs:333:6:333:11 | RefExpr | variables.rs:333:25:333:26 | 10 | |
| variables.rs:333:11:333:11 | a | variables.rs:333:6:333:11 | RefExpr | |
| variables.rs:333:25:333:26 | 10 | variables.rs:333:11:333:11 | a | |
| variables.rs:333:25:333:26 | 10 | variables.rs:333:5:333:27 | MethodCallExpr | |
| variables.rs:334:5:334:13 | PathExpr | variables.rs:334:15:334:15 | a | |
| variables.rs:334:5:334:16 | CallExpr | variables.rs:329:17:335:1 | BlockExpr | |
| variables.rs:334:5:334:17 | ExprStmt | variables.rs:334:5:334:13 | PathExpr | |