OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library test.analysis.notification.highlights2; | 5 library test.analysis.notification.highlights2; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 } | 1087 } |
1088 '''); | 1088 '''); |
1089 return prepareHighlights().then((_) { | 1089 return prepareHighlights().then((_) { |
1090 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T> {'); | 1090 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T> {'); |
1091 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T fff;'); | 1091 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T fff;'); |
1092 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T mmm('); | 1092 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T mmm('); |
1093 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T p)'); | 1093 assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T p)'); |
1094 }); | 1094 }); |
1095 } | 1095 } |
1096 | 1096 |
| 1097 test_UNRESOLVED_INSTANCE_MEMBER_REFERENCE_dynamicVarTarget() { |
| 1098 addTestFile(''' |
| 1099 main(p) { |
| 1100 p.aaa; |
| 1101 p.aaa++; |
| 1102 p.aaa += 0; |
| 1103 ++p.aaa; // ++ |
| 1104 p.aaa = 0; |
| 1105 p.bbb(0); |
| 1106 ''.length.ccc().ddd(); |
| 1107 } |
| 1108 '''); |
| 1109 return prepareHighlights().then((_) { |
| 1110 HighlightRegionType type = |
| 1111 HighlightRegionType.UNRESOLVED_INSTANCE_MEMBER_REFERENCE; |
| 1112 assertHasRegion(type, 'aaa'); |
| 1113 assertHasRegion(type, 'aaa++'); |
| 1114 assertHasRegion(type, 'aaa += 0'); |
| 1115 assertHasRegion(type, 'aaa; // ++'); |
| 1116 assertHasRegion(type, 'aaa ='); |
| 1117 assertHasRegion(type, 'bbb('); |
| 1118 assertHasRegion(type, 'ddd()'); |
| 1119 }); |
| 1120 } |
| 1121 |
| 1122 test_UNRESOLVED_INSTANCE_MEMBER_REFERENCE_nonDynamicTarget() { |
| 1123 addTestFile(''' |
| 1124 import 'dart:math' as math; |
| 1125 main(String str) { |
| 1126 new Object().aaa(); |
| 1127 math.bbb(); |
| 1128 str.ccc(); |
| 1129 } |
| 1130 class A { |
| 1131 m() { |
| 1132 unresolved(1); |
| 1133 this.unresolved(2); |
| 1134 super.unresolved(3); |
| 1135 } |
| 1136 } |
| 1137 '''); |
| 1138 return prepareHighlights().then((_) { |
| 1139 HighlightRegionType type = HighlightRegionType.IDENTIFIER_DEFAULT; |
| 1140 assertHasRegion(type, 'aaa()'); |
| 1141 assertHasRegion(type, 'bbb()'); |
| 1142 assertHasRegion(type, 'ccc()'); |
| 1143 assertHasRegion(type, 'unresolved(1)'); |
| 1144 assertHasRegion(type, 'unresolved(2)'); |
| 1145 assertHasRegion(type, 'unresolved(3)'); |
| 1146 }); |
| 1147 } |
| 1148 |
1097 void _addLibraryForTestPart() { | 1149 void _addLibraryForTestPart() { |
1098 addFile( | 1150 addFile( |
1099 '$testFolder/my_lib.dart', | 1151 '$testFolder/my_lib.dart', |
1100 ''' | 1152 ''' |
1101 library lib; | 1153 library lib; |
1102 part 'test.dart'; | 1154 part 'test.dart'; |
1103 '''); | 1155 '''); |
1104 } | 1156 } |
1105 } | 1157 } |
1106 | 1158 |
1107 @reflectiveTest | 1159 @reflectiveTest |
1108 class HighlightTypeTest { | 1160 class HighlightTypeTest { |
1109 void test_constructor() { | 1161 void test_constructor() { |
1110 expect(HighlightRegionType.CLASS, | 1162 expect(HighlightRegionType.CLASS, |
1111 new HighlightRegionType(HighlightRegionType.CLASS.name)); | 1163 new HighlightRegionType(HighlightRegionType.CLASS.name)); |
1112 } | 1164 } |
1113 | 1165 |
1114 void test_toString() { | 1166 void test_toString() { |
1115 expect(HighlightRegionType.CLASS.toString(), 'HighlightRegionType.CLASS'); | 1167 expect(HighlightRegionType.CLASS.toString(), 'HighlightRegionType.CLASS'); |
1116 } | 1168 } |
1117 | 1169 |
1118 void test_valueOf_unknown() { | 1170 void test_valueOf_unknown() { |
1119 expect(() { | 1171 expect(() { |
1120 new HighlightRegionType('no-such-type'); | 1172 new HighlightRegionType('no-such-type'); |
1121 }, throws); | 1173 }, throws); |
1122 } | 1174 } |
1123 } | 1175 } |
OLD | NEW |