refactor: misc (#9308)
This commit is contained in:
parent
5e3ccbcea9
commit
7498050421
|
@ -1,8 +1,6 @@
|
|||
import {ChangeDetectorRef, Injectable, OnDestroy, Pipe, WrappedValue} from '@angular/core';
|
||||
|
||||
import {ChangeDetectorRef, OnDestroy, Pipe, WrappedValue} from '@angular/core';
|
||||
import {EventEmitter, Observable, ObservableWrapper} from '../facade/async';
|
||||
import {isBlank, isPresent, isPromise} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
interface SubscriptionStrategy {
|
||||
|
@ -63,7 +61,6 @@ var __unused: Promise<any>; // avoid unused import when Promise union types are
|
|||
* @stable
|
||||
*/
|
||||
@Pipe({name: 'async', pure: false})
|
||||
@Injectable()
|
||||
export class AsyncPipe implements OnDestroy {
|
||||
/** @internal */
|
||||
_latestValue: Object = null;
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import {Injectable, Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {isDate, isNumber, isString, DateWrapper, isBlank,} from '../facade/lang';
|
||||
import {DateFormatter} from '../facade/intl';
|
||||
import {StringMapWrapper} from '../facade/collection';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
|
||||
// TODO: move to a global configurable location along with other i18n components.
|
||||
var defaultLocale: string = 'en-US';
|
||||
|
||||
|
@ -80,7 +77,6 @@ var defaultLocale: string = 'en-US';
|
|||
* @experimental
|
||||
*/
|
||||
@Pipe({name: 'date', pure: true})
|
||||
@Injectable()
|
||||
export class DatePipe implements PipeTransform {
|
||||
/** @internal */
|
||||
static _ALIASES: {[key: string]: String} = {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {RegExpWrapper, StringWrapper, isPresent, isStringMap} from '../facade/lang';
|
||||
|
||||
import {StringWrapper, isPresent, isStringMap} from '../facade/lang';
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
var interpolationExp: RegExp = RegExpWrapper.create('#');
|
||||
const _INTERPOLATION_REGEXP: RegExp = /#/g;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,6 +49,6 @@ export class I18nPluralPipe implements PipeTransform {
|
|||
key = value === 0 || value === 1 ? `=${value}` : 'other';
|
||||
valueStr = isPresent(value) ? value.toString() : '';
|
||||
|
||||
return StringWrapper.replaceAll(pluralMap[key], interpolationExp, valueStr);
|
||||
return StringWrapper.replaceAll(pluralMap[key], _INTERPOLATION_REGEXP, valueStr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {StringMapWrapper} from '../facade/collection';
|
||||
import {isStringMap} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {isBlank, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {NumberFormatStyle, NumberFormatter} from '../facade/intl';
|
||||
import {NumberWrapper, RegExpWrapper, Type, isBlank, isNumber, isPresent} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
var defaultLocale: string = 'en-US';
|
||||
var _re = RegExpWrapper.create('^(\\d+)?\\.((\\d+)(\\-(\\d+))?)?$');
|
||||
const _NUMBER_REGEXP = /^(\d+)?\.((\d+)(\-(\d+))?)?$'/g;
|
||||
|
||||
/**
|
||||
* Internal function to format numbers used by Decimal, Percent and Date pipes.
|
||||
|
@ -21,7 +19,7 @@ function formatNumber(
|
|||
}
|
||||
var minInt = 1, minFraction = 0, maxFraction = 3;
|
||||
if (isPresent(digits)) {
|
||||
var parts = RegExpWrapper.firstMatch(_re, digits);
|
||||
var parts = RegExpWrapper.firstMatch(_NUMBER_REGEXP, digits);
|
||||
if (isBlank(parts)) {
|
||||
throw new BaseException(`${digits} is not a valid digit info for number pipes`);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import {Injectable, Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {RegExpWrapper, StringWrapper, isBlank, isFunction, isNumber, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
/**
|
||||
|
@ -35,7 +33,6 @@ import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
|||
*/
|
||||
|
||||
@Pipe({name: 'replace'})
|
||||
@Injectable()
|
||||
export class ReplacePipe implements PipeTransform {
|
||||
transform(value: any, pattern: string|RegExp, replacement: Function|string): any {
|
||||
if (isBlank(value)) {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {StringWrapper, isArray, isBlank, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
import {isBlank, isString} from '../facade/lang';
|
||||
|
||||
import {InvalidPipeArgumentException} from './invalid_pipe_argument_exception';
|
||||
|
||||
|
||||
/**
|
||||
* Implements uppercase transforms to text.
|
||||
*
|
||||
|
|
|
@ -1,63 +1,66 @@
|
|||
export const $EOF = /*@ts2dart_const*/ 0;
|
||||
export const $TAB = /*@ts2dart_const*/ 9;
|
||||
export const $LF = /*@ts2dart_const*/ 10;
|
||||
export const $VTAB = /*@ts2dart_const*/ 11;
|
||||
export const $FF = /*@ts2dart_const*/ 12;
|
||||
export const $CR = /*@ts2dart_const*/ 13;
|
||||
export const $SPACE = /*@ts2dart_const*/ 32;
|
||||
export const $BANG = /*@ts2dart_const*/ 33;
|
||||
export const $DQ = /*@ts2dart_const*/ 34;
|
||||
export const $HASH = /*@ts2dart_const*/ 35;
|
||||
export const $$ = /*@ts2dart_const*/ 36;
|
||||
export const $PERCENT = /*@ts2dart_const*/ 37;
|
||||
export const $AMPERSAND = /*@ts2dart_const*/ 38;
|
||||
export const $SQ = /*@ts2dart_const*/ 39;
|
||||
export const $LPAREN = /*@ts2dart_const*/ 40;
|
||||
export const $RPAREN = /*@ts2dart_const*/ 41;
|
||||
export const $STAR = /*@ts2dart_const*/ 42;
|
||||
export const $PLUS = /*@ts2dart_const*/ 43;
|
||||
export const $COMMA = /*@ts2dart_const*/ 44;
|
||||
export const $MINUS = /*@ts2dart_const*/ 45;
|
||||
export const $PERIOD = /*@ts2dart_const*/ 46;
|
||||
export const $SLASH = /*@ts2dart_const*/ 47;
|
||||
export const $COLON = /*@ts2dart_const*/ 58;
|
||||
export const $SEMICOLON = /*@ts2dart_const*/ 59;
|
||||
export const $LT = /*@ts2dart_const*/ 60;
|
||||
export const $EQ = /*@ts2dart_const*/ 61;
|
||||
export const $GT = /*@ts2dart_const*/ 62;
|
||||
export const $QUESTION = /*@ts2dart_const*/ 63;
|
||||
export const $EOF = 0;
|
||||
export const $TAB = 9;
|
||||
export const $LF = 10;
|
||||
export const $VTAB = 11;
|
||||
export const $FF = 12;
|
||||
export const $CR = 13;
|
||||
export const $SPACE = 32;
|
||||
export const $BANG = 33;
|
||||
export const $DQ = 34;
|
||||
export const $HASH = 35;
|
||||
export const $$ = 36;
|
||||
export const $PERCENT = 37;
|
||||
export const $AMPERSAND = 38;
|
||||
export const $SQ = 39;
|
||||
export const $LPAREN = 40;
|
||||
export const $RPAREN = 41;
|
||||
export const $STAR = 42;
|
||||
export const $PLUS = 43;
|
||||
export const $COMMA = 44;
|
||||
export const $MINUS = 45;
|
||||
export const $PERIOD = 46;
|
||||
export const $SLASH = 47;
|
||||
export const $COLON = 58;
|
||||
export const $SEMICOLON = 59;
|
||||
export const $LT = 60;
|
||||
export const $EQ = 61;
|
||||
export const $GT = 62;
|
||||
export const $QUESTION = 63;
|
||||
|
||||
export const $0 = /*@ts2dart_const*/ 48;
|
||||
export const $9 = /*@ts2dart_const*/ 57;
|
||||
export const $0 = 48;
|
||||
export const $9 = 57;
|
||||
|
||||
export const $A = /*@ts2dart_const*/ 65;
|
||||
export const $E = /*@ts2dart_const*/ 69;
|
||||
export const $Z = /*@ts2dart_const*/ 90;
|
||||
export const $A = 65;
|
||||
export const $E = 69;
|
||||
export const $F = 70;
|
||||
export const $X = 88;
|
||||
export const $Z = 90;
|
||||
|
||||
export const $LBRACKET = /*@ts2dart_const*/ 91;
|
||||
export const $BACKSLASH = /*@ts2dart_const*/ 92;
|
||||
export const $RBRACKET = /*@ts2dart_const*/ 93;
|
||||
export const $CARET = /*@ts2dart_const*/ 94;
|
||||
export const $_ = /*@ts2dart_const*/ 95;
|
||||
export const $LBRACKET = 91;
|
||||
export const $BACKSLASH = 92;
|
||||
export const $RBRACKET = 93;
|
||||
export const $CARET = 94;
|
||||
export const $_ = 95;
|
||||
|
||||
export const $a = /*@ts2dart_const*/ 97;
|
||||
export const $e = /*@ts2dart_const*/ 101;
|
||||
export const $f = /*@ts2dart_const*/ 102;
|
||||
export const $n = /*@ts2dart_const*/ 110;
|
||||
export const $r = /*@ts2dart_const*/ 114;
|
||||
export const $t = /*@ts2dart_const*/ 116;
|
||||
export const $u = /*@ts2dart_const*/ 117;
|
||||
export const $v = /*@ts2dart_const*/ 118;
|
||||
export const $z = /*@ts2dart_const*/ 122;
|
||||
export const $a = 97;
|
||||
export const $e = 101;
|
||||
export const $f = 102;
|
||||
export const $n = 110;
|
||||
export const $r = 114;
|
||||
export const $t = 116;
|
||||
export const $u = 117;
|
||||
export const $v = 118;
|
||||
export const $x = 120;
|
||||
export const $z = 122;
|
||||
|
||||
export const $LBRACE = /*@ts2dart_const*/ 123;
|
||||
export const $BAR = /*@ts2dart_const*/ 124;
|
||||
export const $RBRACE = /*@ts2dart_const*/ 125;
|
||||
export const $NBSP = /*@ts2dart_const*/ 160;
|
||||
export const $LBRACE = 123;
|
||||
export const $BAR = 124;
|
||||
export const $RBRACE = 125;
|
||||
export const $NBSP = 160;
|
||||
|
||||
export const $PIPE = /*@ts2dart_const*/ 124;
|
||||
export const $TILDA = /*@ts2dart_const*/ 126;
|
||||
export const $AT = /*@ts2dart_const*/ 64;
|
||||
export const $PIPE = 124;
|
||||
export const $TILDA = 126;
|
||||
export const $AT = 64;
|
||||
|
||||
export function isWhitespace(code: number): boolean {
|
||||
return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
|
||||
|
|
|
@ -3,7 +3,7 @@ import {ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
|
|||
import {CHANGE_DETECTION_STRATEGY_VALUES, LIFECYCLE_HOOKS_VALUES, LifecycleHooks, VIEW_ENCAPSULATION_VALUES, reflector} from '../core_private';
|
||||
import {ListWrapper, StringMapWrapper} from '../src/facade/collection';
|
||||
import {BaseException, unimplemented} from '../src/facade/exceptions';
|
||||
import {NumberWrapper, RegExpWrapper, StringWrapper, Type, isArray, isBlank, isBoolean, isNumber, isPresent, isString, normalizeBlank, normalizeBool, serializeEnum} from '../src/facade/lang';
|
||||
import {NumberWrapper, RegExpWrapper, Type, isArray, isBlank, isBoolean, isNumber, isPresent, isString, normalizeBlank, normalizeBool, serializeEnum} from '../src/facade/lang';
|
||||
|
||||
import {CssSelector} from './selector';
|
||||
import {getUrlScheme} from './url_resolver';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {ComponentResolver, Type} from '@angular/core';
|
||||
import {assertionsEnabled} from './facade/lang';
|
||||
|
||||
export * from './template_ast';
|
||||
export {TEMPLATE_TRANSFORMS} from './template_parser';
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {resolveForwardRef, Injectable, DirectiveMetadata, ComponentMetadata, InputMetadata, OutputMetadata, HostBindingMetadata, HostListenerMetadata, ContentChildrenMetadata, ViewChildrenMetadata, ContentChildMetadata, ViewChildMetadata,} from '@angular/core';
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
import {ComponentMetadata, DirectiveMetadata, HostBindingMetadata, HostListenerMetadata, Injectable, InputMetadata, OutputMetadata, QueryMetadata, resolveForwardRef} from '@angular/core';
|
||||
|
||||
import {Type, isPresent, stringify} from '../src/facade/lang';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {ReflectorReader, reflector} from '../core_private';
|
||||
import {ListWrapper, StringMapWrapper} from '../src/facade/collection';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {Type, isPresent, stringify} from '../src/facade/lang';
|
||||
|
||||
|
||||
function _isDirectiveMetadata(type: any): boolean {
|
||||
|
@ -19,15 +19,7 @@ function _isDirectiveMetadata(type: any): boolean {
|
|||
*/
|
||||
@Injectable()
|
||||
export class DirectiveResolver {
|
||||
private _reflector: ReflectorReader;
|
||||
|
||||
constructor(_reflector?: ReflectorReader) {
|
||||
if (isPresent(_reflector)) {
|
||||
this._reflector = _reflector;
|
||||
} else {
|
||||
this._reflector = reflector;
|
||||
}
|
||||
}
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
/**
|
||||
* Return {@link DirectiveMetadata} for a given `Type`.
|
||||
|
@ -48,8 +40,8 @@ export class DirectiveResolver {
|
|||
private _mergeWithPropertyMetadata(
|
||||
dm: DirectiveMetadata, propertyMetadata: {[key: string]: any[]},
|
||||
directiveType: Type): DirectiveMetadata {
|
||||
var inputs: any[] /** TODO #9100 */ = [];
|
||||
var outputs: any[] /** TODO #9100 */ = [];
|
||||
var inputs: string[] = [];
|
||||
var outputs: string[] = [];
|
||||
var host: {[key: string]: string} = {};
|
||||
var queries: {[key: string]: any} = {};
|
||||
|
||||
|
@ -84,19 +76,7 @@ export class DirectiveResolver {
|
|||
host[`(${a.eventName})`] = `${propName}(${args})`;
|
||||
}
|
||||
|
||||
if (a instanceof ContentChildrenMetadata) {
|
||||
queries[propName] = a;
|
||||
}
|
||||
|
||||
if (a instanceof ViewChildrenMetadata) {
|
||||
queries[propName] = a;
|
||||
}
|
||||
|
||||
if (a instanceof ContentChildMetadata) {
|
||||
queries[propName] = a;
|
||||
}
|
||||
|
||||
if (a instanceof ViewChildMetadata) {
|
||||
if (a instanceof QueryMetadata) {
|
||||
queries[propName] = a;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as chars from './chars';
|
||||
import {ListWrapper} from './facade/collection';
|
||||
import {NumberWrapper, StringWrapper, isBlank, isPresent} from './facade/lang';
|
||||
import {HtmlTagContentType, NAMED_ENTITIES, getHtmlTagDefinition} from './html_tags';
|
||||
|
@ -48,53 +49,10 @@ export function tokenizeHtml(
|
|||
.tokenize();
|
||||
}
|
||||
|
||||
const $EOF = 0;
|
||||
const $TAB = 9;
|
||||
const $LF = 10;
|
||||
const $FF = 12;
|
||||
const $CR = 13;
|
||||
|
||||
const $SPACE = 32;
|
||||
|
||||
const $BANG = 33;
|
||||
const $DQ = 34;
|
||||
const $HASH = 35;
|
||||
const $$ = 36;
|
||||
const $AMPERSAND = 38;
|
||||
const $SQ = 39;
|
||||
const $MINUS = 45;
|
||||
const $SLASH = 47;
|
||||
const $0 = 48;
|
||||
|
||||
const $SEMICOLON = 59;
|
||||
|
||||
const $9 = 57;
|
||||
const $COLON = 58;
|
||||
const $LT = 60;
|
||||
const $EQ = 61;
|
||||
const $GT = 62;
|
||||
const $QUESTION = 63;
|
||||
const $LBRACKET = 91;
|
||||
const $RBRACKET = 93;
|
||||
const $LBRACE = 123;
|
||||
const $RBRACE = 125;
|
||||
const $COMMA = 44;
|
||||
const $A = 65;
|
||||
const $F = 70;
|
||||
const $X = 88;
|
||||
const $Z = 90;
|
||||
|
||||
const $a = 97;
|
||||
const $f = 102;
|
||||
const $z = 122;
|
||||
const $x = 120;
|
||||
|
||||
const $NBSP = 160;
|
||||
|
||||
var CR_OR_CRLF_REGEXP = /\r\n?/g;
|
||||
|
||||
function unexpectedCharacterErrorMsg(charCode: number): string {
|
||||
var char = charCode === $EOF ? 'EOF' : StringWrapper.fromCharCode(charCode);
|
||||
var char = charCode === chars.$EOF ? 'EOF' : StringWrapper.fromCharCode(charCode);
|
||||
return `Unexpected character "${char}"`;
|
||||
}
|
||||
|
||||
|
@ -138,19 +96,19 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
tokenize(): HtmlTokenizeResult {
|
||||
while (this._peek !== $EOF) {
|
||||
while (this._peek !== chars.$EOF) {
|
||||
var start = this._getLocation();
|
||||
try {
|
||||
if (this._attemptCharCode($LT)) {
|
||||
if (this._attemptCharCode($BANG)) {
|
||||
if (this._attemptCharCode($LBRACKET)) {
|
||||
if (this._attemptCharCode(chars.$LT)) {
|
||||
if (this._attemptCharCode(chars.$BANG)) {
|
||||
if (this._attemptCharCode(chars.$LBRACKET)) {
|
||||
this._consumeCdata(start);
|
||||
} else if (this._attemptCharCode($MINUS)) {
|
||||
} else if (this._attemptCharCode(chars.$MINUS)) {
|
||||
this._consumeComment(start);
|
||||
} else {
|
||||
this._consumeDocType(start);
|
||||
}
|
||||
} else if (this._attemptCharCode($SLASH)) {
|
||||
} else if (this._attemptCharCode(chars.$SLASH)) {
|
||||
this._consumeTagClose(start);
|
||||
} else {
|
||||
this._consumeTagOpen(start);
|
||||
|
@ -165,11 +123,13 @@ class _HtmlTokenizer {
|
|||
this._consumeExpansionCaseStart();
|
||||
|
||||
} else if (
|
||||
this._peek === $RBRACE && this._isInExpansionCase() && this.tokenizeExpansionForms) {
|
||||
this._peek === chars.$RBRACE && this._isInExpansionCase() &&
|
||||
this.tokenizeExpansionForms) {
|
||||
this._consumeExpansionCaseEnd();
|
||||
|
||||
} else if (
|
||||
this._peek === $RBRACE && this._isInExpansionForm() && this.tokenizeExpansionForms) {
|
||||
this._peek === chars.$RBRACE && this._isInExpansionForm() &&
|
||||
this.tokenizeExpansionForms) {
|
||||
this._consumeExpansionFormEnd();
|
||||
|
||||
} else {
|
||||
|
@ -231,19 +191,19 @@ class _HtmlTokenizer {
|
|||
|
||||
private _advance() {
|
||||
if (this._index >= this._length) {
|
||||
throw this._createError(unexpectedCharacterErrorMsg($EOF), this._getSpan());
|
||||
throw this._createError(unexpectedCharacterErrorMsg(chars.$EOF), this._getSpan());
|
||||
}
|
||||
if (this._peek === $LF) {
|
||||
if (this._peek === chars.$LF) {
|
||||
this._line++;
|
||||
this._column = 0;
|
||||
} else if (this._peek !== $LF && this._peek !== $CR) {
|
||||
} else if (this._peek !== chars.$LF && this._peek !== chars.$CR) {
|
||||
this._column++;
|
||||
}
|
||||
this._index++;
|
||||
this._peek =
|
||||
this._index >= this._length ? $EOF : StringWrapper.charCodeAt(this._input, this._index);
|
||||
this._peek = this._index >= this._length ? chars.$EOF :
|
||||
StringWrapper.charCodeAt(this._input, this._index);
|
||||
this._nextPeek = this._index + 1 >= this._length ?
|
||||
$EOF :
|
||||
chars.$EOF :
|
||||
StringWrapper.charCodeAt(this._input, this._index + 1);
|
||||
}
|
||||
|
||||
|
@ -325,7 +285,7 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
private _readChar(decodeEntities: boolean): string {
|
||||
if (decodeEntities && this._peek === $AMPERSAND) {
|
||||
if (decodeEntities && this._peek === chars.$AMPERSAND) {
|
||||
return this._decodeEntity();
|
||||
} else {
|
||||
var index = this._index;
|
||||
|
@ -337,11 +297,11 @@ class _HtmlTokenizer {
|
|||
private _decodeEntity(): string {
|
||||
var start = this._getLocation();
|
||||
this._advance();
|
||||
if (this._attemptCharCode($HASH)) {
|
||||
let isHex = this._attemptCharCode($x) || this._attemptCharCode($X);
|
||||
if (this._attemptCharCode(chars.$HASH)) {
|
||||
let isHex = this._attemptCharCode(chars.$x) || this._attemptCharCode(chars.$X);
|
||||
let numberStart = this._getLocation().offset;
|
||||
this._attemptCharCodeUntilFn(isDigitEntityEnd);
|
||||
if (this._peek != $SEMICOLON) {
|
||||
if (this._peek != chars.$SEMICOLON) {
|
||||
throw this._createError(unexpectedCharacterErrorMsg(this._peek), this._getSpan());
|
||||
}
|
||||
this._advance();
|
||||
|
@ -356,7 +316,7 @@ class _HtmlTokenizer {
|
|||
} else {
|
||||
let startPosition = this._savePosition();
|
||||
this._attemptCharCodeUntilFn(isNamedEntityEnd);
|
||||
if (this._peek != $SEMICOLON) {
|
||||
if (this._peek != chars.$SEMICOLON) {
|
||||
this._restorePosition(startPosition);
|
||||
return '&';
|
||||
}
|
||||
|
@ -394,9 +354,9 @@ class _HtmlTokenizer {
|
|||
|
||||
private _consumeComment(start: ParseLocation) {
|
||||
this._beginToken(HtmlTokenType.COMMENT_START, start);
|
||||
this._requireCharCode($MINUS);
|
||||
this._requireCharCode(chars.$MINUS);
|
||||
this._endToken([]);
|
||||
var textToken = this._consumeRawText(false, $MINUS, () => this._attemptStr('->'));
|
||||
var textToken = this._consumeRawText(false, chars.$MINUS, () => this._attemptStr('->'));
|
||||
this._beginToken(HtmlTokenType.COMMENT_END, textToken.sourceSpan.end);
|
||||
this._endToken([]);
|
||||
}
|
||||
|
@ -405,14 +365,14 @@ class _HtmlTokenizer {
|
|||
this._beginToken(HtmlTokenType.CDATA_START, start);
|
||||
this._requireStr('CDATA[');
|
||||
this._endToken([]);
|
||||
var textToken = this._consumeRawText(false, $RBRACKET, () => this._attemptStr(']>'));
|
||||
var textToken = this._consumeRawText(false, chars.$RBRACKET, () => this._attemptStr(']>'));
|
||||
this._beginToken(HtmlTokenType.CDATA_END, textToken.sourceSpan.end);
|
||||
this._endToken([]);
|
||||
}
|
||||
|
||||
private _consumeDocType(start: ParseLocation) {
|
||||
this._beginToken(HtmlTokenType.DOC_TYPE, start);
|
||||
this._attemptUntilChar($GT);
|
||||
this._attemptUntilChar(chars.$GT);
|
||||
this._advance();
|
||||
this._endToken([this._input.substring(start.offset + 2, this._index - 1)]);
|
||||
}
|
||||
|
@ -420,11 +380,11 @@ class _HtmlTokenizer {
|
|||
private _consumePrefixAndName(): string[] {
|
||||
var nameOrPrefixStart = this._index;
|
||||
var prefix: string = null;
|
||||
while (this._peek !== $COLON && !isPrefixEnd(this._peek)) {
|
||||
while (this._peek !== chars.$COLON && !isPrefixEnd(this._peek)) {
|
||||
this._advance();
|
||||
}
|
||||
var nameStart: number;
|
||||
if (this._peek === $COLON) {
|
||||
if (this._peek === chars.$COLON) {
|
||||
this._advance();
|
||||
prefix = this._input.substring(nameOrPrefixStart, this._index - 1);
|
||||
nameStart = this._index;
|
||||
|
@ -447,10 +407,10 @@ class _HtmlTokenizer {
|
|||
this._consumeTagOpenStart(start);
|
||||
lowercaseTagName = this._input.substring(nameStart, this._index).toLowerCase();
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
while (this._peek !== $SLASH && this._peek !== $GT) {
|
||||
while (this._peek !== chars.$SLASH && this._peek !== chars.$GT) {
|
||||
this._consumeAttributeName();
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
if (this._attemptCharCode($EQ)) {
|
||||
if (this._attemptCharCode(chars.$EQ)) {
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
this._consumeAttributeValue();
|
||||
}
|
||||
|
@ -479,12 +439,12 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
private _consumeRawTextWithTagClose(lowercaseTagName: string, decodeEntities: boolean) {
|
||||
var textToken = this._consumeRawText(decodeEntities, $LT, () => {
|
||||
if (!this._attemptCharCode($SLASH)) return false;
|
||||
var textToken = this._consumeRawText(decodeEntities, chars.$LT, () => {
|
||||
if (!this._attemptCharCode(chars.$SLASH)) return false;
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
if (!this._attemptStrCaseInsensitive(lowercaseTagName)) return false;
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
if (!this._attemptCharCode($GT)) return false;
|
||||
if (!this._attemptCharCode(chars.$GT)) return false;
|
||||
return true;
|
||||
});
|
||||
this._beginToken(HtmlTokenType.TAG_CLOSE, textToken.sourceSpan.end);
|
||||
|
@ -506,7 +466,7 @@ class _HtmlTokenizer {
|
|||
private _consumeAttributeValue() {
|
||||
this._beginToken(HtmlTokenType.ATTR_VALUE);
|
||||
var value: string;
|
||||
if (this._peek === $SQ || this._peek === $DQ) {
|
||||
if (this._peek === chars.$SQ || this._peek === chars.$DQ) {
|
||||
var quoteChar = this._peek;
|
||||
this._advance();
|
||||
var parts: string[] = [];
|
||||
|
@ -524,10 +484,10 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
private _consumeTagOpenEnd() {
|
||||
var tokenType = this._attemptCharCode($SLASH) ? HtmlTokenType.TAG_OPEN_END_VOID :
|
||||
HtmlTokenType.TAG_OPEN_END;
|
||||
var tokenType = this._attemptCharCode(chars.$SLASH) ? HtmlTokenType.TAG_OPEN_END_VOID :
|
||||
HtmlTokenType.TAG_OPEN_END;
|
||||
this._beginToken(tokenType);
|
||||
this._requireCharCode($GT);
|
||||
this._requireCharCode(chars.$GT);
|
||||
this._endToken([]);
|
||||
}
|
||||
|
||||
|
@ -536,25 +496,25 @@ class _HtmlTokenizer {
|
|||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
let prefixAndName = this._consumePrefixAndName();
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
this._requireCharCode($GT);
|
||||
this._requireCharCode(chars.$GT);
|
||||
this._endToken(prefixAndName);
|
||||
}
|
||||
|
||||
private _consumeExpansionFormStart() {
|
||||
this._beginToken(HtmlTokenType.EXPANSION_FORM_START, this._getLocation());
|
||||
this._requireCharCode($LBRACE);
|
||||
this._requireCharCode(chars.$LBRACE);
|
||||
this._endToken([]);
|
||||
|
||||
this._beginToken(HtmlTokenType.RAW_TEXT, this._getLocation());
|
||||
let condition = this._readUntil($COMMA);
|
||||
let condition = this._readUntil(chars.$COMMA);
|
||||
this._endToken([condition], this._getLocation());
|
||||
this._requireCharCode($COMMA);
|
||||
this._requireCharCode(chars.$COMMA);
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
|
||||
this._beginToken(HtmlTokenType.RAW_TEXT, this._getLocation());
|
||||
let type = this._readUntil($COMMA);
|
||||
let type = this._readUntil(chars.$COMMA);
|
||||
this._endToken([type], this._getLocation());
|
||||
this._requireCharCode($COMMA);
|
||||
this._requireCharCode(chars.$COMMA);
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
|
||||
this._expansionCaseStack.push(HtmlTokenType.EXPANSION_FORM_START);
|
||||
|
@ -562,12 +522,12 @@ class _HtmlTokenizer {
|
|||
|
||||
private _consumeExpansionCaseStart() {
|
||||
this._beginToken(HtmlTokenType.EXPANSION_CASE_VALUE, this._getLocation());
|
||||
let value = this._readUntil($LBRACE).trim();
|
||||
let value = this._readUntil(chars.$LBRACE).trim();
|
||||
this._endToken([value], this._getLocation());
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
|
||||
this._beginToken(HtmlTokenType.EXPANSION_CASE_EXP_START, this._getLocation());
|
||||
this._requireCharCode($LBRACE);
|
||||
this._requireCharCode(chars.$LBRACE);
|
||||
this._endToken([], this._getLocation());
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
|
||||
|
@ -576,7 +536,7 @@ class _HtmlTokenizer {
|
|||
|
||||
private _consumeExpansionCaseEnd() {
|
||||
this._beginToken(HtmlTokenType.EXPANSION_CASE_EXP_END, this._getLocation());
|
||||
this._requireCharCode($RBRACE);
|
||||
this._requireCharCode(chars.$RBRACE);
|
||||
this._endToken([], this._getLocation());
|
||||
this._attemptCharCodeUntilFn(isNotWhitespace);
|
||||
|
||||
|
@ -585,7 +545,7 @@ class _HtmlTokenizer {
|
|||
|
||||
private _consumeExpansionFormEnd() {
|
||||
this._beginToken(HtmlTokenType.EXPANSION_FORM_END, this._getLocation());
|
||||
this._requireCharCode($RBRACE);
|
||||
this._requireCharCode(chars.$RBRACE);
|
||||
this._endToken([]);
|
||||
|
||||
this._expansionCaseStack.pop();
|
||||
|
@ -598,7 +558,7 @@ class _HtmlTokenizer {
|
|||
var parts: string[] = [];
|
||||
let interpolation = false;
|
||||
|
||||
if (this._peek === $LBRACE && this._nextPeek === $LBRACE) {
|
||||
if (this._peek === chars.$LBRACE && this._nextPeek === chars.$LBRACE) {
|
||||
parts.push(this._readChar(true));
|
||||
parts.push(this._readChar(true));
|
||||
interpolation = true;
|
||||
|
@ -607,11 +567,12 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
while (!this._isTextEnd(interpolation)) {
|
||||
if (this._peek === $LBRACE && this._nextPeek === $LBRACE) {
|
||||
if (this._peek === chars.$LBRACE && this._nextPeek === chars.$LBRACE) {
|
||||
parts.push(this._readChar(true));
|
||||
parts.push(this._readChar(true));
|
||||
interpolation = true;
|
||||
} else if (this._peek === $RBRACE && this._nextPeek === $RBRACE && interpolation) {
|
||||
} else if (
|
||||
this._peek === chars.$RBRACE && this._nextPeek === chars.$RBRACE && interpolation) {
|
||||
parts.push(this._readChar(true));
|
||||
parts.push(this._readChar(true));
|
||||
interpolation = false;
|
||||
|
@ -623,10 +584,10 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
private _isTextEnd(interpolation: boolean): boolean {
|
||||
if (this._peek === $LT || this._peek === $EOF) return true;
|
||||
if (this._peek === chars.$LT || this._peek === chars.$EOF) return true;
|
||||
if (this.tokenizeExpansionForms) {
|
||||
if (isExpansionFormStart(this._peek, this._nextPeek)) return true;
|
||||
if (this._peek === $RBRACE && !interpolation &&
|
||||
if (this._peek === chars.$RBRACE && !interpolation &&
|
||||
(this._isInExpansionCase() || this._isInExpansionForm()))
|
||||
return true;
|
||||
}
|
||||
|
@ -669,44 +630,46 @@ class _HtmlTokenizer {
|
|||
}
|
||||
|
||||
function isNotWhitespace(code: number): boolean {
|
||||
return !isWhitespace(code) || code === $EOF;
|
||||
return !isWhitespace(code) || code === chars.$EOF;
|
||||
}
|
||||
|
||||
function isWhitespace(code: number): boolean {
|
||||
return (code >= $TAB && code <= $SPACE) || (code === $NBSP);
|
||||
return (code >= chars.$TAB && code <= chars.$SPACE) || (code === chars.$NBSP);
|
||||
}
|
||||
|
||||
function isNameEnd(code: number): boolean {
|
||||
return isWhitespace(code) || code === $GT || code === $SLASH || code === $SQ || code === $DQ ||
|
||||
code === $EQ;
|
||||
return isWhitespace(code) || code === chars.$GT || code === chars.$SLASH || code === chars.$SQ ||
|
||||
code === chars.$DQ || code === chars.$EQ;
|
||||
}
|
||||
|
||||
function isPrefixEnd(code: number): boolean {
|
||||
return (code < $a || $z < code) && (code < $A || $Z < code) && (code < $0 || code > $9);
|
||||
return (code < chars.$a || chars.$z < code) && (code < chars.$A || chars.$Z < code) &&
|
||||
(code < chars.$0 || code > chars.$9);
|
||||
}
|
||||
|
||||
function isDigitEntityEnd(code: number): boolean {
|
||||
return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
|
||||
return code == chars.$SEMICOLON || code == chars.$EOF || !isAsciiHexDigit(code);
|
||||
}
|
||||
|
||||
function isNamedEntityEnd(code: number): boolean {
|
||||
return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
|
||||
return code == chars.$SEMICOLON || code == chars.$EOF || !isAsciiLetter(code);
|
||||
}
|
||||
|
||||
function isExpansionFormStart(peek: number, nextPeek: number): boolean {
|
||||
return peek === $LBRACE && nextPeek != $LBRACE;
|
||||
return peek === chars.$LBRACE && nextPeek != chars.$LBRACE;
|
||||
}
|
||||
|
||||
function isExpansionCaseStart(peek: number): boolean {
|
||||
return peek === $EQ || isAsciiLetter(peek);
|
||||
return peek === chars.$EQ || isAsciiLetter(peek);
|
||||
}
|
||||
|
||||
function isAsciiLetter(code: number): boolean {
|
||||
return code >= $a && code <= $z || code >= $A && code <= $Z;
|
||||
return code >= chars.$a && code <= chars.$z || code >= chars.$A && code <= chars.$Z;
|
||||
}
|
||||
|
||||
function isAsciiHexDigit(code: number): boolean {
|
||||
return code >= $a && code <= $f || code >= $A && code <= $F || code >= $0 && code <= $9;
|
||||
return code >= chars.$a && code <= chars.$f || code >= chars.$A && code <= chars.$F ||
|
||||
code >= chars.$0 && code <= chars.$9;
|
||||
}
|
||||
|
||||
function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
|
||||
|
@ -714,7 +677,7 @@ function compareCharCodeCaseInsensitive(code1: number, code2: number): boolean {
|
|||
}
|
||||
|
||||
function toUpperCaseCharCode(code: number): number {
|
||||
return code >= $a && code <= $z ? code - $a + $A : code;
|
||||
return code >= chars.$a && code <= chars.$z ? code - chars.$a + chars.$A : code;
|
||||
}
|
||||
|
||||
function mergeTextTokens(srcTokens: HtmlToken[]): HtmlToken[] {
|
||||
|
|
|
@ -21,18 +21,11 @@ export class CompileMetadataResolver {
|
|||
private _pipeCache = new Map<Type, cpl.CompilePipeMetadata>();
|
||||
private _anonymousTypes = new Map<Object, number>();
|
||||
private _anonymousTypeIndex = 0;
|
||||
private _reflector: ReflectorReader;
|
||||
|
||||
constructor(
|
||||
private _directiveResolver: DirectiveResolver, private _pipeResolver: PipeResolver,
|
||||
private _viewResolver: ViewResolver, private _config: CompilerConfig,
|
||||
_reflector?: ReflectorReader) {
|
||||
if (isPresent(_reflector)) {
|
||||
this._reflector = _reflector;
|
||||
} else {
|
||||
this._reflector = reflector;
|
||||
}
|
||||
}
|
||||
private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
private sanitizeTokenName(token: any): string {
|
||||
let identifier = stringify(token);
|
||||
|
@ -244,7 +237,7 @@ export class CompileMetadataResolver {
|
|||
let isOptional = false;
|
||||
let query: QueryMetadata = null;
|
||||
let viewQuery: ViewQueryMetadata = null;
|
||||
var token: any /** TODO #9100 */ = null;
|
||||
var token: any = null;
|
||||
if (isArray(param)) {
|
||||
(<any[]>param).forEach((paramEntry) => {
|
||||
if (paramEntry instanceof HostMetadata) {
|
||||
|
@ -372,7 +365,7 @@ export class CompileMetadataResolver {
|
|||
|
||||
getQueryMetadata(q: QueryMetadata, propertyName: string, typeOrFunc: Type|Function):
|
||||
cpl.CompileQueryMetadata {
|
||||
var selectors: any /** TODO #9100 */;
|
||||
var selectors: cpl.CompileTokenMetadata[];
|
||||
if (q.isVarBindingQuery) {
|
||||
selectors = q.varBindings.map(varName => this.getTokenMetadata(varName));
|
||||
} else {
|
||||
|
@ -393,7 +386,7 @@ export class CompileMetadataResolver {
|
|||
}
|
||||
|
||||
function flattenDirectives(view: ViewMetadata, platformDirectives: any[]): Type[] {
|
||||
let directives: any[] /** TODO #9100 */ = [];
|
||||
let directives: Type[] = [];
|
||||
if (isPresent(platformDirectives)) {
|
||||
flattenArray(platformDirectives, directives);
|
||||
}
|
||||
|
@ -404,7 +397,7 @@ function flattenDirectives(view: ViewMetadata, platformDirectives: any[]): Type[
|
|||
}
|
||||
|
||||
function flattenPipes(view: ViewMetadata, platformPipes: any[]): Type[] {
|
||||
let pipes: any[] /** TODO #9100 */ = [];
|
||||
let pipes: Type[] = [];
|
||||
if (isPresent(platformPipes)) {
|
||||
flattenArray(platformPipes, pipes);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,7 @@ function _isPipeMetadata(type: any): boolean {
|
|||
*/
|
||||
@Injectable()
|
||||
export class PipeResolver {
|
||||
private _reflector: ReflectorReader;
|
||||
constructor(_reflector?: ReflectorReader) {
|
||||
if (isPresent(_reflector)) {
|
||||
this._reflector = _reflector;
|
||||
} else {
|
||||
this._reflector = reflector;
|
||||
}
|
||||
}
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
/**
|
||||
* Return {@link PipeMetadata} for a given `Type`.
|
||||
|
@ -40,5 +33,3 @@ export class PipeResolver {
|
|||
throw new BaseException(`No Pipe decorator found on ${stringify(type)}`);
|
||||
}
|
||||
}
|
||||
|
||||
export var CODEGEN_PIPE_RESOLVER = new PipeResolver(reflector);
|
||||
|
|
|
@ -11,18 +11,10 @@ import {Map} from '../src/facade/collection';
|
|||
*/
|
||||
@Injectable()
|
||||
export class ViewResolver {
|
||||
private _reflector: ReflectorReader;
|
||||
|
||||
/** @internal */
|
||||
_cache = new Map<Type, ViewMetadata>();
|
||||
|
||||
constructor(_reflector?: ReflectorReader) {
|
||||
if (isPresent(_reflector)) {
|
||||
this._reflector = _reflector;
|
||||
} else {
|
||||
this._reflector = reflector;
|
||||
}
|
||||
}
|
||||
constructor(private _reflector: ReflectorReader = reflector) {}
|
||||
|
||||
resolve(component: Type): ViewMetadata {
|
||||
var view = this._cache.get(component);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {ListWrapper, Map, MapWrapper, Set, SetWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {BaseException, WrappedException} from '../facade/exceptions';
|
||||
import {Type, isPresent, stringify} from '../facade/lang';
|
||||
import {Map, MapWrapper, Set, SetWrapper, StringMapWrapper} from '../facade/collection';
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
import {Type, isPresent} from '../facade/lang';
|
||||
|
||||
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
|
||||
import {ReflectorReader} from './reflector_reader';
|
||||
|
@ -124,7 +124,7 @@ export class Reflector extends ReflectorReader {
|
|||
}
|
||||
}
|
||||
|
||||
hasLifecycleHook(type: any, lcInterface: /*Type*/ any, lcProperty: string): boolean {
|
||||
hasLifecycleHook(type: any, lcInterface: Type, lcProperty: string): boolean {
|
||||
var interfaces = this.interfaces(type);
|
||||
if (interfaces.indexOf(lcInterface) !== -1) {
|
||||
return true;
|
||||
|
|
|
@ -1272,7 +1272,7 @@ const COMPILER = [
|
|||
'DirectiveAst.sourceSpan:ParseSourceSpan',
|
||||
'DirectiveAst.visit(visitor:TemplateAstVisitor, context:any):any',
|
||||
'DirectiveResolver',
|
||||
'DirectiveResolver.constructor(_reflector?:ReflectorReader)',
|
||||
'DirectiveResolver.constructor(_reflector:ReflectorReader=reflector)',
|
||||
'DirectiveResolver.resolve(type:Type):DirectiveMetadata',
|
||||
'ElementAst',
|
||||
'ElementAst.attrs:AttrAst[]',
|
||||
|
@ -1322,7 +1322,7 @@ const COMPILER = [
|
|||
'OfflineCompiler.loadAndCompileStylesheet(stylesheetUrl:string, shim:boolean, suffix:string):Promise<StyleSheetSourceWithImports>',
|
||||
'OfflineCompiler.normalizeDirectiveMetadata(directive:CompileDirectiveMetadata):Promise<CompileDirectiveMetadata>',
|
||||
'PipeResolver',
|
||||
'PipeResolver.constructor(_reflector?:ReflectorReader)',
|
||||
'PipeResolver.constructor(_reflector:ReflectorReader=reflector)',
|
||||
'PipeResolver.resolve(type:Type):PipeMetadata',
|
||||
'PropertyBindingType',
|
||||
'PropertyBindingType.Animation',
|
||||
|
@ -1400,7 +1400,7 @@ const COMPILER = [
|
|||
'VariableAst.value:string',
|
||||
'VariableAst.visit(visitor:TemplateAstVisitor, context:any):any',
|
||||
'ViewResolver',
|
||||
'ViewResolver.constructor(_reflector?:ReflectorReader)',
|
||||
'ViewResolver.constructor(_reflector:ReflectorReader=reflector)',
|
||||
'ViewResolver.resolve(component:Type):ViewMetadata',
|
||||
'XHR',
|
||||
'XHR.get(url:string):Promise<string>',
|
||||
|
|
Loading…
Reference in New Issue