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

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

Issue 935123002: Issue 21879. Don't include 'this' and 'super' keywords if not in a method/constructor body. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/keyword_computer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/keyword_computer_test.dart
diff --git a/pkg/analysis_server/test/services/completion/keyword_computer_test.dart b/pkg/analysis_server/test/services/completion/keyword_computer_test.dart
index c51d1867e2133b1c49fbf5b256fc1d19ee324b6b..d0bf83f3f1b9d785cf5eabc1a1b4052c2e1b9d25 100644
--- a/pkg/analysis_server/test/services/completion/keyword_computer_test.dart
+++ b/pkg/analysis_server/test/services/completion/keyword_computer_test.dart
@@ -20,6 +20,45 @@ main() {
@reflectiveTest
class KeywordComputerTest extends AbstractCompletionTest {
+ static const List<Keyword> IN_BLOCK_IN_CLASS =
+ const [
+ Keyword.ASSERT,
+ Keyword.CASE,
+ Keyword.CONTINUE,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SUPER,
+ Keyword.SWITCH,
+ Keyword.THIS,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE];
+
+ static const List<Keyword> IN_BLOCK_NOT_IN_CLASS =
+ const [
+ Keyword.ASSERT,
+ Keyword.CASE,
+ Keyword.CONTINUE,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SWITCH,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE];
void assertSuggestKeywords(Iterable<Keyword> expectedKeywords, [int relevance
= DART_RELEVANCE_KEYWORD]) {
@@ -267,56 +306,64 @@ class KeywordComputerTest extends AbstractCompletionTest {
DART_RELEVANCE_HIGH);
}
- test_function_body() {
+ test_function_body_inClass_constructorInitializer() {
+ addTestSource(r'''
+foo(p) {}
+class A {
+ final f;
+ A() : f = foo(() {^});
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS);
+ }
+
+ test_function_body_inClass_field() {
+ addTestSource(r'''
+class A {
+ var f = () {^};
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS);
+ }
+
+ test_function_body_inClass_methodBody() {
+ addTestSource(r'''
+class A {
+ m() {
+ f() {^};
+ }
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(IN_BLOCK_IN_CLASS);
+ }
+
+ test_function_body_inClass_methodBody_inFunction() {
+ addTestSource(r'''
+class A {
+ m() {
+ f() {
+ f2() {^};
+ };
+ }
+}
+''');
+ expect(computeFast(), isTrue);
+ assertSuggestKeywords(IN_BLOCK_IN_CLASS);
+ }
+
+ test_function_body_inUnit() {
addTestSource('main() {^}');
expect(computeFast(), isTrue);
- assertSuggestKeywords(
- [
- Keyword.ASSERT,
- Keyword.CASE,
- Keyword.CONTINUE,
- Keyword.DO,
- Keyword.FACTORY,
- Keyword.FINAL,
- Keyword.FOR,
- Keyword.IF,
- Keyword.NEW,
- Keyword.RETHROW,
- Keyword.RETURN,
- Keyword.SUPER,
- Keyword.SWITCH,
- Keyword.THIS,
- Keyword.THROW,
- Keyword.TRY,
- Keyword.VAR,
- Keyword.VOID,
- Keyword.WHILE]);
+ assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS);
}
- test_function_body2() {
+ test_function_body_inUnit_afterBlock() {
addTestSource('main() {{}^}');
expect(computeFast(), isTrue);
- assertSuggestKeywords(
- [
- Keyword.ASSERT,
- Keyword.CASE,
- Keyword.CONTINUE,
- Keyword.DO,
- Keyword.FACTORY,
- Keyword.FINAL,
- Keyword.FOR,
- Keyword.IF,
- Keyword.NEW,
- Keyword.RETHROW,
- Keyword.RETURN,
- Keyword.SUPER,
- Keyword.SWITCH,
- Keyword.THIS,
- Keyword.THROW,
- Keyword.TRY,
- Keyword.VAR,
- Keyword.VOID,
- Keyword.WHILE]);
+ assertSuggestKeywords(IN_BLOCK_NOT_IN_CLASS);
}
test_in_class() {
@@ -362,27 +409,7 @@ class KeywordComputerTest extends AbstractCompletionTest {
test_method_body() {
addTestSource('class A { foo() {^}}');
expect(computeFast(), isTrue);
- assertSuggestKeywords(
- [
- Keyword.ASSERT,
- Keyword.CASE,
- Keyword.CONTINUE,
- Keyword.DO,
- Keyword.FACTORY,
- Keyword.FINAL,
- Keyword.FOR,
- Keyword.IF,
- Keyword.NEW,
- Keyword.RETHROW,
- Keyword.RETURN,
- Keyword.SUPER,
- Keyword.SWITCH,
- Keyword.THIS,
- Keyword.THROW,
- Keyword.TRY,
- Keyword.VAR,
- Keyword.VOID,
- Keyword.WHILE]);
+ assertSuggestKeywords(IN_BLOCK_IN_CLASS);
}
test_named_constructor_invocation() {
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/keyword_computer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698