TF-4265 Add include list to support custom keywords detection

This commit is contained in:
dab246
2026-01-30 14:01:36 +07:00
committed by Dat H. Pham
parent 1071bb49cf
commit 42fb24e6e5
6 changed files with 331 additions and 98 deletions
@@ -0,0 +1,24 @@
/// Helper mixin to extract the full token surrounding a keyword match.
/// Example: Extracts "file-246" from text when the keyword is "file".
mixin TokenExtractionMixin {
static final RegExp _whitespaceRegExp = RegExp(r'\s');
String getSurroundingToken(String text, int matchStart, int matchEnd) {
int start = matchStart;
int end = matchEnd;
// Expand left until whitespace
while (start > 0) {
if (_whitespaceRegExp.hasMatch(text[start - 1])) break;
start--;
}
// Expand right until whitespace
while (end < text.length) {
if (_whitespaceRegExp.hasMatch(text[end])) break;
end++;
}
return text.substring(start, end);
}
}