| 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.domain.analysis.notification.occurrences; | 5 library test.domain.analysis.notification.occurrences; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; | 10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return prepareOccurrences().then((_) { | 118 return prepareOccurrences().then((_) { |
| 119 assertHasRegion('vvv ='); | 119 assertHasRegion('vvv ='); |
| 120 expect(testOccurences.element.kind, ElementKind.LOCAL_VARIABLE); | 120 expect(testOccurences.element.kind, ElementKind.LOCAL_VARIABLE); |
| 121 expect(testOccurences.element.name, 'vvv'); | 121 expect(testOccurences.element.name, 'vvv'); |
| 122 assertHasOffset('vvv = 42'); | 122 assertHasOffset('vvv = 42'); |
| 123 assertHasOffset('vvv);'); | 123 assertHasOffset('vvv);'); |
| 124 }); | 124 }); |
| 125 }); | 125 }); |
| 126 } | 126 } |
| 127 | 127 |
| 128 test_classType() { | |
| 129 addTestFile(''' | |
| 130 main() { | |
| 131 int a = 1; | |
| 132 int b = 2; | |
| 133 int c = 3; | |
| 134 } | |
| 135 int VVV = 4; | |
| 136 '''); | |
| 137 return prepareOccurrences().then((_) { | |
| 138 assertHasRegion('int a'); | |
| 139 expect(testOccurences.element.kind, ElementKind.CLASS); | |
| 140 expect(testOccurences.element.name, 'int'); | |
| 141 assertHasOffset('int a'); | |
| 142 assertHasOffset('int b'); | |
| 143 assertHasOffset('int c'); | |
| 144 assertHasOffset('int VVV'); | |
| 145 }); | |
| 146 } | |
| 147 | |
| 148 test_field() { | 128 test_field() { |
| 149 addTestFile(''' | 129 addTestFile(''' |
| 150 class A { | 130 class A { |
| 151 int fff; | 131 int fff; |
| 152 A(this.fff); // constructor | 132 A(this.fff); // constructor |
| 153 main() { | 133 main() { |
| 154 fff = 42; | 134 fff = 42; |
| 155 print(fff); // print | 135 print(fff); // print |
| 156 } | 136 } |
| 157 } | 137 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 print(VVV); | 211 print(VVV); |
| 232 } | 212 } |
| 233 '''); | 213 '''); |
| 234 return prepareOccurrences().then((_) { | 214 return prepareOccurrences().then((_) { |
| 235 assertHasRegion('VVV = 1;'); | 215 assertHasRegion('VVV = 1;'); |
| 236 expect(testOccurences.element.kind, ElementKind.TOP_LEVEL_VARIABLE); | 216 expect(testOccurences.element.kind, ElementKind.TOP_LEVEL_VARIABLE); |
| 237 assertHasOffset('VVV = 2;'); | 217 assertHasOffset('VVV = 2;'); |
| 238 assertHasOffset('VVV);'); | 218 assertHasOffset('VVV);'); |
| 239 }); | 219 }); |
| 240 } | 220 } |
| 221 |
| 222 test_type_class() { |
| 223 addTestFile(''' |
| 224 main() { |
| 225 int a = 1; |
| 226 int b = 2; |
| 227 int c = 3; |
| 241 } | 228 } |
| 229 int VVV = 4; |
| 230 '''); |
| 231 return prepareOccurrences().then((_) { |
| 232 assertHasRegion('int a'); |
| 233 expect(testOccurences.element.kind, ElementKind.CLASS); |
| 234 expect(testOccurences.element.name, 'int'); |
| 235 assertHasOffset('int a'); |
| 236 assertHasOffset('int b'); |
| 237 assertHasOffset('int c'); |
| 238 assertHasOffset('int VVV'); |
| 239 }); |
| 240 } |
| 241 |
| 242 test_type_dynamic() { |
| 243 addTestFile(''' |
| 244 main() { |
| 245 dynamic a = 1; |
| 246 dynamic b = 2; |
| 247 } |
| 248 dynamic V = 3; |
| 249 '''); |
| 250 return prepareOccurrences().then((_) { |
| 251 int offset = findOffset('dynamic a'); |
| 252 findRegion(offset, 'dynamic'.length, false); |
| 253 }); |
| 254 } |
| 255 |
| 256 test_type_void() { |
| 257 addTestFile(''' |
| 258 void main() { |
| 259 } |
| 260 '''); |
| 261 return prepareOccurrences().then((_) { |
| 262 int offset = findOffset('void main()'); |
| 263 findRegion(offset, 'void'.length, false); |
| 264 }); |
| 265 } |
| 266 } |
| OLD | NEW |