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

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

Issue 814533005: Incrementally resolve users of a changed method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/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 89b14119485a5a29a9ad13c95d711c8269e58d8f..1c5c9168669f383d40a8ad11a374844ac8fccd5b 100644
--- a/pkg/analyzer/test/generated/incremental_resolver_test.dart
+++ b/pkg/analyzer/test/generated/incremental_resolver_test.dart
@@ -25,6 +25,7 @@ import 'resolver_test.dart';
import 'test_support.dart';
+
main() {
groupSep = ' | ';
runReflectiveTests(DeclarationMatcherTest);
@@ -34,6 +35,33 @@ main() {
}
+void _assertEqualError(AnalysisError incrError, AnalysisError fullError) {
+ expect(incrError.errorCode, same(fullError.errorCode));
+ expect(incrError.source, fullError.source);
+ expect(incrError.offset, fullError.offset);
+ expect(incrError.length, fullError.length);
+ expect(incrError.message, fullError.message);
+}
+
+
+void _assertEqualErrors(List<AnalysisError> incrErrors,
+ List<AnalysisError> fullErrors) {
+ expect(incrErrors, hasLength(fullErrors.length));
+ if (incrErrors.isNotEmpty) {
+ incrErrors.sort((a, b) => a.offset - b.offset);
+ }
+ if (fullErrors.isNotEmpty) {
+ fullErrors.sort((a, b) => a.offset - b.offset);
+ }
+ int length = incrErrors.length;
+ for (int i = 0; i < length; i++) {
+ AnalysisError incrError = incrErrors[i];
+ AnalysisError fullError = fullErrors[i];
+ _assertEqualError(incrError, fullError);
+ }
+}
+
+
@ReflectiveTestCase()
class DeclarationMatcherTest extends ResolverTestCase {
void setUp() {
@@ -815,7 +843,6 @@ class A {
}
void test_false_method_parameters_type_edit() {
- // TODO
_assertDoesNotMatchOK(r'''
class A {
m(int p) {
@@ -1899,6 +1926,7 @@ class IncrementalResolverTest extends ResolverTestCase {
void setUp() {
super.setUp();
test_resolveApiChanges = true;
+ log.logger = log.NULL_LOGGER;
}
void test_api_method_edit_returnType() {
@@ -1910,7 +1938,8 @@ class A {
}
main() {
A a = new A();
- var v = a.m();
+ int v = a.m();
+ print(v);
}
''');
_resolve(_editString('int m', 'String m'), _isDeclaration);
@@ -2240,22 +2269,32 @@ class B {
_shiftTokens(unit.beginToken, offset, delta);
}
// do incremental resolution
+ int updateOffset = edit.offset;
+ int updateEndOld = updateOffset + edit.length;
+ int updateOldNew = updateOffset + edit.replacement.length;
IncrementalResolver resolver = new IncrementalResolver(
- typeProvider,
unit.element,
- edit.offset,
- edit.length,
- edit.replacement.length);
+ updateOffset,
+ updateEndOld,
+ updateOldNew);
bool success = resolver.resolve(newNode);
expect(success, isTrue);
+ List<AnalysisError> newErrors = analysisContext.getErrors(source).errors;
// resolve "newCode" from scratch
CompilationUnit fullNewUnit;
{
source = addSource(newCode);
+ _runTasks();
LibraryElement library = resolve(source);
fullNewUnit = resolveCompilationUnit(source, library);
}
_SameResolutionValidator.assertSameResolution(unit, fullNewUnit);
+ // errors
+ List<AnalysisError> newFullErrors =
+ analysisContext.getErrors(source).errors;
+ _assertEqualErrors(newErrors, newFullErrors);
+ // prepare for the next cycle
+ code = newCode;
}
void _resolveUnit(String code) {
@@ -2263,6 +2302,14 @@ class B {
source = addSource(code);
library = resolve(source);
unit = resolveCompilationUnit(source, library);
+ _runTasks();
+ }
+
+ void _runTasks() {
+ AnalysisResult result = analysisContext.performAnalysisTask();
+ while (result.changeNotices != null) {
+ result = analysisContext.performAnalysisTask();
+ }
}
static AstNode _findNodeAt(CompilationUnit oldUnit, int offset,
@@ -2689,7 +2736,7 @@ a() {
b() {
foo(42);
}
-foo(String p) {};
+foo(String p) {}
''');
_updateAndValidate(r'''
a() {
@@ -2698,7 +2745,7 @@ a() {
b() {
foo(42);
}
-foo(String p) {};
+foo(String p) {}
''');
}
@@ -2989,32 +3036,6 @@ f3() {
}
}
- static void _assertEqualError(AnalysisError incrError,
- AnalysisError fullError) {
- expect(incrError.errorCode, same(fullError.errorCode));
- expect(incrError.source, fullError.source);
- expect(incrError.offset, fullError.offset);
- expect(incrError.length, fullError.length);
- expect(incrError.message, fullError.message);
- }
-
- static void _assertEqualErrors(List<AnalysisError> incrErrors,
- List<AnalysisError> fullErrors) {
- expect(incrErrors, hasLength(fullErrors.length));
- if (incrErrors.isNotEmpty) {
- incrErrors.sort((a, b) => a.offset - b.offset);
- }
- if (fullErrors.isNotEmpty) {
- fullErrors.sort((a, b) => a.offset - b.offset);
- }
- int length = incrErrors.length;
- for (int i = 0; i < length; i++) {
- AnalysisError incrError = incrErrors[i];
- AnalysisError fullError = fullErrors[i];
- _assertEqualError(incrError, fullError);
- }
- }
-
static void _assertEqualToken(Token incrToken, Token fullToken) {
expect(incrToken.type, fullToken.type);
expect(incrToken.offset, fullToken.offset);
@@ -3027,8 +3048,6 @@ f3() {
Token incrToken = incrUnit.beginToken;
Token fullToken = fullUnit.beginToken;
while (incrToken.type != TokenType.EOF && fullToken.type != TokenType.EOF) {
-// print('$incrToken @ ${incrToken.offset}');
-// print('$fullToken @ ${fullToken.offset}');
_assertEqualToken(incrToken, fullToken);
// comments
{

Powered by Google App Engine
This is Rietveld 408576698