Skip to content

Commit 9c8e0a5

Browse files
Napalysasgerf
andcommitted
Applied changes from comments.
Co-authored-by: Asgerf <[email protected]>
1 parent f48eab9 commit 9c8e0a5

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

javascript/extractor/src/com/semmle/js/parser/RegExpParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public List<Error> getErrors() {
7171
private List<Error> errors;
7272
private List<BackReference> backrefs;
7373
private int maxbackref;
74-
private Boolean vFlagEnabled = false;
75-
private Boolean uFlagEnabled = false;
74+
private boolean vFlagEnabled = false;
75+
private boolean uFlagEnabled = false;
7676

7777
/** Parse the given string as a regular expression. */
7878
public Result parse(String src) {

javascript/ql/lib/semmle/javascript/Regexp.qll

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,12 @@ class RegExpAlt extends RegExpTerm, @regexp_alt {
312312
*/
313313
class RegExpIntersection extends RegExpTerm, @regexp_intersection {
314314
/** Gets an intersected term of this term. */
315-
RegExpTerm getIntersectedTerm() { result = this.getAChild() }
315+
RegExpTerm getAnElement() { result = this.getAChild() }
316316

317317
/** Gets the number of intersected terms of this term. */
318318
int getNumIntersectedTerm() { result = this.getNumChild() }
319319

320-
override predicate isNullable() { this.getIntersectedTerm().isNullable() }
321-
322-
override string getAMatchedString() {
323-
exists(string s | s = this.getChild(0).getAMatchedString() |
324-
forall(int i | i in [1 .. this.getNumChild() - 1] | s = this.getChild(i).getAMatchedString()) and
325-
result = s
326-
)
327-
}
320+
override predicate isNullable() { this.getAnElement().isNullable() }
328321

329322
override string getAPrimaryQlClass() { result = "RegExpIntersection" }
330323
}
@@ -339,13 +332,13 @@ class RegExpIntersection extends RegExpTerm, @regexp_intersection {
339332
* ```
340333
*/
341334
class RegExpSubtraction extends RegExpTerm, @regexp_subtraction {
342-
/** Gets the minuend (the left operand) of this subtraction. */
335+
/** Gets the minuend (left operand) of this subtraction. */
343336
RegExpTerm getFirstTerm() { result = this.getChild(0) }
344337

345338
/** Gets the number of subtractions terms of this term. */
346339
int getNumSubtractedTerm() { result = this.getNumChild() - 1 }
347340

348-
/** Gets the subtrahend (the right operand) of this subtraction. */
341+
/** Gets a subtrahend (right operand) of this subtraction. */
349342
RegExpTerm getASubtractedTerm() { exists(int i | i > 0 and result = this.getChild(i)) }
350343

351344
override predicate isNullable() { none() }
@@ -1207,11 +1200,11 @@ private class StringConcatRegExpPatternSource extends RegExpPatternSource {
12071200
*/
12081201
class RegExpQuotedString extends RegExpTerm, @regexp_quoted_string {
12091202
/** Gets the term representing the contents of this quoted string. */
1210-
RegExpTerm getQuotedString() { result = this.getAChild() }
1203+
RegExpTerm getTerm() { result = this.getAChild() }
12111204

12121205
override predicate isNullable() { none() }
12131206

1214-
override string getAMatchedString() { result = this.getQuotedString().getAMatchedString() }
1207+
override string getAMatchedString() { result = this.getTerm().getAMatchedString() }
12151208

12161209
override string getAPrimaryQlClass() { result = "RegExpQuotedString" }
12171210
}

0 commit comments

Comments
 (0)