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:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 | 7 |
8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/src/dart/analysis/driver.dart'; | 10 import 'package:analyzer/src/dart/analysis/driver.dart'; |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 await _indexTestUnit(''' | 807 await _indexTestUnit(''' |
808 foo({var p}) {} | 808 foo({var p}) {} |
809 main() { | 809 main() { |
810 foo(p: 1); | 810 foo(p: 1); |
811 } | 811 } |
812 '''); | 812 '''); |
813 Element element = findElement('p'); | 813 Element element = findElement('p'); |
814 assertThat(element)..isReferencedAt('p: 1', true); | 814 assertThat(element)..isReferencedAt('p: 1', true); |
815 } | 815 } |
816 | 816 |
| 817 test_isReferencedBy_synthetic_leastUpperBound() async { |
| 818 await _indexTestUnit(''' |
| 819 int f1({int p}) => 1; |
| 820 int f2({int p}) => 2; |
| 821 main(bool b) { |
| 822 var f = b ? f1 : f2; |
| 823 f(p: 0); |
| 824 }'''); |
| 825 // We should not crash because of reference to "p" - a named parameter |
| 826 // of a synthetic LUB FunctionElement created for "f". |
| 827 } |
| 828 |
817 test_isReferencedBy_TopLevelVariableElement() async { | 829 test_isReferencedBy_TopLevelVariableElement() async { |
818 provider.newFile( | 830 provider.newFile( |
819 _p('$testProject/lib.dart'), | 831 _p('$testProject/lib.dart'), |
820 ''' | 832 ''' |
821 library lib; | 833 library lib; |
822 var V; | 834 var V; |
823 '''); | 835 '''); |
824 await _indexTestUnit(''' | 836 await _indexTestUnit(''' |
825 import 'lib.dart' show V; // imp | 837 import 'lib.dart' show V; // imp |
826 import 'lib.dart' as pref; | 838 import 'lib.dart' as pref; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 final bool isQualified; | 1243 final bool isQualified; |
1232 | 1244 |
1233 _Relation(this.kind, this.offset, this.length, this.isQualified); | 1245 _Relation(this.kind, this.offset, this.length, this.isQualified); |
1234 | 1246 |
1235 @override | 1247 @override |
1236 String toString() { | 1248 String toString() { |
1237 return '_Relation{kind: $kind, offset: $offset, length: $length, ' | 1249 return '_Relation{kind: $kind, offset: $offset, length: $length, ' |
1238 'isQualified: $isQualified}lified)'; | 1250 'isQualified: $isQualified}lified)'; |
1239 } | 1251 } |
1240 } | 1252 } |
OLD | NEW |