Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1840)

Side by Side Diff: pkg/analysis_server/test/services/correction/status_test.dart

Issue 2869083002: Convert server to use RangeFactory (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 7 import 'package:analysis_server/src/protocol_server.dart' hide Element;
8 import 'package:analysis_server/src/services/correction/source_range.dart';
9 import 'package:analysis_server/src/services/correction/status.dart'; 8 import 'package:analysis_server/src/services/correction/status.dart';
10 import 'package:analysis_server/src/services/search/search_engine.dart'; 9 import 'package:analysis_server/src/services/search/search_engine.dart';
11 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; 10 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
12 import 'package:analyzer/dart/ast/ast.dart'; 11 import 'package:analyzer/dart/ast/ast.dart';
13 import 'package:analyzer/dart/element/element.dart'; 12 import 'package:analyzer/dart/element/element.dart';
14 import 'package:analyzer/src/generated/source.dart'; 13 import 'package:analyzer/src/generated/source.dart';
14 import 'package:analyzer_plugin/utilities/range_factory.dart';
15 import 'package:test/test.dart'; 15 import 'package:test/test.dart';
16 import 'package:test_reflective_loader/test_reflective_loader.dart'; 16 import 'package:test_reflective_loader/test_reflective_loader.dart';
17 17
18 import '../../abstract_single_unit.dart'; 18 import '../../abstract_single_unit.dart';
19 19
20 main() { 20 main() {
21 defineReflectiveSuite(() { 21 defineReflectiveSuite(() {
22 defineReflectiveTests(RefactoringLocationTest); 22 defineReflectiveTests(RefactoringLocationTest);
23 defineReflectiveTests(RefactoringStatusTest); 23 defineReflectiveTests(RefactoringStatusTest);
24 }); 24 });
(...skipping 12 matching lines...) Expand all
37 expect(location.file, '/test.dart'); 37 expect(location.file, '/test.dart');
38 expect(location.offset, 6); 38 expect(location.offset, 6);
39 expect(location.length, 7); 39 expect(location.length, 7);
40 expect(location.startLine, 1); 40 expect(location.startLine, 1);
41 expect(location.startColumn, 7); 41 expect(location.startColumn, 7);
42 } 42 }
43 43
44 test_createLocation_forMatch() async { 44 test_createLocation_forMatch() async {
45 await resolveTestUnit('class MyClass {}'); 45 await resolveTestUnit('class MyClass {}');
46 Element element = findElement('MyClass'); 46 Element element = findElement('MyClass');
47 SourceRange range = rangeElementName(element); 47 SourceRange sourceRange = range.elementName(element);
48 SearchMatch match = new SearchMatchImpl( 48 SearchMatch match = new SearchMatchImpl(
49 element.context, 49 element.context,
50 element.library.source.uri.toString(), 50 element.library.source.uri.toString(),
51 element.source.uri.toString(), 51 element.source.uri.toString(),
52 null, 52 null,
53 range, 53 sourceRange,
54 true, 54 true,
55 false); 55 false);
56 // check 56 // check
57 Location location = newLocation_fromMatch(match); 57 Location location = newLocation_fromMatch(match);
58 expect(location.file, '/test.dart'); 58 expect(location.file, '/test.dart');
59 expect(location.offset, range.offset); 59 expect(location.offset, sourceRange.offset);
60 expect(location.length, range.length); 60 expect(location.length, sourceRange.length);
61 } 61 }
62 62
63 test_createLocation_forNode() async { 63 test_createLocation_forNode() async {
64 await resolveTestUnit(''' 64 await resolveTestUnit('''
65 main() { 65 main() {
66 } 66 }
67 '''); 67 ''');
68 AstNode node = findNodeAtString('main'); 68 AstNode node = findNodeAtString('main');
69 // check 69 // check
70 Location location = newLocation_fromNode(node); 70 Location location = newLocation_fromNode(node);
71 expect(location.file, '/test.dart'); 71 expect(location.file, '/test.dart');
72 expect(location.offset, node.offset); 72 expect(location.offset, node.offset);
73 expect(location.length, node.length); 73 expect(location.length, node.length);
74 } 74 }
75 75
76 test_createLocation_forUnit() async { 76 test_createLocation_forUnit() async {
77 await resolveTestUnit(''); 77 await resolveTestUnit('');
78 SourceRange range = rangeStartLength(10, 20); 78 SourceRange sourceRange = new SourceRange(10, 20);
79 // check 79 // check
80 Location location = newLocation_fromUnit(testUnit, range); 80 Location location = newLocation_fromUnit(testUnit, sourceRange);
81 expect(location.file, '/test.dart'); 81 expect(location.file, '/test.dart');
82 expect(location.offset, range.offset); 82 expect(location.offset, sourceRange.offset);
83 expect(location.length, range.length); 83 expect(location.length, sourceRange.length);
84 } 84 }
85 } 85 }
86 86
87 @reflectiveTest 87 @reflectiveTest
88 class RefactoringStatusTest { 88 class RefactoringStatusTest {
89 void test_addError() { 89 void test_addError() {
90 RefactoringStatus refactoringStatus = new RefactoringStatus(); 90 RefactoringStatus refactoringStatus = new RefactoringStatus();
91 // initial state 91 // initial state
92 expect(refactoringStatus.severity, null); 92 expect(refactoringStatus.severity, null);
93 // add ERROR 93 // add ERROR
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); 229 expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL);
230 expect(refactoringStatus.message, 'msg'); 230 expect(refactoringStatus.message, 'msg');
231 } 231 }
232 232
233 void test_newWarning() { 233 void test_newWarning() {
234 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg'); 234 RefactoringStatus refactoringStatus = new RefactoringStatus.warning('msg');
235 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING); 235 expect(refactoringStatus.severity, RefactoringProblemSeverity.WARNING);
236 expect(refactoringStatus.message, 'msg'); 236 expect(refactoringStatus.message, 'msg');
237 } 237 }
238 } 238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698