cleanup(router): clang-format

This commit is contained in:
vsavkin 2016-06-09 14:33:09 -07:00
parent 9de56481f1
commit 2982892acc
8 changed files with 26 additions and 41 deletions

View File

@ -7,9 +7,7 @@ import {RouterOutletMap} from './router_outlet_map';
import {ActivatedRoute} from './router_state';
import {DefaultUrlSerializer, UrlSerializer} from './url_serializer';
export interface ExtraOptions {
enableTracing?: boolean;
}
export interface ExtraOptions { enableTracing?: boolean; }
/**
* A list of {@link Provider}s. To use the router, you must add this to your application.
@ -31,8 +29,7 @@ export interface ExtraOptions {
*/
export function provideRouter(config: RouterConfig, opts: ExtraOptions): any[] {
return [
Location,
{provide: LocationStrategy, useClass: PathLocationStrategy},
Location, {provide: LocationStrategy, useClass: PathLocationStrategy},
{provide: UrlSerializer, useClass: DefaultUrlSerializer},
{
@ -76,10 +73,10 @@ export function provideRouter(config: RouterConfig, opts: ExtraOptions): any[] {
const appRef = injector.get(ApplicationRef);
if (appRef.componentTypes.length == 0) {
appRef.registerBootstrapListener((_) => {
injector.get(Router).initialNavigation()
injector.get(Router).initialNavigation();
});
} else {
injector.get(Router).initialNavigation()
injector.get(Router).initialNavigation();
}
}, 0);
return _ => null;

View File

@ -36,8 +36,8 @@ export class RouterOutlet {
}
activate(
factory: ComponentFactory<any>, activatedRoute: ActivatedRoute, providers: ResolvedReflectiveProvider[],
outletMap: RouterOutletMap): void {
factory: ComponentFactory<any>, activatedRoute: ActivatedRoute,
providers: ResolvedReflectiveProvider[], outletMap: RouterOutletMap): void {
this.outletMap = outletMap;
this._activatedRoute = activatedRoute;
const inj = ReflectiveInjector.fromResolvedProviders(providers, this.location.parentInjector);

View File

@ -1,12 +1,12 @@
import {RouterLink} from './directives/router_link';
import {RouterOutlet} from './directives/router_outlet';
export {ExtraOptions} from './common_router_providers';
export {Route, RouterConfig} from './config';
export {CanActivate, CanDeactivate} from './interfaces';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RoutesRecognized, Router} from './router';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router, RoutesRecognized} from './router';
export {RouterOutletMap} from './router_outlet_map';
export {provideRouter} from './router_providers';
export {ExtraOptions} from './common_router_providers';
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
export {PRIMARY_OUTLET, Params} from './shared';
export {DefaultUrlSerializer, UrlSerializer} from './url_serializer';

View File

@ -41,9 +41,7 @@ export interface NavigationExtras {
export class NavigationStart {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationStart(id: ${this.id}, url: '${this.url}')`;
}
toString(): string { return `NavigationStart(id: ${this.id}, url: '${this.url}')`; }
}
/**
@ -52,9 +50,7 @@ export class NavigationStart {
export class NavigationEnd {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationEnd(id: ${this.id}, url: '${this.url}')`;
}
toString(): string { return `NavigationEnd(id: ${this.id}, url: '${this.url}')`; }
}
/**
@ -63,9 +59,7 @@ export class NavigationEnd {
export class NavigationCancel {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationCancel(id: ${this.id}, url: '${this.url}')`;
}
toString(): string { return `NavigationCancel(id: ${this.id}, url: '${this.url}')`; }
}
/**
@ -83,7 +77,9 @@ export class NavigationError {
* An event triggered when routes are recognized
*/
export class RoutesRecognized {
constructor(public id: number, public url: UrlTree, public urlAfterRedirects: UrlTree, public state: RouterStateSnapshot) {}
constructor(
public id: number, public url: UrlTree, public urlAfterRedirects: UrlTree,
public state: RouterStateSnapshot) {}
toString(): string {
return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
@ -108,7 +104,7 @@ export class Router {
constructor(
private rootComponentType: Type, private resolver: ComponentResolver,
private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap,
private location: Location, private injector:g Injector, private config: RouterConfig) {
private location: Location, private injector: g Injector, private config: RouterConfig) {
this.routerEvents = new Subject<Event>();
this.currentUrlTree = createEmptyUrlTree();
this.currentRouterState = createEmptyState(this.rootComponentType);
@ -273,7 +269,8 @@ export class Router {
})
.mergeMap((newRouterStateSnapshot) => {
this.routerEvents.next(new RoutesRecognized(id, url, updatedUrl, newRouterStateSnapshot));
this.routerEvents.next(
new RoutesRecognized(id, url, updatedUrl, newRouterStateSnapshot));
return resolve(this.resolver, newRouterStateSnapshot);
})

View File

@ -25,6 +25,7 @@ import {RouterConfig} from './config';
*/
export function provideRouter(config: RouterConfig, opts: common.ExtraOptions = {}): any[] {
return [
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...common.provideRouter(config, opts)
{provide: PlatformLocation, useClass: BrowserPlatformLocation},
...common.provideRouter(config, opts)
];
}

View File

@ -34,9 +34,7 @@ export class RouterState extends Tree<ActivatedRoute> {
super(root);
}
toString(): string {
return this.snapshot.toString();
}
toString(): string { return this.snapshot.toString(); }
}
export function createEmptyState(rootComponent: Type): RouterState {
@ -135,7 +133,7 @@ export class ActivatedRouteSnapshot {
}
toString(): string {
const url = this.urlSegments.map(s => s.toString()).join("/");
const url = this.urlSegments.map(s => s.toString()).join('/');
const matched = this._routeConfig ? this._routeConfig.path : '';
return `Route(url:'${url}', path:'${matched}')`;
}
@ -164,9 +162,7 @@ export class RouterStateSnapshot extends Tree<ActivatedRouteSnapshot> {
super(root);
}
toString(): string {
return serializeNode(this._root);
}
toString(): string { return serializeNode(this._root); }
}
function serializeNode(node: TreeNode<ActivatedRouteSnapshot>): string {

View File

@ -1,7 +1,7 @@
import {PRIMARY_OUTLET} from './shared';
import {DefaultUrlSerializer, serializeSegment} from './url_serializer';
import {shallowEqual} from './utils/collection';
import {Tree, TreeNode} from './utils/tree';
import {DefaultUrlSerializer, serializeSegment} from './url_serializer';
export function createEmptyUrlTree() {
return new UrlTree(
@ -21,9 +21,7 @@ export class UrlTree extends Tree<UrlSegment> {
super(root);
}
toString(): string {
return new DefaultUrlSerializer().serialize(this);
}
toString(): string { return new DefaultUrlSerializer().serialize(this); }
}
export class UrlSegment {
@ -33,9 +31,7 @@ export class UrlSegment {
constructor(
public path: string, public parameters: {[key: string]: string}, public outlet: string) {}
toString(): string {
return serializeSegment(this);
}
toString(): string { return serializeSegment(this); }
}
export function equalUrlSegments(a: UrlSegment[], b: UrlSegment[]): boolean {

View File

@ -71,7 +71,5 @@ function contains<T>(tree: TreeNode<T>, subtree: TreeNode<T>): boolean {
export class TreeNode<T> {
constructor(public value: T, public children: TreeNode<T>[]) {}
toString(): string {
return `TreeNode(${this.value})`;
}
toString(): string { return `TreeNode(${this.value})`; }
}