style(compiler-cli): reformat of codebase with new clang-format version (#36520)

This commit reformats the packages/compiler-cli tree using the new version
of clang-format.

PR Close #36520
This commit is contained in:
Alex Rickabaugh
2020-04-07 12:43:43 -07:00
committed by atscott
parent 717df13207
commit 0a69a2832b
205 changed files with 2949 additions and 2122 deletions

View File

@ -20,7 +20,9 @@ export class NormalService {
})
export class AppComponent {
found: boolean;
constructor(service: ShakeableService) { this.found = !!service.normal; }
constructor(service: ShakeableService) {
this.found = !!service.normal;
}
}
@NgModule({

View File

@ -29,7 +29,9 @@ export class AppComponent {
export class ChildComponent {
found: boolean;
constructor(@Optional() @Self() service: Service|null) { this.found = !!service; }
constructor(@Optional() @Self() service: Service|null) {
this.found = !!service;
}
}
@NgModule({

View File

@ -21,7 +21,9 @@ export class NormalService {
})
export class AppComponent {
found: boolean;
constructor(service: NormalService) { this.found = !!service.shakeable; }
constructor(service: NormalService) {
this.found = !!service.shakeable;
}
}
@NgModule({

View File

@ -17,7 +17,9 @@ import {ServerModule} from '@angular/platform-server';
})
export class AppComponent {
data: string;
constructor(service: Service) { this.data = service.data; }
constructor(service: Service) {
this.data = service.data;
}
}
@NgModule({

View File

@ -6,11 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Inject, Injectable, InjectionToken, NgModule, forwardRef, inject} from '@angular/core';
import {Component, forwardRef, Inject, inject, Injectable, InjectionToken, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServerModule} from '@angular/platform-server';
export interface IService { readonly dep: {readonly data: string;}; }
export interface IService {
readonly dep: {readonly data: string;};
}
@NgModule({})
export class TokenModule {
@ -28,7 +30,9 @@ export const TOKEN = new InjectionToken('test', {
})
export class AppComponent {
data: string;
constructor(@Inject(TOKEN) service: IService) { this.data = service.dep.data; }
constructor(@Inject(TOKEN) service: IService) {
this.data = service.dep.data;
}
}
@NgModule({

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, INJECTOR, Injectable, NgModule} from '@angular/core';
import {Component, Injectable, INJECTOR, NgModule} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {renderModuleFactory} from '@angular/platform-server';
import {BasicAppModuleNgFactory} from 'app_built/src/basic.ngfactory';
@ -104,7 +104,6 @@ describe('ngInjectableDef Bazel Integration', () => {
});
it('allows provider override in JIT for module-scoped @Injectables', () => {
@NgModule()
class Module {
}
@ -172,7 +171,9 @@ describe('ngInjectableDef Bazel Integration', () => {
// ChildServices exteds ParentService but does not have @Injectable
class ChildService extends ParentService {
constructor(value: string) { super(value); }
constructor(value: string) {
super(value);
}
static ngInjectableDef = {
providedIn: 'root',
factory: () => new ChildService('child'),

View File

@ -6,17 +6,23 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable, InjectionToken, Injector, NgModule, forwardRef, ɵcreateInjector as createInjector} from '@angular/core';
import {forwardRef, Injectable, InjectionToken, Injector, NgModule, ɵcreateInjector as createInjector} from '@angular/core';
import {AOT_TOKEN, AotModule, AotService} from 'app_built/src/module';
describe('Ivy NgModule', () => {
describe('AOT', () => {
let injector: Injector;
beforeEach(() => { injector = createInjector(AotModule); });
it('works', () => { expect(injector.get(AotService) instanceof AotService).toBeTruthy(); });
beforeEach(() => {
injector = createInjector(AotModule);
});
it('works', () => {
expect(injector.get(AotService) instanceof AotService).toBeTruthy();
});
it('merges imports and exports', () => { expect(injector.get(AOT_TOKEN)).toEqual('exports'); });
it('merges imports and exports', () => {
expect(injector.get(AOT_TOKEN)).toEqual('exports');
});
});
@ -38,7 +44,9 @@ describe('Ivy NgModule', () => {
class JitAppModule {
}
it('works', () => { createInjector(JitAppModule); });
it('works', () => {
createInjector(JitAppModule);
});
it('throws an error on circular module dependencies', () => {
@NgModule({

View File

@ -16,10 +16,8 @@ export class LazyFeatureComponent {
@NgModule({
imports: [RouterModule.forChild([
{path: '', component: LazyFeatureComponent, pathMatch: 'full'},
{path: 'feature', loadChildren: './feature.module#FeatureModule'}, {
path: 'nested-feature',
loadChildren: './lazy-feature-nested.module#LazyFeatureNestedModule'
}
{path: 'feature', loadChildren: './feature.module#FeatureModule'},
{path: 'nested-feature', loadChildren: './lazy-feature-nested.module#LazyFeatureNestedModule'}
])],
declarations: [LazyFeatureComponent]
})

View File

@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {AUTO_STYLE, animate, state, style, transition, trigger} from '@angular/animations';
import {animate, AUTO_STYLE, state, style, transition, trigger} from '@angular/animations';
import {Component} from '@angular/core';
@Component({
@ -30,8 +30,16 @@ import {Component} from '@angular/core';
})
export class AnimateCmp {
stateExpression: string;
constructor() { this.setAsClosed(); }
setAsSomethingElse() { this.stateExpression = 'something'; }
setAsOpen() { this.stateExpression = 'open'; }
setAsClosed() { this.stateExpression = 'closed'; }
constructor() {
this.setAsClosed();
}
setAsSomethingElse() {
this.stateExpression = 'something';
}
setAsOpen() {
this.stateExpression = 'open';
}
setAsClosed() {
this.stateExpression = 'closed';
}
}

View File

@ -8,6 +8,8 @@
import {InjectionToken} from '@angular/core';
export interface Named { name: string; }
export interface Named {
name: string;
}
export const CUSTOM = new InjectionToken<Named>('CUSTOM');

View File

@ -10,5 +10,7 @@ import {Component} from '@angular/core';
@Component({selector: 'comp-with-error', templateUrl: 'errors.html'})
export class BindingErrorComp {
createError() { throw new Error('Test'); }
createError() {
throw new Error('Test');
}
}

View File

@ -7,7 +7,7 @@
*/
import * as common from '@angular/common';
import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, EventEmitter, Inject, InjectionToken, NgModule, Output, forwardRef} from '@angular/core';
import {Component, CUSTOM_ELEMENTS_SCHEMA, Directive, EventEmitter, forwardRef, Inject, InjectionToken, NgModule, Output} from '@angular/core';
import {Observable} from 'rxjs';
import {wrapInArray} from './funcs';
@ -62,7 +62,9 @@ export class CompUsingCustomElements {
})
export class CompConsumingEvents {
handleDomEventVoid(e: any): void {}
handleDomEventPreventDefault(e: any): boolean { return false; }
handleDomEventPreventDefault(e: any): boolean {
return false;
}
handleDirEvent(e: any): void {}
}
@ -70,8 +72,7 @@ export class CompConsumingEvents {
selector: '[dirEvent]',
})
export class DirPublishingEvents {
@Output('dirEvent')
dirEvent: Observable<string> = new EventEmitter();
@Output('dirEvent') dirEvent: Observable<string> = new EventEmitter();
}
@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: wrapInArray(CompUsingCustomElements)})

View File

@ -11,7 +11,7 @@ import {Component, Directive, Injectable, NgModule, Pipe} from '@angular/core';
const instances = new Map<any, Base>();
export function expectInstanceCreated(type: any) {
const instance = instances.get(type) !;
const instance = instances.get(type)!;
expect(instance).toBeDefined();
expect(instance.dep instanceof SomeDep).toBe(true);
}
@ -19,7 +19,9 @@ export function expectInstanceCreated(type: any) {
export class SomeDep {}
export class Base {
constructor(public dep: SomeDep) { instances.set(Object.getPrototypeOf(this).constructor, this); }
constructor(public dep: SomeDep) {
instances.set(Object.getPrototypeOf(this).constructor, this);
}
}
@Component({templateUrl: './jit_summaries.html'})
@ -36,7 +38,9 @@ export class SomeDirective extends Base {
@Pipe({name: 'somePipe'})
export class SomePipe extends Base {
transform(value: any) { return value; }
transform(value: any) {
return value;
}
}
@Injectable()

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {ApplicationRef, NgModule, forwardRef} from '@angular/core';
import {ApplicationRef, forwardRef, NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {ServerModule} from '@angular/platform-server';
import {FlatModule} from 'flat_module';

View File

@ -19,24 +19,26 @@ export class ServiceUsingLibModule {
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
export class SomeDirectiveInRootModule {
@Input()
someDir: string;
@Input() someDir: string;
}
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
export class SomeDirectiveInLibModule {
@Input()
someDir: string;
@Input() someDir: string;
}
@Pipe({name: 'somePipe'})
export class SomePipeInRootModule {
transform(value: string): any { return `transformed ${value}`; }
transform(value: string): any {
return `transformed ${value}`;
}
}
@Pipe({name: 'somePipe'})
export class SomePipeInLibModule {
transform(value: string): any { return `transformed ${value}`; }
transform(value: string): any {
return `transformed ${value}`;
}
}
@Component({selector: 'comp', template: `<div [someDir]="'someValue' | somePipe"></div>`})
@ -66,8 +68,8 @@ export class SomeLibModule {
return {
ngModule: SomeLibModule,
providers: [
ServiceUsingLibModule, provideValueWithEntryComponents(
[{a: 'b', component: CompUsingLibModuleDirectiveAndPipe}])
ServiceUsingLibModule,
provideValueWithEntryComponents([{a: 'b', component: CompUsingLibModuleDirectiveAndPipe}])
]
};
}

View File

@ -8,9 +8,9 @@
import {Component} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {ServerTestingModule, platformServerTesting} from '@angular/platform-server/testing';
import {platformServerTesting, ServerTestingModule} from '@angular/platform-server/testing';
import {SomeDep, SomeDirective, SomeModule, SomePipe, SomePrivateComponent, SomeService, expectInstanceCreated} from '../src/jit_summaries';
import {expectInstanceCreated, SomeDep, SomeDirective, SomeModule, SomePipe, SomePrivateComponent, SomeService} from '../src/jit_summaries';
import {SomeModuleNgSummary} from '../src/jit_summaries.ngsummary';
describe('Jit Summaries', () => {
@ -18,7 +18,9 @@ describe('Jit Summaries', () => {
TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting(), SomeModuleNgSummary);
});
afterEach(() => { TestBed.resetTestEnvironment(); });
afterEach(() => {
TestBed.resetTestEnvironment();
});
it('should use directive metadata from summaries', () => {
@Component({template: '<div someDir></div>'})

View File

@ -10,7 +10,7 @@ import './init';
import {ComponentUsingThirdParty} from '../src/comp_using_3rdp';
import {ComponentUsingFlatModule} from '../src/comp_using_flat_module';
import {MainModule} from '../src/module';
import {CompUsingLibModuleDirectiveAndPipe, CompUsingRootModuleDirectiveAndPipe, SOME_TOKEN, ServiceUsingLibModule, SomeLibModule, SomeService} from '../src/module_fixtures';
import {CompUsingLibModuleDirectiveAndPipe, CompUsingRootModuleDirectiveAndPipe, ServiceUsingLibModule, SOME_TOKEN, SomeLibModule, SomeService} from '../src/module_fixtures';
import {createComponent, createModule} from './util';

View File

@ -19,7 +19,6 @@ describe('child queries', () => {
debugElement.query(By.directive(CompWithChildQuery));
expect(childQueryCompFixture.componentInstance.child).toBeDefined();
expect(childQueryCompFixture.componentInstance.child instanceof CompForChildQuery).toBe(true);
});
it('should support compiling children queries', () => {

View File

@ -31,7 +31,7 @@ function getSourcePositionForStack(stack: string): {source: string, line: number
const htmlLocations = stack
.split('\n')
// e.g. at View_MyComp_0 (...html:153:40)
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line) !)
.map(line => /\((.*\.html):(\d+):(\d+)/.exec(line)!)
.filter(match => !!match)
.map(match => ({
source: match[1],

View File

@ -22,10 +22,15 @@ import {createProgram, readConfiguration} from '@angular/compiler-cli';
* properly read and wrote.
*/
function main() {
Promise.resolve().then(() => lazyRoutesTest()).then(() => { process.exit(0); }).catch((err) => {
console.error(err.stack);
process.exit(1);
});
Promise.resolve()
.then(() => lazyRoutesTest())
.then(() => {
process.exit(0);
})
.catch((err) => {
console.error(err.stack);
process.exit(1);
});
}
function lazyRoutesTest() {
@ -36,7 +41,8 @@ function lazyRoutesTest() {
const host = ts.createCompilerHost(config.options, true);
const program = createProgram({
rootNames: config.rootNames,
options: config.options, host,
options: config.options,
host,
});
config.options.basePath = basePath;

View File

@ -13,7 +13,7 @@ import {platformServerTesting} from '@angular/platform-server/testing';
import {MainModule} from '../src/module';
import {MainModuleNgFactory} from '../src/module.ngfactory';
let mainModuleRef: NgModuleRef<MainModule> = null !;
let mainModuleRef: NgModuleRef<MainModule> = null!;
beforeEach((done) => {
platformServerTesting().bootstrapModuleFactory(MainModuleNgFactory).then((moduleRef: any) => {
mainModuleRef = moduleRef;