refactor(compiler): Change arguments of CompilerConfig to named arguments

BREAKIKNG CHANGE:
`CompilerConfig` used to take positional arguments and now takes named arguments.

Closes #9172
This commit is contained in:
Tobias Bosch
2016-06-13 10:06:40 -07:00
parent 1745366530
commit bc888bf3a1
15 changed files with 110 additions and 103 deletions
+1 -5
View File
@@ -31,10 +31,6 @@ import {ViewResolver} from './view_resolver';
import {DirectiveResolver} from './directive_resolver';
import {PipeResolver} from './pipe_resolver';
function _createCompilerConfig() {
return new CompilerConfig(assertionsEnabled(), false, true);
}
/**
* A set of providers that provide `RuntimeCompiler` and its dependencies to use for
* template compilation.
@@ -43,7 +39,7 @@ export const COMPILER_PROVIDERS: Array<any|Type|{[k: string]: any}|any[]> =
/*@ts2dart_const*/[
Lexer, Parser, HtmlParser, TemplateParser, DirectiveNormalizer, CompileMetadataResolver,
DEFAULT_PACKAGE_URL_PROVIDER, StyleCompiler, ViewCompiler,
/*@ts2dart_Provider*/ {provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []},
/*@ts2dart_Provider*/ {provide: CompilerConfig, useValue: new CompilerConfig()},
RuntimeCompiler,
/*@ts2dart_Provider*/ {provide: ComponentResolver, useExisting: RuntimeCompiler},
DomElementSchemaRegistry,
+22 -10
View File
@@ -1,7 +1,7 @@
import {ViewEncapsulation} from '@angular/core';
import {unimplemented} from '../src/facade/exceptions';
import {Type, isBlank} from '../src/facade/lang';
import {Type, assertionsEnabled, isBlank} from '../src/facade/lang';
import {CompileIdentifierMetadata} from './compile_metadata';
import {Identifiers} from './identifiers';
@@ -9,19 +9,31 @@ import {Identifiers} from './identifiers';
export class CompilerConfig {
public renderTypes: RenderTypes;
public defaultEncapsulation: ViewEncapsulation;
public genDebugInfo: boolean;
public logBindingUpdate: boolean;
public useJit: boolean;
public platformDirectives: any[];
public platformPipes: any[];
constructor(
public genDebugInfo: boolean, public logBindingUpdate: boolean, public useJit: boolean,
renderTypes: RenderTypes = null, defaultEncapsulation: ViewEncapsulation = null,
public platformDirectives: any[] = [], public platformPipes: any[] = []) {
if (isBlank(renderTypes)) {
renderTypes = new DefaultRenderTypes();
}
{renderTypes = new DefaultRenderTypes(), defaultEncapsulation = ViewEncapsulation.Emulated,
genDebugInfo = assertionsEnabled(), logBindingUpdate = assertionsEnabled(), useJit = true,
platformDirectives = [], platformPipes = []}: {
renderTypes?: RenderTypes,
defaultEncapsulation?: ViewEncapsulation,
genDebugInfo?: boolean,
logBindingUpdate?: boolean,
useJit?: boolean,
platformDirectives?: any[],
platformPipes?: any[]
} = {}) {
this.renderTypes = renderTypes;
if (isBlank(defaultEncapsulation)) {
defaultEncapsulation = ViewEncapsulation.Emulated;
}
this.defaultEncapsulation = defaultEncapsulation;
this.genDebugInfo = genDebugInfo;
this.logBindingUpdate = logBindingUpdate;
this.useJit = useJit;
this.platformDirectives = platformDirectives;
this.platformPipes = platformPipes;
}
}