Skip to content

Commit bc83a27

Browse files
committed
Give a better error message when something in the intl file is not a method
1 parent 4cd0c8b commit bc83a27

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/intl_suggestors/message_parser.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ class MessageParser {
4949
rethrow;
5050
}
5151
var intlClass = parsed.unit.declarations.first as ClassDeclaration;
52+
var allDeclarations = intlClass.members.toList();
53+
for (var decl in allDeclarations) {
54+
if (decl is! MethodDeclaration) {
55+
throw FormatException('Invalid member, not a method declaration: "$decl"');
56+
}
57+
}
5258
var methodDeclarations =
53-
intlClass.members.toList().cast<MethodDeclaration>();
59+
allDeclarations.cast<MethodDeclaration>();
5460
methods = [
5561
for (var declaration in methodDeclarations)
5662
Method(declaration.name.name, messageText(declaration),

0 commit comments

Comments
 (0)