| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:convert'; | 5 import 'dart:convert'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/summary/format.dart'; | 9 import 'package:analyzer/src/summary/format.dart'; |
| 10 import 'package:analyzer/src/summary/idl.dart'; | 10 import 'package:analyzer/src/summary/idl.dart'; |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 print(foo); | 812 print(foo); |
| 813 print(foo()); | 813 print(foo()); |
| 814 } | 814 } |
| 815 '''); | 815 '''); |
| 816 FunctionElement element = findElement('foo'); | 816 FunctionElement element = findElement('foo'); |
| 817 assertThat(element) | 817 assertThat(element) |
| 818 ..isReferencedAt('foo);', false) | 818 ..isReferencedAt('foo);', false) |
| 819 ..isInvokedAt('foo());', false); | 819 ..isInvokedAt('foo());', false); |
| 820 } | 820 } |
| 821 | 821 |
| 822 void test_isReferencedBy_FunctionElement_with_LibraryElement() { |
| 823 addSource( |
| 824 '/foo.dart', |
| 825 r''' |
| 826 bar() {} |
| 827 '''); |
| 828 _indexTestUnit(''' |
| 829 import "foo.dart"; |
| 830 main() { |
| 831 bar(); |
| 832 } |
| 833 '''); |
| 834 LibraryElement fooLibrary = testLibraryElement.imports[0].importedLibrary; |
| 835 assertThat(fooLibrary)..isReferencedAt('"foo.dart";', true, length: 10); |
| 836 { |
| 837 FunctionElement bar = fooLibrary.definingCompilationUnit.functions[0]; |
| 838 assertThat(bar)..isInvokedAt('bar();', false); |
| 839 } |
| 840 } |
| 841 |
| 822 void test_isReferencedBy_FunctionTypeAliasElement() { | 842 void test_isReferencedBy_FunctionTypeAliasElement() { |
| 823 _indexTestUnit(''' | 843 _indexTestUnit(''' |
| 824 typedef A(); | 844 typedef A(); |
| 825 main(A p) { | 845 main(A p) { |
| 826 } | 846 } |
| 827 '''); | 847 '''); |
| 828 Element element = findElement('A'); | 848 Element element = findElement('A'); |
| 829 assertThat(element)..isReferencedAt('A p) {', false); | 849 assertThat(element)..isReferencedAt('A p) {', false); |
| 830 } | 850 } |
| 831 | 851 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1289 final bool isQualified; | 1309 final bool isQualified; |
| 1290 | 1310 |
| 1291 _Relation(this.kind, this.offset, this.length, this.isQualified); | 1311 _Relation(this.kind, this.offset, this.length, this.isQualified); |
| 1292 | 1312 |
| 1293 @override | 1313 @override |
| 1294 String toString() { | 1314 String toString() { |
| 1295 return '_Relation{kind: $kind, offset: $offset, length: $length, ' | 1315 return '_Relation{kind: $kind, offset: $offset, length: $length, ' |
| 1296 'isQualified: $isQualified}'; | 1316 'isQualified: $isQualified}'; |
| 1297 } | 1317 } |
| 1298 } | 1318 } |
| OLD | NEW |