| 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.computer.element; | 5 library test.computer.element; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 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_server.dart'; | 10 import 'package:analysis_server/src/protocol_server.dart'; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 expect(element.kind, ElementKind.CLASS); | 236 expect(element.kind, ElementKind.CLASS); |
| 237 expect(element.name, '_MyClass'); | 237 expect(element.name, '_MyClass'); |
| 238 { | 238 { |
| 239 Location location = element.location; | 239 Location location = element.location; |
| 240 expect(location.file, '/test.dart'); | 240 expect(location.file, '/test.dart'); |
| 241 expect(location.offset, 27); | 241 expect(location.offset, 27); |
| 242 expect(location.length, '_MyClass'.length); | 242 expect(location.length, '_MyClass'.length); |
| 243 expect(location.startLine, 2); | 243 expect(location.startLine, 2); |
| 244 expect(location.startColumn, 16); | 244 expect(location.startColumn, 16); |
| 245 } | 245 } |
| 246 expect(element.parameters, isNull); |
| 246 expect( | 247 expect( |
| 247 element.flags, | 248 element.flags, |
| 248 Element.FLAG_ABSTRACT | Element.FLAG_DEPRECATED | Element.FLAG_PRIVATE); | 249 Element.FLAG_ABSTRACT | Element.FLAG_DEPRECATED | Element.FLAG_PRIVATE); |
| 249 } | 250 } |
| 250 | 251 |
| 251 void test_fromElement_CONSTRUCTOR() { | 252 void test_fromElement_CONSTRUCTOR() { |
| 252 engine.Source source = addSource('/test.dart', ''' | 253 engine.Source source = addSource('/test.dart', ''' |
| 253 class A { | 254 class A { |
| 254 const A.myConstructor(int a, [String b]); | 255 const A.myConstructor(int a, [String b]); |
| 255 }'''); | 256 }'''); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 expect(location.startColumn, 16); | 294 expect(location.startColumn, 16); |
| 294 } | 295 } |
| 295 expect(element.parameters, isNull); | 296 expect(element.parameters, isNull); |
| 296 expect(element.returnType, isNull); | 297 expect(element.returnType, isNull); |
| 297 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC); | 298 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC); |
| 298 } | 299 } |
| 299 | 300 |
| 300 void test_fromElement_GETTER() { | 301 void test_fromElement_GETTER() { |
| 301 engine.Source source = addSource('/test.dart', ''' | 302 engine.Source source = addSource('/test.dart', ''' |
| 302 class A { | 303 class A { |
| 303 String myGetter => 42; | 304 String get myGetter => 42; |
| 304 }'''); | 305 }'''); |
| 305 engine.CompilationUnit unit = resolveLibraryUnit(source); | 306 engine.CompilationUnit unit = resolveLibraryUnit(source); |
| 306 engine.PropertyAccessorElement engineElement = | 307 engine.PropertyAccessorElement engineElement = |
| 307 findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER); | 308 findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER); |
| 308 // create notification Element | 309 // create notification Element |
| 309 Element element = newElement_fromEngine(engineElement); | 310 Element element = newElement_fromEngine(engineElement); |
| 310 expect(element.kind, ElementKind.GETTER); | 311 expect(element.kind, ElementKind.GETTER); |
| 311 expect(element.name, 'myGetter'); | 312 expect(element.name, 'myGetter'); |
| 312 { | 313 { |
| 313 Location location = element.location; | 314 Location location = element.location; |
| 314 expect(location.file, '/test.dart'); | 315 expect(location.file, '/test.dart'); |
| 315 expect(location.offset, 19); | 316 expect(location.offset, 23); |
| 316 expect(location.length, 'myGetter'.length); | 317 expect(location.length, 'myGetter'.length); |
| 317 expect(location.startLine, 2); | 318 expect(location.startLine, 2); |
| 318 expect(location.startColumn, 10); | 319 expect(location.startColumn, 14); |
| 319 } | 320 } |
| 320 expect(element.parameters, '()'); | 321 expect(element.parameters, '()'); |
| 321 expect(element.returnType, 'String'); | 322 expect(element.returnType, 'String'); |
| 322 expect(element.flags, 0); | 323 expect(element.flags, 0); |
| 323 } | 324 } |
| 324 | 325 |
| 325 void test_fromElement_LABEL() { | 326 void test_fromElement_LABEL() { |
| 326 engine.Source source = addSource('/test.dart', ''' | 327 engine.Source source = addSource('/test.dart', ''' |
| 327 main() { | 328 main() { |
| 328 myLabel: | 329 myLabel: |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // use SearchResultKind inside the analysis server? | 510 // use SearchResultKind inside the analysis server? |
| 510 new EnumTester<MatchKind, SearchResultKind>().run( | 511 new EnumTester<MatchKind, SearchResultKind>().run( |
| 511 newSearchResultKind_fromEngine, | 512 newSearchResultKind_fromEngine, |
| 512 exceptions: { | 513 exceptions: { |
| 513 // TODO(paulberry): do any of the exceptions below constitute bugs? | 514 // TODO(paulberry): do any of the exceptions below constitute bugs? |
| 514 MatchKind.ANGULAR_REFERENCE: SearchResultKind.UNKNOWN, | 515 MatchKind.ANGULAR_REFERENCE: SearchResultKind.UNKNOWN, |
| 515 MatchKind.ANGULAR_CLOSING_TAG_REFERENCE: SearchResultKind.UNKNOWN | 516 MatchKind.ANGULAR_CLOSING_TAG_REFERENCE: SearchResultKind.UNKNOWN |
| 516 }); | 517 }); |
| 517 } | 518 } |
| 518 } | 519 } |
| OLD | NEW |