getMemoryFilesForNestedDirectory method

Future<List<MemoryFileInfo>> getMemoryFilesForNestedDirectory(
  1. String dir,
  2. String targetPath,
  3. Set<String> processedPaths
)

Gets memory files for a single nested directory.

Implementation

Future<List<MemoryFileInfo>> getMemoryFilesForNestedDirectory(
  String dir,
  String targetPath,
  Set<String> processedPaths,
) async {
  final result = <MemoryFileInfo>[];

  if (_isSettingSourceEnabled('projectSettings')) {
    result.addAll(
      await processMemoryFile(
        '$dir/NEOMAGE.md',
        MemoryType.project,
        processedPaths,
        false,
      ),
    );
    result.addAll(
      await processMemoryFile(
        '$dir/.neomage/NEOMAGE.md',
        MemoryType.project,
        processedPaths,
        false,
      ),
    );
  }

  if (_isSettingSourceEnabled('localSettings')) {
    result.addAll(
      await processMemoryFile(
        '$dir/NEOMAGE.local.md',
        MemoryType.local,
        processedPaths,
        false,
      ),
    );
  }

  final rulesDir = '$dir/.neomage/rules';

  // Unconditional rules
  final unconditionalPaths = Set<String>.from(processedPaths);
  result.addAll(
    await processMdRules(
      rulesDir: rulesDir,
      type: MemoryType.project,
      processedPaths: unconditionalPaths,
      includeExternal: false,
      conditionalRule: false,
    ),
  );

  // Conditional rules
  result.addAll(
    await _processConditionedMdRules(
      targetPath,
      rulesDir,
      MemoryType.project,
      processedPaths,
      false,
    ),
  );

  for (final path in unconditionalPaths) {
    processedPaths.add(path);
  }

  return result;
}