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

Side by Side Diff: packages/analyzer/lib/src/generated/java_engine.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 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
OLDNEW
1 library java.engine; 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.
2 4
3 import 'interner.dart'; 5 library analyzer.src.generated.java_engine;
4 import 'java_core.dart'; 6
7 import 'package:analyzer/src/generated/interner.dart';
8 import 'package:analyzer/src/generated/java_core.dart';
9
10 export 'package:analyzer/exception/exception.dart';
5 11
6 /** 12 /**
7 * A predicate is a one-argument function that returns a boolean value. 13 * A predicate is a one-argument function that returns a boolean value.
8 */ 14 */
9 typedef bool Predicate<E>(E argument); 15 typedef bool Predicate<E>(E argument);
10 16
11 /**
12 * Instances of the class `AnalysisException` represent an exception that
13 * occurred during the analysis of one or more sources.
14 */
15 class AnalysisException implements Exception {
16 /**
17 * The message that explains why the exception occurred.
18 */
19 final String message;
20
21 /**
22 * The exception that caused this exception, or `null` if this exception was
23 * not caused by another exception.
24 */
25 final CaughtException cause;
26
27 /**
28 * Initialize a newly created exception to have the given [message] and
29 * [cause].
30 */
31 AnalysisException([this.message = 'Exception', this.cause = null]);
32
33 String toString() {
34 StringBuffer buffer = new StringBuffer();
35 buffer.write("AnalysisException: ");
36 buffer.writeln(message);
37 if (cause != null) {
38 buffer.write('Caused by ');
39 cause._writeOn(buffer);
40 }
41 return buffer.toString();
42 }
43 }
44
45 /**
46 * Instances of the class `CaughtException` represent an exception that was
47 * caught and has an associated stack trace.
48 */
49 class CaughtException implements Exception {
50 /**
51 * The exception that was caught.
52 */
53 final Object exception;
54
55 /**
56 * The stack trace associated with the exception.
57 */
58 StackTrace stackTrace;
59
60 /**
61 * Initialize a newly created caught exception to have the given [exception]
62 * and [stackTrace].
63 */
64 CaughtException(this.exception, stackTrace) {
65 if (stackTrace == null) {
66 try {
67 throw this;
68 } catch (_, st) {
69 stackTrace = st;
70 }
71 }
72 this.stackTrace = stackTrace;
73 }
74
75 @override
76 String toString() {
77 StringBuffer buffer = new StringBuffer();
78 _writeOn(buffer);
79 return buffer.toString();
80 }
81
82 /**
83 * Write a textual representation of the caught exception and its associated
84 * stack trace.
85 */
86 void _writeOn(StringBuffer buffer) {
87 if (exception is AnalysisException) {
88 AnalysisException analysisException = exception;
89 buffer.writeln(analysisException.message);
90 if (stackTrace != null) {
91 buffer.writeln(stackTrace.toString());
92 }
93 CaughtException cause = analysisException.cause;
94 if (cause != null) {
95 buffer.write('Caused by ');
96 cause._writeOn(buffer);
97 }
98 } else {
99 buffer.writeln(exception.toString());
100 buffer.writeln(stackTrace.toString());
101 }
102 }
103 }
104
105 class FileNameUtilities { 17 class FileNameUtilities {
106 static String getExtension(String fileName) { 18 static String getExtension(String fileName) {
107 if (fileName == null) { 19 if (fileName == null) {
108 return ""; 20 return "";
109 } 21 }
110 int index = fileName.lastIndexOf('.'); 22 int index = fileName.lastIndexOf('.');
111 if (index >= 0) { 23 if (index >= 0) {
112 return fileName.substring(index + 1); 24 return fileName.substring(index + 1);
113 } 25 }
114 return ""; 26 return "";
115 } 27 }
116 } 28 }
117 29
118 class StringUtilities { 30 class StringUtilities {
119 static const String EMPTY = ''; 31 static const String EMPTY = '';
120 static const List<String> EMPTY_ARRAY = const <String>[]; 32 static const List<String> EMPTY_ARRAY = const <String>[];
121 33
122 static Interner INTERNER = new NullInterner(); 34 static Interner INTERNER = new NullInterner();
123 35
36 /**
37 * Compute line starts for the given [content].
38 * Lines end with `\r`, `\n` or `\r\n`.
39 */
40 static List<int> computeLineStarts(String content) {
41 List<int> lineStarts = <int>[0];
42 int length = content.length;
43 int unit;
44 for (int index = 0; index < length; index++) {
45 unit = content.codeUnitAt(index);
46 // Special-case \r\n.
47 if (unit == 0x0D /* \r */) {
48 // Peek ahead to detect a following \n.
49 if ((index + 1 < length) && content.codeUnitAt(index + 1) == 0x0A) {
50 // Line start will get registered at next index at the \n.
51 } else {
52 lineStarts.add(index + 1);
53 }
54 }
55 // \n
56 if (unit == 0x0A) {
57 lineStarts.add(index + 1);
58 }
59 }
60 return lineStarts;
61 }
62
124 static endsWith3(String str, int c1, int c2, int c3) { 63 static endsWith3(String str, int c1, int c2, int c3) {
125 var length = str.length; 64 var length = str.length;
126 return length >= 3 && 65 return length >= 3 &&
127 str.codeUnitAt(length - 3) == c1 && 66 str.codeUnitAt(length - 3) == c1 &&
128 str.codeUnitAt(length - 2) == c2 && 67 str.codeUnitAt(length - 2) == c2 &&
129 str.codeUnitAt(length - 1) == c3; 68 str.codeUnitAt(length - 1) == c3;
130 } 69 }
131 70
132 static endsWithChar(String str, int c) { 71 static endsWithChar(String str, int c) {
133 int length = str.length; 72 int length = str.length;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 174
236 /** 175 /**
237 * Produce a string containing all of the names in the given array, surrounded by single quotes, 176 * Produce a string containing all of the names in the given array, surrounded by single quotes,
238 * and separated by commas. The list must contain at least two elements. 177 * and separated by commas. The list must contain at least two elements.
239 * 178 *
240 * @param names the names to be printed 179 * @param names the names to be printed
241 * @return the result of printing the names 180 * @return the result of printing the names
242 */ 181 */
243 static String printListOfQuotedNames(List<String> names) { 182 static String printListOfQuotedNames(List<String> names) {
244 if (names == null) { 183 if (names == null) {
245 throw new IllegalArgumentException("The list must not be null"); 184 throw new ArgumentError("The list must not be null");
246 } 185 }
247 int count = names.length; 186 int count = names.length;
248 if (count < 2) { 187 if (count < 2) {
249 throw new IllegalArgumentException( 188 throw new ArgumentError("The list must contain at least two names");
250 "The list must contain at least two names");
251 } 189 }
252 StringBuffer buffer = new StringBuffer(); 190 StringBuffer buffer = new StringBuffer();
253 buffer.write("'"); 191 buffer.write("'");
254 buffer.write(names[0]); 192 buffer.write(names[0]);
255 buffer.write("'"); 193 buffer.write("'");
256 for (int i = 1; i < count - 1; i++) { 194 for (int i = 1; i < count - 1; i++) {
257 buffer.write(", '"); 195 buffer.write(", '");
258 buffer.write(names[i]); 196 buffer.write(names[i]);
259 buffer.write("'"); 197 buffer.write("'");
260 } 198 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 274 }
337 } 275 }
338 276
339 class UUID { 277 class UUID {
340 static int __nextId = 0; 278 static int __nextId = 0;
341 final String id; 279 final String id;
342 UUID(this.id); 280 UUID(this.id);
343 String toString() => id; 281 String toString() => id;
344 static UUID randomUUID() => new UUID((__nextId).toString()); 282 static UUID randomUUID() => new UUID((__nextId).toString());
345 } 283 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/generated/java_core.dart ('k') | packages/analyzer/lib/src/generated/java_engine_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698