Expose getFirstPatternCase, not getPatternCase/2

This commit is contained in:
Chris Smowton
2023-11-27 14:07:18 +00:00
parent 40464ed1f9
commit 6f3bff19cc
2 changed files with 10 additions and 3 deletions

View File

@@ -478,9 +478,9 @@ private module ControlFlowGraphImpl {
or
result instanceof NullDefaultCase
or
not exists(getPatternCase(switch, _))
not exists(getFirstPatternCase(switch))
or
result.getIndex() <= getPatternCase(switch, 0).getIndex()
result.getIndex() <= getFirstPatternCase(switch).getIndex()
)
}

View File

@@ -5,11 +5,18 @@ import java
/**
* Gets the `i`th `PatternCase` defined on `switch`, if one exists.
*/
PatternCase getPatternCase(StmtParent switch, int i) {
private PatternCase getPatternCase(StmtParent switch, int i) {
result =
rank[i + 1](PatternCase pc, int caseIdx | pc.isNthCaseOf(switch, caseIdx) | pc order by caseIdx)
}
/**
* Gets the first `PatternCase` defined on `switch`, if one exists.
*/
PatternCase getFirstPatternCase(StmtParent switch) {
result = getPatternCase(switch, 0)
}
/**
* Gets the PatternCase after pc, if one exists.
*/