hasCustomPlatformImpl function

bool hasCustomPlatformImpl(
  1. String baseDir,
  2. String platform,
  3. String className
)

Whether Windows or Linux should get its OWN impl file instead of sharing src/Hybrid$className.cpp — driven entirely by what's actually on disk, not by annotation config, so both "keep everything in one shared file" and "diverge Windows and Linux" stay available as a plugin-author choice (some plugins want one file for easier maintenance when the logic really is identical; others want Windows and Linux to genuinely diverge — e.g. different threading primitives, platform intrinsics).

True only when $baseDir/$platform/src/Hybrid$className.cpp exists AND contains actual code — i.e. the plugin author genuinely started writing platform-specific implementation there. An untouched stub, a file that still carries the starter's _implStubTodoMarker, or a comments-only file (someone deleting the stub body and leaving notes) all mean "keep sharing" — nitrogen never forces a plugin onto the separated shape. (Keying off marker ABSENCE alone misread a hand-authored comment-only file as an opt-in — issue #12's detection note.)

Implementation

bool hasCustomPlatformImpl(String baseDir, String platform, String className) {
  final f = File(p.join(baseDir, platform, 'src', 'Hybrid$className.cpp'));
  if (!f.existsSync()) return false;
  final content = f.readAsStringSync();
  if (content.contains(_implStubTodoMarker)) return false;
  // Strip // and /* */ comments plus preprocessor-free blank lines; anything
  // left is real code (class definitions, method bodies, registration).
  final withoutBlock = content.replaceAll(RegExp(r'/\*.*?\*/', dotAll: true), '');
  final codeLines = withoutBlock.split('\n').map((l) {
    final idx = l.indexOf('//');
    return (idx >= 0 ? l.substring(0, idx) : l).trim();
  }).where((l) => l.isNotEmpty);
  return codeLines.isNotEmpty;
}