fix(deps): Update clang-format to 1.0.14.
This commit is contained in:

committed by
Tobias Bosch

parent
e50f537667
commit
15f1eb28a2
@ -89,7 +89,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefToken]),
|
||||
bind(LifeCycle)
|
||||
.toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()),
|
||||
[ExceptionHandler]),
|
||||
[ExceptionHandler]),
|
||||
bind(EventManager)
|
||||
.toFactory(
|
||||
(ngZone) =>
|
||||
@ -142,15 +142,15 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
function _createNgZone(givenReporter: Function): NgZone {
|
||||
var defaultErrorReporter = (exception, stackTrace) => {
|
||||
var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n");
|
||||
DOM.logError(`${exception}\n\n${longStackTrace}`);
|
||||
throw exception;
|
||||
};
|
||||
DOM.logError(`${exception}\n\n${longStackTrace}`);
|
||||
throw exception;
|
||||
};
|
||||
|
||||
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
|
||||
var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter;
|
||||
|
||||
var zone = new NgZone({enableLongStackTrace: assertionsEnabled()});
|
||||
zone.initCallbacks({onErrorHandler: reporter});
|
||||
return zone;
|
||||
var zone = new NgZone({enableLongStackTrace: assertionsEnabled()});
|
||||
zone.initCallbacks({onErrorHandler: reporter});
|
||||
return zone;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,84 +175,83 @@ export class Compiler {
|
||||
var nestedPVPromises = [];
|
||||
ListWrapper.forEach(this._collectComponentElementBinders(protoViews), (elementBinder) => {
|
||||
var nestedComponent = elementBinder.componentDirective;
|
||||
var elementBinderDone = (nestedPv: AppProtoView) => {
|
||||
elementBinder.nestedProtoView = nestedPv;
|
||||
};
|
||||
var elementBinderDone =
|
||||
(nestedPv: AppProtoView) => { elementBinder.nestedProtoView = nestedPv; };
|
||||
var nestedCall = this._compile(nestedComponent);
|
||||
if (PromiseWrapper.isPromise(nestedCall)) {
|
||||
ListWrapper.push(nestedPVPromises,
|
||||
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
|
||||
ListWrapper.push(nestedPVPromises,
|
||||
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
|
||||
} else if (isPresent(nestedCall)) {
|
||||
elementBinderDone(<AppProtoView>nestedCall);
|
||||
}
|
||||
});
|
||||
|
||||
if (nestedPVPromises.length > 0) {
|
||||
return PromiseWrapper.all(nestedPVPromises).then((_) => protoView);
|
||||
} else {
|
||||
return protoView;
|
||||
}
|
||||
}
|
||||
|
||||
private _collectComponentElementBinders(protoViews: List<AppProtoView>): List<ElementBinder> {
|
||||
var componentElementBinders = [];
|
||||
ListWrapper.forEach(protoViews, (protoView) => {
|
||||
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
|
||||
if (isPresent(elementBinder.componentDirective)) {
|
||||
ListWrapper.push(componentElementBinders, elementBinder);
|
||||
elementBinderDone(<AppProtoView>nestedCall);
|
||||
}
|
||||
});
|
||||
});
|
||||
return componentElementBinders;
|
||||
}
|
||||
|
||||
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
|
||||
var componentUrl =
|
||||
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
|
||||
var templateAbsUrl = null;
|
||||
if (isPresent(view.templateUrl)) {
|
||||
templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl);
|
||||
} else if (isPresent(view.template)) {
|
||||
// Note: If we have an inline template, we also need to send
|
||||
// the url for the component to the render so that it
|
||||
// is able to resolve urls in stylesheets.
|
||||
templateAbsUrl = componentUrl;
|
||||
}
|
||||
return new renderApi.ViewDefinition({
|
||||
componentId: stringify(component),
|
||||
absUrl: templateAbsUrl, template: view.template,
|
||||
directives: ListWrapper.map(directives, directiveBinding => directiveBinding.metadata)
|
||||
});
|
||||
}
|
||||
|
||||
private _flattenDirectives(template: View): List<Type> {
|
||||
if (isBlank(template.directives)) return [];
|
||||
|
||||
var directives = [];
|
||||
this._flattenList(template.directives, directives);
|
||||
|
||||
return directives;
|
||||
}
|
||||
|
||||
private _flattenList(tree: List<any>, out: List<Type | Binding | List<any>>): void {
|
||||
for (var i = 0; i < tree.length; i++) {
|
||||
var item = resolveForwardRef(tree[i]);
|
||||
if (ListWrapper.isList(item)) {
|
||||
this._flattenList(item, out);
|
||||
if (nestedPVPromises.length > 0) {
|
||||
return PromiseWrapper.all(nestedPVPromises).then((_) => protoView);
|
||||
} else {
|
||||
ListWrapper.push(out, item);
|
||||
return protoView;
|
||||
}
|
||||
}
|
||||
|
||||
private _collectComponentElementBinders(protoViews: List<AppProtoView>): List<ElementBinder> {
|
||||
var componentElementBinders = [];
|
||||
ListWrapper.forEach(protoViews, (protoView) => {
|
||||
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
|
||||
if (isPresent(elementBinder.componentDirective)) {
|
||||
ListWrapper.push(componentElementBinders, elementBinder);
|
||||
}
|
||||
});
|
||||
});
|
||||
return componentElementBinders;
|
||||
}
|
||||
|
||||
private _buildRenderTemplate(component, view, directives): renderApi.ViewDefinition {
|
||||
var componentUrl =
|
||||
this._urlResolver.resolve(this._appUrl, this._componentUrlMapper.getUrl(component));
|
||||
var templateAbsUrl = null;
|
||||
if (isPresent(view.templateUrl)) {
|
||||
templateAbsUrl = this._urlResolver.resolve(componentUrl, view.templateUrl);
|
||||
} else if (isPresent(view.template)) {
|
||||
// Note: If we have an inline template, we also need to send
|
||||
// the url for the component to the render so that it
|
||||
// is able to resolve urls in stylesheets.
|
||||
templateAbsUrl = componentUrl;
|
||||
}
|
||||
return new renderApi.ViewDefinition({
|
||||
componentId: stringify(component),
|
||||
absUrl: templateAbsUrl, template: view.template,
|
||||
directives: ListWrapper.map(directives, directiveBinding => directiveBinding.metadata)
|
||||
});
|
||||
}
|
||||
|
||||
private _flattenDirectives(template: View): List<Type> {
|
||||
if (isBlank(template.directives)) return [];
|
||||
|
||||
var directives = [];
|
||||
this._flattenList(template.directives, directives);
|
||||
|
||||
return directives;
|
||||
}
|
||||
|
||||
private _flattenList(tree: List<any>, out: List<Type | Binding | List<any>>): void {
|
||||
for (var i = 0; i < tree.length; i++) {
|
||||
var item = resolveForwardRef(tree[i]);
|
||||
if (ListWrapper.isList(item)) {
|
||||
this._flattenList(item, out);
|
||||
} else {
|
||||
ListWrapper.push(out, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static _isValidDirective(value: Type | Binding): boolean {
|
||||
return isPresent(value) && (value instanceof Type || value instanceof Binding);
|
||||
}
|
||||
|
||||
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
|
||||
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
||||
throw new BaseException(
|
||||
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static _isValidDirective(value: Type | Binding): boolean {
|
||||
return isPresent(value) && (value instanceof Type || value instanceof Binding);
|
||||
}
|
||||
|
||||
private static _assertTypeIsComponent(directiveBinding: DirectiveBinding): void {
|
||||
if (directiveBinding.metadata.type !== renderApi.DirectiveMetadata.COMPONENT_TYPE) {
|
||||
throw new BaseException(
|
||||
`Could not load '${stringify(directiveBinding.key.token)}' because it is not a component.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,81 +38,85 @@ export class DynamicComponentLoader {
|
||||
loadIntoExistingLocation(typeOrBinding, location: ElementRef,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
var binding = this._getBinding(typeOrBinding);
|
||||
return this._compiler.compile(binding.token).then(componentProtoViewRef => {
|
||||
this._viewManager.createDynamicComponentView(location, componentProtoViewRef, binding,
|
||||
injector);
|
||||
var component = this._viewManager.getComponent(location);
|
||||
var dispose = () => { throw new BaseException("Not implemented");};
|
||||
return new ComponentRef(location, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a root component that is placed at the first element that matches the
|
||||
* component's selector.
|
||||
* The loaded component receives injection normally as a hosted view.
|
||||
*/
|
||||
loadAsRoot(typeOrBinding, overrideSelector = null,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
return this._compiler.compileInHost(this._getBinding(typeOrBinding)).then(hostProtoViewRef => {
|
||||
var hostViewRef =
|
||||
this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => { this._viewManager.destroyRootHostView(hostViewRef);
|
||||
};
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a component into a free host view that is not yet attached to
|
||||
* a parent on the render side, although it is attached to a parent in the injector hierarchy.
|
||||
* The loaded component receives injection normally as a hosted view.
|
||||
*/
|
||||
loadIntoNewLocation(typeOrBinding, parentComponentLocation: ElementRef,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
return this._compiler.compileInHost(this._getBinding(typeOrBinding)).then(hostProtoViewRef => {
|
||||
var hostViewRef =
|
||||
this._viewManager.createFreeHostView(parentComponentLocation, hostProtoViewRef, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => {
|
||||
this._viewManager.destroyFreeHostView(parentComponentLocation, hostViewRef);
|
||||
};
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a component next to the provided ElementRef. The loaded component receives
|
||||
* injection normally as a hosted view.
|
||||
*/
|
||||
loadNextToExistingLocation(typeOrBinding, location: ElementRef,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
var binding = this._getBinding(typeOrBinding);
|
||||
return this._compiler.compileInHost(binding).then(hostProtoViewRef => {
|
||||
var viewContainer = this._viewManager.getViewContainer(location);
|
||||
var hostViewRef = viewContainer.create(hostProtoViewRef, viewContainer.length, null, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => { var index = viewContainer.indexOf(hostViewRef);
|
||||
viewContainer.remove(index);
|
||||
};
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
private _getBinding(typeOrBinding): Binding {
|
||||
var binding;
|
||||
if (typeOrBinding instanceof Binding) {
|
||||
binding = typeOrBinding;
|
||||
} else {
|
||||
binding = bind(typeOrBinding).toClass(typeOrBinding);
|
||||
return this._compiler.compile(binding.token)
|
||||
.then(componentProtoViewRef => {
|
||||
this._viewManager.createDynamicComponentView(location, componentProtoViewRef, binding,
|
||||
injector);
|
||||
var component = this._viewManager.getComponent(location);
|
||||
var dispose = () => { throw new BaseException("Not implemented"); };
|
||||
return new ComponentRef(location, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a root component that is placed at the first element that matches the
|
||||
* component's selector.
|
||||
* The loaded component receives injection normally as a hosted view.
|
||||
*/
|
||||
loadAsRoot(typeOrBinding, overrideSelector = null,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
return this._compiler.compileInHost(this._getBinding(typeOrBinding))
|
||||
.then(hostProtoViewRef => {
|
||||
var hostViewRef =
|
||||
this._viewManager.createRootHostView(hostProtoViewRef, overrideSelector, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => { this._viewManager.destroyRootHostView(hostViewRef); };
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a component into a free host view that is not yet attached to
|
||||
* a parent on the render side, although it is attached to a parent in the injector hierarchy.
|
||||
* The loaded component receives injection normally as a hosted view.
|
||||
*/
|
||||
loadIntoNewLocation(typeOrBinding, parentComponentLocation: ElementRef,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
return this._compiler.compileInHost(this._getBinding(typeOrBinding))
|
||||
.then(hostProtoViewRef => {
|
||||
var hostViewRef = this._viewManager.createFreeHostView(parentComponentLocation,
|
||||
hostProtoViewRef, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => {
|
||||
this._viewManager.destroyFreeHostView(parentComponentLocation, hostViewRef);
|
||||
};
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a component next to the provided ElementRef. The loaded component receives
|
||||
* injection normally as a hosted view.
|
||||
*/
|
||||
loadNextToExistingLocation(typeOrBinding, location: ElementRef,
|
||||
injector: Injector = null): Promise<ComponentRef> {
|
||||
var binding = this._getBinding(typeOrBinding);
|
||||
return this._compiler.compileInHost(binding).then(hostProtoViewRef => {
|
||||
var viewContainer = this._viewManager.getViewContainer(location);
|
||||
var hostViewRef =
|
||||
viewContainer.create(hostProtoViewRef, viewContainer.length, null, injector);
|
||||
var newLocation = new ElementRef(hostViewRef, 0);
|
||||
var component = this._viewManager.getComponent(newLocation);
|
||||
|
||||
var dispose = () => {
|
||||
var index = viewContainer.indexOf(hostViewRef);
|
||||
viewContainer.remove(index);
|
||||
};
|
||||
return new ComponentRef(newLocation, component, dispose);
|
||||
});
|
||||
}
|
||||
|
||||
private _getBinding(typeOrBinding): Binding {
|
||||
var binding;
|
||||
if (typeOrBinding instanceof Binding) {
|
||||
binding = typeOrBinding;
|
||||
} else {
|
||||
binding = bind(typeOrBinding).toClass(typeOrBinding);
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
|
@ -39,43 +39,45 @@ export class LifeCycle {
|
||||
|
||||
constructor(exceptionHandler: ExceptionHandler, changeDetector: ChangeDetector = null,
|
||||
enforceNoNewChanges: boolean = false) {
|
||||
this._errorHandler = (exception, stackTrace) => { exceptionHandler.call(exception, stackTrace);
|
||||
throw exception;
|
||||
};
|
||||
this._changeDetector =
|
||||
changeDetector; // may be null when instantiated from application bootstrap
|
||||
this._enforceNoNewChanges = enforceNoNewChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
registerWith(zone: NgZone, changeDetector: ChangeDetector = null) {
|
||||
if (isPresent(changeDetector)) {
|
||||
this._changeDetector = changeDetector;
|
||||
this._errorHandler = (exception, stackTrace) => {
|
||||
exceptionHandler.call(exception, stackTrace);
|
||||
throw exception;
|
||||
};
|
||||
this._changeDetector =
|
||||
changeDetector; // may be null when instantiated from application bootstrap
|
||||
this._enforceNoNewChanges = enforceNoNewChanges;
|
||||
}
|
||||
|
||||
zone.initCallbacks({onErrorHandler: this._errorHandler, onTurnDone: () => this.tick()});
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
registerWith(zone: NgZone, changeDetector: ChangeDetector = null) {
|
||||
if (isPresent(changeDetector)) {
|
||||
this._changeDetector = changeDetector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke this method to explicitly process change detection and its side-effects.
|
||||
*
|
||||
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
|
||||
* further
|
||||
* changes are detected. If additional changes are picked up during this second cycle, bindings in
|
||||
* the app have
|
||||
* side-effects that cannot be resolved in a single change detection pass. In this case, Angular
|
||||
* throws an error,
|
||||
* since an Angular application can only have one change detection pass during which all change
|
||||
* detection must
|
||||
* complete.
|
||||
*
|
||||
*/
|
||||
tick() {
|
||||
this._changeDetector.detectChanges();
|
||||
if (this._enforceNoNewChanges) {
|
||||
this._changeDetector.checkNoChanges();
|
||||
zone.initCallbacks({onErrorHandler: this._errorHandler, onTurnDone: () => this.tick()});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke this method to explicitly process change detection and its side-effects.
|
||||
*
|
||||
* In development mode, `tick()` also performs a second change detection cycle to ensure that no
|
||||
* further
|
||||
* changes are detected. If additional changes are picked up during this second cycle, bindings
|
||||
* in
|
||||
* the app have
|
||||
* side-effects that cannot be resolved in a single change detection pass. In this case, Angular
|
||||
* throws an error,
|
||||
* since an Angular application can only have one change detection pass during which all change
|
||||
* detection must
|
||||
* complete.
|
||||
*
|
||||
*/
|
||||
tick() {
|
||||
this._changeDetector.detectChanges();
|
||||
if (this._enforceNoNewChanges) {
|
||||
this._changeDetector.checkNoChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user