Address review feedback

This commit is contained in:
Nick Rolfe
2020-12-18 10:08:45 +00:00
parent a87fe410af
commit 4718de08b2
8 changed files with 32 additions and 72 deletions

View File

@@ -22,7 +22,8 @@ class Literal extends Expr {
override string toString() { result = this.getValueText() }
string getValueText() { result = range.getValueText() }
/** Gets the source text for this literal. */
final string getValueText() { result = range.getValueText() }
}
/**

View File

@@ -10,10 +10,10 @@ class Operation extends Expr {
override Operation::Range range;
/** Gets the operator of this operation. */
string getOperator() { result = range.getOperator() }
final string getOperator() { result = range.getOperator() }
/** Gets an operand of this operation. */
Expr getAnOperand() { result = range.getAnOperand() }
final Expr getAnOperand() { result = range.getAnOperand() }
}
/** A unary operation. */
@@ -21,7 +21,7 @@ class UnaryOperation extends Operation, @unary {
override UnaryOperation::Range range;
/** Gets the operand of this unary operation. */
Expr getOperand() { result = range.getOperand() }
final Expr getOperand() { result = range.getOperand() }
override string toString() { result = this.getOperator() + " ..." }
}
@@ -109,10 +109,10 @@ class BinaryOperation extends Operation, @binary {
override string toString() { result = "... " + this.getOperator() + " ..." }
/** Gets the left operand of this binary operation. */
Expr getLeftOperand() { result = range.getLeftOperand() }
final Expr getLeftOperand() { result = range.getLeftOperand() }
/** Gets the right operand of this binary operation. */
Expr getRightOperand() { result = range.getRightOperand() }
final Expr getRightOperand() { result = range.getRightOperand() }
}
/**
@@ -351,9 +351,9 @@ class CaseEqExpr extends EqualityOperation, @binary_equalequalequal {
class RelationalOperation extends ComparisonOperation {
override RelationalOperation::Range range;
Expr getGreaterOperand() { result = range.getGreaterOperand() }
final Expr getGreaterOperand() { result = range.getGreaterOperand() }
Expr getLesserOperand() { result = range.getLesserOperand() }
final Expr getLesserOperand() { result = range.getLesserOperand() }
}
/**
@@ -451,10 +451,10 @@ class Assignment extends Operation {
override string toString() { result = "... " + this.getOperator() + " ..." }
/** Gets the left hand side of this assignment. */
Expr getLhs() { result = range.getLhs() }
final Expr getLhs() { result = range.getLhs() }
/** Gets the right hand side of this assignment. */
Expr getRhs() { result = range.getRhs() }
final Expr getRhs() { result = range.getRhs() }
}
/**

View File

@@ -76,7 +76,7 @@ class LocalVariableAccess extends VariableAccess {
final override LocalVariableAccess::Range range;
/** Gets the variable this identifier refers to. */
override LocalVariable getVariable() { result = range.getVariable() }
final override LocalVariable getVariable() { result = range.getVariable() }
final override string getAPrimaryQlClass() { result = "LocalVariableAccess" }
}

View File

@@ -213,9 +213,7 @@ module NoRegexMatchExpr {
}
module Assignment {
class DbUnion = @operator_assignment or @assignment;
abstract class Range extends Operation::Range, DbUnion {
abstract class Range extends Operation::Range {
abstract Expr getLhs();
abstract Expr getRhs();

View File

@@ -19,26 +19,17 @@ query predicate assignOperations(
query predicate assignArithmeticOperations(
AssignArithmeticOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLhs() and
right = o.getRhs() and
pClass = o.getAPrimaryQlClass()
assignOperations(o, operator, left, right, pClass)
}
query predicate assignLogicalOperations(
AssignLogicalOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLhs() and
right = o.getRhs() and
pClass = o.getAPrimaryQlClass()
assignOperations(o, operator, left, right, pClass)
}
query predicate assignBitwiseOperations(
AssignBitwiseOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLhs() and
right = o.getRhs() and
pClass = o.getAPrimaryQlClass()
assignOperations(o, operator, left, right, pClass)
}

View File

@@ -55,8 +55,8 @@ equalityOperations
| operations.rb:53:1:53:8 | ... != ... | != | operations.rb:53:1:53:1 | a | operations.rb:53:6:53:8 | 123 | NEExpr |
| operations.rb:54:1:54:7 | ... === ... | === | operations.rb:54:1:54:1 | m | operations.rb:54:7:54:7 | n | CaseEqExpr |
relationalOperations
| operations.rb:57:1:57:5 | ... > ... | > | operations.rb:57:1:57:1 | x | operations.rb:57:5:57:5 | 0 | GTExpr |
| operations.rb:58:1:58:8 | ... >= ... | >= | operations.rb:58:1:58:1 | y | operations.rb:58:6:58:8 | 100 | GEExpr |
| operations.rb:57:1:57:5 | ... > ... | > | operations.rb:57:5:57:5 | 0 | operations.rb:57:1:57:1 | x | GTExpr |
| operations.rb:58:1:58:8 | ... >= ... | >= | operations.rb:58:6:58:8 | 100 | operations.rb:58:1:58:1 | y | GEExpr |
| operations.rb:59:1:59:5 | ... < ... | < | operations.rb:59:1:59:1 | a | operations.rb:59:5:59:5 | b | LTExpr |
| operations.rb:60:1:60:8 | ... <= ... | <= | operations.rb:60:1:60:1 | 7 | operations.rb:60:6:60:8 | foo | LEExpr |
spaceshipExprs

View File

@@ -12,80 +12,56 @@ query predicate binaryOperations(
query predicate binaryArithmeticOperations(
BinaryArithmeticOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
binaryOperations(o, operator, left, right, pClass)
}
query predicate binaryLogicalOperations(
BinaryLogicalOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
binaryOperations(o, operator, left, right, pClass)
}
query predicate binaryBitwiseOperations(
BinaryBitwiseOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
binaryOperations(o, operator, left, right, pClass)
}
query predicate comparisonOperations(
ComparisonOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
binaryOperations(o, operator, left, right, pClass)
}
query predicate equalityOperations(
EqualityOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
binaryOperations(o, operator, left, right, pClass)
}
query predicate relationalOperations(
RelationalOperation o, string operator, Expr left, Expr right, string pClass
RelationalOperation o, string operator, Expr lesser, Expr greater, string pClass
) {
operator = o.getOperator() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
lesser = o.getLesserOperand() and
greater = o.getGreaterOperand() and
pClass = o.getAPrimaryQlClass()
}
query predicate spaceshipExprs(
SpaceshipExpr e, string operator, Expr left, Expr right, string pClass
) {
operator = e.getOperator() and
left = e.getLeftOperand() and
right = e.getRightOperand() and
pClass = e.getAPrimaryQlClass()
binaryOperations(e, operator, left, right, pClass)
}
query predicate regexMatchExprs(
RegexMatchExpr e, string operator, Expr left, Expr right, string pClass
) {
operator = e.getOperator() and
left = e.getLeftOperand() and
right = e.getRightOperand() and
pClass = e.getAPrimaryQlClass()
binaryOperations(e, operator, left, right, pClass)
}
query predicate noRegexMatchExprs(
NoRegexMatchExpr e, string operator, Expr left, Expr right, string pClass
) {
operator = e.getOperator() and
left = e.getLeftOperand() and
right = e.getRightOperand() and
pClass = e.getAPrimaryQlClass()
binaryOperations(e, operator, left, right, pClass)
}

View File

@@ -9,23 +9,17 @@ query predicate unaryOperations(UnaryOperation o, string operator, Expr operand,
query predicate unaryLogicalOperations(
UnaryLogicalOperation o, string operator, Expr operand, string pClass
) {
operator = o.getOperator() and
operand = o.getOperand() and
pClass = o.getAPrimaryQlClass()
unaryOperations(o, operator, operand, pClass)
}
query predicate unaryArithmeticOperations(
UnaryArithmeticOperation o, string operator, Expr operand, string pClass
) {
operator = o.getOperator() and
operand = o.getOperand() and
pClass = o.getAPrimaryQlClass()
unaryOperations(o, operator, operand, pClass)
}
query predicate unaryBitwiseOperations(
UnaryBitwiseOperation o, string operator, Expr operand, string pClass
) {
operator = o.getOperator() and
operand = o.getOperand() and
pClass = o.getAPrimaryQlClass()
unaryOperations(o, operator, operand, pClass)
}