| OLD | NEW |
| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 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. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.parser; | 8 library engine.parser; |
| 9 | 9 |
| 10 import "dart:math" as math; | 10 import "dart:math" as math; |
| (...skipping 3412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3423 } | 3423 } |
| 3424 if (scalarValue < Character.MAX_VALUE) { | 3424 if (scalarValue < Character.MAX_VALUE) { |
| 3425 buffer.writeCharCode(scalarValue); | 3425 buffer.writeCharCode(scalarValue); |
| 3426 } else { | 3426 } else { |
| 3427 buffer.write(Character.toChars(scalarValue)); | 3427 buffer.write(Character.toChars(scalarValue)); |
| 3428 } | 3428 } |
| 3429 } | 3429 } |
| 3430 | 3430 |
| 3431 /** | 3431 /** |
| 3432 * Return the content of a string with the given literal representation. The | 3432 * Return the content of a string with the given literal representation. The |
| 3433 * [lexeme] is the literal representation of the string. The flag [first] is | 3433 * [lexeme] is the literal representation of the string. The flag [isFirst] is |
| 3434 * `true` if this is the first token in a string literal. The flag [last] is | 3434 * `true` if this is the first token in a string literal. The flag [isLast] is |
| 3435 * `true` if this is the last token in a string literal. | 3435 * `true` if this is the last token in a string literal. |
| 3436 */ | 3436 */ |
| 3437 String _computeStringValue(String lexeme, bool first, bool last) { | 3437 String _computeStringValue(String lexeme, bool isFirst, bool isLast) { |
| 3438 bool isRaw = false; | 3438 bool isRaw = false; |
| 3439 int start = 0; | 3439 int start = 0; |
| 3440 if (first) { | 3440 if (isFirst) { |
| 3441 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || | 3441 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || |
| 3442 StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { | 3442 StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { |
| 3443 isRaw = true; | 3443 isRaw = true; |
| 3444 start += 4; | 3444 start = _trimInitialWhitespace(lexeme, start + 4); |
| 3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || | 3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || |
| 3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { | 3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { |
| 3447 isRaw = true; | 3447 isRaw = true; |
| 3448 start += 2; | 3448 start += 2; |
| 3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || | 3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || |
| 3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { | 3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { |
| 3451 start += 3; | 3451 start = _trimInitialWhitespace(lexeme, start + 3); |
| 3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || | 3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || |
| 3453 StringUtilities.startsWithChar(lexeme, 0x27)) { | 3453 StringUtilities.startsWithChar(lexeme, 0x27)) { |
| 3454 start += 1; | 3454 start += 1; |
| 3455 } | 3455 } |
| 3456 } | 3456 } |
| 3457 int end = lexeme.length; | 3457 int end = lexeme.length; |
| 3458 if (last) { | 3458 if (isLast) { |
| 3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || | 3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || |
| 3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { | 3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { |
| 3461 end -= 3; | 3461 end -= 3; |
| 3462 } else if (StringUtilities.endsWithChar(lexeme, 0x22) || | 3462 } else if (StringUtilities.endsWithChar(lexeme, 0x22) || |
| 3463 StringUtilities.endsWithChar(lexeme, 0x27)) { | 3463 StringUtilities.endsWithChar(lexeme, 0x27)) { |
| 3464 end -= 1; | 3464 end -= 1; |
| 3465 } | 3465 } |
| 3466 } | 3466 } |
| 3467 if (end - start + 1 < 0) { | 3467 if (end - start + 1 < 0) { |
| 3468 AnalysisEngine.instance.logger.logError( | 3468 AnalysisEngine.instance.logger.logError( |
| 3469 "Internal error: computeStringValue($lexeme, $first, $last)"); | 3469 "Internal error: computeStringValue($lexeme, $isFirst, $isLast)"); |
| 3470 return ""; | 3470 return ""; |
| 3471 } | 3471 } |
| 3472 if (isRaw) { | 3472 if (isRaw) { |
| 3473 return lexeme.substring(start, end); | 3473 return lexeme.substring(start, end); |
| 3474 } | 3474 } |
| 3475 StringBuffer buffer = new StringBuffer(); | 3475 StringBuffer buffer = new StringBuffer(); |
| 3476 int index = start; | 3476 int index = start; |
| 3477 while (index < end) { | 3477 while (index < end) { |
| 3478 index = _translateCharacter(buffer, lexeme, index); | 3478 index = _translateCharacter(buffer, lexeme, index); |
| 3479 } | 3479 } |
| 3480 return buffer.toString(); | 3480 return buffer.toString(); |
| 3481 } | 3481 } |
| 3482 | 3482 |
| 3483 /** | 3483 /** |
| 3484 * Given the [lexeme] for a multi-line string whose content begins at the |
| 3485 * given [start] index, return the index of the first character that is |
| 3486 * included in the value of the string. According to the specification: |
| 3487 * |
| 3488 * If the first line of a multiline string consists solely of the whitespace |
| 3489 * characters defined by the production WHITESPACE 20.1), possibly prefixed |
| 3490 * by \, then that line is ignored, including the new line at its end. |
| 3491 */ |
| 3492 int _trimInitialWhitespace(String lexeme, int start) { |
| 3493 int length = lexeme.length; |
| 3494 int index = start; |
| 3495 while (index < length) { |
| 3496 int currentChar = lexeme.codeUnitAt(index); |
| 3497 if (currentChar == 0x0D) { |
| 3498 if (index + 1 < length && lexeme.codeUnitAt(index + 1) == 0x0A) { |
| 3499 return index + 2; |
| 3500 } |
| 3501 return index + 1; |
| 3502 } else if (currentChar == 0x0A) { |
| 3503 return index + 1; |
| 3504 } else if (currentChar == 0x5C) { |
| 3505 if (index + 1 >= length) { |
| 3506 return start; |
| 3507 } |
| 3508 currentChar = lexeme.codeUnitAt(index + 1); |
| 3509 if (currentChar != 0x0D && |
| 3510 currentChar != 0x0A && |
| 3511 currentChar != 0x09 && |
| 3512 currentChar != 0x20) { |
| 3513 return start; |
| 3514 } |
| 3515 } else if (currentChar != 0x09 && currentChar != 0x20) { |
| 3516 return start; |
| 3517 } |
| 3518 index++; |
| 3519 } |
| 3520 return start; |
| 3521 } |
| 3522 |
| 3523 /** |
| 3484 * Convert the given [method] declaration into the nearest valid top-level | 3524 * Convert the given [method] declaration into the nearest valid top-level |
| 3485 * function declaration (that is, the function declaration that most closely | 3525 * function declaration (that is, the function declaration that most closely |
| 3486 * captures the components of the given method declaration). | 3526 * captures the components of the given method declaration). |
| 3487 */ | 3527 */ |
| 3488 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => | 3528 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => |
| 3489 new FunctionDeclaration(method.documentationComment, method.metadata, | 3529 new FunctionDeclaration(method.documentationComment, method.metadata, |
| 3490 method.externalKeyword, method.returnType, method.propertyKeyword, | 3530 method.externalKeyword, method.returnType, method.propertyKeyword, |
| 3491 method.name, new FunctionExpression(method.parameters, method.body)); | 3531 method.name, new FunctionExpression(method.parameters, method.body)); |
| 3492 | 3532 |
| 3493 /** | 3533 /** |
| (...skipping 7043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10537 } | 10577 } |
| 10538 | 10578 |
| 10539 /** | 10579 /** |
| 10540 * Copy resolution data from the [fromNode] to the [toNode]. | 10580 * Copy resolution data from the [fromNode] to the [toNode]. |
| 10541 */ | 10581 */ |
| 10542 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 10582 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 10543 ResolutionCopier copier = new ResolutionCopier(); | 10583 ResolutionCopier copier = new ResolutionCopier(); |
| 10544 copier._isEqualNodes(fromNode, toNode); | 10584 copier._isEqualNodes(fromNode, toNode); |
| 10545 } | 10585 } |
| 10546 } | 10586 } |
| OLD | NEW |