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

Unified Diff: pkg/analysis_server/test/services/index/dart_index_contributor_test.dart

Issue 582453002: Index and search of import prefixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
Index: pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart b/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
index 1804b1db17d717db9a2c2fbb9ea67c621e391a7b..f0b26947aa8f1c50969e09df68c9510bfc96fc9f 100644
--- a/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
+++ b/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
@@ -42,7 +42,7 @@ bool _equalsLocation(Location actual, ExpectedLocation expected) {
*/
bool _equalsLocationProperties(Location actual, Element expectedElement,
int expectedOffset, int expectedLength, bool isQualified, bool isResolved) {
- return expectedElement == actual.element &&
+ return (expectedElement == null || expectedElement == actual.element) &&
expectedOffset == actual.offset &&
expectedLength == actual.length &&
isQualified == actual.isQualified &&
@@ -54,7 +54,8 @@ bool _equalsRecordedRelation(RecordedRelation recordedRelation,
Element expectedElement, Relationship expectedRelationship,
ExpectedLocation expectedLocation) {
return expectedElement == recordedRelation.element &&
- expectedRelationship == recordedRelation.relationship &&
+ (expectedRelationship == null ||
+ expectedRelationship == recordedRelation.relationship) &&
(expectedLocation == null ||
_equalsLocation(recordedRelation.location, expectedLocation));
}
@@ -1337,6 +1338,30 @@ main() {
_expectedLocation(mainElement, 'p: 1'));
}
+ void test_isReferencedBy_PrefixElement() {
+ _indexTestUnit('''
+import 'dart:async' as ppp;
+main() {
+ ppp.Future a;
+ ppp.Stream b;
+}
+''');
+ // prepare elements
+ PrefixElement element = findNodeElementAtString('ppp;');
+ Element elementA = findElement('a');
+ Element elementB = findElement('b');
+ // verify
+ _assertRecordedRelation(
+ element,
+ IndexConstants.IS_REFERENCED_BY,
+ _expectedLocation(elementA, 'ppp.Future'));
+ _assertRecordedRelation(
+ element,
+ IndexConstants.IS_REFERENCED_BY,
+ _expectedLocation(elementB, 'ppp.Stream'));
+ _assertNoRecordedRelation(element, null, _expectedLocation(null, 'ppp;'));
+ }
+
void test_isReferencedBy_TopLevelVariableElement() {
addSource('/lib.dart', '''
library lib;

Powered by Google App Engine
This is Rietveld 408576698