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

Side by Side Diff: pkg/analyzer_plugin/test/utilities/range_factory_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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/element/element.dart'; 6 import 'package:analyzer/dart/element/element.dart';
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/generated/parser.dart'; 8 import 'package:analyzer/src/generated/parser.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer_plugin/utilities/range_factory.dart'; 10 import 'package:analyzer_plugin/utilities/range_factory.dart';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 SimpleIdentifier mainName = mainFunction.name; 69 SimpleIdentifier mainName = mainFunction.name;
70 FunctionBody mainBody = mainFunction.functionExpression.body; 70 FunctionBody mainBody = mainFunction.functionExpression.body;
71 expect(range.nodes([mainName, mainBody]), new SourceRange(1, 9)); 71 expect(range.nodes([mainName, mainBody]), new SourceRange(1, 9));
72 } 72 }
73 73
74 test_nodes_empty() async { 74 test_nodes_empty() async {
75 await resolveTestUnit('main() {}'); 75 await resolveTestUnit('main() {}');
76 expect(range.nodes([]), new SourceRange(0, 0)); 76 expect(range.nodes([]), new SourceRange(0, 0));
77 } 77 }
78 78
79 test_offsetBy() {
80 expect(range.offsetBy(new SourceRange(7, 3), 2), new SourceRange(9, 3));
81 }
82
83 test_offsetEndIndex() {
84 expect(range.offsetEndIndex(6, 11), new SourceRange(6, 5));
85 }
86
79 test_startEnd_nodeNode() async { 87 test_startEnd_nodeNode() async {
80 await resolveTestUnit(' main() {}'); 88 await resolveTestUnit(' main() {}');
81 FunctionDeclaration mainFunction = testUnit.declarations[0]; 89 FunctionDeclaration mainFunction = testUnit.declarations[0];
82 SimpleIdentifier mainName = mainFunction.name; 90 SimpleIdentifier mainName = mainFunction.name;
83 FunctionBody mainBody = mainFunction.functionExpression.body; 91 FunctionBody mainBody = mainFunction.functionExpression.body;
84 expect(range.startEnd(mainName, mainBody), new SourceRange(1, 9)); 92 expect(range.startEnd(mainName, mainBody), new SourceRange(1, 9));
85 } 93 }
86 94
87 test_startLength_node() async { 95 test_startLength_node() async {
88 await resolveTestUnit(' main() {}'); 96 await resolveTestUnit(' main() {}');
(...skipping 10 matching lines...) Expand all
99 expect(range.startStart(mainName, mainBody), new SourceRange(0, 7)); 107 expect(range.startStart(mainName, mainBody), new SourceRange(0, 7));
100 } 108 }
101 109
102 test_token() async { 110 test_token() async {
103 await resolveTestUnit(' main() {}'); 111 await resolveTestUnit(' main() {}');
104 FunctionDeclaration mainFunction = testUnit.declarations[0]; 112 FunctionDeclaration mainFunction = testUnit.declarations[0];
105 SimpleIdentifier mainName = mainFunction.name; 113 SimpleIdentifier mainName = mainFunction.name;
106 expect(range.token(mainName.beginToken), new SourceRange(1, 4)); 114 expect(range.token(mainName.beginToken), new SourceRange(1, 4));
107 } 115 }
108 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698