| 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 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 [isFirst] 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 [isLast] 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 isFirst, bool isLast) { | 3437 String _computeStringValue(String lexeme, bool isFirst, bool isLast) { |
| 3438 bool isRaw = false; | 3438 StringLexemeHelper helper = new StringLexemeHelper(lexeme, isFirst, isLast); |
| 3439 int start = 0; | 3439 int start = helper.start; |
| 3440 if (isFirst) { | 3440 int end = helper.end; |
| 3441 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || | |
| 3442 StringUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { | |
| 3443 isRaw = true; | |
| 3444 start = _trimInitialWhitespace(lexeme, start + 4); | |
| 3445 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || | |
| 3446 StringUtilities.startsWith2(lexeme, 0, 0x72, 0x27)) { | |
| 3447 isRaw = true; | |
| 3448 start += 2; | |
| 3449 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || | |
| 3450 StringUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { | |
| 3451 start = _trimInitialWhitespace(lexeme, start + 3); | |
| 3452 } else if (StringUtilities.startsWithChar(lexeme, 0x22) || | |
| 3453 StringUtilities.startsWithChar(lexeme, 0x27)) { | |
| 3454 start += 1; | |
| 3455 } | |
| 3456 } | |
| 3457 int end = lexeme.length; | |
| 3458 if (isLast) { | |
| 3459 if (StringUtilities.endsWith3(lexeme, 0x22, 0x22, 0x22) || | |
| 3460 StringUtilities.endsWith3(lexeme, 0x27, 0x27, 0x27)) { | |
| 3461 end -= 3; | |
| 3462 } else if (StringUtilities.endsWithChar(lexeme, 0x22) || | |
| 3463 StringUtilities.endsWithChar(lexeme, 0x27)) { | |
| 3464 end -= 1; | |
| 3465 } | |
| 3466 } | |
| 3467 if (end - start + 1 < 0) { | 3441 if (end - start + 1 < 0) { |
| 3468 AnalysisEngine.instance.logger.logError( | 3442 AnalysisEngine.instance.logger.logError( |
| 3469 "Internal error: computeStringValue($lexeme, $isFirst, $isLast)"); | 3443 "Internal error: computeStringValue($lexeme, $isFirst, $isLast)"); |
| 3470 return ""; | 3444 return ""; |
| 3471 } | 3445 } |
| 3472 if (isRaw) { | 3446 if (helper.isRaw) { |
| 3473 return lexeme.substring(start, end); | 3447 return lexeme.substring(start, end); |
| 3474 } | 3448 } |
| 3475 StringBuffer buffer = new StringBuffer(); | 3449 StringBuffer buffer = new StringBuffer(); |
| 3476 int index = start; | 3450 int index = start; |
| 3477 while (index < end) { | 3451 while (index < end) { |
| 3478 index = _translateCharacter(buffer, lexeme, index); | 3452 index = _translateCharacter(buffer, lexeme, index); |
| 3479 } | 3453 } |
| 3480 return buffer.toString(); | 3454 return buffer.toString(); |
| 3481 } | 3455 } |
| 3482 | 3456 |
| 3483 /** | 3457 /** |
| 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 /** | |
| 3524 * Convert the given [method] declaration into the nearest valid top-level | 3458 * Convert the given [method] declaration into the nearest valid top-level |
| 3525 * function declaration (that is, the function declaration that most closely | 3459 * function declaration (that is, the function declaration that most closely |
| 3526 * captures the components of the given method declaration). | 3460 * captures the components of the given method declaration). |
| 3527 */ | 3461 */ |
| 3528 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => | 3462 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) => |
| 3529 new FunctionDeclaration(method.documentationComment, method.metadata, | 3463 new FunctionDeclaration(method.documentationComment, method.metadata, |
| 3530 method.externalKeyword, method.returnType, method.propertyKeyword, | 3464 method.externalKeyword, method.returnType, method.propertyKeyword, |
| 3531 method.name, new FunctionExpression(method.parameters, method.body)); | 3465 method.name, new FunctionExpression(method.parameters, method.body)); |
| 3532 | 3466 |
| 3533 /** | 3467 /** |
| (...skipping 7043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10577 } | 10511 } |
| 10578 | 10512 |
| 10579 /** | 10513 /** |
| 10580 * Copy resolution data from the [fromNode] to the [toNode]. | 10514 * Copy resolution data from the [fromNode] to the [toNode]. |
| 10581 */ | 10515 */ |
| 10582 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 10516 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 10583 ResolutionCopier copier = new ResolutionCopier(); | 10517 ResolutionCopier copier = new ResolutionCopier(); |
| 10584 copier._isEqualNodes(fromNode, toNode); | 10518 copier._isEqualNodes(fromNode, toNode); |
| 10585 } | 10519 } |
| 10586 } | 10520 } |
| OLD | NEW |