Cleanup from code review feedback

This commit is contained in:
Jonathan Leitschuh
2022-03-09 10:45:46 -05:00
parent 65457cc2e2
commit 363fff2358
8 changed files with 12 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
---
category: minorAnalysis
---
* Add new method `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
* Add new predicate `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
`String.valueOf` string rendering of a constant expression.

View File

@@ -166,10 +166,10 @@ class CompileTimeConstantExpr extends Expr {
*
* The stringified version of a compile-time constant expression is the equivalent to
* the result of calling `String.valueOf(expr)` on the expression.
*
*
* Note that this does not handle the following cases:
*
* - mathematical computations of type `long`.
* - mathematical computations of type `long`, `float`, or `double`.
*/
pragma[nomagic]
string getStringifiedValue() {
@@ -200,11 +200,11 @@ class CompileTimeConstantExpr extends Expr {
string getStringValue() {
result = this.(StringLiteral).getValue()
or
(
this.getType() instanceof TypeString and
this.getType() instanceof TypeString and // When the expression type is `String`
result =
// Then the resultant string is the addition of both operands stringified value, regardless of type.
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringifiedValue() +
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringifiedValue()
)
or
// Ternary conditional, with compile-time constant condition.
exists(ConditionalExpr ce, boolean condition |

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Expr
import java
from CompileTimeConstantExpr constant, RefType tpe
where

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Variable
import java
from Variable v, CompileTimeConstantExpr init, RefType enclosing, boolean constant
where

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Variable
import java
from Variable v, Expr init, RefType enclosing
where

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Variable
import java
from Variable v, CompileTimeConstantExpr init, RefType enclosing, int constant
where

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Variable
import java
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
where

View File

@@ -1,4 +1,4 @@
import semmle.code.java.Variable
import java
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
where