Skip to content

Commit c02f2bd

Browse files
committed
chore: adjust formatting to new clang-format.
- fixes wrapping for object literal keys called `template`. - spacing in destructuring expressions. - changes to keep trailing return types of functions closer to their function declaration. - better formatting of string literals. Closes angular#4828
1 parent 4a1b873 commit c02f2bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+246
-237
lines changed

modules/angular2/src/core/application.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export {
1818
} from './application_ref';
1919

2020
/// See [commonBootstrap] for detailed documentation.
21-
export function bootstrap(appComponentType: /*Type*/ any,
22-
appProviders: Array<Type | Provider | any[]> = null):
23-
Promise<ComponentRef> {
21+
export function bootstrap(
22+
appComponentType: /*Type*/ any,
23+
appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
2424
var providers = [compilerProviders()];
2525
if (isPresent(appProviders)) {
2626
providers.push(appProviders);

modules/angular2/src/core/application_common.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ export function platform(providers?: Array<Type | Provider | any[]>): PlatformRe
218218
*
219219
* Returns a `Promise` of {@link ComponentRef}.
220220
*/
221-
export function commonBootstrap(appComponentType: /*Type*/ any,
222-
appProviders: Array<Type | Provider | any[]> = null):
223-
Promise<ComponentRef> {
221+
export function commonBootstrap(
222+
appComponentType: /*Type*/ any,
223+
appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
224224
var p = platform();
225225
var bindings = [applicationCommonProviders(), applicationDomProviders()];
226226
if (isPresent(appProviders)) {

modules/angular2/src/core/application_ref.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ export abstract class PlatformRef {
203203
* new application. Once this promise resolves, the application will be
204204
* constructed in the same manner as a normal `application()`.
205205
*/
206-
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
207-
Promise<ApplicationRef>;
206+
abstract asyncApplication(bindingFn: (zone: NgZone) =>
207+
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef>;
208208

209209
/**
210210
* Destroy the Angular platform and all Angular applications on the page.
@@ -228,8 +228,8 @@ export class PlatformRef_ extends PlatformRef {
228228
return app;
229229
}
230230

231-
asyncApplication(bindingFn: (zone: NgZone) =>
232-
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef> {
231+
asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
232+
Promise<ApplicationRef> {
233233
var zone = createNgZone();
234234
var completer = PromiseWrapper.completer();
235235
zone.run(() => {
@@ -314,8 +314,8 @@ export abstract class ApplicationRef {
314314
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
315315
* ```
316316
*/
317-
abstract bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>):
318-
Promise<ComponentRef>;
317+
abstract bootstrap(componentType: Type,
318+
providers?: Array<Type | Provider | any[]>): Promise<ComponentRef>;
319319

320320
/**
321321
* Retrieve the application {@link Injector}.

modules/angular2/src/core/change_detection/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export var CHANGE_DETECTION_STRATEGY_VALUES = [
5151
ChangeDetectionStrategy.OnPushObserve
5252
];
5353

54-
export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy):
55-
boolean {
54+
export function isDefaultChangeDetectionStrategy(
55+
changeDetectionStrategy: ChangeDetectionStrategy): boolean {
5656
return isBlank(changeDetectionStrategy) ||
5757
changeDetectionStrategy === ChangeDetectionStrategy.Default;
5858
}

modules/angular2/src/core/compiler/command_compiler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ class CodegenCommandFactory implements CommandFactory<string> {
200200
}
201201
}
202202

203-
function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[], context: any):
204-
any {
203+
function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[],
204+
context: any): any {
205205
templateVisitAll(visitor, asts, context);
206206
return context;
207207
}

modules/angular2/src/core/compiler/directive_metadata.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ export class CompileDirectiveMetadata {
159159
hostListeners: hostListeners,
160160
hostProperties: hostProperties,
161161
hostAttributes: hostAttributes,
162-
lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [], template: template
162+
lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [],
163+
template: template
163164
});
164165
}
165166

modules/angular2/src/core/compiler/html_parser.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
4040
`${parentSourceInfo} > #text(${value}):nth-child(${indexInParent})`);
4141
}
4242

43-
function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string):
44-
HtmlAttrAst {
43+
function parseAttr(element: Element, parentSourceInfo: string, attrName: string,
44+
attrValue: string): HtmlAttrAst {
4545
// TODO(tbosch): add source row/column source info from parse5 / package:html
4646
var lowerCaseAttrName = attrName.toLowerCase();
4747
return new HtmlAttrAst(lowerCaseAttrName, attrValue,
4848
`${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`);
4949
}
5050

51-
function parseElement(element: Element, indexInParent: number, parentSourceInfo: string):
52-
HtmlElementAst {
51+
function parseElement(element: Element, indexInParent: number,
52+
parentSourceInfo: string): HtmlElementAst {
5353
// normalize nodename always as lower case so that following build steps
5454
// can rely on this
5555
var nodeName = DOM.nodeName(element).toLowerCase();

modules/angular2/src/core/compiler/style_url_resolver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function isStyleUrlResolvable(url: string): boolean {
2424
* Rewrites stylesheets by resolving and removing the @import urls that
2525
* are either relative or don't have a `package:` scheme
2626
*/
27-
export function extractStyleUrls(resolver: UrlResolver, baseUrl: string, cssText: string):
28-
StyleWithImports {
27+
export function extractStyleUrls(resolver: UrlResolver, baseUrl: string,
28+
cssText: string): StyleWithImports {
2929
var foundUrls = [];
3030
var modifiedCssText = StringWrapper.replaceAllMapped(cssText, _cssImportRe, (m) => {
3131
var url = isPresent(m[1]) ? m[1] : m[2];

modules/angular2/src/core/compiler/template_compiler.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export class TemplateCompiler {
5050
this._appId = appId;
5151
}
5252

53-
normalizeDirectiveMetadata(directive:
54-
CompileDirectiveMetadata): Promise<CompileDirectiveMetadata> {
53+
normalizeDirectiveMetadata(directive: CompileDirectiveMetadata):
54+
Promise<CompileDirectiveMetadata> {
5555
if (!directive.isComponent) {
5656
// For non components there is nothing to be normalized yet.
5757
return PromiseWrapper.resolve(directive);
@@ -70,7 +70,8 @@ export class TemplateCompiler {
7070
hostListeners: directive.hostListeners,
7171
hostProperties: directive.hostProperties,
7272
hostAttributes: directive.hostAttributes,
73-
lifecycleHooks: directive.lifecycleHooks, template: normalizedTemplate
73+
lifecycleHooks: directive.lifecycleHooks,
74+
template: normalizedTemplate
7475
}));
7576
}
7677

modules/angular2/src/core/di/provider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ function _extractToken(typeOrFunc, metadata /*any[] | any*/, params: any[][]): D
686686
}
687687
}
688688

689-
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps):
690-
Dependency {
689+
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility,
690+
depProps): Dependency {
691691
return new Dependency(Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility,
692692
depProps);
693693
}

modules/angular2/src/core/facade/collection.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
6161
var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): any[]} = (function() {
6262
try {
6363
if ((<any>(new Map()).values()).next) {
64-
return function createArrayFromMap(m: Map<any, any>, getValues: boolean):
65-
any[] { return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys()); };
64+
return function createArrayFromMap(m: Map<any, any>, getValues: boolean): any[] {
65+
return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys());
66+
};
6667
}
6768
} catch (e) {
6869
}

modules/angular2/src/core/forms/directives/shared.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any)
6868
}
6969

7070
// TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented
71-
export function selectValueAccessor(dir: NgControl, valueAccessors: ControlValueAccessor[]):
72-
ControlValueAccessor {
71+
export function selectValueAccessor(dir: NgControl,
72+
valueAccessors: ControlValueAccessor[]): ControlValueAccessor {
7373
if (isBlank(valueAccessors)) return null;
7474

7575
var defaultAccessor;

modules/angular2/src/core/forms/model.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ export abstract class AbstractControl {
111111

112112
setParent(parent: ControlGroup | ControlArray): void { this._parent = parent; }
113113

114-
updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):
115-
void {
114+
updateValueAndValidity(
115+
{onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}): void {
116116
onlySelf = normalizeBool(onlySelf);
117117
emitEvent = isPresent(emitEvent) ? emitEvent : true;
118118

@@ -237,10 +237,11 @@ export class Control extends AbstractControl {
237237
* via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
238238
* specified.
239239
*/
240-
updateValue(value: any,
241-
{onlySelf, emitEvent, emitModelToViewChange}:
242-
{onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean} = {}):
243-
void {
240+
updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}: {
241+
onlySelf?: boolean,
242+
emitEvent?: boolean,
243+
emitModelToViewChange?: boolean
244+
} = {}): void {
244245
emitModelToViewChange = isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
245246
this._value = value;
246247
if (isPresent(this._onChange) && emitModelToViewChange) this._onChange(this._value);

modules/angular2/src/core/linker/dynamic_component_loader.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ export abstract class DynamicComponentLoader {
232232
* <child-component>Child</child-component>
233233
* ```
234234
*/
235-
abstract loadNextToLocation(type: Type, location: ElementRef, providers?: ResolvedProvider[]):
236-
Promise<ComponentRef>;
235+
abstract loadNextToLocation(type: Type, location: ElementRef,
236+
providers?: ResolvedProvider[]): Promise<ComponentRef>;
237237
}
238238

239239
@Injectable()

modules/angular2/src/core/linker/proto_view_factory.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ function provideDirective(directiveResolver: DirectiveResolver, type: Type): Dir
283283
return DirectiveProvider.createFromType(type, annotation);
284284
}
285285

286-
export function createDirectiveVariableBindings(variableNameAndValues: Array<string | number>,
287-
directiveProviders: DirectiveProvider[]):
288-
Map<string, number> {
286+
export function createDirectiveVariableBindings(
287+
variableNameAndValues: Array<string | number>,
288+
directiveProviders: DirectiveProvider[]): Map<string, number> {
289289
var directiveVariableBindings = new Map<string, number>();
290290
for (var i = 0; i < variableNameAndValues.length; i += 2) {
291291
var templateName = <string>variableNameAndValues[i];

modules/angular2/src/core/linker/template_commands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ export class EmbeddedTemplateCmd implements TemplateCmd, IBeginElementCmd,
165165

166166
export function embeddedTemplate(attrNameAndValues: string[], variableNameAndValues: string[],
167167
directives: Type[], isMerged: boolean, ngContentIndex: number,
168-
changeDetectorFactory: Function, children: TemplateCmd[]):
169-
EmbeddedTemplateCmd {
168+
changeDetectorFactory: Function,
169+
children: TemplateCmd[]): EmbeddedTemplateCmd {
170170
return new EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged,
171171
ngContentIndex, changeDetectorFactory, children);
172172
}

modules/angular2/src/core/linker/view_manager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export abstract class AppViewManager {
5555
* Throws an exception if the specified `hostLocation` is not a Host Element of a Component, or if
5656
* variable `variableName` couldn't be found in the Component View of this Component.
5757
*/
58-
abstract getNamedElementInComponentView(hostLocation: ElementRef, variableName: string):
59-
ElementRef;
58+
abstract getNamedElementInComponentView(hostLocation: ElementRef,
59+
variableName: string): ElementRef;
6060

6161
/**
6262
* Returns the component instance for the provided Host Element.

modules/angular2/src/core/render/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ export abstract class Renderer {
209209
*
210210
* Returns an instance of {@link RenderViewWithFragments}, representing the Render View.
211211
*/
212-
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number):
213-
RenderViewWithFragments;
212+
abstract createView(protoViewRef: RenderProtoViewRef,
213+
fragmentCount: number): RenderViewWithFragments;
214214

215215
/**
216216
* Destroys a Render View specified via `viewRef`.

modules/angular2/src/core/render/dom/dom_renderer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
131131
abstract createRootHostView(hostProtoViewRef: RenderProtoViewRef, fragmentCount: number,
132132
hostElementSelector: string): RenderViewWithFragments;
133133

134-
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number):
135-
RenderViewWithFragments;
134+
abstract createView(protoViewRef: RenderProtoViewRef,
135+
fragmentCount: number): RenderViewWithFragments;
136136

137137
abstract destroyView(viewRef: RenderViewRef);
138138

@@ -207,8 +207,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
207207
propertyValue);
208208
}
209209

210-
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string):
211-
void {
210+
setElementAttribute(location: RenderElementRef, attributeName: string,
211+
attributeValue: string): void {
212212
var view = resolveInternalDomView(location.renderView);
213213
var element = view.boundElements[location.boundElementIndex];
214214
var dashCasedAttributeName = camelCaseToDashCase(attributeName);

modules/angular2/src/core/testability/browser_testability.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export class BrowserGetTestability implements GetTestability {
2828
static init() { setTestabilityGetter(new BrowserGetTestability()); }
2929

3030
addToWindow(registry: TestabilityRegistry): void {
31-
global.getAngularTestability = function(elem: Element, findInAncestors: boolean = true):
32-
PublicTestability {
33-
var testability = registry.findTestabilityInTree(elem, findInAncestors);
34-
35-
if (testability == null) {
36-
throw new Error('Could not find testability for element.');
37-
}
38-
return new PublicTestability(testability);
39-
};
31+
global.getAngularTestability = function(elem: Element,
32+
findInAncestors: boolean = true): PublicTestability {
33+
var testability = registry.findTestabilityInTree(elem, findInAncestors);
34+
35+
if (testability == null) {
36+
throw new Error('Could not find testability for element.');
37+
}
38+
return new PublicTestability(testability);
39+
};
4040
global.getAllAngularTestabilities = function(): PublicTestability[] {
4141
var testabilities = registry.getAllTestabilities();
4242
return testabilities.map((testability) => { return new PublicTestability(testability); });

modules/angular2/src/core/util/decorators.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ if (!(Reflect && Reflect.getMetadata)) {
236236
throw 'reflect-metadata shim is required when using class decorators';
237237
}
238238

239-
export function makeDecorator(annotationCls, chainFn: (fn: Function) => void = null):
240-
(...args: any[]) => (cls: any) => any {
239+
export function makeDecorator(
240+
annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {
241241
function DecoratorFactory(objOrType): (cls: any) => any {
242242
var annotationInstance = new (<any>annotationCls)(objOrType);
243243
if (this instanceof annotationCls) {

modules/angular2/src/http/backends/mock_backend.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Connection, ConnectionBackend} from '../interfaces';
66
import {isPresent} from 'angular2/src/core/facade/lang';
77
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
88
var Rx = require('@reactivex/rxjs/dist/cjs/Rx');
9-
let{Subject, ReplaySubject} = Rx;
9+
let {Subject, ReplaySubject} = Rx;
1010

1111
/**
1212
*

modules/angular2/src/router/lifecycle_annotations.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ export {
4242
*
4343
* {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
4444
*/
45-
export var CanActivate:
46-
(hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
47-
ClassDecorator = makeDecorator(CanActivateAnnotation);
45+
export var CanActivate: (hook: (next: ComponentInstruction, prev: ComponentInstruction) =>
46+
Promise<boolean>| boolean) => ClassDecorator =
47+
makeDecorator(CanActivateAnnotation);

modules/angular2/src/router/route_config_impl.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class Route implements RouteDefinition {
4141
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
4242
loader: Function;
4343
redirectTo: string;
44-
constructor({path, component, as, data}:
45-
{path: string, component: Type, as?: string, data?: {[key: string]: any}}) {
44+
constructor({path, component, as,
45+
data}: {path: string, component: Type, as?: string, data?: {[key: string]: any}}) {
4646
this.path = path;
4747
this.component = component;
4848
this.as = as;
@@ -115,8 +115,8 @@ export class AsyncRoute implements RouteDefinition {
115115
path: string;
116116
loader: Function;
117117
as: string;
118-
constructor({path, loader, as, data}:
119-
{path: string, loader: Function, as?: string, data?: {[key: string]: any}}) {
118+
constructor({path, loader, as,
119+
data}: {path: string, loader: Function, as?: string, data?: {[key: string]: any}}) {
120120
this.path = path;
121121
this.loader = loader;
122122
this.as = as;

modules/angular2/src/router/router.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ function splitAndFlattenLinkParams(linkParams: any[]): any[] {
544544
}, []);
545545
}
546546

547-
function canActivateOne(nextInstruction: Instruction, prevInstruction: Instruction):
548-
Promise<boolean> {
547+
function canActivateOne(nextInstruction: Instruction,
548+
prevInstruction: Instruction): Promise<boolean> {
549549
var next = _resolveToTrue;
550550
if (isPresent(nextInstruction.child)) {
551551
next = canActivateOne(nextInstruction.child,

0 commit comments

Comments
 (0)