mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Java: Improve documentation regarding minus in front of numeric literals
This commit is contained in:
@@ -638,7 +638,20 @@ class BooleanLiteral extends Literal, @booleanliteral {
|
|||||||
override string getAPrimaryQlClass() { result = "BooleanLiteral" }
|
override string getAPrimaryQlClass() { result = "BooleanLiteral" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An integer literal. For example, `23`. */
|
/**
|
||||||
|
* An integer literal. For example, `23`.
|
||||||
|
*
|
||||||
|
* An integer literal can never be negative except when:
|
||||||
|
* - It is written in binary, octal or hexadecimal notation
|
||||||
|
* - It is written in decimal notation, has the value `2147483648` and is preceded
|
||||||
|
* by a minus; in this case the value of the IntegerLiteral is -2147483648 and
|
||||||
|
* the preceding minus will *not* be modeled as `MinusExpr`.<br/>
|
||||||
|
* In all other cases the preceding minus, if any, will be modeled as separate
|
||||||
|
* `MinusExpr`.
|
||||||
|
*
|
||||||
|
* The last exception is necessary because `2147483648` on its own would not be
|
||||||
|
* a valid integer literal (and could also not be parsed as CodeQL `int`).
|
||||||
|
*/
|
||||||
class IntegerLiteral extends Literal, @integerliteral {
|
class IntegerLiteral extends Literal, @integerliteral {
|
||||||
/** Gets the int representation of this literal. */
|
/** Gets the int representation of this literal. */
|
||||||
int getIntValue() { result = getValue().toInt() }
|
int getIntValue() { result = getValue().toInt() }
|
||||||
@@ -646,17 +659,41 @@ class IntegerLiteral extends Literal, @integerliteral {
|
|||||||
override string getAPrimaryQlClass() { result = "IntegerLiteral" }
|
override string getAPrimaryQlClass() { result = "IntegerLiteral" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A long literal. For example, `23l`. */
|
/**
|
||||||
|
* A long literal. For example, `23L`.
|
||||||
|
*
|
||||||
|
* A long literal can never be negative except when:
|
||||||
|
* - It is written in binary, octal or hexadecimal notation
|
||||||
|
* - It is written in decimal notation, has the value `9223372036854775808` and
|
||||||
|
* is preceded by a minus; in this case the value of the LongLiteral is
|
||||||
|
* -9223372036854775808 and the preceding minus will *not* be modeled as
|
||||||
|
* `MinusExpr`.<br/>
|
||||||
|
* In all other cases the preceding minus, if any, will be modeled as separate
|
||||||
|
* `MinusExpr`.
|
||||||
|
*
|
||||||
|
* The last exception is necessary because `9223372036854775808` on its own
|
||||||
|
* would not be a valid long literal.
|
||||||
|
*/
|
||||||
class LongLiteral extends Literal, @longliteral {
|
class LongLiteral extends Literal, @longliteral {
|
||||||
override string getAPrimaryQlClass() { result = "LongLiteral" }
|
override string getAPrimaryQlClass() { result = "LongLiteral" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A floating point literal. For example, `4.2f`. */
|
/**
|
||||||
|
* A float literal. For example, `4.2f`.
|
||||||
|
*
|
||||||
|
* A float literal is never negative; a preceding minus, if any, will always
|
||||||
|
* be modeled as separate `MinusExpr`.
|
||||||
|
*/
|
||||||
class FloatingPointLiteral extends Literal, @floatingpointliteral {
|
class FloatingPointLiteral extends Literal, @floatingpointliteral {
|
||||||
override string getAPrimaryQlClass() { result = "FloatingPointLiteral" }
|
override string getAPrimaryQlClass() { result = "FloatingPointLiteral" }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A double literal. For example, `4.2`. */
|
/**
|
||||||
|
* A double literal. For example, `4.2`.
|
||||||
|
*
|
||||||
|
* A double literal is never negative; a preceding minus, if any, will always
|
||||||
|
* be modeled as separate `MinusExpr`.
|
||||||
|
*/
|
||||||
class DoubleLiteral extends Literal, @doubleliteral {
|
class DoubleLiteral extends Literal, @doubleliteral {
|
||||||
override string getAPrimaryQlClass() { result = "DoubleLiteral" }
|
override string getAPrimaryQlClass() { result = "DoubleLiteral" }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user