-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Java: Rename several AST predicates. #21267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5e6e64b
Java: Rename UnaryExpr.getExpr to getOperand.
aschackmull 36fa0a2
Java: Rename getTrueExpr/getFalseExpr on ConditionalExpr to getThen/g…
aschackmull 6f40ac1
Java: Rename ReturnStmt.getResult to getExpr.
aschackmull 4fcf3fb
Java: Make loop classes extend LoopStmt and use getBody instead of ge…
aschackmull 2d02908
Java: Add change note.
aschackmull 32fe12a
Java: Delay deprecation a bit.
aschackmull 11003e6
Java: Fix qldoc
aschackmull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,7 +140,7 @@ class IfStmt extends ConditionalStmt, @ifstmt { | |
| } | ||
|
|
||
| /** A `for` loop. */ | ||
| class ForStmt extends ConditionalStmt, @forstmt { | ||
| class ForStmt extends ConditionalStmt, LoopStmtImpl, @forstmt { | ||
| /** | ||
| * Gets an initializer expression of the loop. | ||
| * | ||
|
|
@@ -167,8 +167,15 @@ class ForStmt extends ConditionalStmt, @forstmt { | |
| index = result.getIndex() - 3 | ||
| } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use getBody() instead. | ||
| * | ||
| * Gets the body of this `for` loop. | ||
| */ | ||
| deprecated Stmt getStmt() { result.getParent() = this and result.getIndex() = 2 } | ||
|
|
||
| /** Gets the body of this `for` loop. */ | ||
| Stmt getStmt() { result.getParent() = this and result.getIndex() = 2 } | ||
| override Stmt getBody() { result.getParent() = this and result.getIndex() = 2 } | ||
|
|
||
| /** | ||
| * Gets a variable that is used as an iteration variable: it is defined, | ||
|
|
@@ -191,7 +198,7 @@ class ForStmt extends ConditionalStmt, @forstmt { | |
| this.getCondition().getAChildExpr*() = result.getAnAccess() | ||
| } | ||
|
|
||
| override string pp() { result = "for (...;...;...) " + this.getStmt().pp() } | ||
| override string pp() { result = "for (...;...;...) " + this.getBody().pp() } | ||
|
|
||
| override string toString() { result = "for (...;...;...)" } | ||
|
|
||
|
|
@@ -201,17 +208,24 @@ class ForStmt extends ConditionalStmt, @forstmt { | |
| } | ||
|
|
||
| /** An enhanced `for` loop. (Introduced in Java 5.) */ | ||
| class EnhancedForStmt extends Stmt, @enhancedforstmt { | ||
| class EnhancedForStmt extends LoopStmtImpl, @enhancedforstmt { | ||
| /** Gets the local variable declaration expression of this enhanced `for` loop. */ | ||
| LocalVariableDeclExpr getVariable() { result.getParent() = this } | ||
|
|
||
| /** Gets the expression over which this enhanced `for` loop iterates. */ | ||
| Expr getExpr() { result.isNthChildOf(this, 1) } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use getBody() instead. | ||
|
||
| * | ||
| * Gets the body of this enhanced `for` loop. | ||
| */ | ||
| deprecated Stmt getStmt() { result.getParent() = this } | ||
|
|
||
| /** Gets the body of this enhanced `for` loop. */ | ||
| Stmt getStmt() { result.getParent() = this } | ||
| override Stmt getBody() { result.getParent() = this } | ||
|
|
||
| override string pp() { result = "for (... : ...) " + this.getStmt().pp() } | ||
| override string pp() { result = "for (... : ...) " + this.getBody().pp() } | ||
|
|
||
| override string toString() { result = "for (... : ...)" } | ||
|
|
||
|
|
@@ -221,14 +235,21 @@ class EnhancedForStmt extends Stmt, @enhancedforstmt { | |
| } | ||
|
|
||
| /** A `while` loop. */ | ||
| class WhileStmt extends ConditionalStmt, @whilestmt { | ||
| class WhileStmt extends ConditionalStmt, LoopStmtImpl, @whilestmt { | ||
| /** Gets the boolean condition of this `while` loop. */ | ||
| override Expr getCondition() { result.getParent() = this } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use getBody() instead. | ||
|
||
| * | ||
| * Gets the body of this `while` loop. | ||
| */ | ||
| deprecated Stmt getStmt() { result.getParent() = this } | ||
|
|
||
| /** Gets the body of this `while` loop. */ | ||
| Stmt getStmt() { result.getParent() = this } | ||
| override Stmt getBody() { result.getParent() = this } | ||
|
|
||
| override string pp() { result = "while (...) " + this.getStmt().pp() } | ||
| override string pp() { result = "while (...) " + this.getBody().pp() } | ||
|
|
||
| override string toString() { result = "while (...)" } | ||
|
|
||
|
|
@@ -238,14 +259,21 @@ class WhileStmt extends ConditionalStmt, @whilestmt { | |
| } | ||
|
|
||
| /** A `do` loop. */ | ||
| class DoStmt extends ConditionalStmt, @dostmt { | ||
| class DoStmt extends ConditionalStmt, LoopStmtImpl, @dostmt { | ||
| /** Gets the condition of this `do` loop. */ | ||
| override Expr getCondition() { result.getParent() = this } | ||
|
|
||
| /** | ||
| * DEPRECATED: Use getBody() instead. | ||
|
||
| * | ||
| * Gets the body of this `do` loop. | ||
| */ | ||
| deprecated Stmt getStmt() { result.getParent() = this } | ||
|
|
||
| /** Gets the body of this `do` loop. */ | ||
| Stmt getStmt() { result.getParent() = this } | ||
| override Stmt getBody() { result.getParent() = this } | ||
|
|
||
| override string pp() { result = "do " + this.getStmt().pp() + " while (...)" } | ||
| override string pp() { result = "do " + this.getBody().pp() + " while (...)" } | ||
|
|
||
| override string toString() { result = "do ... while (...)" } | ||
|
|
||
|
|
@@ -258,30 +286,16 @@ class DoStmt extends ConditionalStmt, @dostmt { | |
| * A loop statement, including `for`, enhanced `for`, | ||
| * `while` and `do` statements. | ||
| */ | ||
| class LoopStmt extends Stmt { | ||
| LoopStmt() { | ||
| this instanceof ForStmt or | ||
| this instanceof EnhancedForStmt or | ||
| this instanceof WhileStmt or | ||
| this instanceof DoStmt | ||
| } | ||
|
|
||
| abstract private class LoopStmtImpl extends Stmt { | ||
| /** Gets the body of this loop statement. */ | ||
| Stmt getBody() { | ||
| result = this.(ForStmt).getStmt() or | ||
| result = this.(EnhancedForStmt).getStmt() or | ||
| result = this.(WhileStmt).getStmt() or | ||
| result = this.(DoStmt).getStmt() | ||
| } | ||
| abstract Stmt getBody(); | ||
|
|
||
| /** Gets the boolean condition of this loop statement. */ | ||
| Expr getCondition() { | ||
| result = this.(ForStmt).getCondition() or | ||
| result = this.(WhileStmt).getCondition() or | ||
| result = this.(DoStmt).getCondition() | ||
| } | ||
| Expr getCondition() { none() } | ||
| } | ||
|
|
||
| final class LoopStmt = LoopStmtImpl; | ||
|
|
||
| /** A `try` statement. */ | ||
| class TryStmt extends Stmt, @trystmt { | ||
| /** Gets the block of the `try` statement. */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same