JavaScript: Move getAMatchedConstant(RegExpTerm) into the library.

This commit is contained in:
Max Schaefer
2019-11-05 12:15:39 +00:00
parent a5a5debdc7
commit 12ea81af9c
2 changed files with 14 additions and 14 deletions

View File

@@ -185,6 +185,11 @@ class RegExpTerm extends Locatable, @regexpterm {
* into account.
*/
string getConstantValue() { none() }
/**
* Gets a string that is matched by this regular-expression term.
*/
string getAMatchedString() { result = getConstantValue() }
}
/**
@@ -280,6 +285,8 @@ class RegExpAlt extends RegExpTerm, @regexp_alt {
int getNumAlternative() { result = getNumChild() }
override predicate isNullable() { getAlternative().isNullable() }
override string getAMatchedString() { result = getAlternative().getAMatchedString() }
}
/**
@@ -574,6 +581,8 @@ class RegExpGroup extends RegExpTerm, @regexp_group {
override predicate isNullable() { getAChild().isNullable() }
override string getConstantValue() { result = getAChild().getConstantValue() }
override string getAMatchedString() { result = getAChild().getAMatchedString() }
}
/**
@@ -759,6 +768,10 @@ class RegExpCharacterClass extends RegExpTerm, @regexp_char_class {
predicate isInverted() { isInverted(this) }
override predicate isNullable() { none() }
override string getAMatchedString() {
not isInverted() and result = getAChild().getAMatchedString()
}
}
/**