From 2982892accd95c8988de65d9ee2084459b8825dd Mon Sep 17 00:00:00 2001 From: vsavkin Date: Thu, 9 Jun 2016 14:33:09 -0700 Subject: [PATCH] cleanup(router): clang-format --- .../router/src/common_router_providers.ts | 11 ++++------ .../router/src/directives/router_outlet.ts | 4 ++-- modules/@angular/router/src/index.ts | 4 ++-- modules/@angular/router/src/router.ts | 21 ++++++++----------- .../@angular/router/src/router_providers.ts | 3 ++- modules/@angular/router/src/router_state.ts | 10 +++------ modules/@angular/router/src/url_tree.ts | 10 +++------ modules/@angular/router/src/utils/tree.ts | 4 +--- 8 files changed, 26 insertions(+), 41 deletions(-) diff --git a/modules/@angular/router/src/common_router_providers.ts b/modules/@angular/router/src/common_router_providers.ts index 55e723b4c5..8ebc5ee46a 100644 --- a/modules/@angular/router/src/common_router_providers.ts +++ b/modules/@angular/router/src/common_router_providers.ts @@ -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; diff --git a/modules/@angular/router/src/directives/router_outlet.ts b/modules/@angular/router/src/directives/router_outlet.ts index d049af3b3f..0e57f288a9 100644 --- a/modules/@angular/router/src/directives/router_outlet.ts +++ b/modules/@angular/router/src/directives/router_outlet.ts @@ -36,8 +36,8 @@ export class RouterOutlet { } activate( - factory: ComponentFactory, activatedRoute: ActivatedRoute, providers: ResolvedReflectiveProvider[], - outletMap: RouterOutletMap): void { + factory: ComponentFactory, activatedRoute: ActivatedRoute, + providers: ResolvedReflectiveProvider[], outletMap: RouterOutletMap): void { this.outletMap = outletMap; this._activatedRoute = activatedRoute; const inj = ReflectiveInjector.fromResolvedProviders(providers, this.location.parentInjector); diff --git a/modules/@angular/router/src/index.ts b/modules/@angular/router/src/index.ts index 7c053bf66f..2c7ddf0d58 100644 --- a/modules/@angular/router/src/index.ts +++ b/modules/@angular/router/src/index.ts @@ -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'; diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index e859e81f81..966df54c97 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -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(); 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); }) diff --git a/modules/@angular/router/src/router_providers.ts b/modules/@angular/router/src/router_providers.ts index 4c0b7d9426..253f74ebdc 100644 --- a/modules/@angular/router/src/router_providers.ts +++ b/modules/@angular/router/src/router_providers.ts @@ -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) ]; } diff --git a/modules/@angular/router/src/router_state.ts b/modules/@angular/router/src/router_state.ts index 701790046a..0331602b1f 100644 --- a/modules/@angular/router/src/router_state.ts +++ b/modules/@angular/router/src/router_state.ts @@ -34,9 +34,7 @@ export class RouterState extends Tree { 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 { super(root); } - toString(): string { - return serializeNode(this._root); - } + toString(): string { return serializeNode(this._root); } } function serializeNode(node: TreeNode): string { diff --git a/modules/@angular/router/src/url_tree.ts b/modules/@angular/router/src/url_tree.ts index 46ddd1843a..5c765b9222 100644 --- a/modules/@angular/router/src/url_tree.ts +++ b/modules/@angular/router/src/url_tree.ts @@ -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 { 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 { diff --git a/modules/@angular/router/src/utils/tree.ts b/modules/@angular/router/src/utils/tree.ts index b458e881d0..a508c1f56f 100644 --- a/modules/@angular/router/src/utils/tree.ts +++ b/modules/@angular/router/src/utils/tree.ts @@ -71,7 +71,5 @@ function contains(tree: TreeNode, subtree: TreeNode): boolean { export class TreeNode { constructor(public value: T, public children: TreeNode[]) {} - toString(): string { - return `TreeNode(${this.value})`; - } + toString(): string { return `TreeNode(${this.value})`; } } \ No newline at end of file