start method

Starts the analyser and returns information about the found string literals.

Implementation

Future<List<FoundRtlWidget>> start() async {
  _logger.fine('Starting analysis.');
  final collection = AnalysisContextCollection(includedPaths: [basePath]);
  _logger.finer('Finding contexts.');
  for (final context in collection.contexts) {
    for (final filePath in context.contextRoot.analyzedFiles()) {
      final relative = path.relative(filePath, from: basePath);
      if (excludePaths.where((element) => element.shouldExclude(relative)).isNotEmpty ||
          // exclude generated code.
          filePath.endsWith('.g.dart')) {
        filesSkipped.add(filePath);
        continue;
      }
      filesAnalyzed.add(filePath);
      await _analyzeSingleFile(context, filePath);
    }
  }
  _logger.info('Found ${foundRtlWidgets.length} literals:');
  // for (final f in foundRtlWidgets) {
  //   final relative = path.relative(f.filePath, from: basePath);
  //   _logger.info('$relative:${f.loc} ${f.stringLiteral}');
  // }
  return foundRtlWidgets;
}