compileHighlightPattern function

RegExp compileHighlightPattern(
  1. String source, {
  2. bool caseSensitive = true,
  3. bool multiLine = false,
  4. bool dotAll = false,
  5. bool unicode = false,
})

Compiles a highlighting pattern. If the source uses a regex feature Dart's engine rejects, returns a never-matching pattern so a single bad rule disables itself instead of breaking the whole language.

Implementation

RegExp compileHighlightPattern(
  String source, {
  bool caseSensitive = true,
  bool multiLine = false,
  bool dotAll = false,
  bool unicode = false,
}) {
  try {
    return RegExp(
      source,
      caseSensitive: caseSensitive,
      multiLine: multiLine,
      dotAll: dotAll,
      unicode: unicode,
    );
  } on FormatException {
    return _never;
  }
}