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

Side by Side Diff: pkg/analysis_server/test/services/completion/keyword_contributor_test.dart

Issue 1410893002: Disable completion in comment text. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.dart.keyword; 5 library test.services.completion.dart.keyword;
6 6
7 import 'package:analysis_server/plugin/protocol/protocol.dart'; 7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
9 import 'package:analysis_server/src/services/completion/keyword_contributor.dart '; 9 import 'package:analysis_server/src/services/completion/keyword_contributor.dart ';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 [Keyword.EXPORT, Keyword.IMPORT, Keyword.LIBRARY, Keyword.PART], 429 [Keyword.EXPORT, Keyword.IMPORT, Keyword.LIBRARY, Keyword.PART],
430 relevance: DART_RELEVANCE_HIGH); 430 relevance: DART_RELEVANCE_HIGH);
431 } 431 }
432 432
433 test_catch() { 433 test_catch() {
434 addTestSource('main() {try {} catch (e) {^}}}'); 434 addTestSource('main() {try {} catch (e) {^}}}');
435 expect(computeFast(), isTrue); 435 expect(computeFast(), isTrue);
436 var keywords = <Keyword>[]; 436 var keywords = <Keyword>[];
437 keywords.addAll(STMT_START_OUTSIDE_CLASS); 437 keywords.addAll(STMT_START_OUTSIDE_CLASS);
438 keywords.add(Keyword.RETHROW); 438 keywords.add(Keyword.RETHROW);
439 assertSuggestKeywords(keywords, 439 assertSuggestKeywords(keywords, relevance: DART_RELEVANCE_KEYWORD);
440 relevance: DART_RELEVANCE_KEYWORD);
441 } 440 }
442 441
443 test_class() { 442 test_class() {
444 addTestSource('class A e^ { }'); 443 addTestSource('class A e^ { }');
445 expect(computeFast(), isTrue); 444 expect(computeFast(), isTrue);
446 assertSuggestKeywords([Keyword.EXTENDS, Keyword.IMPLEMENTS], 445 assertSuggestKeywords([Keyword.EXTENDS, Keyword.IMPLEMENTS],
447 relevance: DART_RELEVANCE_HIGH); 446 relevance: DART_RELEVANCE_HIGH);
448 } 447 }
449 448
450 test_class_body() { 449 test_class_body() {
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 addTestSource( 1028 addTestSource(
1030 'library bar; import "zoo.dart"; imp^ import "package:foo/foo.dart";'); 1029 'library bar; import "zoo.dart"; imp^ import "package:foo/foo.dart";');
1031 expect(computeFast(), isTrue); 1030 expect(computeFast(), isTrue);
1032 // TODO(danrubel) should not suggest declaration keywords 1031 // TODO(danrubel) should not suggest declaration keywords
1033 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, 1032 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS,
1034 relevance: DART_RELEVANCE_HIGH); 1033 relevance: DART_RELEVANCE_HIGH);
1035 expect(request.replacementOffset, 32); 1034 expect(request.replacementOffset, 32);
1036 expect(request.replacementLength, 3); 1035 expect(request.replacementLength, 3);
1037 } 1036 }
1038 1037
1038 test_inComment_block() {
1039 addTestSource('''
1040 main() {
1041 /* text ^ */
1042 print(42);
1043 }
1044 ''');
1045 expect(computeFast(), isTrue);
1046 assertNoSuggestions();
1047 }
1048
1049 test_inComment_endOfLine() {
1050 addTestSource('''
1051 main() {
1052 // text ^
1053 }
1054 ''');
1055 expect(computeFast(), isTrue);
1056 assertNoSuggestions();
1057 }
1058
1039 test_is_expression() { 1059 test_is_expression() {
1040 addTestSource('main() {if (x is^)}'); 1060 addTestSource('main() {if (x is^)}');
1041 expect(computeFast(), isTrue); 1061 expect(computeFast(), isTrue);
1042 assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH); 1062 assertSuggestKeywords([Keyword.IS], relevance: DART_RELEVANCE_HIGH);
1043 } 1063 }
1044 1064
1045 test_library() { 1065 test_library() {
1046 addTestSource('library foo;^'); 1066 addTestSource('library foo;^');
1047 expect(computeFast(), isTrue); 1067 expect(computeFast(), isTrue);
1048 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS, 1068 assertSuggestKeywords(DIRECTIVE_AND_DECLARATION_KEYWORDS,
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 (c) => msg.writeln(' $c, ${other.contains(c) ? '' : '<<<<<<<<<<<'}')); 1415 (c) => msg.writeln(' $c, ${other.contains(c) ? '' : '<<<<<<<<<<<'}'));
1396 } 1416 }
1397 1417
1398 bool _equalSets(Iterable<String> iter1, Iterable<String> iter2) { 1418 bool _equalSets(Iterable<String> iter1, Iterable<String> iter2) {
1399 if (iter1.length != iter2.length) return false; 1419 if (iter1.length != iter2.length) return false;
1400 if (iter1.any((c) => !iter2.contains(c))) return false; 1420 if (iter1.any((c) => !iter2.contains(c))) return false;
1401 if (iter2.any((c) => !iter1.contains(c))) return false; 1421 if (iter2.any((c) => !iter1.contains(c))) return false;
1402 return true; 1422 return true;
1403 } 1423 }
1404 } 1424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698