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

Unified Diff: pkg/analyzer/test/generated/incremental_resolver_test.dart

Issue 746903002: Build elements for local variable and label in functions/methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 1 month 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/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/incremental_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/incremental_resolver_test.dart b/pkg/analyzer/test/generated/incremental_resolver_test.dart
index 21c2f6cd8fc79a0aa66e3734a8f4a6d267012c64..27f5e67452668e97a4a5a19fd4c2a8311026f1ad 100644
--- a/pkg/analyzer/test/generated/incremental_resolver_test.dart
+++ b/pkg/analyzer/test/generated/incremental_resolver_test.dart
@@ -1100,18 +1100,29 @@ class A {
_resolve(_editString(');', ') : f = a + b;'), _isClassMember);
}
- void fail_test_functionBody_addLocalVariable() {
- // TODO(scheglov) this test fails, because we don't create element models
- // for new local variables
+ void fail_test_constructor_fieldInitializer_edit() {
+ // TODO(scheglov) resolver uses "enclosingClass", which we don't set yet
_resolveUnit(r'''
-main(int a, int b) {
+class A {
+ int f;
+ A(int a, int b) : f = a + b {
+ int a = 42;
+ }
+}''');
+ _resolve(_editString('+', '*'), _isExpression);
+ }
+
+ void fail_test_topLevelFunction_parameter_rename() {
+ // TODO(scheglov) Decide if incremental parser keeps the element
+ // of the function. If so, we can resolve parameter renames.
+ _resolveUnit(r'''
+int main(int a, int b) {
return a + b;
}
''');
- _resolve(_editString(' return a + b;', r'''
- int res = a + b;
- return res;
-'''), _isBlock);
+ _resolve(_editString(r'''(int a, int b) {
+ return a + b;''', r'''(int first, int b) {
+ return first + b;'''), _isDeclaration);
}
void test_constructor_body() {
@@ -1125,17 +1136,6 @@ class A {
_resolve(_editString('+', '*'), _isFunctionBody);
}
- void test_constructor_fieldInitializer_edit() {
- _resolveUnit(r'''
-class A {
- int f;
- A(int a, int b) : f = a + b {
- int a = 42;
- }
-}''');
- _resolve(_editString('+', '*'), _isExpression);
- }
-
void test_constructor_superConstructorInvocation() {
_resolveUnit(r'''
class A {
@@ -1181,6 +1181,71 @@ class A {
_resolve(_editString('+', '*'), _isFunctionBody);
}
+ void test_method_label_add() {
+ _resolveUnit(r'''
+class A {
+ int m(int a, int b) {
+ return a + b;
+ }
+}
+''');
+ _resolve(_editString('return', 'label: return'), _isBlock);
+ }
+
+ void test_method_localVariable_add() {
+ _resolveUnit(r'''
+class A {
+ int m(int a, int b) {
+ return a + b;
+ }
+}
+''');
+ _resolve(_editString(' return a + b;', r'''
+ int res = a + b;
+ return res;
+'''), _isBlock);
+ }
+
+ void test_topLevelFunction_label_add() {
+ _resolveUnit(r'''
+int main(int a, int b) {
+ return a + b;
+}
+''');
+ _resolve(_editString(' return', 'label: return a + b;'), _isBlock);
+ }
+
+ void test_topLevelFunction_label_remove() {
+ _resolveUnit(r'''
+int main(int a, int b) {
+ label: return a + b;
+}
+''');
+ _resolve(_editString('label: ', ''), _isBlock);
+ }
+
+ void test_topLevelFunction_localVariable_add() {
+ _resolveUnit(r'''
+int main(int a, int b) {
+ return a + b;
+}
+''');
+ _resolve(_editString(' return a + b;', r'''
+ int res = a + b;
+ return res;
+'''), _isBlock);
+ }
+
+ void test_topLevelFunction_localVariable_remove() {
+ _resolveUnit(r'''
+int main(int a, int b) {
+ int res = a * b;
+ return a + b;
+}
+''');
+ _resolve(_editString('int res = a * b;', ''), _isBlock);
+ }
+
void test_topLevelVariable_initializer() {
_resolveUnit(r'''
int C = 1 + 2;
@@ -1278,6 +1343,8 @@ class B {
static bool _isClassMember(AstNode node) => node is ClassMember;
+ static bool _isDeclaration(AstNode node) => node is Declaration;
+
static bool _isExpression(AstNode node) => node is Expression;
static bool _isFunctionBody(AstNode node) => node is FunctionBody;
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698