Ruby: address review feedback

This commit is contained in:
Nick Rolfe
2022-03-28 11:19:24 +01:00
parent c7ba7fd389
commit a9eac19dac
3 changed files with 8 additions and 10 deletions

View File

@@ -2,4 +2,4 @@
category: minorAnalysis
---
* Whereas `ConstantValue::getString()` previously returned both string and regular-expression values, it now returns only string values. The same applies to `ConstantValue::isString(value)`.
* Regular-expression values can now be accessed with the new predicates `ConstantValue::getRegExp()`, `ConstantValue::isRegExp(value)`, and `ConstantValue::isRegExpWithFlags(value, flags).
* Regular-expression values can now be accessed with the new predicates `ConstantValue::getRegExp()`, `ConstantValue::isRegExp(value)`, and `ConstantValue::isRegExpWithFlags(value, flags)`.

View File

@@ -74,7 +74,7 @@ class ConstantValue extends TConstantValue {
/** Gets the regexp value, if this is a regexp. */
string getRegExp() { this.isRegExpWithFlags(result, _) }
/** Holds if this is the regexp value `/s/`. */
/** Holds if this is the regexp value `/s/`, ignoring any flags. */
predicate isRegExp(string s) { this.isRegExpWithFlags(s, _) }
/** Holds if this is the regexp value `/s/flags` . */
@@ -125,13 +125,13 @@ module ConstantValue {
class ConstantStringlikeValue extends ConstantValue, TStringlike { }
/** A constant string value. */
class ConstantStringValue extends ConstantValue, TString { }
class ConstantStringValue extends ConstantStringlikeValue, TString { }
/** A constant symbol value. */
class ConstantSymbolValue extends ConstantValue, TSymbol { }
class ConstantSymbolValue extends ConstantStringlikeValue, TSymbol { }
/** A constant regexp value. */
class ConstantRegExpValue extends ConstantValue, TRegExp { }
class ConstantRegExpValue extends ConstantStringlikeValue, TRegExp { }
/** A constant Boolean value. */
class ConstantBooleanValue extends ConstantValue, TBoolean { }

View File

@@ -18,9 +18,7 @@ query predicate regexpEscapeSequenceComponents(RegExpEscapeSequenceComponent c,
}
query predicate stringlikeLiterals(StringlikeLiteral l, string value, string kind) {
value = l.getConstantValue().getString() and kind = "string"
or
value = l.getConstantValue().getSymbol() and kind = "symbol"
or
value = l.getConstantValue().getRegExp() and kind = "regexp"
exists(ConstantValue v |
v = l.getConstantValue() and value = v.getStringlikeValue() and kind = v.getValueType()
)
}