chore: run clang-format on code base.

This fixes several minor indentation issues (instanceof precendence,
type declaration specificity, template string length calculation).

This should also fix some flip-flop situations with template strings.
This commit is contained in:
Martin Probst 2015-07-10 11:29:41 +02:00
parent 45994a53ce
commit 3bf8c18c56
26 changed files with 128 additions and 138 deletions

View File

@ -122,8 +122,8 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
_dynamicChangeDetection: ChangeDetection;
_protoChangeDetectorFactories: StringMap<string, Function>;
constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional()
protoChangeDetectorsForTest?: StringMap<string, Function>) {
constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional() protoChangeDetectorsForTest?:
StringMap<string, Function>) {
super();
this._dynamicChangeDetection = new DynamicChangeDetection();
this._protoChangeDetectorFactories = isPresent(protoChangeDetectorsForTest) ?

View File

@ -108,8 +108,7 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
visitAccessMember(ast: AccessMember): number {
var receiver = ast.receiver.visit(this);
if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name) &&
ast.receiver instanceof
ImplicitReceiver) {
ast.receiver instanceof ImplicitReceiver) {
return this._addRecord(RecordType.LOCAL, ast.name, ast.name, [], null, receiver);
} else {
return this._addRecord(RecordType.PROPERTY, ast.name, ast.getter, [], null, receiver);

View File

@ -245,8 +245,8 @@ export class DirectiveBinding extends ResolvedBinding {
[];
var metadata = DirectiveMetadata.create({
id: stringify(rb.key.token),
type: ann instanceof
Component ? DirectiveMetadata.COMPONENT_TYPE : DirectiveMetadata.DIRECTIVE_TYPE,
type: ann instanceof Component ? DirectiveMetadata.COMPONENT_TYPE :
DirectiveMetadata.DIRECTIVE_TYPE,
selector: ann.selector,
compileChildren: ann.compileChildren,
events: ann.events,
@ -260,8 +260,7 @@ export class DirectiveBinding extends ResolvedBinding {
callOnInit: hasLifecycleHook(onInit, rb.key.token, ann),
callOnAllChangesDone: hasLifecycleHook(onAllChangesDone, rb.key.token, ann),
changeDetection: ann instanceof
Component ? ann.changeDetection : null,
changeDetection: ann instanceof Component ? ann.changeDetection : null,
exportAs: ann.exportAs
});
@ -452,10 +451,8 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
// we couple ourselves to the injector strategy to avoid polymoprhic calls
var injectorStrategy = <any>this._injector.internalStrategy;
this._strategy = injectorStrategy instanceof InjectorInlineStrategy ?
new ElementInjectorInlineStrategy(
injectorStrategy, this) :
new ElementInjectorDynamicStrategy(
injectorStrategy, this);
new ElementInjectorInlineStrategy(injectorStrategy, this) :
new ElementInjectorDynamicStrategy(injectorStrategy, this);
this.hydrated = false;

View File

@ -39,9 +39,9 @@ class BindingRecordsCreator {
return bindings;
}
getDirectiveRecords(
elementBinders: List<renderApi.ElementBinder>,
allDirectiveMetadatas: List<renderApi.DirectiveMetadata>): List<DirectiveRecord> {
getDirectiveRecords(elementBinders: List<renderApi.ElementBinder>,
allDirectiveMetadatas:
List<renderApi.DirectiveMetadata>): List<DirectiveRecord> {
var directiveRecords = [];
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
@ -277,8 +277,8 @@ function _createVariableBindings(renderProtoView): Map<string, string> {
return variableBindings;
}
function _collectNestedProtoViewsVariableNames(
nestedPvsWithIndex: List<RenderProtoViewWithIndex>): List<List<string>> {
function _collectNestedProtoViewsVariableNames(nestedPvsWithIndex: List<RenderProtoViewWithIndex>):
List<List<string>> {
var nestedPvVariableNames = ListWrapper.createFixedSize(nestedPvsWithIndex.length);
ListWrapper.forEach(nestedPvsWithIndex, (pvWithIndex) => {
var parentVariableNames =
@ -301,8 +301,8 @@ function _createVariableNames(parentVariableNames: List<string>, renderProtoView
return res;
}
export function createVariableLocations(
elementBinders: List<renderApi.ElementBinder>): Map<string, number> {
export function createVariableLocations(elementBinders: List<renderApi.ElementBinder>):
Map<string, number> {
var variableLocations = new Map();
for (var i = 0; i < elementBinders.length; i++) {
var binder = elementBinders[i];
@ -374,8 +374,8 @@ function _createProtoElementInjector(binderIndex, parentPeiWithDistance, renderE
}
function _createElementBinder(protoView: AppProtoView, boundElementIndex, renderElementBinder,
protoElementInjector, componentDirectiveBinding,
directiveBindings): ElementBinder {
protoElementInjector, componentDirectiveBinding, directiveBindings):
ElementBinder {
var parent = null;
if (renderElementBinder.parentIndex !== -1) {
parent = protoView.elementBinders[renderElementBinder.parentIndex];
@ -393,9 +393,9 @@ function _createElementBinder(protoView: AppProtoView, boundElementIndex, render
return elBinder;
}
export function createDirectiveVariableBindings(
renderElementBinder: renderApi.ElementBinder,
directiveBindings: List<DirectiveBinding>): Map<string, number> {
export function createDirectiveVariableBindings(renderElementBinder: renderApi.ElementBinder,
directiveBindings: List<DirectiveBinding>):
Map<string, number> {
var directiveVariableBindings = new Map();
MapWrapper.forEach(renderElementBinder.variableBindings, (templateName, exportAs) => {
var dirIndex = _findDirectiveIndexByExportAs(renderElementBinder, directiveBindings, exportAs);

View File

@ -177,13 +177,10 @@ export class Binding {
*/
dependencies: List<any>;
constructor(token, {toClass, toValue, toAlias, toFactory, deps}: {
toClass?: Type,
toValue?: any,
toAlias?: any,
toFactory?: Function,
deps?: List<any>
}) {
constructor(
token,
{toClass, toValue, toAlias, toFactory, deps}:
{toClass?: Type, toValue?: any, toAlias?: any, toFactory?: Function, deps?: List<any>}) {
this.token = token;
this.toClass = toClass;
this.toValue = toValue;
@ -374,8 +371,8 @@ export class BindingBuilder {
}
}
function _constructDependencies(factoryFunction: Function,
dependencies: List<any>): List<Dependency> {
function _constructDependencies(factoryFunction: Function, dependencies: List<any>):
List<Dependency> {
if (isBlank(dependencies)) {
return _dependenciesFor(factoryFunction);
} else {
@ -393,8 +390,8 @@ function _dependenciesFor(typeOrFunc): List<Dependency> {
return ListWrapper.map(params, (p: List<any>) => _extractToken(typeOrFunc, p, params));
}
function _extractToken(typeOrFunc, annotations /*List<any> | any*/,
params: List<List<any>>): Dependency {
function _extractToken(typeOrFunc, annotations /*List<any> | any*/, params: List<List<any>>):
Dependency {
var depProps = [];
var token = null;
var optional = false;

View File

@ -135,8 +135,7 @@ export class InstantiationError extends AbstractBindingError {
super(key, function(keys: List<any>) {
var first = stringify(ListWrapper.first(keys).token);
return `Error during instantiation of ${first}!${constructResolvingPath(keys)}.` +
` ORIGINAL ERROR: ${originalException}` +
`\n\n ORIGINAL STACK: ${originalStack}`;
` ORIGINAL ERROR: ${originalException}` + `\n\n ORIGINAL STACK: ${originalStack}`;
}, originalException, originalStack);
this.causeKey = key;

View File

@ -786,8 +786,8 @@ function _resolveBindings(bindings: List<Type | Binding | List<any>>): List<Reso
return resolvedList;
}
function _createListOfBindings(
flattenedBindings: Map<number, ResolvedBinding>): List<ResolvedBinding> {
function _createListOfBindings(flattenedBindings: Map<number, ResolvedBinding>):
List<ResolvedBinding> {
return MapWrapper.values(flattenedBindings);
}

View File

@ -10,9 +10,8 @@ export var StringMap = global.Object;
var createMapFromPairs: {(pairs: List<any>): Map<any, any>} = (function() {
try {
if (new Map([1, 2]).size === 2) {
return function createMapFromPairs(pairs: List<any>): Map<any, any> {
return new Map(pairs);
};
return function createMapFromPairs(pairs: List<any>):
Map<any, any> { return new Map(pairs); };
}
} catch (e) {
}

View File

@ -107,9 +107,9 @@ export class FormBuilder {
}
_createControl(controlConfig: any): modelModule.AbstractControl {
if (controlConfig instanceof modelModule.Control || controlConfig instanceof
modelModule.ControlGroup || controlConfig instanceof
modelModule.ControlArray) {
if (controlConfig instanceof modelModule.Control ||
controlConfig instanceof modelModule.ControlGroup ||
controlConfig instanceof modelModule.ControlArray) {
return controlConfig;
} else if (isArray(controlConfig)) {

View File

@ -98,8 +98,8 @@ export class AbstractControl {
}
}
updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean,
emitEvent?: boolean} = {}): void {
updateValueAndValidity({onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):
void {
onlySelf = isPresent(onlySelf) ? onlySelf : false;
emitEvent = isPresent(emitEvent) ? emitEvent : true;
@ -151,8 +151,8 @@ export class Control extends AbstractControl {
this._valueChanges = new EventEmitter();
}
updateValue(value: any,
{onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}): void {
updateValue(value: any, {onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):
void {
this._value = value;
if (isPresent(this._onChange)) this._onChange(this._value);
this.updateValueAndValidity({onlySelf: onlySelf, emitEvent: emitEvent});

View File

@ -188,8 +188,8 @@ export class DomRenderer extends Renderer {
view.setElementProperty(location.boundElementIndex, propertyName, propertyValue);
}
setElementAttribute(location: RenderElementRef, attributeName: string,
attributeValue: string): void {
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string):
void {
var view = resolveInternalDomView(location.renderView);
view.setElementAttribute(location.boundElementIndex, attributeName, attributeValue);
}

View File

@ -89,8 +89,8 @@ export class KeyEventsPlugin extends EventManagerPlugin {
return fullKey;
}
static eventCallback(element, shouldSupportBubble, fullKey, handler,
zone): (event: Event) => void {
static eventCallback(element, shouldSupportBubble, fullKey, handler, zone):
(event: Event) => void {
return (event) => {
var correctElement = shouldSupportBubble || event.target === element;
if (correctElement && StringWrapper.equals(KeyEventsPlugin.getEventFullKey(event), fullKey)) {

View File

@ -343,10 +343,10 @@ const ATTRIBUTE_PREFIX = 'attr';
const CLASS_PREFIX = 'class';
const STYLE_PREFIX = 'style';
function buildElementPropertyBindings(
protoElement: /*element*/ any, isNgComponent: boolean,
function buildElementPropertyBindings(protoElement: /*element*/ any, isNgComponent: boolean,
bindingsInTemplate: Map<string, ASTWithSource>,
directiveTempaltePropertyNames: Set<string>): List<api.ElementPropertyBinding> {
directiveTempaltePropertyNames: Set<string>):
List<api.ElementPropertyBinding> {
var propertyBindings = [];
MapWrapper.forEach(bindingsInTemplate, (ast, propertyNameInTemplate) => {
var propertyBinding = createElementPropertyBinding(ast, propertyNameInTemplate);
@ -376,8 +376,8 @@ function isValidElementPropertyBinding(protoElement: /*element*/ any, isNgCompon
return true;
}
function createElementPropertyBinding(ast: ASTWithSource,
propertyNameInTemplate: string): api.ElementPropertyBinding {
function createElementPropertyBinding(ast: ASTWithSource, propertyNameInTemplate: string):
api.ElementPropertyBinding {
var parts = StringWrapper.split(propertyNameInTemplate, PROPERTY_PARTS_SEPARATOR);
if (parts.length === 1) {
var propName = parts[0];

View File

@ -118,7 +118,8 @@ function _clearInterval(id: number) {
}
function _fnAndFlush(fn: Function): Function {
return (... args) => { fn.apply(global, args);
return (...args) => {
fn.apply(global, args);
flushMicrotasks();
}
}

View File

@ -242,9 +242,8 @@ export function makeDecorator(annotationCls, chainFn: (fn: Function) => void = n
if (this instanceof annotationCls) {
return annotationInstance;
} else {
var chainAnnotation = isFunction(this) && this.annotations instanceof Array ?
this.annotations :
[];
var chainAnnotation =
isFunction(this) && this.annotations instanceof Array ? this.annotations : [];
chainAnnotation.push(annotationInstance);
var TypeDecorator: TypeDecorator = <TypeDecorator>function TypeDecorator(cls) {
var annotations = Reflect.getMetadata('annotations', cls);

View File

@ -213,11 +213,13 @@ class _DirectiveUpdating {
* Map from test id to _DirectiveUpdating.
* Definitions in this map define definitions which allow testing directive updating.
*/
static availableDefinitions: StringMap<string, _DirectiveUpdating> = {
static availableDefinitions:
StringMap<string, _DirectiveUpdating> = {
'directNoDispatcher': new _DirectiveUpdating(
[_DirectiveUpdating.updateA('42', _DirectiveUpdating.basicRecords[0])],
[_DirectiveUpdating.basicRecords[0]]),
'groupChanges': new _DirectiveUpdating(
'groupChanges':
new _DirectiveUpdating(
[
_DirectiveUpdating.updateA('1', _DirectiveUpdating.basicRecords[0]),
_DirectiveUpdating.updateB('2', _DirectiveUpdating.basicRecords[0]),
@ -240,8 +242,9 @@ class _DirectiveUpdating {
'readingDirectives':
new _DirectiveUpdating(
[
BindingRecord.createForHostProperty(
new DirectiveIndex(0, 0), _getParser().parseBinding('a', 'location'), PROP_NAME)
BindingRecord.createForHostProperty(new DirectiveIndex(0, 0),
_getParser().parseBinding('a', 'location'),
PROP_NAME)
],
[_DirectiveUpdating.basicRecords[0]]),
'interpolation':

View File

@ -6,10 +6,9 @@ import {RecordType, ProtoRecord} from 'angular2/src/change_detection/proto_recor
import {DirectiveIndex} from 'angular2/src/change_detection/directive_record';
export function main() {
function r(
funcOrValue, args, contextIndex, selfIndex,
{lastInBinding, mode, name,
directiveIndex}: {lastInBinding?: any, mode?: any, name?: any, directiveIndex?: any} = {}) {
function r(funcOrValue, args, contextIndex, selfIndex,
{lastInBinding, mode, name, directiveIndex}:
{lastInBinding?: any, mode?: any, name?: any, directiveIndex?: any} = {}) {
if (isBlank(lastInBinding)) lastInBinding = false;
if (isBlank(mode)) mode = RecordType.PROPERTY;
if (isBlank(name)) name = "name";

View File

@ -158,8 +158,7 @@ export class Unparser implements AstVisitor {
visitMethodCall(ast: MethodCall) {
this._visit(ast.receiver);
this._expression += ast.receiver instanceof ImplicitReceiver ? `${ast.name}(` :
`.${ast.name}(`;
this._expression += ast.receiver instanceof ImplicitReceiver ? `${ast.name}(` : `.${ast.name}(`;
var isFirst = true;
ast.args.forEach(arg => {
if (!isFirst) this._expression += ', ';

View File

@ -58,8 +58,8 @@ export function main() {
rootProtoView = createRootProtoView(directiveResolver, MainComponent);
});
function createCompiler(
renderCompileResults: List<renderApi.ProtoViewDto | Promise<renderApi.ProtoViewDto>>,
function createCompiler(renderCompileResults:
List<renderApi.ProtoViewDto | Promise<renderApi.ProtoViewDto>>,
protoViewFactoryResults: List<List<AppProtoView>>) {
var urlResolver = new UrlResolver();
renderCompileRequests = [];
@ -510,8 +510,8 @@ function createViewportElementBinder(nestedProtoView): ElementBinder {
return elBinder;
}
function createRenderProtoView(elementBinders = null,
type: renderApi.ViewType = null): renderApi.ProtoViewDto {
function createRenderProtoView(elementBinders = null, type: renderApi.ViewType = null):
renderApi.ProtoViewDto {
if (isBlank(type)) {
type = renderApi.ViewType.COMPONENT;
}

View File

@ -67,8 +67,8 @@ export class DomTestbed {
DOM.appendChild(DOM.querySelector(document, 'body'), this.rootEl);
}
compileAll(directivesOrViewDefinitions: List<DirectiveMetadata |
ViewDefinition>): Promise<List<ProtoViewDto>> {
compileAll(directivesOrViewDefinitions:
List<DirectiveMetadata | ViewDefinition>): Promise<List<ProtoViewDto>> {
return PromiseWrapper.all(ListWrapper.map(directivesOrViewDefinitions, (entry) => {
if (entry instanceof DirectiveMetadata) {
return this.compiler.compileHost(entry);

View File

@ -69,10 +69,8 @@ export class PerfLogFeatures {
gc: boolean;
frameCapture: boolean;
constructor({render = false, gc = false,
frameCapture = false}: {render?: boolean,
gc?: boolean,
frameCapture?: boolean} = {}) {
constructor({render = false, gc = false, frameCapture = false}:
{render?: boolean, gc?: boolean, frameCapture?: boolean} = {}) {
this.render = render;
this.gc = gc;
this.frameCapture = frameCapture;

View File

@ -141,8 +141,8 @@ export class ChromeDriverExtension extends WebDriverExtension {
}
}
function normalizeEvent(chromeEvent: StringMap<string, any>,
data: StringMap<string, any>): StringMap<string, any> {
function normalizeEvent(chromeEvent: StringMap<string, any>, data: StringMap<string, any>):
StringMap<string, any> {
var ph = chromeEvent['ph'];
if (StringWrapper.equals(ph, 'S')) {
ph = 'b';

View File

@ -81,8 +81,8 @@ export function main() {
createExtension()
.timeEnd('name1', 'name2')
.then((_) => {
expect(log).toEqual(
[['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
expect(log)
.toEqual([['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
async.done();
});
}));

View File

@ -71,8 +71,8 @@ export function main() {
createExtension()
.timeEnd('name1', 'name2')
.then((_) => {
expect(log).toEqual(
[['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
expect(log)
.toEqual([['executeScript', `console.timeEnd('name1');console.time('name2');`]]);
async.done();
});
}));