diff --git a/java/ql/lib/semmle/code/java/PrettyPrintAst.qll b/java/ql/lib/semmle/code/java/PrettyPrintAst.qll index 36f5ce1ed89..de1bf3100a3 100644 --- a/java/ql/lib/semmle/code/java/PrettyPrintAst.qll +++ b/java/ql/lib/semmle/code/java/PrettyPrintAst.qll @@ -784,18 +784,18 @@ private class PpSwitchCase extends PpAst, SwitchCase { private class PpPatternCase extends PpAst, PatternCase { private predicate isAnonymousPattern(int n) { - this.getPatternAtIndex(n).asBindingOrUnnamedPattern().isAnonymous() + this.getPattern(n).asBindingOrUnnamedPattern().isAnonymous() } override string getPart(int i) { - exists(int n, int base | exists(this.getPatternAtIndex(n)) and base = n * 4 | + exists(int n, int base | exists(this.getPattern(n)) and base = n * 4 | i = base and (if n = 0 then result = "case " else result = ", ") or i = base + 2 and - this.getPatternAtIndex(n) instanceof LocalVariableDeclExpr and + this.getPattern(n) instanceof LocalVariableDeclExpr and ( - exists(this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getTypeAccess()) + exists(this.getPattern(n).asBindingOrUnnamedPattern().getTypeAccess()) or not this.isAnonymousPattern(n) ) and @@ -805,11 +805,11 @@ private class PpPatternCase extends PpAst, PatternCase { ( if this.isAnonymousPattern(n) then result = "_" - else result = this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getName() + else result = this.getPattern(n).asBindingOrUnnamedPattern().getName() ) ) or - exists(int base | base = (max(int n | exists(this.getPatternAtIndex(n))) + 1) * 4 | + exists(int base | base = (max(int n | exists(this.getPattern(n))) + 1) * 4 | i = base and result = ":" and not this.isRule() or i = base and result = " -> " and this.isRule() @@ -819,14 +819,14 @@ private class PpPatternCase extends PpAst, PatternCase { } override PpAst getChild(int i) { - exists(int n, int base | exists(this.getPatternAtIndex(n)) and base = n * 4 | + exists(int n, int base | exists(this.getPattern(n)) and base = n * 4 | i = base + 1 and - result = this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getTypeAccess() + result = this.getPattern(n).asBindingOrUnnamedPattern().getTypeAccess() or - i = base + 1 and result = this.getPatternAtIndex(n).asRecordPattern() + i = base + 1 and result = this.getPattern(n).asRecordPattern() ) or - exists(int base | base = (max(int n | exists(this.getPatternAtIndex(n))) + 1) * 4 | + exists(int base | base = (max(int n | exists(this.getPattern(n))) + 1) * 4 | i = base + 1 and result = this.getRuleExpression() or i = base + 1 and result = this.getRuleStatement() diff --git a/java/ql/lib/semmle/code/java/PrintAst.qll b/java/ql/lib/semmle/code/java/PrintAst.qll index 9444a4a66bf..0af012234bb 100644 --- a/java/ql/lib/semmle/code/java/PrintAst.qll +++ b/java/ql/lib/semmle/code/java/PrintAst.qll @@ -432,7 +432,7 @@ final class PatternCaseNode extends ExprStmtNode { not result.(ElementNode).getElement() instanceof LocalVariableDeclExpr and not result.(ElementNode).getElement() instanceof TypeAccess or - result = TLocalVarDeclNode(pc.getPatternAtIndex(childIndex)) + result = TLocalVarDeclNode(pc.getPattern(childIndex)) } } diff --git a/java/ql/lib/semmle/code/java/Statement.qll b/java/ql/lib/semmle/code/java/Statement.qll index 1b138e68fc6..f4eafd39e9f 100644 --- a/java/ql/lib/semmle/code/java/Statement.qll +++ b/java/ql/lib/semmle/code/java/Statement.qll @@ -542,19 +542,19 @@ class PatternCase extends SwitchCase { PatternCase() { exists(PatternExpr pe | pe.isNthChildOf(this, _)) } /** - * DEPRECATED: alias for getPatternAtIndex(0) + * DEPRECATED: alias for getPattern(0) */ - deprecated PatternExpr getPattern() { result = this.getPatternAtIndex(0) } + deprecated PatternExpr getPattern() { result = this.getPattern(0) } /** * Gets this case's `n`th pattern. */ - PatternExpr getPatternAtIndex(int n) { result.isNthChildOf(this, n) } + PatternExpr getPattern(int n) { result.isNthChildOf(this, n) } /** * Gets any of this case's patterns. */ - PatternExpr getAPattern() { result = this.getPatternAtIndex(_) } + PatternExpr getAPattern() { result = this.getPattern(_) } /** * Gets this case's sole pattern, if there is exactly one.