Skip to content

Commit 1c13cd2

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Remove _SyntacticErrorGenerator class.
Despite its name, `_SyntacticErrorGenerator` didn't actually do any code generation; it simply iterated through the analyzer's `ParserErrorCode`s looking for diagnostics that could potentially be shared with the CFE. This logic was part of a previous effort to unify analyzer and CFE error codes, and is no longer needed. Removing it will make it easier to clean up and refactor the logic for handling shared error codes. Change-Id: I6a6a69647555aa071c20cb79a12ce5c8c24ee9dd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451900 Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 85b994c commit 1c13cd2

File tree

1 file changed

+0
-89
lines changed

1 file changed

+0
-89
lines changed

pkg/analyzer/tool/messages/generate.dart

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@
1717
library;
1818

1919
import 'dart:convert';
20-
import 'dart:io';
2120

2221
import 'package:analyzer_testing/package_root.dart' as pkg_root;
2322
import 'package:analyzer_utilities/extensions/string.dart';
2423
import 'package:analyzer_utilities/messages.dart';
2524
import 'package:analyzer_utilities/tools.dart';
2625
import 'package:collection/collection.dart';
27-
import 'package:path/path.dart';
2826

2927
import 'error_code_info.dart';
3028

3129
Future<void> main() async {
3230
await GeneratedContent.generateAll(pkg_root.packageRoot, allTargets);
33-
34-
_SyntacticErrorGenerator().printSummary();
3531
}
3632

3733
/// A list of all targets generated by this code generator.
@@ -297,88 +293,3 @@ import 'package:analyzer/src/pubspec/pubspec_warning_code.dart';
297293
);
298294
}
299295
}
300-
301-
class _SyntacticErrorGenerator {
302-
final String errorConverterSource;
303-
final String parserSource;
304-
305-
factory _SyntacticErrorGenerator() {
306-
String frontEndSharedPkgPath = normalize(
307-
join(pkg_root.packageRoot, '_fe_analyzer_shared'),
308-
);
309-
310-
String errorConverterSource = File(
311-
join(
312-
analyzerPkgPath,
313-
joinAll(posix.split('lib/src/fasta/error_converter.dart')),
314-
),
315-
).readAsStringSync();
316-
String parserSource = File(
317-
join(
318-
frontEndSharedPkgPath,
319-
joinAll(posix.split('lib/src/parser/parser.dart')),
320-
),
321-
).readAsStringSync();
322-
323-
return _SyntacticErrorGenerator._(errorConverterSource, parserSource);
324-
}
325-
326-
_SyntacticErrorGenerator._(this.errorConverterSource, this.parserSource);
327-
328-
void printSummary() {
329-
// Build a map of error message to ParserErrorCode
330-
var messageToName = <String, String>{};
331-
for (var entry in analyzerMessages['ParserErrorCode']!.entries) {
332-
String message = entry.value.problemMessage.replaceAll(
333-
placeholderPattern,
334-
'',
335-
);
336-
messageToName[message] = entry.key;
337-
}
338-
339-
String messageFromEntryTemplate(ErrorCodeInfo entry) {
340-
String problemMessage = entry.problemMessage;
341-
String message = problemMessage.replaceAll(RegExp(r'#\w+'), '');
342-
return message;
343-
}
344-
345-
// Remove entries that have already been translated
346-
for (ErrorCodeInfo entry
347-
in sharedToAnalyzerErrorCodeTables.infoToAnalyzerCode.keys) {
348-
messageToName.remove(messageFromEntryTemplate(entry));
349-
}
350-
351-
// Print the # of autogenerated ParserErrorCodes.
352-
print(
353-
'${messageToName.length} of '
354-
'${sharedToAnalyzerErrorCodeTables.infoToAnalyzerCode.length} ParserErrorCodes generated.',
355-
);
356-
357-
// List the ParserErrorCodes that could easily be auto generated
358-
// but have not been already.
359-
var analyzerToFasta = <String, List<String>>{};
360-
frontEndMessages.forEach((fastaName, entry) {
361-
var analyzerName = messageToName[messageFromEntryTemplate(entry)];
362-
if (analyzerName != null) {
363-
analyzerToFasta
364-
.putIfAbsent(analyzerName, () => <String>[])
365-
.add(fastaName);
366-
}
367-
});
368-
if (analyzerToFasta.isNotEmpty) {
369-
print('');
370-
print('The following ParserErrorCodes could be auto generated:');
371-
for (String analyzerName in analyzerToFasta.keys.toList()..sort()) {
372-
List<String> fastaNames = analyzerToFasta[analyzerName]!;
373-
if (fastaNames.length == 1) {
374-
print(' $analyzerName = ${fastaNames.first}');
375-
} else {
376-
print(' $analyzerName = $fastaNames');
377-
}
378-
}
379-
if (analyzerToFasta.length > 3) {
380-
print(' ${analyzerToFasta.length} total');
381-
}
382-
}
383-
}
384-
}

0 commit comments

Comments
 (0)