Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 2070x 2070x 2070x 2070x 2070x 2070x 157x 266x 266x 1829x 1829x 106x 160x 2095x 438x 667x 182x 182x 164x 164x 135x 1x | class ParameterTypeMatcher {
constructor(parameter, regexp, text, matchPosition) {
this._parameterType = parameter
this._treeRegexp = regexp
this._text = text
this._matchPosition = matchPosition || 0
const captureGroupRegexp = new RegExp(`(${regexp})`)
this._match = captureGroupRegexp.exec(text.slice(this._matchPosition))
}
get parameterType() {
return this._parameterType
}
advanceTo(newMatchPosition) {
for (
let advancedPos = newMatchPosition;
advancedPos < this._text.length;
advancedPos++
) {
let matcher = new ParameterTypeMatcher(
this._parameterType,
this._treeRegexp,
this._text,
advancedPos
)
if (matcher.find) {
return matcher
}
}
return new ParameterTypeMatcher(
this._parameterType,
this._treeRegexp,
this._text,
this._text.length
)
}
get find() {
return this._match && this.group !== ''
}
get start() {
return this._matchPosition + this._match.index
}
get group() {
return this._match[0]
}
static compare(a, b) {
const posComparison = a.start - b.start
if (posComparison !== 0) return posComparison
const lengthComparison = b.group.length - a.group.length
if (lengthComparison !== 0) return lengthComparison
return 0
}
}
module.exports = ParameterTypeMatcher
|