Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart

Issue 1360123003: only suggest rethrow inside catch block - fixes #24214 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/keyword_contributor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
index 6aa3536b327097b02ba1eb97dc9b6edafbc0c194..fe9ef1430d2a735b0fa3d73ecf5d8f7b88cf1d7a 100644
--- a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
@@ -1,4 +1,5 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -70,6 +71,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
}
_addStatementKeywords(node);
+ if (_inCatchClause(node)) {
+ _addSuggestion(Keyword.RETHROW, DART_RELEVANCE_KEYWORD - 1);
+ }
}
@override
@@ -446,7 +450,6 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
Keyword.VOID,
Keyword.WHILE
]);
- _addSuggestion(Keyword.RETHROW, DART_RELEVANCE_KEYWORD - 1);
}
void _addSuggestion(Keyword keyword,
@@ -481,6 +484,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
return body != null && body.isAsynchronous;
}
+ bool _inCatchClause(Block node) =>
+ node.getAncestor((p) => p is CatchClause) != null;
+
bool _inClassMemberBody(AstNode node) {
while (true) {
AstNode body = node.getAncestor((n) => n is FunctionBody);
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/keyword_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698