share {js,rb}/regex/missing-regexp-anchor

This commit is contained in:
erik-krogh
2022-12-15 21:52:02 +01:00
parent 355499ea52
commit 26c5480ee6
10 changed files with 346 additions and 384 deletions

View File

@@ -85,6 +85,9 @@ module Impl implements RegexTreeViewSig {
/** Gets the associated regex. */
abstract Regex getRegex();
/** Gets the last child term of this element. */
RegExpTerm getLastChild() { result = this.getChild(this.getNumChild() - 1) }
}
/**
@@ -567,6 +570,13 @@ module Impl implements RegexTreeViewSig {
RegExpWordBoundary() { this.getChar() = "\\b" }
}
/**
* A non-word boundary, that is, a regular expression term of the form `\B`.
*/
class RegExpNonWordBoundary extends RegExpSpecialChar {
RegExpNonWordBoundary() { this.getChar() = "\\B" }
}
/**
* Gets the hex number for the `hex` char.
*/
@@ -922,6 +932,21 @@ module Impl implements RegexTreeViewSig {
override string getPrimaryQLClass() { result = "RegExpDot" }
}
/**
* A term that matches a specific position between characters in the string.
*
* Example:
*
* ```
* ^
* ```
*/
class RegExpAnchor extends RegExpSpecialChar {
RegExpAnchor() { this.getChar() = ["$", "^"] }
override string getPrimaryQLClass() { result = "RegExpAnchor" }
}
/**
* A dollar assertion `$` matching the end of a line.
*
@@ -931,7 +956,7 @@ module Impl implements RegexTreeViewSig {
* $
* ```
*/
class RegExpDollar extends RegExpSpecialChar {
class RegExpDollar extends RegExpAnchor {
RegExpDollar() { this.getChar() = "$" }
override string getPrimaryQLClass() { result = "RegExpDollar" }
@@ -946,7 +971,7 @@ module Impl implements RegexTreeViewSig {
* ^
* ```
*/
class RegExpCaret extends RegExpSpecialChar {
class RegExpCaret extends RegExpAnchor {
RegExpCaret() { this.getChar() = "^" }
override string getPrimaryQLClass() { result = "RegExpCaret" }