build: reformat repo to new clang@1.4.0 (#36613)

PR Close #36613
This commit is contained in:
Joey Perrott
2020-04-13 16:40:21 -07:00
committed by atscott
parent 5e80e7e216
commit 698b0288be
1160 changed files with 31667 additions and 24000 deletions

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ export class HttpHeaders {
* Internal map of lowercase header names to values.
*/
// TODO(issue/24571): remove '!'.
private headers !: Map<string, string[]>;
private headers!: Map<string, string[]>;
/**
@ -36,7 +36,7 @@ export class HttpHeaders {
/**
* Complete the lazy initialization of this object (needed before reading).
*/
private lazyInit !: HttpHeaders | Function | null;
private lazyInit!: HttpHeaders|Function|null;
/**
* Queued updates to be materialized the next initialization.
@ -59,7 +59,7 @@ export class HttpHeaders {
const value = line.slice(index + 1).trim();
this.maybeSetNormalizedName(name, key);
if (this.headers.has(key)) {
this.headers.get(key) !.push(value);
this.headers.get(key)!.push(value);
} else {
this.headers.set(key, [value]);
}
@ -169,7 +169,7 @@ export class HttpHeaders {
*
* @returns A clone of the HTTP headers object with the given value deleted.
*/
delete (name: string, value?: string|string[]): HttpHeaders {
delete(name: string, value?: string|string[]): HttpHeaders {
return this.clone({name, value, op: 'd'});
}
@ -197,8 +197,8 @@ export class HttpHeaders {
private copyFrom(other: HttpHeaders) {
other.init();
Array.from(other.headers.keys()).forEach(key => {
this.headers.set(key, other.headers.get(key) !);
this.normalizedNames.set(key, other.normalizedNames.get(key) !);
this.headers.set(key, other.headers.get(key)!);
this.normalizedNames.set(key, other.normalizedNames.get(key)!);
});
}
@ -215,7 +215,7 @@ export class HttpHeaders {
switch (update.op) {
case 'a':
case 's':
let value = update.value !;
let value = update.value!;
if (typeof value === 'string') {
value = [value];
}
@ -255,6 +255,6 @@ export class HttpHeaders {
forEach(fn: (name: string, values: string[]) => void) {
this.init();
Array.from(this.normalizedNames.keys())
.forEach(key => fn(this.normalizedNames.get(key) !, this.headers.get(key) !));
.forEach(key => fn(this.normalizedNames.get(key)!, this.headers.get(key)!));
}
}

View File

@ -38,8 +38,8 @@ import {HttpEvent} from './response';
* To use the same instance of `HttpInterceptors` for the entire app, import the `HttpClientModule`
* only in your `AppModule`, and add the interceptors to the root application injector .
* If you import `HttpClientModule` multiple times across different modules (for example, in lazy
* loading modules), each import creates a new copy of the `HttpClientModule`, which overwrites the interceptors
* provided in the root module.
* loading modules), each import creates a new copy of the `HttpClientModule`, which overwrites the
* interceptors provided in the root module.
*
*/
export interface HttpInterceptor {

View File

@ -36,7 +36,9 @@ export const JSONP_ERR_WRONG_RESPONSE_TYPE = 'JSONP requests must use Json respo
*
*
*/
export abstract class JsonpCallbackContext { [key: string]: (data: any) => void; }
export abstract class JsonpCallbackContext {
[key: string]: (data: any) => void;
}
/**
* Processes an `HttpRequest` with the JSONP method,
@ -53,7 +55,9 @@ export class JsonpClientBackend implements HttpBackend {
/**
* Get the name of the next callback method, by incrementing the global `nextRequestId`.
*/
private nextCallback(): string { return `ng_jsonp_callback_${nextRequestId++}`; }
private nextCallback(): string {
return `ng_jsonp_callback_${nextRequestId++}`;
}
/**
* Processes a JSONP request and returns an event stream of the results.
@ -157,7 +161,8 @@ export class JsonpClientBackend implements HttpBackend {
observer.next(new HttpResponse({
body,
status: 200,
statusText: 'OK', url,
statusText: 'OK',
url,
}));
// Complete the stream, the response is over.
@ -178,7 +183,8 @@ export class JsonpClientBackend implements HttpBackend {
observer.error(new HttpErrorResponse({
error,
status: 0,
statusText: 'JSONP Error', url,
statusText: 'JSONP Error',
url,
}));
};

View File

@ -52,7 +52,7 @@ export class HttpInterceptingHandler implements HttpHandler {
*
*/
export function interceptingHandler(
backend: HttpBackend, interceptors: HttpInterceptor[] | null = []): HttpHandler {
backend: HttpBackend, interceptors: HttpInterceptor[]|null = []): HttpHandler {
if (!interceptors) {
return backend;
}

View File

@ -37,28 +37,36 @@ export class HttpUrlEncodingCodec implements HttpParameterCodec {
* @param key The key name.
* @returns The encoded key name.
*/
encodeKey(key: string): string { return standardEncoding(key); }
encodeKey(key: string): string {
return standardEncoding(key);
}
/**
* Encodes the value of a URL parameter or query-string.
* @param value The value.
* @returns The encoded value.
*/
encodeValue(value: string): string { return standardEncoding(value); }
encodeValue(value: string): string {
return standardEncoding(value);
}
/**
* Decodes an encoded URL parameter or query-string key.
* @param key The encoded key name.
* @returns The decoded key name.
*/
decodeKey(key: string): string { return decodeURIComponent(key); }
decodeKey(key: string): string {
return decodeURIComponent(key);
}
/**
* Decodes an encoded URL parameter or query-string value.
* @param value The encoded value.
* @returns The decoded value.
*/
decodeValue(value: string) { return decodeURIComponent(value); }
decodeValue(value: string) {
return decodeURIComponent(value);
}
}
@ -97,7 +105,8 @@ interface Update {
op: 'a'|'d'|'s';
}
/** Options used to construct an `HttpParams` instance.
/**
* Options used to construct an `HttpParams` instance.
*
* @publicApi
*/
@ -109,7 +118,7 @@ export interface HttpParamsOptions {
fromString?: string;
/** Object map of the HTTP parameters. Mutually exclusive with `fromString`. */
fromObject?: {[param: string]: string | ReadonlyArray<string>};
fromObject?: {[param: string]: string|ReadonlyArray<string>};
/** Encoding codec used to parse and serialize the parameters. */
encoder?: HttpParameterCodec;
@ -140,7 +149,7 @@ export class HttpParams {
this.map = new Map<string, string[]>();
Object.keys(options.fromObject).forEach(key => {
const value = (options.fromObject as any)[key];
this.map !.set(key, Array.isArray(value) ? value : [value]);
this.map!.set(key, Array.isArray(value) ? value : [value]);
});
} else {
this.map = null;
@ -155,7 +164,7 @@ export class HttpParams {
*/
has(param: string): boolean {
this.init();
return this.map !.has(param);
return this.map!.has(param);
}
/**
@ -166,7 +175,7 @@ export class HttpParams {
*/
get(param: string): string|null {
this.init();
const res = this.map !.get(param);
const res = this.map!.get(param);
return !!res ? res[0] : null;
}
@ -178,7 +187,7 @@ export class HttpParams {
*/
getAll(param: string): string[]|null {
this.init();
return this.map !.get(param) || null;
return this.map!.get(param) || null;
}
/**
@ -187,7 +196,7 @@ export class HttpParams {
*/
keys(): string[] {
this.init();
return Array.from(this.map !.keys());
return Array.from(this.map!.keys());
}
/**
@ -196,7 +205,9 @@ export class HttpParams {
* @param value The new value to add.
* @return A new body with the appended value.
*/
append(param: string, value: string): HttpParams { return this.clone({param, value, op: 'a'}); }
append(param: string, value: string): HttpParams {
return this.clone({param, value, op: 'a'});
}
/**
* Replaces the value for a parameter.
@ -204,7 +215,9 @@ export class HttpParams {
* @param value The new value.
* @return A new body with the new value.
*/
set(param: string, value: string): HttpParams { return this.clone({param, value, op: 's'}); }
set(param: string, value: string): HttpParams {
return this.clone({param, value, op: 's'});
}
/**
* Removes a given value or all values from a parameter.
@ -213,7 +226,9 @@ export class HttpParams {
* @return A new body with the given value removed, or with all values
* removed if no value is specified.
*/
delete (param: string, value?: string): HttpParams { return this.clone({param, value, op: 'd'}); }
delete(param: string, value?: string): HttpParams {
return this.clone({param, value, op: 'd'});
}
/**
* Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
@ -227,7 +242,7 @@ export class HttpParams {
// `a: ['1']` produces `'a=1'`
// `b: []` produces `''`
// `c: ['1', '2']` produces `'c=1&c=2'`
return this.map !.get(key) !.map(value => eKey + '=' + this.encoder.encodeValue(value))
return this.map!.get(key)!.map(value => eKey + '=' + this.encoder.encodeValue(value))
.join('&');
})
// filter out empty values because `b: []` produces `''`
@ -237,7 +252,7 @@ export class HttpParams {
}
private clone(update: Update): HttpParams {
const clone = new HttpParams({ encoder: this.encoder } as HttpParamsOptions);
const clone = new HttpParams({encoder: this.encoder} as HttpParamsOptions);
clone.cloneFrom = this.cloneFrom || this;
clone.updates = (this.updates || []).concat([update]);
return clone;
@ -249,29 +264,29 @@ export class HttpParams {
}
if (this.cloneFrom !== null) {
this.cloneFrom.init();
this.cloneFrom.keys().forEach(key => this.map !.set(key, this.cloneFrom !.map !.get(key) !));
this.updates !.forEach(update => {
this.cloneFrom.keys().forEach(key => this.map!.set(key, this.cloneFrom!.map!.get(key)!));
this.updates!.forEach(update => {
switch (update.op) {
case 'a':
case 's':
const base = (update.op === 'a' ? this.map !.get(update.param) : undefined) || [];
base.push(update.value !);
this.map !.set(update.param, base);
const base = (update.op === 'a' ? this.map!.get(update.param) : undefined) || [];
base.push(update.value!);
this.map!.set(update.param, base);
break;
case 'd':
if (update.value !== undefined) {
let base = this.map !.get(update.param) || [];
let base = this.map!.get(update.param) || [];
const idx = base.indexOf(update.value);
if (idx !== -1) {
base.splice(idx, 1);
}
if (base.length > 0) {
this.map !.set(update.param, base);
this.map!.set(update.param, base);
} else {
this.map !.delete(update.param);
this.map!.delete(update.param);
}
} else {
this.map !.delete(update.param);
this.map!.delete(update.param);
break;
}
}

View File

@ -89,7 +89,7 @@ export class HttpRequest<T> {
* Outgoing headers for this request.
*/
// TODO(issue/24571): remove '!'.
readonly headers !: HttpHeaders;
readonly headers!: HttpHeaders;
/**
* Whether this request should be made in a way that exposes progress events.
@ -121,7 +121,7 @@ export class HttpRequest<T> {
* Outgoing URL parameters.
*/
// TODO(issue/24571): remove '!'.
readonly params !: HttpParams;
readonly params!: HttpParams;
/**
* The outgoing URL with all URL parameters set.
@ -312,7 +312,7 @@ export class HttpRequest<T> {
body?: T|null,
method?: string,
url?: string,
setHeaders?: {[name: string]: string | string[]},
setHeaders?: {[name: string]: string|string[]},
setParams?: {[param: string]: string},
}): HttpRequest<T>;
clone<V>(update: {
@ -324,7 +324,7 @@ export class HttpRequest<T> {
body?: V|null,
method?: string,
url?: string,
setHeaders?: {[name: string]: string | string[]},
setHeaders?: {[name: string]: string|string[]},
setParams?: {[param: string]: string},
}): HttpRequest<V>;
clone(update: {
@ -336,7 +336,7 @@ export class HttpRequest<T> {
body?: any|null,
method?: string,
url?: string,
setHeaders?: {[name: string]: string | string[]},
setHeaders?: {[name: string]: string|string[]},
setParams?: {[param: string]: string};
} = {}): HttpRequest<any> {
// For method, url, and responseType, take the current value unless
@ -368,20 +368,23 @@ export class HttpRequest<T> {
// Set every requested header.
headers =
Object.keys(update.setHeaders)
.reduce((headers, name) => headers.set(name, update.setHeaders ![name]), headers);
.reduce((headers, name) => headers.set(name, update.setHeaders![name]), headers);
}
// Check whether the caller has asked to set params.
if (update.setParams) {
// Set every requested param.
params = Object.keys(update.setParams)
.reduce((params, param) => params.set(param, update.setParams ![param]), params);
.reduce((params, param) => params.set(param, update.setParams![param]), params);
}
// Finally, construct the new HttpRequest using the pieces from above.
return new HttpRequest(
method, url, body, {
params, headers, reportProgress, responseType, withCredentials,
});
return new HttpRequest(method, url, body, {
params,
headers,
reportProgress,
responseType,
withCredentials,
});
}
}

View File

@ -100,7 +100,9 @@ export interface HttpUploadProgressEvent extends HttpProgressEvent {
*
* @publicApi
*/
export interface HttpSentEvent { type: HttpEventType.Sent; }
export interface HttpSentEvent {
type: HttpEventType.Sent;
}
/**
* A user-defined event.
@ -110,7 +112,9 @@ export interface HttpSentEvent { type: HttpEventType.Sent; }
*
* @publicApi
*/
export interface HttpUserEvent<T> { type: HttpEventType.User; }
export interface HttpUserEvent<T> {
type: HttpEventType.User;
}
/**
* An error that represents a failed attempt to JSON.parse text coming back
@ -133,7 +137,7 @@ export interface HttpJsonParseError {
* @publicApi
*/
export type HttpEvent<T> =
HttpSentEvent | HttpHeaderResponse | HttpResponse<T>| HttpProgressEvent | HttpUserEvent<T>;
HttpSentEvent|HttpHeaderResponse|HttpResponse<T>|HttpProgressEvent|HttpUserEvent<T>;
/**
* Base class for both `HttpResponse` and `HttpHeaderResponse`.
@ -172,7 +176,7 @@ export abstract class HttpResponseBase {
* Type of the response, narrowed to either the full response or the header.
*/
// TODO(issue/24571): remove '!'.
readonly type !: HttpEventType.Response | HttpEventType.ResponseHeader;
readonly type!: HttpEventType.Response|HttpEventType.ResponseHeader;
/**
* Super-constructor for all responses.
@ -260,7 +264,11 @@ export class HttpResponse<T> extends HttpResponseBase {
* Construct a new `HttpResponse`.
*/
constructor(init: {
body?: T | null, headers?: HttpHeaders; status?: number; statusText?: string; url?: string;
body?: T|null,
headers?: HttpHeaders;
status?: number;
statusText?: string;
url?: string;
} = {}) {
super(init);
this.body = init.body !== undefined ? init.body : null;
@ -272,10 +280,18 @@ export class HttpResponse<T> extends HttpResponseBase {
clone(update: {headers?: HttpHeaders; status?: number; statusText?: string; url?: string;}):
HttpResponse<T>;
clone<V>(update: {
body?: V | null, headers?: HttpHeaders; status?: number; statusText?: string; url?: string;
body?: V|null,
headers?: HttpHeaders;
status?: number;
statusText?: string;
url?: string;
}): HttpResponse<V>;
clone(update: {
body?: any | null; headers?: HttpHeaders; status?: number; statusText?: string; url?: string;
body?: any|null;
headers?: HttpHeaders;
status?: number;
statusText?: string;
url?: string;
} = {}): HttpResponse<any> {
return new HttpResponse<any>({
body: (update.body !== undefined) ? update.body : this.body,
@ -311,7 +327,11 @@ export class HttpErrorResponse extends HttpResponseBase implements Error {
readonly ok = false;
constructor(init: {
error?: any; headers?: HttpHeaders; status?: number; statusText?: string; url?: string;
error?: any;
headers?: HttpHeaders;
status?: number;
statusText?: string;
url?: string;
}) {
// Initialize with a default status of 0 / Unknown Error.
super(init, 0, 'Unknown Error');
@ -322,8 +342,8 @@ export class HttpErrorResponse extends HttpResponseBase implements Error {
if (this.status >= 200 && this.status < 300) {
this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;
} else {
this.message =
`Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${init.statusText}`;
this.message = `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${
init.statusText}`;
}
this.error = init.error || null;
}

View File

@ -35,7 +35,9 @@ function getResponseUrl(xhr: any): string|null {
*
* @publicApi
*/
export abstract class XhrFactory { abstract build(): XMLHttpRequest; }
export abstract class XhrFactory {
abstract build(): XMLHttpRequest;
}
/**
* A factory for `HttpXhrBackend` that uses the `XMLHttpRequest` browser API.
@ -44,7 +46,9 @@ export abstract class XhrFactory { abstract build(): XMLHttpRequest; }
@Injectable()
export class BrowserXhr implements XhrFactory {
constructor() {}
build(): any { return <any>(new XMLHttpRequest()); }
build(): any {
return <any>(new XMLHttpRequest());
}
}
/**
@ -200,7 +204,7 @@ export class HttpXhrBackend implements HttpBackend {
// Even though the response status was 2xx, this is still an error.
ok = false;
// The parse error contains the text of the body that failed to parse.
body = { error, text: body } as HttpJsonParseError;
body = {error, text: body} as HttpJsonParseError;
}
}
}
@ -318,7 +322,7 @@ export class HttpXhrBackend implements HttpBackend {
}
// Fire the request, and notify the event stream that it was fired.
xhr.send(reqBody !);
xhr.send(reqBody!);
observer.next({type: HttpEventType.Sent});
// This is the return from the Observable function, which is the