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