| 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.services.correction.status; | 5 library test.services.correction.status; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' hide Element; |
| 8 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 7 import 'package:analysis_server/src/services/correction/status.dart'; | 9 import 'package:analysis_server/src/services/correction/status.dart'; |
| 8 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 9 import 'package:analysis_server/src/services/correction/source_range.dart'; | |
| 10 import '../../abstract_single_unit.dart'; | |
| 11 import '../../reflective_tests.dart'; | |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/element.dart'; | 12 import 'package:analyzer/src/generated/element.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 16 import 'package:analysis_server/src/protocol.dart' hide Element; | 15 |
| 16 import '../../abstract_single_unit.dart'; |
| 17 import '../../reflective_tests.dart'; |
| 17 | 18 |
| 18 | 19 |
| 19 main() { | 20 main() { |
| 20 groupSep = ' | '; | 21 groupSep = ' | '; |
| 21 runReflectiveTests(RefactoringLocationTest); | 22 runReflectiveTests(RefactoringLocationTest); |
| 22 runReflectiveTests(RefactoringStatusTest); | 23 runReflectiveTests(RefactoringStatusTest); |
| 23 } | 24 } |
| 24 | 25 |
| 25 | 26 |
| 26 @ReflectiveTestCase() | 27 @ReflectiveTestCase() |
| 27 class RefactoringLocationTest extends AbstractSingleUnitTest { | 28 class RefactoringLocationTest extends AbstractSingleUnitTest { |
| 28 void test_createLocation_forElement() { | 29 void test_createLocation_forElement() { |
| 29 resolveTestUnit('class MyClass {}'); | 30 resolveTestUnit('class MyClass {}'); |
| 30 Element element = findElement('MyClass'); | 31 Element element = findElement('MyClass'); |
| 31 // check | 32 // check |
| 32 Location location = new Location.fromElement(element); | 33 Location location = newLocation_fromElement(element); |
| 33 expect(location.file, '/test.dart'); | 34 expect(location.file, '/test.dart'); |
| 34 expect(location.offset, 6); | 35 expect(location.offset, 6); |
| 35 expect(location.length, 7); | 36 expect(location.length, 7); |
| 36 expect(location.startLine, 1); | 37 expect(location.startLine, 1); |
| 37 expect(location.startColumn, 7); | 38 expect(location.startColumn, 7); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void test_createLocation_forMatch() { | 41 void test_createLocation_forMatch() { |
| 41 resolveTestUnit('class MyClass {}'); | 42 resolveTestUnit('class MyClass {}'); |
| 42 Element element = findElement('MyClass'); | 43 Element element = findElement('MyClass'); |
| 43 SourceRange range = rangeElementName(element); | 44 SourceRange range = rangeElementName(element); |
| 44 SearchMatch match = new SearchMatch(null, element, range, true, false); | 45 SearchMatch match = new SearchMatch(null, element, range, true, false); |
| 45 // check | 46 // check |
| 46 Location location = new Location.fromMatch(match); | 47 Location location = newLocation_fromMatch(match); |
| 47 expect(location.file, '/test.dart'); | 48 expect(location.file, '/test.dart'); |
| 48 expect(location.offset, range.offset); | 49 expect(location.offset, range.offset); |
| 49 expect(location.length, range.length); | 50 expect(location.length, range.length); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void test_createLocation_forNode() { | 53 void test_createLocation_forNode() { |
| 53 resolveTestUnit(''' | 54 resolveTestUnit(''' |
| 54 main() { | 55 main() { |
| 55 } | 56 } |
| 56 '''); | 57 '''); |
| 57 AstNode node = findNodeAtString('main'); | 58 AstNode node = findNodeAtString('main'); |
| 58 // check | 59 // check |
| 59 Location location = new Location.fromNode(node); | 60 Location location = newLocation_fromNode(node); |
| 60 expect(location.file, '/test.dart'); | 61 expect(location.file, '/test.dart'); |
| 61 expect(location.offset, node.offset); | 62 expect(location.offset, node.offset); |
| 62 expect(location.length, node.length); | 63 expect(location.length, node.length); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void test_createLocation_forUnit() { | 66 void test_createLocation_forUnit() { |
| 66 resolveTestUnit(''); | 67 resolveTestUnit(''); |
| 67 SourceRange range = rangeStartLength(10, 20); | 68 SourceRange range = rangeStartLength(10, 20); |
| 68 // check | 69 // check |
| 69 Location location = new Location.fromUnit(testUnit, range); | 70 Location location = newLocation_fromUnit(testUnit, range); |
| 70 expect(location.file, '/test.dart'); | 71 expect(location.file, '/test.dart'); |
| 71 expect(location.offset, range.offset); | 72 expect(location.offset, range.offset); |
| 72 expect(location.length, range.length); | 73 expect(location.length, range.length); |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 | 77 |
| 77 @ReflectiveTestCase() | 78 @ReflectiveTestCase() |
| 78 class RefactoringStatusTest { | 79 class RefactoringStatusTest { |
| 79 void test_addError() { | 80 void test_addError() { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); | 220 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); |
| 220 expect(refactoringStatus.message, 'msg'); | 221 expect(refactoringStatus.message, 'msg'); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void test_newWarning() { | 224 void test_newWarning() { |
| 224 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg'); | 225 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg'); |
| 225 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING); | 226 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING); |
| 226 expect(refactoringStatus.message, 'msg'); | 227 expect(refactoringStatus.message, 'msg'); |
| 227 } | 228 } |
| 228 } | 229 } |
| OLD | NEW |