Skip to content

Commit 9e135f0

Browse files
committed
Polishing.
Reformat code and reorder author tags. See #4025
1 parent 1334008 commit 9e135f0

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
/**
3333
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an EQL query without making any changes.
3434
*
35-
* @author TaeHyun Kang(polyglot-k)
3635
* @author Greg Turnquist
3736
* @author Christoph Strobl
3837
* @author Mark Paluch
38+
* @author TaeHyun Kang
3939
* @since 3.2
4040
*/
4141
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" })
@@ -44,19 +44,23 @@ class EqlQueryRenderer extends EqlBaseVisitor<QueryTokenStream> {
4444
/**
4545
* Is this AST tree a {@literal subquery}?
4646
*
47-
* @return boolean
47+
* @return {@literal true} is the query is a subquery; {@literal false} otherwise.
4848
*/
4949
static boolean isSubquery(ParserRuleContext ctx) {
5050

5151
while (ctx != null) {
52+
5253
if (ctx instanceof EqlParser.SubqueryContext) {
5354
return true;
5455
}
56+
5557
if (ctx instanceof EqlParser.Update_statementContext || ctx instanceof EqlParser.Delete_statementContext) {
5658
return false;
5759
}
60+
5861
ctx = ctx.getParent();
5962
}
63+
6064
return false;
6165
}
6266

@@ -68,11 +72,14 @@ static boolean isSubquery(ParserRuleContext ctx) {
6872
static boolean isSetQuery(ParserRuleContext ctx) {
6973

7074
while (ctx != null) {
75+
7176
if (ctx instanceof EqlParser.Set_fuctionContext) {
7277
return true;
7378
}
79+
7480
ctx = ctx.getParent();
7581
}
82+
7683
return false;
7784
}
7885

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryRenderer.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
/**
3333
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an HQL query without making any changes.
3434
*
35-
* @author TaeHyun Kang(polyglot-k)
3635
* @author Greg Turnquist
3736
* @author Christoph Strobl
3837
* @author Oscar Fanchin
3938
* @author Mark Paluch
39+
* @author TaeHyun Kang
4040
* @since 3.1
4141
*/
4242
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode", "UnreachableCode" })
@@ -45,42 +45,48 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
4545
/**
4646
* Is this AST tree a {@literal subquery}?
4747
*
48-
* @return boolean
48+
* @return {@literal true} is the query is a subquery; {@literal false} otherwise.
4949
*/
5050
static boolean isSubquery(ParserRuleContext ctx) {
5151

5252
while (ctx != null) {
53+
5354
if (ctx instanceof HqlParser.SubqueryContext || ctx instanceof HqlParser.CteContext) {
5455
return true;
5556
}
57+
5658
if (ctx instanceof HqlParser.SelectStatementContext ||
5759
ctx instanceof HqlParser.InsertStatementContext ||
5860
ctx instanceof HqlParser.DeleteStatementContext ||
59-
ctx instanceof HqlParser.UpdateStatementContext
60-
) {
61+
ctx instanceof HqlParser.UpdateStatementContext) {
6162
return false;
6263
}
64+
6365
ctx = ctx.getParent();
6466
}
67+
6568
return false;
6669
}
6770

6871
/**
6972
* Is this AST tree a {@literal set} query that has been added through {@literal UNION|INTERSECT|EXCEPT}?
7073
*
71-
* @return boolean
74+
* @return {@literal true} is the query is a set query; {@literal false} otherwise.
7275
*/
7376
static boolean isSetQuery(ParserRuleContext ctx) {
7477

7578
while (ctx != null) {
76-
ParserRuleContext parent = ctx.getParent();
77-
if (ctx instanceof HqlParser.OrderedQueryContext && parent instanceof HqlParser.QueryExpressionContext qec) {
79+
80+
if (ctx instanceof HqlParser.OrderedQueryContext
81+
&& ctx.getParent() instanceof HqlParser.QueryExpressionContext qec) {
7882
if (qec.orderedQuery().indexOf(ctx) != 0) {
7983
return true;
8084
}
8185
}
82-
ctx = parent;
86+
87+
ctx = ctx.getParent();
8388
}
89+
8490
return false;
8591
}
8692

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
/**
3333
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders a JPQL query without making any changes.
3434
*
35-
* @author TaeHyun Kang(polyglot-k)
3635
* @author Greg Turnquist
3736
* @author Christoph Strobl
3837
* @author Mark Paluch
38+
* @author TaeHyun Kang
3939
* @since 3.1
4040
*/
4141
@SuppressWarnings({ "ConstantConditions", "DuplicatedCode" })
@@ -44,19 +44,23 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<QueryTokenStream> {
4444
/**
4545
* Is this AST tree a {@literal subquery}?
4646
*
47-
* @return boolean
47+
* @return {@literal true} is the query is a subquery; {@literal false} otherwise.
4848
*/
4949
static boolean isSubquery(ParserRuleContext ctx) {
5050

5151
while (ctx != null) {
52+
5253
if (ctx instanceof JpqlParser.SubqueryContext) {
5354
return true;
5455
}
56+
5557
if (ctx instanceof JpqlParser.Update_statementContext || ctx instanceof JpqlParser.Delete_statementContext) {
5658
return false;
5759
}
60+
5861
ctx = ctx.getParent();
5962
}
63+
6064
return false;
6165
}
6266

@@ -68,11 +72,14 @@ static boolean isSubquery(ParserRuleContext ctx) {
6872
static boolean isSetQuery(ParserRuleContext ctx) {
6973

7074
while (ctx != null) {
75+
7176
if (ctx instanceof JpqlParser.Set_fuctionContext) {
7277
return true;
7378
}
79+
7480
ctx = ctx.getParent();
7581
}
82+
7683
return false;
7784
}
7885

0 commit comments

Comments
 (0)