Skip to content

Commit

Permalink
fix: exclude comments from analysis during the execution of 'analyze'
Browse files Browse the repository at this point in the history
  • Loading branch information
shun-fukumoto committed Mar 17, 2024
1 parent c0edcc3 commit 5dbdb38
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions slang/lib/src/runner/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,16 @@ void _getUnusedTranslationsInSourceCodeRecursive({
/// and joins them into a single (huge) string without any spaces.
String loadSourceCode(List<File> files) {
final buffer = StringBuffer();
final regex = RegExp(r'\s');
final spacesRegex = RegExp(r'\s');
final singleLineCommentsRegex = RegExp(r'\/\/.*');
final multiLineCommentsRegex = RegExp(r'\/\*.*?\*\/', multiLine: true);

for (final file in files) {
buffer.write(file.readAsStringSync().replaceAll(regex, ''));
buffer.write(file
.readAsStringSync()
.replaceAll(singleLineCommentsRegex, '')
.replaceAll(multiLineCommentsRegex, '')
.replaceAll(spacesRegex, ''));
}

return buffer.toString();
Expand Down

0 comments on commit 5dbdb38

Please sign in to comment.