Chromium Code Reviews| Index: pkg/intl/lib/extract_messages.dart |
| diff --git a/pkg/intl/lib/extract_messages.dart b/pkg/intl/lib/extract_messages.dart |
| index 66b2258b2287bd9f16bea293601f93801298f868..79101bea4dbd2875940b4ce8747a27b24523014a 100644 |
| --- a/pkg/intl/lib/extract_messages.dart |
| +++ b/pkg/intl/lib/extract_messages.dart |
| @@ -112,9 +112,7 @@ class MessageFindingVisitor extends GeneralizingASTVisitor { |
| const validNames = const ["message", "plural", "gender", "select"]; |
| if (!validNames.contains(node.methodName.name)) return false; |
| if (!(node.target is SimpleIdentifier)) return false; |
| - SimpleIdentifier target = node.target; |
| - if (target.token.toString() != "Intl") return false; |
| - return true; |
| + return !(node.target.token.toString() != "Intl"); |
|
Alan Knight
2014/01/28 01:33:46
Can we delete both "not"s and simplify this?
vicb
2014/01/28 07:52:45
I did hesitate and thought there might be tricky e
|
| } |
| Message _expectedInstance(String type) { |
| @@ -175,7 +173,7 @@ class MessageFindingVisitor extends GeneralizingASTVisitor { |
| */ |
| void visitMethodInvocation(MethodInvocation node) { |
| if (!addIntlMessage(node)) { |
| - return super.visitMethodInvocation(node); |
| + super.visitMethodInvocation(node); |
| } |
| } |
| @@ -190,10 +188,9 @@ class MessageFindingVisitor extends GeneralizingASTVisitor { |
| var reason = checkValidity(node); |
| if (reason != null) { |
| if (!suppressWarnings) { |
| - var err = new StringBuffer(); |
| - err.write("Skipping invalid Intl.message invocation\n <$node>\n"); |
| - err.write(" reason: $reason\n"); |
| - err.write(_reportErrorLocation(node)); |
| + var err = new StringBuffer() |
| + ..write("Skipping invalid Intl.message invocation\n <$node>\n") |
| + ..writeAll([" reason: $reason\n", _reportErrorLocation(node)]); |
| warnings.add(err.toString()); |
| print(err); |
| } |
| @@ -252,10 +249,9 @@ class MessageFindingVisitor extends GeneralizingASTVisitor { |
| message.messagePieces.addAll(interpolation.pieces); |
| } on IntlMessageExtractionException catch (e) { |
| message = null; |
| - var err = new StringBuffer(); |
| - err.write("Error $e\n"); |
| - err.write("Processing <$node>\n"); |
| - err.write(_reportErrorLocation(node)); |
| + var err = new StringBuffer() |
| + ..writeAll(["Error ", e, "\nProcessing <", node, ">\n"]) |
| + ..write(_reportErrorLocation(node)); |
| print(err); |
| warnings.add(err); |
| } |
| @@ -304,7 +300,7 @@ class MessageFindingVisitor extends GeneralizingASTVisitor { |
| * special-purpose visitor. |
| */ |
| class InterpolationVisitor extends SimpleASTVisitor { |
| - Message message; |
| + final Message message; |
| InterpolationVisitor(this.message); |
| @@ -373,7 +369,7 @@ class PluralAndGenderVisitor extends SimpleASTVisitor { |
| * A plural or gender always exists in the context of a parent message, |
| * which could in turn also be a plural or gender. |
| */ |
| - ComplexMessage parent; |
| + final ComplexMessage parent; |
| /** |
| * The pieces of the message. We are given an initial version of this |
| @@ -381,11 +377,11 @@ class PluralAndGenderVisitor extends SimpleASTVisitor { |
| */ |
| List pieces; |
| - PluralAndGenderVisitor(this.pieces, this.parent) : super() {} |
| - |
| /** This will be set to true if we find a plural or gender. */ |
| bool foundPluralOrGender = false; |
| + PluralAndGenderVisitor(this.pieces, this.parent) : super(); |
| + |
| visitInterpolationExpression(InterpolationExpression node) { |
| // TODO(alanknight): Provide better errors for malformed expressions. |
| if (!looksLikePluralOrGender(node.expression)) return; |
| @@ -408,9 +404,7 @@ class PluralAndGenderVisitor extends SimpleASTVisitor { |
| return false; |
| } |
| if (!(node.target is SimpleIdentifier)) return false; |
| - SimpleIdentifier target = node.target; |
| - if (target.token.toString() != "Intl") return false; |
| - return true; |
| + return !(node.target.token.toString() != "Intl"); |
|
Alan Knight
2014/01/28 01:33:46
Again, I think we can just remove both "not"s
vicb
2014/01/28 07:52:45
fixed
|
| } |
| /** |
| @@ -445,10 +439,9 @@ class PluralAndGenderVisitor extends SimpleASTVisitor { |
| message[key] = interpolation.pieces; |
| } on IntlMessageExtractionException catch (e) { |
| message = null; |
| - var err = new StringBuffer(); |
| - err.write("Error $e"); |
| - err.write("Processing <$node>"); |
| - err.write(_reportErrorLocation(node)); |
| + var err = new StringBuffer() |
| + ..writeAll(["Error ", $e, "\nProcessing <", node, ">"]) |
| + ..write(_reportErrorLocation(node)); |
| print(err); |
| warnings.add(err); |
| } |
| @@ -479,4 +472,4 @@ class IntlMessageExtractionException implements Exception { |
| const IntlMessageExtractionException([this.message = ""]); |
| String toString() => "IntlMessageExtractionException: $message"; |
| -} |
| +} |