refactor(facade): inline StringWrapper (#12051)

This commit is contained in:
Alex Eagle
2016-10-06 15:10:27 -07:00
committed by Tobias Bosch
parent bb35fcb562
commit 8c975ed156
34 changed files with 105 additions and 288 deletions

View File

@ -8,7 +8,7 @@
import {Injectable} from '@angular/core';
import * as chars from '../chars';
import {NumberWrapper, StringJoiner, StringWrapper, isPresent} from '../facade/lang';
import {NumberWrapper, StringJoiner, isPresent} from '../facade/lang';
export enum TokenType {
Character,
@ -93,7 +93,7 @@ export class Token {
}
function newCharacterToken(index: number, code: number): Token {
return new Token(index, TokenType.Character, code, StringWrapper.fromCharCode(code));
return new Token(index, TokenType.Character, code, String.fromCharCode(code));
}
function newIdentifierToken(index: number, text: string): Token {
@ -133,8 +133,7 @@ class _Scanner {
}
advance() {
this.peek =
++this.index >= this.length ? chars.$EOF : StringWrapper.charCodeAt(this.input, this.index);
this.peek = ++this.index >= this.length ? chars.$EOF : this.input.charCodeAt(this.index);
}
scanToken(): Token {
@ -146,7 +145,7 @@ class _Scanner {
peek = chars.$EOF;
break;
} else {
peek = StringWrapper.charCodeAt(input, index);
peek = input.charCodeAt(index);
}
}
@ -187,16 +186,16 @@ class _Scanner {
case chars.$SLASH:
case chars.$PERCENT:
case chars.$CARET:
return this.scanOperator(start, StringWrapper.fromCharCode(peek));
return this.scanOperator(start, String.fromCharCode(peek));
case chars.$QUESTION:
return this.scanComplexOperator(start, '?', chars.$PERIOD, '.');
case chars.$LT:
case chars.$GT:
return this.scanComplexOperator(start, StringWrapper.fromCharCode(peek), chars.$EQ, '=');
return this.scanComplexOperator(start, String.fromCharCode(peek), chars.$EQ, '=');
case chars.$BANG:
case chars.$EQ:
return this.scanComplexOperator(
start, StringWrapper.fromCharCode(peek), chars.$EQ, '=', chars.$EQ, '=');
start, String.fromCharCode(peek), chars.$EQ, '=', chars.$EQ, '=');
case chars.$AMPERSAND:
return this.scanComplexOperator(start, '&', chars.$AMPERSAND, '&');
case chars.$BAR:
@ -207,7 +206,7 @@ class _Scanner {
}
this.advance();
return this.error(`Unexpected character [${StringWrapper.fromCharCode(peek)}]`, 0);
return this.error(`Unexpected character [${String.fromCharCode(peek)}]`, 0);
}
scanCharacter(start: number, code: number): Token {
@ -310,7 +309,7 @@ class _Scanner {
unescapedCode = unescape(this.peek);
this.advance();
}
buffer.add(StringWrapper.fromCharCode(unescapedCode));
buffer.add(String.fromCharCode(unescapedCode));
marker = this.index;
} else if (this.peek == chars.$EOF) {
return this.error('Unterminated quote', 0);

View File

@ -9,7 +9,7 @@
import {Injectable} from '@angular/core';
import * as chars from '../chars';
import {StringWrapper, escapeRegExp, isBlank, isPresent} from '../facade/lang';
import {escapeRegExp, isBlank, isPresent} from '../facade/lang';
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config';
import {AST, ASTWithSource, AstVisitor, Binary, BindingPipe, Chain, Conditional, EmptyExpr, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, ParseSpan, ParserError, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding} from './ast';
@ -122,7 +122,7 @@ export class Parser {
input: string, location: string,
interpolationConfig: InterpolationConfig = DEFAULT_INTERPOLATION_CONFIG): SplitInterpolation {
const regexp = _createInterpolateRegExp(interpolationConfig);
const parts = StringWrapper.split(input, regexp);
const parts = input.split(regexp);
if (parts.length <= 1) {
return null;
}
@ -160,8 +160,8 @@ export class Parser {
private _commentStart(input: string): number {
var outerQuote: number = null;
for (let i = 0; i < input.length - 1; i++) {
const char = StringWrapper.charCodeAt(input, i);
const nextChar = StringWrapper.charCodeAt(input, i + 1);
const char = input.charCodeAt(i);
const nextChar = input.charCodeAt(i + 1);
if (char === chars.$SLASH && nextChar == chars.$SLASH && isBlank(outerQuote)) return i;
@ -177,7 +177,7 @@ export class Parser {
private _checkNoInterpolation(
input: string, location: any, interpolationConfig: InterpolationConfig): void {
var regexp = _createInterpolateRegExp(interpolationConfig);
var parts = StringWrapper.split(input, regexp);
var parts = input.split(regexp);
if (parts.length > 1) {
this._reportError(
`Got interpolation (${interpolationConfig.start}${interpolationConfig.end}) where expression was expected`,
@ -239,7 +239,7 @@ export class _ParseAST {
expectCharacter(code: number) {
if (this.optionalCharacter(code)) return;
this.error(`Missing expected ${StringWrapper.fromCharCode(code)}`);
this.error(`Missing expected ${String.fromCharCode(code)}`);
}
optionalOperator(op: string): boolean {