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

Side by Side Diff: pkg/analyzer/lib/src/generated/java_core.dart

Issue 1688113004: Remove unused or unneeded stuff from java_core.dart. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 analyzer.src.generated.java_core; 5 library analyzer.src.generated.java_core;
6 6
7 const int LONG_MAX_VALUE = 0x7fffffffffffffff;
8
9 final Stopwatch nanoTimeStopwatch = new Stopwatch(); 7 final Stopwatch nanoTimeStopwatch = new Stopwatch();
10 8
11 /** 9 /**
12 * Inserts the given arguments into [pattern].
13 *
14 * format('Hello, {0}!', 'John') = 'Hello, John!'
15 * format('{0} are you {1}ing?', 'How', 'do') = 'How are you doing?'
16 * format('{0} are you {1}ing?', 'What', 'read') = 'What are you reading?'
17 */
18 String format(String pattern,
Brian Wilkerson 2016/02/12 15:50:33 'format' is used in analysis_server, so it can't b
Bob Nystrom 2016/02/12 19:11:21 Done.
19 [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]) {
20 return formatList(pattern, [arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7]);
21 }
22
23 /**
24 * Inserts the given [args] into [pattern]. 10 * Inserts the given [args] into [pattern].
25 * 11 *
26 * format('Hello, {0}!', ['John']) = 'Hello, John!' 12 * format('Hello, {0}!', ['John']) = 'Hello, John!'
27 * format('{0} are you {1}ing?', ['How', 'do']) = 'How are you doing?' 13 * format('{0} are you {1}ing?', ['How', 'do']) = 'How are you doing?'
28 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?' 14 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?'
29 */ 15 */
30 String formatList(String pattern, List<Object> arguments) { 16 String formatList(String pattern, List<Object> arguments) {
31 if (arguments == null || arguments.isEmpty) { 17 if (arguments == null || arguments.isEmpty) {
32 assert(!pattern.contains(new RegExp(r'\{(\d+)\}'))); 18 assert(!pattern.contains(new RegExp(r'\{(\d+)\}')));
33 return pattern; 19 return pattern;
34 } 20 }
35 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { 21 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) {
36 String indexStr = match.group(1); 22 String indexStr = match.group(1);
37 int index = int.parse(indexStr); 23 int index = int.parse(indexStr);
38 Object arg = arguments[index]; 24 Object arg = arguments[index];
39 assert(arg != null); 25 assert(arg != null);
40 return arg != null ? arg.toString() : null; 26 return arg != null ? arg.toString() : null;
41 }); 27 });
42 } 28 }
43 29
44 bool javaCollectionContainsAll(Iterable list, Iterable c) {
45 return c.fold(true, (bool prev, e) => prev && list.contains(e));
46 }
47
48 javaListSet(List list, int index, newValue) {
49 var oldValue = list[index];
50 list[index] = newValue;
51 return oldValue;
52 }
53
54 bool javaSetEquals(Set a, Set b) {
55 return a.containsAll(b) && b.containsAll(a);
56 }
57
58 bool javaStringEqualsIgnoreCase(String a, String b) {
59 return a.toLowerCase() == b.toLowerCase();
60 }
61
62 bool javaStringRegionMatches(
63 String t, int toffset, String o, int ooffset, int len) {
64 if (toffset < 0) return false;
65 if (ooffset < 0) return false;
66 var tend = toffset + len;
67 var oend = ooffset + len;
68 if (tend > t.length) return false;
69 if (oend > o.length) return false;
70 return t.substring(toffset, tend) == o.substring(ooffset, oend);
71 }
72
73 /// Parses given string to [Uri], throws [URISyntaxException] if invalid. 30 /// Parses given string to [Uri], throws [URISyntaxException] if invalid.
74 Uri parseUriWithException(String str) { 31 Uri parseUriWithException(String str) {
75 Uri uri; 32 Uri uri;
76 try { 33 try {
77 uri = Uri.parse(str); 34 uri = Uri.parse(str);
78 } on FormatException catch (e) { 35 } on FormatException catch (e) {
79 throw new URISyntaxException(e.toString()); 36 throw new URISyntaxException(e.toString());
80 } 37 }
81 if (uri.path.isEmpty) { 38 if (uri.path.isEmpty) {
82 throw new URISyntaxException('empty path'); 39 throw new URISyntaxException('empty path');
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 80 }
124 return sb.toString(); 81 return sb.toString();
125 } 82 }
126 83
127 class Character { 84 class Character {
128 static const int MAX_VALUE = 0xffff; 85 static const int MAX_VALUE = 0xffff;
129 static const int MAX_CODE_POINT = 0x10ffff; 86 static const int MAX_CODE_POINT = 0x10ffff;
130 static const int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000; 87 static const int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
131 static const int MIN_LOW_SURROGATE = 0xDC00; 88 static const int MIN_LOW_SURROGATE = 0xDC00;
132 static const int MIN_HIGH_SURROGATE = 0xD800; 89 static const int MIN_HIGH_SURROGATE = 0xD800;
90
133 static int digit(int codePoint, int radix) { 91 static int digit(int codePoint, int radix) {
134 if (radix != 16) { 92 if (radix != 16) {
135 throw new ArgumentError("only radix == 16 is supported"); 93 throw new ArgumentError("only radix == 16 is supported");
136 } 94 }
137 if (0x30 <= codePoint && codePoint <= 0x39) { 95 if (0x30 <= codePoint && codePoint <= 0x39) {
138 return codePoint - 0x30; 96 return codePoint - 0x30;
139 } 97 }
140 if (0x41 <= codePoint && codePoint <= 0x46) { 98 if (0x41 <= codePoint && codePoint <= 0x46) {
141 return 0xA + (codePoint - 0x41); 99 return 0xA + (codePoint - 0x41);
142 } 100 }
143 if (0x61 <= codePoint && codePoint <= 0x66) { 101 if (0x61 <= codePoint && codePoint <= 0x66) {
144 return 0xA + (codePoint - 0x61); 102 return 0xA + (codePoint - 0x61);
145 } 103 }
146 return -1; 104 return -1;
147 } 105 }
148 106
149 static bool isDigit(int c) { 107 static bool isDigit(int c) => c >= 0x30 && c <= 0x39;
150 return c >= 0x30 && c <= 0x39;
151 }
152 108
153 static bool isLetter(int c) { 109 static bool isLetter(int c) =>
154 return c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A; 110 c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A;
155 }
156 111
157 static bool isLetterOrDigit(int c) { 112 static bool isLetterOrDigit(int c) => isLetter(c) || isDigit(c);
158 return isLetter(c) || isDigit(c);
159 }
160 113
161 static bool isLowerCase(int c) { 114 static bool isWhitespace(int c) =>
162 return c >= 0x61 && c <= 0x7A; 115 c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D;
163 }
164
165 static bool isUpperCase(int c) {
166 return c >= 0x41 && c <= 0x5A;
167 }
168
169 static bool isWhitespace(int c) {
170 return c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D;
171 }
172 116
173 static String toChars(int codePoint) { 117 static String toChars(int codePoint) {
174 if (codePoint < 0 || codePoint > MAX_CODE_POINT) { 118 if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
175 throw new IllegalArgumentException(); 119 throw new IllegalArgumentException();
176 } 120 }
177 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) { 121 if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
178 return new String.fromCharCode(codePoint); 122 return new String.fromCharCode(codePoint);
179 } 123 }
180 int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT; 124 int offset = codePoint - MIN_SUPPLEMENTARY_CODE_POINT;
181 int c0 = ((offset & 0x7FFFFFFF) >> 10) + MIN_HIGH_SURROGATE; 125 int c0 = ((offset & 0x7FFFFFFF) >> 10) + MIN_HIGH_SURROGATE;
182 int c1 = (offset & 0x3ff) + MIN_LOW_SURROGATE; 126 int c1 = (offset & 0x3ff) + MIN_LOW_SURROGATE;
183 return new String.fromCharCodes([c0, c1]); 127 return new String.fromCharCodes([c0, c1]);
184 } 128 }
185
186 static int toLowerCase(int c) {
187 if (c >= 0x41 && c <= 0x5A) {
188 return 0x61 + (c - 0x41);
189 }
190 return c;
191 }
192
193 static int toUpperCase(int c) {
194 if (c >= 0x61 && c <= 0x7A) {
195 return 0x41 + (c - 0x61);
196 }
197 return c;
198 }
199 } 129 }
200 130
201 abstract class Enum<E extends Enum> implements Comparable<E> { 131 abstract class Enum<E extends Enum> implements Comparable<E> {
202 /// The name of this enum constant, as declared in the enum declaration. 132 /// The name of this enum constant, as declared in the enum declaration.
203 final String name; 133 final String name;
204 134
205 /// The position in the enum declaration. 135 /// The position in the enum declaration.
206 final int ordinal; 136 final int ordinal;
207 const Enum(this.name, this.ordinal); 137 const Enum(this.name, this.ordinal);
208 int get hashCode => ordinal; 138 int get hashCode => ordinal;
209 int compareTo(E other) => ordinal - other.ordinal; 139 int compareTo(E other) => ordinal - other.ordinal;
210 String toString() => name; 140 String toString() => name;
211 } 141 }
212 142
213 class IllegalArgumentException extends JavaException { 143 class IllegalArgumentException extends JavaException {
214 IllegalArgumentException([message = "", cause = null]) 144 IllegalArgumentException([message = "", cause = null])
215 : super(message, cause); 145 : super(message, cause);
216 } 146 }
217 147
218 class IllegalStateException extends JavaException { 148 class IllegalStateException extends JavaException {
219 IllegalStateException([message = ""]) : super(message); 149 IllegalStateException([message = ""]) : super(message);
220 } 150 }
221 151
222 class JavaArrays {
223 static bool equals(List a, List b) {
224 if (identical(a, b)) {
225 return true;
226 }
227 if (a.length != b.length) {
228 return false;
229 }
230 var len = a.length;
231 for (int i = 0; i < len; i++) {
232 if (a[i] != b[i]) {
233 return false;
234 }
235 }
236 return true;
237 }
238
239 static int makeHashCode(List a) {
Brian Wilkerson 2016/02/12 15:50:33 'makeHashCode' is used in analysis_server
Bob Nystrom 2016/02/12 19:11:21 Done.
240 if (a == null) {
241 return 0;
242 }
243 int result = 1;
244 for (var element in a) {
245 result = 31 * result + (element == null ? 0 : element.hashCode);
246 }
247 return result;
248 }
249 }
250
251 class JavaException implements Exception { 152 class JavaException implements Exception {
252 final String message; 153 final String message;
253 final Object cause; 154 final Object cause;
254 JavaException([this.message = "", this.cause = null]); 155 JavaException([this.message = "", this.cause = null]);
255 JavaException.withCause(this.cause) : message = null; 156 JavaException.withCause(this.cause) : message = null;
256 String toString() => "$runtimeType: $message $cause"; 157 String toString() => "$runtimeType: $message $cause";
257 } 158 }
258 159
259 class JavaIOException extends JavaException { 160 class JavaIOException extends JavaException {
260 JavaIOException([message = "", cause = null]) : super(message, cause); 161 JavaIOException([message = "", cause = null]) : super(message, cause);
(...skipping 24 matching lines...) Expand all
285 if (fromIndex > target.length) return -1; 186 if (fromIndex > target.length) return -1;
286 if (fromIndex < 0) fromIndex = 0; 187 if (fromIndex < 0) fromIndex = 0;
287 return target.indexOf(str, fromIndex); 188 return target.indexOf(str, fromIndex);
288 } 189 }
289 190
290 static int lastIndexOf(String target, String str, int fromIndex) { 191 static int lastIndexOf(String target, String str, int fromIndex) {
291 if (fromIndex > target.length) return -1; 192 if (fromIndex > target.length) return -1;
292 if (fromIndex < 0) fromIndex = 0; 193 if (fromIndex < 0) fromIndex = 0;
293 return target.lastIndexOf(str, fromIndex); 194 return target.lastIndexOf(str, fromIndex);
294 } 195 }
295
296 static bool startsWithBefore(String s, String other, int start) {
297 return s.indexOf(other, start) != -1;
298 }
299 } 196 }
300 197
301 class JavaSystem { 198 class JavaSystem {
302 static int currentTimeMillis() { 199 static int currentTimeMillis() {
303 return (new DateTime.now()).millisecondsSinceEpoch; 200 return (new DateTime.now()).millisecondsSinceEpoch;
304 } 201 }
305 202
306 static int nanoTime() { 203 static int nanoTime() {
307 if (!nanoTimeStopwatch.isRunning) { 204 if (!nanoTimeStopwatch.isRunning) {
308 nanoTimeStopwatch.start(); 205 nanoTimeStopwatch.start();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 338
442 class UnsupportedOperationException extends JavaException { 339 class UnsupportedOperationException extends JavaException {
443 UnsupportedOperationException([message = ""]) : super(message); 340 UnsupportedOperationException([message = ""]) : super(message);
444 } 341 }
445 342
446 class URISyntaxException implements Exception { 343 class URISyntaxException implements Exception {
447 final String message; 344 final String message;
448 URISyntaxException(this.message); 345 URISyntaxException(this.message);
449 String toString() => "URISyntaxException: $message"; 346 String toString() => "URISyntaxException: $message";
450 } 347 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/utilities_collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698