Skip to content

Commit dcebcc3

Browse files
committed
Rename getPatternAtIndex
1 parent 568bddc commit dcebcc3

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

java/ql/lib/semmle/code/java/PrettyPrintAst.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -784,18 +784,18 @@ private class PpSwitchCase extends PpAst, SwitchCase {
784784

785785
private class PpPatternCase extends PpAst, PatternCase {
786786
private predicate isAnonymousPattern(int n) {
787-
this.getPatternAtIndex(n).asBindingOrUnnamedPattern().isAnonymous()
787+
this.getPattern(n).asBindingOrUnnamedPattern().isAnonymous()
788788
}
789789

790790
override string getPart(int i) {
791-
exists(int n, int base | exists(this.getPatternAtIndex(n)) and base = n * 4 |
791+
exists(int n, int base | exists(this.getPattern(n)) and base = n * 4 |
792792
i = base and
793793
(if n = 0 then result = "case " else result = ", ")
794794
or
795795
i = base + 2 and
796-
this.getPatternAtIndex(n) instanceof LocalVariableDeclExpr and
796+
this.getPattern(n) instanceof LocalVariableDeclExpr and
797797
(
798-
exists(this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getTypeAccess())
798+
exists(this.getPattern(n).asBindingOrUnnamedPattern().getTypeAccess())
799799
or
800800
not this.isAnonymousPattern(n)
801801
) and
@@ -805,11 +805,11 @@ private class PpPatternCase extends PpAst, PatternCase {
805805
(
806806
if this.isAnonymousPattern(n)
807807
then result = "_"
808-
else result = this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getName()
808+
else result = this.getPattern(n).asBindingOrUnnamedPattern().getName()
809809
)
810810
)
811811
or
812-
exists(int base | base = (max(int n | exists(this.getPatternAtIndex(n))) + 1) * 4 |
812+
exists(int base | base = (max(int n | exists(this.getPattern(n))) + 1) * 4 |
813813
i = base and result = ":" and not this.isRule()
814814
or
815815
i = base and result = " -> " and this.isRule()
@@ -819,14 +819,14 @@ private class PpPatternCase extends PpAst, PatternCase {
819819
}
820820

821821
override PpAst getChild(int i) {
822-
exists(int n, int base | exists(this.getPatternAtIndex(n)) and base = n * 4 |
822+
exists(int n, int base | exists(this.getPattern(n)) and base = n * 4 |
823823
i = base + 1 and
824-
result = this.getPatternAtIndex(n).asBindingOrUnnamedPattern().getTypeAccess()
824+
result = this.getPattern(n).asBindingOrUnnamedPattern().getTypeAccess()
825825
or
826-
i = base + 1 and result = this.getPatternAtIndex(n).asRecordPattern()
826+
i = base + 1 and result = this.getPattern(n).asRecordPattern()
827827
)
828828
or
829-
exists(int base | base = (max(int n | exists(this.getPatternAtIndex(n))) + 1) * 4 |
829+
exists(int base | base = (max(int n | exists(this.getPattern(n))) + 1) * 4 |
830830
i = base + 1 and result = this.getRuleExpression()
831831
or
832832
i = base + 1 and result = this.getRuleStatement()

java/ql/lib/semmle/code/java/PrintAst.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ final class PatternCaseNode extends ExprStmtNode {
432432
not result.(ElementNode).getElement() instanceof LocalVariableDeclExpr and
433433
not result.(ElementNode).getElement() instanceof TypeAccess
434434
or
435-
result = TLocalVarDeclNode(pc.getPatternAtIndex(childIndex))
435+
result = TLocalVarDeclNode(pc.getPattern(childIndex))
436436
}
437437
}
438438

java/ql/lib/semmle/code/java/Statement.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,19 +542,19 @@ class PatternCase extends SwitchCase {
542542
PatternCase() { exists(PatternExpr pe | pe.isNthChildOf(this, _)) }
543543

544544
/**
545-
* DEPRECATED: alias for getPatternAtIndex(0)
545+
* DEPRECATED: alias for getPattern(0)
546546
*/
547-
deprecated PatternExpr getPattern() { result = this.getPatternAtIndex(0) }
547+
deprecated PatternExpr getPattern() { result = this.getPattern(0) }
548548

549549
/**
550550
* Gets this case's `n`th pattern.
551551
*/
552-
PatternExpr getPatternAtIndex(int n) { result.isNthChildOf(this, n) }
552+
PatternExpr getPattern(int n) { result.isNthChildOf(this, n) }
553553

554554
/**
555555
* Gets any of this case's patterns.
556556
*/
557-
PatternExpr getAPattern() { result = this.getPatternAtIndex(_) }
557+
PatternExpr getAPattern() { result = this.getPattern(_) }
558558

559559
/**
560560
* Gets this case's sole pattern, if there is exactly one.

0 commit comments

Comments
 (0)