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

Unified Diff: pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart

Issue 2662973007: suggest catch and finally keywords (Closed)
Patch Set: merge Created 3 years, 10 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
Index: pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
index 4f059411d20297a41658f145989730dadbe36d40..c9462d3c2ee735630ca67c93776f684ce9f0ad97 100644
--- a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
@@ -470,13 +470,202 @@ class KeywordContributorTest extends DartCompletionContributorTest {
relevance: DART_RELEVANCE_HIGH);
}
- test_catch() async {
+ test_catch_1a() async {
+ // '}' Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} ^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_1b() async {
+ // [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} c^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_1c() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} ^;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_1d() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} ^ Foo foo;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_2a() async {
+ // '}' Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} on SomeException {} ^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_2b() async {
+ // [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} on SomeException {} c^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_2c() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} on SomeException {} ^;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_2d() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} on SomeException {} ^ Foo foo;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_3a() async {
+ // '}' Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} catch (e) {} ^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_3b() async {
+ // [ExpressionStatement 'c'] Block BlockFunctionBody FunctionExpression
+ addTestSource('main() {try {} catch (e) {} c^}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_3c() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} catch (e) {} ^;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_3d() async {
+ // [EmptyStatement] Block BlockFunction FunctionExpression
+ addTestSource('main() {try {} catch (e) {} ^ Foo foo;}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ keywords.add(Keyword.FINALLY);
+ keywords.addAll(STMT_START_OUTSIDE_CLASS);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4a1() async {
+ // [CatchClause] TryStatement Block
+ addTestSource('main() {try {} ^ on SomeException {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4a2() async {
+ // ['c' VariableDeclarationStatement] Block BlockFunctionBody
+ addTestSource('main() {try {} c^ on SomeException {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ // TODO(danrubel) finally should not be suggested here
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4b1() async {
+ // [CatchClause] TryStatement Block
+ addTestSource('main() {try {} ^ catch (e) {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4b2() async {
+ // ['c' ExpressionStatement] Block BlockFunctionBody
+ addTestSource('main() {try {} c^ catch (e) {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ // TODO(danrubel) finally should not be suggested here
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4c1() async {
+ // ['finally'] TryStatement Block
+ addTestSource('main() {try {} ^ finally {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_4c2() async {
+ // ['c' ExpressionStatement] Block BlockFunctionBody
+ addTestSource('main() {try {} c^ finally {}}');
+ await computeSuggestions();
+ var keywords = <Keyword>[];
+ keywords.add(Keyword.CATCH);
+ // TODO(danrubel) finally should not be suggested here
+ keywords.add(Keyword.FINALLY);
+ assertSuggestKeywords(keywords, pseudoKeywords: ['on']);
+ }
+
+ test_catch_block() async {
+ // '}' Block CatchClause TryStatement Block
addTestSource('main() {try {} catch (e) {^}}}');
await computeSuggestions();
var keywords = <Keyword>[];
keywords.addAll(STMT_START_OUTSIDE_CLASS);
keywords.add(Keyword.RETHROW);
- assertSuggestKeywords(keywords, relevance: DART_RELEVANCE_KEYWORD);
+ assertSuggestKeywords(keywords);
}
test_class() async {

Powered by Google App Engine
This is Rietveld 408576698