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

Unified Diff: pkg/analysis_server/test/analysis_notification_occurrences_test.dart

Issue 396043003: Improve occurrences calculation - merge accessors, members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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/computer/computer_occurrences.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/analysis_notification_occurrences_test.dart
diff --git a/pkg/analysis_server/test/analysis_notification_occurrences_test.dart b/pkg/analysis_server/test/analysis_notification_occurrences_test.dart
index 816effd6144d4b42eccfb65c24b33dd756a0b05b..8f65214ddac96a5c50d7a2c6328944ac7aace627 100644
--- a/pkg/analysis_server/test/analysis_notification_occurrences_test.dart
+++ b/pkg/analysis_server/test/analysis_notification_occurrences_test.dart
@@ -66,8 +66,9 @@ class AnalysisNotificationOccurrencesTest extends AbstractAnalysisTest {
for (int occurrenceOffset in occurrences.offsets) {
if (occurrenceOffset == offset) {
if (exists == false) {
- fail('Not expected to find (offset=$offset; length=$length) in\n'
- '${occurrencesList.join('\n')}');
+ fail(
+ 'Not expected to find (offset=$offset; length=$length) in\n'
+ '${occurrencesList.join('\n')}');
}
testOccurences = occurrences;
return;
@@ -75,8 +76,9 @@ class AnalysisNotificationOccurrencesTest extends AbstractAnalysisTest {
}
}
if (exists == true) {
- fail('Expected to find (offset=$offset; length=$length) in\n'
- '${occurrencesList.join('\n')}');
+ fail(
+ 'Expected to find (offset=$offset; length=$length) in\n'
+ '${occurrencesList.join('\n')}');
}
}
@@ -92,8 +94,8 @@ class AnalysisNotificationOccurrencesTest extends AbstractAnalysisTest {
String file = notification.getParameter(FILE);
if (file == testFile) {
occurrencesList = <Occurrences>[];
- List<Map<String, Object>> jsonList = notification.getParameter(
- OCCURRENCES);
+ List<Map<String, Object>> jsonList =
+ notification.getParameter(OCCURRENCES);
for (Map<String, Object> json in jsonList) {
occurrencesList.add(new Occurrences.fromJson(json));
}
@@ -145,6 +147,26 @@ int VVV = 4;
});
}
+ test_field() {
+ addTestFile('''
+class A {
+ int fff;
+ A(this.fff); // constructor
+ main() {
+ fff = 42;
+ print(fff); // print
+ }
+}
+''');
+ return prepareOccurrences(() {
+ assertHasRegion('fff;');
+ expect(testOccurences.element.kind, ElementKind.FIELD);
+ assertHasOffset('fff); // constructor');
+ assertHasOffset('fff = 42;');
+ assertHasOffset('fff); // print');
+ });
+ }
+
test_localVariable() {
addTestFile('''
main() {
@@ -162,4 +184,60 @@ main() {
assertHasOffset('vvv);');
});
}
+
+ test_memberField() {
+ addTestFile('''
+class A<T> {
+ T fff;
+}
+main() {
+ var a = new A<int>();
+ var b = new A<String>();
+ a.fff = 1;
+ b.fff = 2;
+}
+''');
+ return prepareOccurrences(() {
+ assertHasRegion('fff;');
+ expect(testOccurences.element.kind, ElementKind.FIELD);
+ assertHasOffset('fff = 1;');
+ assertHasOffset('fff = 2;');
+ });
+ }
+
+ test_memberMethod() {
+ addTestFile('''
+class A<T> {
+ T mmm() {}
+}
+main() {
+ var a = new A<int>();
+ var b = new A<String>();
+ a.mmm(); // a
+ b.mmm(); // b
+}
+''');
+ return prepareOccurrences(() {
+ assertHasRegion('mmm() {}');
+ expect(testOccurences.element.kind, ElementKind.METHOD);
+ assertHasOffset('mmm(); // a');
+ assertHasOffset('mmm(); // b');
+ });
+ }
+
+ test_topLevelVariable() {
+ addTestFile('''
+var VVV = 1;
+main() {
+ VVV = 2;
+ print(VVV);
+}
+''');
+ return prepareOccurrences(() {
+ assertHasRegion('VVV = 1;');
+ expect(testOccurences.element.kind, ElementKind.TOP_LEVEL_VARIABLE);
+ assertHasOffset('VVV = 2;');
+ assertHasOffset('VVV);');
+ });
+ }
}
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_occurrences.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698