Skip to content

Commit 363fff2

Browse files
committed
Cleanup from code review feedback
1 parent 65457cc commit 363fff2

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
22
category: minorAnalysis
33
---
4-
* Add new method `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
4+
* Add new predicate `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
55
`String.valueOf` string rendering of a constant expression.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ class CompileTimeConstantExpr extends Expr {
166166
*
167167
* The stringified version of a compile-time constant expression is the equivalent to
168168
* the result of calling `String.valueOf(expr)` on the expression.
169-
*
169+
*
170170
* Note that this does not handle the following cases:
171171
*
172-
* - mathematical computations of type `long`.
172+
* - mathematical computations of type `long`, `float`, or `double`.
173173
*/
174174
pragma[nomagic]
175175
string getStringifiedValue() {
@@ -200,11 +200,11 @@ class CompileTimeConstantExpr extends Expr {
200200
string getStringValue() {
201201
result = this.(StringLiteral).getValue()
202202
or
203-
(
204-
this.getType() instanceof TypeString and
203+
this.getType() instanceof TypeString and // When the expression type is `String`
204+
result =
205+
// Then the resultant string is the addition of both operands stringified value, regardless of type.
205206
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringifiedValue() +
206207
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringifiedValue()
207-
)
208208
or
209209
// Ternary conditional, with compile-time constant condition.
210210
exists(ConditionalExpr ce, boolean condition |

java/ql/test/library-tests/constants/CompileTimeConstantExpr.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Expr
1+
import java
22

33
from CompileTimeConstantExpr constant, RefType tpe
44
where

java/ql/test/library-tests/constants/getBooleanValue.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Variable
1+
import java
22

33
from Variable v, CompileTimeConstantExpr init, RefType enclosing, boolean constant
44
where

java/ql/test/library-tests/constants/getInitializer.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Variable
1+
import java
22

33
from Variable v, Expr init, RefType enclosing
44
where

java/ql/test/library-tests/constants/getIntValue.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Variable
1+
import java
22

33
from Variable v, CompileTimeConstantExpr init, RefType enclosing, int constant
44
where

java/ql/test/library-tests/constants/getStringValue.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Variable
1+
import java
22

33
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
44
where

java/ql/test/library-tests/constants/getStringified.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import semmle.code.java.Variable
1+
import java
22

33
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
44
where

0 commit comments

Comments
 (0)