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 #4828
This commit is contained in:
Martin Probst
2015-10-28 08:59:19 +01:00
parent 4a1b873fad
commit c02f2bdab0
50 changed files with 245 additions and 236 deletions

View File

@ -18,9 +18,9 @@ export {
} from './application_ref';
/// See [commonBootstrap] for detailed documentation.
export function bootstrap(appComponentType: /*Type*/ any,
appProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
export function bootstrap(
appComponentType: /*Type*/ any,
appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var providers = [compilerProviders()];
if (isPresent(appProviders)) {
providers.push(appProviders);

View File

@ -218,9 +218,9 @@ export function platform(providers?: Array<Type | Provider | any[]>): PlatformRe
*
* Returns a `Promise` of {@link ComponentRef}.
*/
export function commonBootstrap(appComponentType: /*Type*/ any,
appProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
export function commonBootstrap(
appComponentType: /*Type*/ any,
appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var p = platform();
var bindings = [applicationCommonProviders(), applicationDomProviders()];
if (isPresent(appProviders)) {

View File

@ -203,8 +203,8 @@ export abstract class PlatformRef {
* new application. Once this promise resolves, the application will be
* constructed in the same manner as a normal `application()`.
*/
abstract asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
Promise<ApplicationRef>;
abstract asyncApplication(bindingFn: (zone: NgZone) =>
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef>;
/**
* Destroy the Angular platform and all Angular applications on the page.
@ -228,8 +228,8 @@ export class PlatformRef_ extends PlatformRef {
return app;
}
asyncApplication(bindingFn: (zone: NgZone) =>
Promise<Array<Type | Provider | any[]>>): Promise<ApplicationRef> {
asyncApplication(bindingFn: (zone: NgZone) => Promise<Array<Type | Provider | any[]>>):
Promise<ApplicationRef> {
var zone = createNgZone();
var completer = PromiseWrapper.completer();
zone.run(() => {
@ -314,8 +314,8 @@ export abstract class ApplicationRef {
* app.bootstrap(SecondRootComponent, [provide(OverrideBinding, {useClass: OverriddenBinding})]);
* ```
*/
abstract bootstrap(componentType: Type, providers?: Array<Type | Provider | any[]>):
Promise<ComponentRef>;
abstract bootstrap(componentType: Type,
providers?: Array<Type | Provider | any[]>): Promise<ComponentRef>;
/**
* Retrieve the application {@link Injector}.

View File

@ -51,8 +51,8 @@ export var CHANGE_DETECTION_STRATEGY_VALUES = [
ChangeDetectionStrategy.OnPushObserve
];
export function isDefaultChangeDetectionStrategy(changeDetectionStrategy: ChangeDetectionStrategy):
boolean {
export function isDefaultChangeDetectionStrategy(
changeDetectionStrategy: ChangeDetectionStrategy): boolean {
return isBlank(changeDetectionStrategy) ||
changeDetectionStrategy === ChangeDetectionStrategy.Default;
}

View File

@ -200,8 +200,8 @@ class CodegenCommandFactory implements CommandFactory<string> {
}
}
function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[], context: any):
any {
function visitAndReturnContext(visitor: TemplateAstVisitor, asts: TemplateAst[],
context: any): any {
templateVisitAll(visitor, asts, context);
return context;
}

View File

@ -159,7 +159,8 @@ export class CompileDirectiveMetadata {
hostListeners: hostListeners,
hostProperties: hostProperties,
hostAttributes: hostAttributes,
lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [], template: template
lifecycleHooks: isPresent(lifecycleHooks) ? lifecycleHooks : [],
template: template
});
}

View File

@ -40,16 +40,16 @@ function parseText(text: Text, indexInParent: number, parentSourceInfo: string):
`${parentSourceInfo} > #text(${value}):nth-child(${indexInParent})`);
}
function parseAttr(element: Element, parentSourceInfo: string, attrName: string, attrValue: string):
HtmlAttrAst {
function parseAttr(element: Element, parentSourceInfo: string, attrName: string,
attrValue: string): HtmlAttrAst {
// TODO(tbosch): add source row/column source info from parse5 / package:html
var lowerCaseAttrName = attrName.toLowerCase();
return new HtmlAttrAst(lowerCaseAttrName, attrValue,
`${parentSourceInfo}[${lowerCaseAttrName}=${attrValue}]`);
}
function parseElement(element: Element, indexInParent: number, parentSourceInfo: string):
HtmlElementAst {
function parseElement(element: Element, indexInParent: number,
parentSourceInfo: string): HtmlElementAst {
// normalize nodename always as lower case so that following build steps
// can rely on this
var nodeName = DOM.nodeName(element).toLowerCase();

View File

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

View File

@ -50,8 +50,8 @@ export class TemplateCompiler {
this._appId = appId;
}
normalizeDirectiveMetadata(directive:
CompileDirectiveMetadata): Promise<CompileDirectiveMetadata> {
normalizeDirectiveMetadata(directive: CompileDirectiveMetadata):
Promise<CompileDirectiveMetadata> {
if (!directive.isComponent) {
// For non components there is nothing to be normalized yet.
return PromiseWrapper.resolve(directive);
@ -70,7 +70,8 @@ export class TemplateCompiler {
hostListeners: directive.hostListeners,
hostProperties: directive.hostProperties,
hostAttributes: directive.hostAttributes,
lifecycleHooks: directive.lifecycleHooks, template: normalizedTemplate
lifecycleHooks: directive.lifecycleHooks,
template: normalizedTemplate
}));
}

View File

@ -686,8 +686,8 @@ function _extractToken(typeOrFunc, metadata /*any[] | any*/, params: any[][]): D
}
}
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility, depProps):
Dependency {
function _createDependency(token, optional, lowerBoundVisibility, upperBoundVisibility,
depProps): Dependency {
return new Dependency(Key.get(token), optional, lowerBoundVisibility, upperBoundVisibility,
depProps);
}

View File

@ -61,8 +61,9 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
var _arrayFromMap: {(m: Map<any, any>, getValues: boolean): any[]} = (function() {
try {
if ((<any>(new Map()).values()).next) {
return function createArrayFromMap(m: Map<any, any>, getValues: boolean):
any[] { return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys()); };
return function createArrayFromMap(m: Map<any, any>, getValues: boolean): any[] {
return getValues ? (<any>Array).from(m.values()) : (<any>Array).from(m.keys());
};
}
} catch (e) {
}

View File

@ -68,8 +68,8 @@ export function isPropertyUpdated(changes: {[key: string]: any}, viewModel: any)
}
// TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented
export function selectValueAccessor(dir: NgControl, valueAccessors: ControlValueAccessor[]):
ControlValueAccessor {
export function selectValueAccessor(dir: NgControl,
valueAccessors: ControlValueAccessor[]): ControlValueAccessor {
if (isBlank(valueAccessors)) return null;
var defaultAccessor;

View File

@ -111,8 +111,8 @@ export abstract class AbstractControl {
setParent(parent: ControlGroup | ControlArray): void { this._parent = parent; }
updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):
void {
updateValueAndValidity(
{onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}): void {
onlySelf = normalizeBool(onlySelf);
emitEvent = isPresent(emitEvent) ? emitEvent : true;
@ -237,10 +237,11 @@ export class Control extends AbstractControl {
* via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
* specified.
*/
updateValue(value: any,
{onlySelf, emitEvent, emitModelToViewChange}:
{onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean} = {}):
void {
updateValue(value: any, {onlySelf, emitEvent, emitModelToViewChange}: {
onlySelf?: boolean,
emitEvent?: boolean,
emitModelToViewChange?: boolean
} = {}): void {
emitModelToViewChange = isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
this._value = value;
if (isPresent(this._onChange) && emitModelToViewChange) this._onChange(this._value);

View File

@ -232,8 +232,8 @@ export abstract class DynamicComponentLoader {
* <child-component>Child</child-component>
* ```
*/
abstract loadNextToLocation(type: Type, location: ElementRef, providers?: ResolvedProvider[]):
Promise<ComponentRef>;
abstract loadNextToLocation(type: Type, location: ElementRef,
providers?: ResolvedProvider[]): Promise<ComponentRef>;
}
@Injectable()

View File

@ -283,9 +283,9 @@ function provideDirective(directiveResolver: DirectiveResolver, type: Type): Dir
return DirectiveProvider.createFromType(type, annotation);
}
export function createDirectiveVariableBindings(variableNameAndValues: Array<string | number>,
directiveProviders: DirectiveProvider[]):
Map<string, number> {
export function createDirectiveVariableBindings(
variableNameAndValues: Array<string | number>,
directiveProviders: DirectiveProvider[]): Map<string, number> {
var directiveVariableBindings = new Map<string, number>();
for (var i = 0; i < variableNameAndValues.length; i += 2) {
var templateName = <string>variableNameAndValues[i];

View File

@ -165,8 +165,8 @@ export class EmbeddedTemplateCmd implements TemplateCmd, IBeginElementCmd,
export function embeddedTemplate(attrNameAndValues: string[], variableNameAndValues: string[],
directives: Type[], isMerged: boolean, ngContentIndex: number,
changeDetectorFactory: Function, children: TemplateCmd[]):
EmbeddedTemplateCmd {
changeDetectorFactory: Function,
children: TemplateCmd[]): EmbeddedTemplateCmd {
return new EmbeddedTemplateCmd(attrNameAndValues, variableNameAndValues, directives, isMerged,
ngContentIndex, changeDetectorFactory, children);
}

View File

@ -55,8 +55,8 @@ export abstract class AppViewManager {
* Throws an exception if the specified `hostLocation` is not a Host Element of a Component, or if
* variable `variableName` couldn't be found in the Component View of this Component.
*/
abstract getNamedElementInComponentView(hostLocation: ElementRef, variableName: string):
ElementRef;
abstract getNamedElementInComponentView(hostLocation: ElementRef,
variableName: string): ElementRef;
/**
* Returns the component instance for the provided Host Element.

View File

@ -209,8 +209,8 @@ export abstract class Renderer {
*
* Returns an instance of {@link RenderViewWithFragments}, representing the Render View.
*/
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number):
RenderViewWithFragments;
abstract createView(protoViewRef: RenderProtoViewRef,
fragmentCount: number): RenderViewWithFragments;
/**
* Destroys a Render View specified via `viewRef`.

View File

@ -131,8 +131,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
abstract createRootHostView(hostProtoViewRef: RenderProtoViewRef, fragmentCount: number,
hostElementSelector: string): RenderViewWithFragments;
abstract createView(protoViewRef: RenderProtoViewRef, fragmentCount: number):
RenderViewWithFragments;
abstract createView(protoViewRef: RenderProtoViewRef,
fragmentCount: number): RenderViewWithFragments;
abstract destroyView(viewRef: RenderViewRef);
@ -207,8 +207,8 @@ export abstract class DomRenderer extends Renderer implements NodeFactory<Node>
propertyValue);
}
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string):
void {
setElementAttribute(location: RenderElementRef, attributeName: string,
attributeValue: string): void {
var view = resolveInternalDomView(location.renderView);
var element = view.boundElements[location.boundElementIndex];
var dashCasedAttributeName = camelCaseToDashCase(attributeName);

View File

@ -28,15 +28,15 @@ export class BrowserGetTestability implements GetTestability {
static init() { setTestabilityGetter(new BrowserGetTestability()); }
addToWindow(registry: TestabilityRegistry): void {
global.getAngularTestability = function(elem: Element, findInAncestors: boolean = true):
PublicTestability {
var testability = registry.findTestabilityInTree(elem, findInAncestors);
global.getAngularTestability = function(elem: Element,
findInAncestors: boolean = true): PublicTestability {
var testability = registry.findTestabilityInTree(elem, findInAncestors);
if (testability == null) {
throw new Error('Could not find testability for element.');
}
return new PublicTestability(testability);
};
if (testability == null) {
throw new Error('Could not find testability for element.');
}
return new PublicTestability(testability);
};
global.getAllAngularTestabilities = function(): PublicTestability[] {
var testabilities = registry.getAllTestabilities();
return testabilities.map((testability) => { return new PublicTestability(testability); });

View File

@ -236,8 +236,8 @@ if (!(Reflect && Reflect.getMetadata)) {
throw 'reflect-metadata shim is required when using class decorators';
}
export function makeDecorator(annotationCls, chainFn: (fn: Function) => void = null):
(...args: any[]) => (cls: any) => any {
export function makeDecorator(
annotationCls, chainFn: (fn: Function) => void = null): (...args: any[]) => (cls: any) => any {
function DecoratorFactory(objOrType): (cls: any) => any {
var annotationInstance = new (<any>annotationCls)(objOrType);
if (this instanceof annotationCls) {

View File

@ -6,7 +6,7 @@ import {Connection, ConnectionBackend} from '../interfaces';
import {isPresent} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
var Rx = require('@reactivex/rxjs/dist/cjs/Rx');
let{Subject, ReplaySubject} = Rx;
let {Subject, ReplaySubject} = Rx;
/**
*

View File

@ -42,6 +42,6 @@ export {
*
* {@example router/ts/can_activate/can_activate_example.ts region='canActivate' }
*/
export var CanActivate:
(hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
ClassDecorator = makeDecorator(CanActivateAnnotation);
export var CanActivate: (hook: (next: ComponentInstruction, prev: ComponentInstruction) =>
Promise<boolean>| boolean) => ClassDecorator =
makeDecorator(CanActivateAnnotation);

View File

@ -41,8 +41,8 @@ export class Route implements RouteDefinition {
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
loader: Function;
redirectTo: string;
constructor({path, component, as, data}:
{path: string, component: Type, as?: string, data?: {[key: string]: any}}) {
constructor({path, component, as,
data}: {path: string, component: Type, as?: string, data?: {[key: string]: any}}) {
this.path = path;
this.component = component;
this.as = as;
@ -115,8 +115,8 @@ export class AsyncRoute implements RouteDefinition {
path: string;
loader: Function;
as: string;
constructor({path, loader, as, data}:
{path: string, loader: Function, as?: string, data?: {[key: string]: any}}) {
constructor({path, loader, as,
data}: {path: string, loader: Function, as?: string, data?: {[key: string]: any}}) {
this.path = path;
this.loader = loader;
this.as = as;

View File

@ -544,8 +544,8 @@ function splitAndFlattenLinkParams(linkParams: any[]): any[] {
}, []);
}
function canActivateOne(nextInstruction: Instruction, prevInstruction: Instruction):
Promise<boolean> {
function canActivateOne(nextInstruction: Instruction,
prevInstruction: Instruction): Promise<boolean> {
var next = _resolveToTrue;
if (isPresent(nextInstruction.child)) {
next = canActivateOne(nextInstruction.child,

View File

@ -144,22 +144,22 @@ export function beforeEach(fn: FunctionWithParamTokens | AnyTestFn): void {
}
}
export function it(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null):
void {
export function it(name: string, fn: FunctionWithParamTokens | AnyTestFn,
timeOut: number = null): void {
return _it(jsmIt, name, fn, timeOut);
}
export function xit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null):
void {
export function xit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
timeOut: number = null): void {
return _it(jsmXIt, name, fn, timeOut);
}
export function iit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null):
void {
export function iit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
timeOut: number = null): void {
return _it(jsmIIt, name, fn, timeOut);
}
export function fit(name: string, fn: FunctionWithParamTokens | AnyTestFn, timeOut: number = null):
void {
export function fit(name: string, fn: FunctionWithParamTokens | AnyTestFn,
timeOut: number = null): void {
return _it(jsmIIt, name, fn, timeOut);
}

View File

@ -28,8 +28,8 @@ var _postMessage: PostMessageInterface = <any>postMessage;
* See the bootstrap() docs for more details.
*/
export function bootstrapWebWorker(
appComponentType: Type, componentInjectableProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
appComponentType: Type,
componentInjectableProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
Parse5DomAdapter.makeCurrent();
var sink = new PostMessageBusSink({
postMessage: (message: any, transferrables?:[ArrayBuffer]) => {

View File

@ -91,8 +91,8 @@ class PrintLogger {
logGroupEnd() {}
}
function webWorkerProviders(appComponentType, bus: MessageBus, initData: {[key: string]: any}):
Array<Type | Provider | any[]> {
function webWorkerProviders(appComponentType, bus: MessageBus,
initData: {[key: string]: any}): Array<Type | Provider | any[]> {
return [
compilerProviders(),
Serializer,
@ -114,9 +114,9 @@ function webWorkerProviders(appComponentType, bus: MessageBus, initData: {[key:
];
}
export function bootstrapWebWorkerCommon(appComponentType: Type, bus: MessageBus,
appProviders: Array<Type | Provider | any[]> = null):
Promise<ComponentRef> {
export function bootstrapWebWorkerCommon(
appComponentType: Type, bus: MessageBus,
appProviders: Array<Type | Provider | any[]> = null): Promise<ComponentRef> {
var bootstrapProcess: PromiseCompleter<any> = PromiseWrapper.completer();
var appPromise = platform().asyncApplication((zone: NgZone) => {
// TODO(rado): prepopulate template cache, so applications with only

View File

@ -1,6 +1,6 @@
// no deserialization is necessary in TS.
// This is only here to match dart interface
export function deserializeGenericEvent(serializedEvent: {[key: string]: any}):
{[key: string]: any} {
export function deserializeGenericEvent(
serializedEvent: {[key: string]: any}): {[key: string]: any} {
return serializedEvent;
}