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

Unified Diff: pkg/analyzer/test/src/summary/index_unit_test.dart

Issue 1789663003: Index synthetic top-level variable and 'loadLibrary' references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/summary/index_unit.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/summary/index_unit_test.dart
diff --git a/pkg/analyzer/test/src/summary/index_unit_test.dart b/pkg/analyzer/test/src/summary/index_unit_test.dart
index dd0e2d0b19c0142e1db5c19f2eebbf1ed2cba5d2..fa9503250a33fff11b1a65312c55674e4f6ca52a 100644
--- a/pkg/analyzer/test/src/summary/index_unit_test.dart
+++ b/pkg/analyzer/test/src/summary/index_unit_test.dart
@@ -314,6 +314,21 @@ main() {
..isInvokedAt('foo(); // nq', false);
}
+ void test_isInvokedBy_FunctionElement_synthetic_loadLibrary() {
+ verifyNoTestUnitErrors = false;
+ _indexTestUnit('''
+import 'dart:math' deferred as math;
+main() {
+ math.loadLibrary(); // 1
+ math.loadLibrary(); // 2
+}
+''');
+ LibraryElement mathLib = testLibraryElement.imports[0].importedLibrary;
+ FunctionElement element = mathLib.loadLibraryFunction;
+ assertThat(element).isInvokedAt('loadLibrary(); // 1', true);
+ assertThat(element).isInvokedAt('loadLibrary(); // 2', true);
+ }
+
void test_isInvokedBy_MethodElement() {
_indexTestUnit('''
class A {
@@ -790,6 +805,35 @@ main() {
..isReferencedAt('V = 5; // nq', false);
}
+ void test_isReferencedBy_TopLevelVariableElement_synthetic_hasGetterSetter() {
+ verifyNoTestUnitErrors = false;
+ addSource(
+ '/lib.dart',
+ '''
+int get V => 0;
+void set V(_) {}
+''');
+ _indexTestUnit('''
+import 'lib.dart' show V;
+''');
+ TopLevelVariableElement element = importedUnit().topLevelVariables[0];
+ assertThat(element).isReferencedAt('V;', true);
+ }
+
+ void test_isReferencedBy_TopLevelVariableElement_synthetic_hasSetter() {
+ verifyNoTestUnitErrors = false;
+ addSource(
+ '/lib.dart',
+ '''
+void set V(_) {}
+''');
+ _indexTestUnit('''
+import 'lib.dart' show V;
+''');
+ TopLevelVariableElement element = importedUnit().topLevelVariables[0];
+ assertThat(element).isReferencedAt('V;', true);
+ }
+
void test_isReferencedBy_typeInVariableList() {
_indexTestUnit('''
class A {}
@@ -862,7 +906,7 @@ main(C c) {
List<_Relation> relations,
IndexRelationKind expectedRelationKind,
ExpectedLocation expectedLocation) {
- for (var relation in relations) {
+ for (_Relation relation in relations) {
if (relation.kind == expectedRelationKind &&
relation.offset == expectedLocation.offset &&
relation.length == expectedLocation.length &&
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698