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

Side by Side Diff: pkg/analysis_services/lib/src/correction/source_range.dart

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library services.src.correction.source_range_factory;
6
7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/scanner.dart';
11 import 'package:analyzer/src/generated/source.dart';
12
13
14 SourceRange rangeElementName(Element element) {
15 return new SourceRange(element.nameOffset, element.displayName.length);
16 }
17
18 SourceRange rangeEndEnd(a, b) {
19 int offset = a.end;
20 var length = b.end - offset;
21 return new SourceRange(offset, length);
22 }
23
24 SourceRange rangeEndLength(a, int length) {
25 int offset = a is int ? a : a.end;
26 return new SourceRange(offset, length);
27 }
28
29 SourceRange rangeEndStart(a, b) {
30 int offset = a.end;
31 var length = (b is int ? b : b.offset) - offset;
32 return new SourceRange(offset, length);
33 }
34
35 SourceRange rangeError(AnalysisError error) {
36 return new SourceRange(error.offset, error.length);
37 }
38
39 SourceRange rangeNode(AstNode node) {
40 return new SourceRange(node.offset, node.length);
41 }
42
43 SourceRange rangeNodes(List<AstNode> nodes) {
44 if (nodes.isEmpty) {
45 return new SourceRange(0, 0);
46 }
47 AstNode first = nodes.first;
48 AstNode last = nodes.last;
49 return rangeStartEnd(first, last);
50 }
51
52 SourceRange rangeOffsetEnd(o) {
53 int offset = o.offset;
54 int length = o.end - offset;
55 return new SourceRange(offset, length);
56 }
57
58 SourceRange rangeStartEnd(a, b) {
59 int offset = a is int ? a : a.offset;
60 int end = b is int ? b : b.end;
61 var length = end - offset;
62 return new SourceRange(offset, length);
63 }
64
65 SourceRange rangeStartLength(a, int length) {
66 int offset = a is int ? a : a.offset;
67 return new SourceRange(offset, length);
68 }
69
70 SourceRange rangeStartStart(a, b) {
71 int offset = a is int ? a : a.offset;
72 var length = (b is int ? b : b.offset) - offset;
73 return new SourceRange(offset, length);
74 }
75
76 SourceRange rangeToken(Token token) {
77 return new SourceRange(token.offset, token.length);
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698