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

Unified Diff: pkg/analyzer/test/src/task/incremental_element_builder_test.dart

Issue 1131053002: Don't update offsets for elements of 'part' and 'part of' directives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/analyzer/lib/src/task/incremental_element_builder.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/src/task/incremental_element_builder_test.dart
diff --git a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
index 56b622613cceea65ffbbb992e95e692af99c876e..dd05bcb557e6620ff596664bd809ea64a719c9b1 100644
--- a/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
+++ b/pkg/analyzer/test/src/task/incremental_element_builder_test.dart
@@ -68,6 +68,33 @@ import 'dart:math';
}
}
+ test_directives_keepOffset_partOf() {
+ String libCode = '''
+// comment to shift tokens
+library my_lib;
+part 'test.dart';
+''';
+ Source libSource = newSource('/lib.dart', libCode);
+ _buildOldUnit(r'''
+part of my_lib;
+class A {}
+''', libSource);
+ _buildNewUnit(r'''
+part of my_lib;
+class A {}
+''');
+ var oldDirectives = oldUnit.directives;
+ var newDirectives = newUnit.directives;
+ {
+ Directive newNode = newDirectives[0];
+ expect(newNode, same(oldDirectives[0]));
+ expect(getNodeText(newNode), 'part of my_lib;');
+ LibraryElement element = newNode.element;
+ expect(element, isNotNull);
+ expect(element.nameOffset, libCode.indexOf('my_lib;'));
+ }
+ }
+
test_directives_remove() {
_buildOldUnit(r'''
library test;
@@ -557,10 +584,13 @@ bool a =1, b = 2;
expect(newUnit.element, unitElement);
}
- void _buildOldUnit(String oldCode) {
+ void _buildOldUnit(String oldCode, [Source libSource]) {
this.oldCode = oldCode;
source = newSource('/test.dart', oldCode);
- oldUnit = context.resolveCompilationUnit2(source, source);
+ if (libSource == null) {
+ libSource = source;
+ }
+ oldUnit = context.resolveCompilationUnit2(source, libSource);
unitElement = oldUnit.element;
expect(unitElement, isNotNull);
}
« no previous file with comments | « pkg/analyzer/lib/src/task/incremental_element_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698