Add missing javadoc and getUniquePattern predicate

This commit is contained in:
Chris Smowton
2024-03-22 15:01:09 +00:00
parent f44becea7f
commit c7cb885e71

View File

@@ -551,8 +551,16 @@ class PatternCase extends SwitchCase {
*/
PatternExpr getPatternAtIndex(int n) { result.isNthChildOf(this, n) }
/**
* Gets any of this case's patterns.
*/
PatternExpr getAPattern() { result = this.getPatternAtIndex(_) }
/**
* Gets this case's sole pattern, if there is exactly one.
*/
PatternExpr getUniquePattern() { result = unique(PatternExpr pe | pe = this.getPatternAtIndex(_)) }
/** Gets the guard applicable to this pattern case, if any. */
Expr getGuard() { result.isNthChildOf(this, -3) }