OLD | NEW |
| (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 // This code was auto-generated, is not intended to be edited, and is subject to | |
6 // significant change. Please see the README file for more information. | |
7 | |
8 library service.correction.stubs; | |
9 | |
10 import 'package:analyzer/src/generated/ast.dart' show AstNode; | |
11 import 'package:analyzer/src/generated/element.dart'; | |
12 import 'package:analyzer/src/generated/scanner.dart'; | |
13 import 'package:analyzer/src/generated/source.dart'; | |
14 | |
15 | |
16 abstract class SearchFilter { | |
17 bool passes(SearchMatch match); | |
18 } | |
19 | |
20 class SearchMatch { | |
21 final Element element = null; | |
22 final SourceRange sourceRange = null; | |
23 } | |
24 | |
25 | |
26 class SearchEngine { | |
27 } | |
28 | |
29 | |
30 class SourceRangeFactory { | |
31 static SourceRange rangeElementName(Element element) { | |
32 return new SourceRange(element.nameOffset, element.name.length); | |
33 } | |
34 | |
35 static SourceRange rangeEndEnd(a, b) { | |
36 int offset = a.end; | |
37 var length = b.end - offset; | |
38 return new SourceRange(offset, length); | |
39 } | |
40 | |
41 static SourceRange rangeEndLength(a, int length) { | |
42 return new SourceRange(a.nameOffset, length); | |
43 } | |
44 | |
45 static SourceRange rangeEndStart(a, b) { | |
46 int offset = a.end; | |
47 var length = b.offset - offset; | |
48 return new SourceRange(offset, length); | |
49 } | |
50 | |
51 static SourceRange rangeNode(AstNode node) { | |
52 return new SourceRange(node.offset, node.length); | |
53 } | |
54 | |
55 static SourceRange rangeNodes(List<AstNode> nodes) { | |
56 if (nodes.isEmpty) { | |
57 return new SourceRange(0, 0); | |
58 } | |
59 AstNode first = nodes.first; | |
60 AstNode last = nodes.last; | |
61 return rangeStartEnd(first, last); | |
62 } | |
63 | |
64 static SourceRange rangeStartEnd(a, b) { | |
65 int offset = a.offset; | |
66 var length = b.end - offset; | |
67 return new SourceRange(offset, length); | |
68 } | |
69 | |
70 static SourceRange rangeStartLength(a, int length) { | |
71 int offset = a.offset; | |
72 return new SourceRange(offset, length); | |
73 } | |
74 | |
75 static SourceRange rangeStartStart(a, b) { | |
76 int offset = a.offset; | |
77 var length = b.offset - offset; | |
78 return new SourceRange(offset, length); | |
79 } | |
80 | |
81 static SourceRange rangeToken(Token node) { | |
82 return new SourceRange(node.offset, node.length); | |
83 } | |
84 } | |
85 | |
86 | |
87 class StringUtils { | |
88 static String capitalize(String str) { | |
89 if (isEmpty(str)) { | |
90 return str; | |
91 } | |
92 return str.substring(0, 1).toUpperCase() + str.substring(1); | |
93 } | |
94 | |
95 static bool equals(String cs1, String cs2) { | |
96 if (cs1 == cs2) { | |
97 return true; | |
98 } | |
99 if (cs1 == null || cs2 == null) { | |
100 return false; | |
101 } | |
102 return cs1 == cs2; | |
103 } | |
104 | |
105 static bool isEmpty(String str) { | |
106 return str == null || str.isEmpty; | |
107 } | |
108 | |
109 static String join(Iterable iter, [String separator = ' ', int start = 0, int | |
110 end = -1]) { | |
111 if (start != 0) { | |
112 iter = iter.skip(start); | |
113 } | |
114 if (end != -1) { | |
115 iter = iter.take(end - start); | |
116 } | |
117 return iter.join(separator); | |
118 } | |
119 | |
120 static String remove(String str, String remove) { | |
121 if (isEmpty(str) || isEmpty(remove)) { | |
122 return str; | |
123 } | |
124 return str.replaceAll(remove, ''); | |
125 } | |
126 | |
127 static String removeStart(String str, String remove) { | |
128 if (isEmpty(str) || isEmpty(remove)) { | |
129 return str; | |
130 } | |
131 if (str.startsWith(remove)) { | |
132 return str.substring(remove.length); | |
133 } | |
134 return str; | |
135 } | |
136 | |
137 static String repeat(String s, int n) { | |
138 StringBuffer sb = new StringBuffer(); | |
139 for (int i = 0; i < n; i++) { | |
140 sb.write(s); | |
141 } | |
142 return sb.toString(); | |
143 } | |
144 | |
145 static List<String> split(String s, [String pattern = '']) { | |
146 return s.split(pattern); | |
147 } | |
148 | |
149 static List<String> splitByWholeSeparatorPreserveAllTokens(String s, String | |
150 pattern) { | |
151 return s.split(pattern); | |
152 } | |
153 } | |
OLD | NEW |