Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index 8626a5f91f2a31ff50b019d4a65dccb289b76b8c..f529389486013538a1c2c0e6d3b0d207973cc744 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -4545,10 +4545,15 @@ void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, |
| bool is_patch = false; |
| bool is_abstract = false; |
| TokenPosition declaration_pos = |
| - metadata_pos.IsReal() ? metadata_pos : TokenPos(); |
| - if (is_patch_source() && |
| + metadata_pos.IsReal() ? metadata_pos : TokenPos(); |
| + if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| + is_patch = true; |
| + metadata_pos = TokenPosition::kNoSource; |
| + declaration_pos = TokenPos(); |
| + } else if (is_patch_source() && |
| (CurrentToken() == Token::kIDENT) && |
| CurrentLiteral()->Equals("patch")) { |
| + ReportWarning("deprecated use of patch annotation"); |
|
kasperl
2016/08/09 11:48:09
patch annotation -> patch "keyword"?
hausner
2016/08/09 15:48:45
Done. This legacy support and warning should go aw
|
| ConsumeToken(); |
| is_patch = true; |
| } else if (CurrentToken() == Token::kABSTRACT) { |
| @@ -5264,6 +5269,19 @@ void Parser::ConsumeRightAngleBracket() { |
| } |
| +bool Parser::IsPatchAnnotation(TokenPosition pos) { |
| + if (pos == TokenPosition::kNoSource) { |
| + return false; |
| + } |
| + TokenPosition saved_pos = TokenPos(); |
| + SetPosition(pos); |
| + ExpectToken(Token::kAT); |
| + bool is_patch = IsSymbol(Symbols::Patch()); |
| + SetPosition(saved_pos); |
| + return is_patch; |
| +} |
| + |
| + |
| TokenPosition Parser::SkipMetadata() { |
| if (CurrentToken() != Token::kAT) { |
| return TokenPosition::kNoSource; |
| @@ -5606,10 +5624,14 @@ void Parser::ParseTopLevelFunction(TopLevel* top_level, |
| const bool is_static = true; |
| bool is_external = false; |
| bool is_patch = false; |
| - if (is_patch_source() && |
| + if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| + is_patch = true; |
| + metadata_pos = TokenPosition::kNoSource; |
| + } else if (is_patch_source() && |
| (CurrentToken() == Token::kIDENT) && |
| CurrentLiteral()->Equals("patch") && |
| (LookaheadToken(1) != Token::kLPAREN)) { |
| + ReportWarning("deprecated use of patch annotation"); |
| ConsumeToken(); |
| is_patch = true; |
| } else if (CurrentToken() == Token::kEXTERNAL) { |
| @@ -5729,9 +5751,13 @@ void Parser::ParseTopLevelAccessor(TopLevel* top_level, |
| bool is_external = false; |
| bool is_patch = false; |
| AbstractType& result_type = AbstractType::Handle(Z); |
| - if (is_patch_source() && |
| + if (is_patch_source() && IsPatchAnnotation(metadata_pos)) { |
| + is_patch = true; |
| + metadata_pos = TokenPosition::kNoSource; |
| + } else if (is_patch_source() && |
| (CurrentToken() == Token::kIDENT) && |
| CurrentLiteral()->Equals("patch")) { |
| + ReportWarning("deprecated use of patch annotation"); |
| ConsumeToken(); |
| is_patch = true; |
| } else if (CurrentToken() == Token::kEXTERNAL) { |