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

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

PR Close #36520
This commit is contained in:
Alex Rickabaugh
2020-04-08 10:14:18 -07:00
committed by atscott
parent 0a69a2832b
commit 83a9159063
193 changed files with 5904 additions and 4574 deletions

View File

@ -31,8 +31,12 @@ export class AST {
* Absolute location of the expression AST in a source code file.
*/
public sourceSpan: AbsoluteSourceSpan) {}
visit(visitor: AstVisitor, context: any = null): any { return null; }
toString(): string { return 'AST'; }
visit(visitor: AstVisitor, context: any = null): any {
return null;
}
toString(): string {
return 'AST';
}
}
/**
@ -54,8 +58,12 @@ export class Quote extends AST {
public uninterpretedExpression: string, public location: any) {
super(span, sourceSpan);
}
visit(visitor: AstVisitor, context: any = null): any { return visitor.visitQuote(this, context); }
toString(): string { return 'Quote'; }
visit(visitor: AstVisitor, context: any = null): any {
return visitor.visitQuote(this, context);
}
toString(): string {
return 'Quote';
}
}
export class EmptyExpr extends AST {
@ -77,7 +85,9 @@ export class Chain extends AST {
constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, public expressions: any[]) {
super(span, sourceSpan);
}
visit(visitor: AstVisitor, context: any = null): any { return visitor.visitChain(this, context); }
visit(visitor: AstVisitor, context: any = null): any {
return visitor.visitChain(this, context);
}
}
export class Conditional extends AST {
@ -148,7 +158,9 @@ export class BindingPipe extends AST {
public args: any[], public nameSpan: AbsoluteSourceSpan) {
super(span, sourceSpan);
}
visit(visitor: AstVisitor, context: any = null): any { return visitor.visitPipe(this, context); }
visit(visitor: AstVisitor, context: any = null): any {
return visitor.visitPipe(this, context);
}
}
export class LiteralPrimitive extends AST {
@ -280,7 +292,9 @@ export class ASTWithSource extends AST {
}
return this.ast.visit(visitor, context);
}
toString(): string { return `${this.source} in ${this.location}`; }
toString(): string {
return `${this.source} in ${this.location}`;
}
}
/**
@ -302,7 +316,7 @@ export class ASTWithSource extends AST {
* the LHS of a HTML attribute to the expression in the RHS. All other bindings
* in the example above are derived solely from the RHS.
*/
export type TemplateBinding = VariableBinding | ExpressionBinding;
export type TemplateBinding = VariableBinding|ExpressionBinding;
export class VariableBinding {
/**
@ -379,7 +393,9 @@ export class RecursiveAstVisitor implements AstVisitor {
this.visit(ast.left, context);
this.visit(ast.right, context);
}
visitChain(ast: Chain, context: any): any { this.visitAll(ast.expressions, context); }
visitChain(ast: Chain, context: any): any {
this.visitAll(ast.expressions, context);
}
visitConditional(ast: Conditional, context: any): any {
this.visit(ast.condition, context);
this.visit(ast.trueExp, context);
@ -411,15 +427,23 @@ export class RecursiveAstVisitor implements AstVisitor {
visitLiteralArray(ast: LiteralArray, context: any): any {
this.visitAll(ast.expressions, context);
}
visitLiteralMap(ast: LiteralMap, context: any): any { this.visitAll(ast.values, context); }
visitLiteralMap(ast: LiteralMap, context: any): any {
this.visitAll(ast.values, context);
}
visitLiteralPrimitive(ast: LiteralPrimitive, context: any): any {}
visitMethodCall(ast: MethodCall, context: any): any {
this.visit(ast.receiver, context);
this.visitAll(ast.args, context);
}
visitPrefixNot(ast: PrefixNot, context: any): any { this.visit(ast.expression, context); }
visitNonNullAssert(ast: NonNullAssert, context: any): any { this.visit(ast.expression, context); }
visitPropertyRead(ast: PropertyRead, context: any): any { this.visit(ast.receiver, context); }
visitPrefixNot(ast: PrefixNot, context: any): any {
this.visit(ast.expression, context);
}
visitNonNullAssert(ast: NonNullAssert, context: any): any {
this.visit(ast.expression, context);
}
visitPropertyRead(ast: PropertyRead, context: any): any {
this.visit(ast.receiver, context);
}
visitPropertyWrite(ast: PropertyWrite, context: any): any {
this.visit(ast.receiver, context);
this.visit(ast.value, context);
@ -441,7 +465,9 @@ export class RecursiveAstVisitor implements AstVisitor {
}
export class AstTransformer implements AstVisitor {
visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST { return ast; }
visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST {
return ast;
}
visitInterpolation(ast: Interpolation, context: any): AST {
return new Interpolation(ast.span, ast.sourceSpan, ast.strings, this.visitAll(ast.expressions));
@ -476,7 +502,7 @@ export class AstTransformer implements AstVisitor {
visitFunctionCall(ast: FunctionCall, context: any): AST {
return new FunctionCall(
ast.span, ast.sourceSpan, ast.target !.visit(this), this.visitAll(ast.args));
ast.span, ast.sourceSpan, ast.target!.visit(this), this.visitAll(ast.args));
}
visitLiteralArray(ast: LiteralArray, context: any): AST {
@ -542,7 +568,9 @@ export class AstTransformer implements AstVisitor {
// A transformer that only creates new nodes if the transformer makes a change or
// a change is made a child node.
export class AstMemoryEfficientTransformer implements AstVisitor {
visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST { return ast; }
visitImplicitReceiver(ast: ImplicitReceiver, context: any): AST {
return ast;
}
visitInterpolation(ast: Interpolation, context: any): Interpolation {
const expressions = this.visitAll(ast.expressions);
@ -551,7 +579,9 @@ export class AstMemoryEfficientTransformer implements AstVisitor {
return ast;
}
visitLiteralPrimitive(ast: LiteralPrimitive, context: any): AST { return ast; }
visitLiteralPrimitive(ast: LiteralPrimitive, context: any): AST {
return ast;
}
visitPropertyRead(ast: PropertyRead, context: any): AST {
const receiver = ast.receiver.visit(this);
@ -704,7 +734,9 @@ export class AstMemoryEfficientTransformer implements AstVisitor {
return ast;
}
visitQuote(ast: Quote, context: any): AST { return ast; }
visitQuote(ast: Quote, context: any): AST {
return ast;
}
}
// Bindings

View File

@ -42,37 +42,61 @@ export class Token {
return this.type == TokenType.Character && this.numValue == code;
}
isNumber(): boolean { return this.type == TokenType.Number; }
isNumber(): boolean {
return this.type == TokenType.Number;
}
isString(): boolean { return this.type == TokenType.String; }
isString(): boolean {
return this.type == TokenType.String;
}
isOperator(operator: string): boolean {
return this.type == TokenType.Operator && this.strValue == operator;
}
isIdentifier(): boolean { return this.type == TokenType.Identifier; }
isIdentifier(): boolean {
return this.type == TokenType.Identifier;
}
isKeyword(): boolean { return this.type == TokenType.Keyword; }
isKeyword(): boolean {
return this.type == TokenType.Keyword;
}
isKeywordLet(): boolean { return this.type == TokenType.Keyword && this.strValue == 'let'; }
isKeywordLet(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'let';
}
isKeywordAs(): boolean { return this.type == TokenType.Keyword && this.strValue == 'as'; }
isKeywordAs(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'as';
}
isKeywordNull(): boolean { return this.type == TokenType.Keyword && this.strValue == 'null'; }
isKeywordNull(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'null';
}
isKeywordUndefined(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'undefined';
}
isKeywordTrue(): boolean { return this.type == TokenType.Keyword && this.strValue == 'true'; }
isKeywordTrue(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'true';
}
isKeywordFalse(): boolean { return this.type == TokenType.Keyword && this.strValue == 'false'; }
isKeywordFalse(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'false';
}
isKeywordThis(): boolean { return this.type == TokenType.Keyword && this.strValue == 'this'; }
isKeywordThis(): boolean {
return this.type == TokenType.Keyword && this.strValue == 'this';
}
isError(): boolean { return this.type == TokenType.Error; }
isError(): boolean {
return this.type == TokenType.Error;
}
toNumber(): number { return this.type == TokenType.Number ? this.numValue : -1; }
toNumber(): number {
return this.type == TokenType.Number ? this.numValue : -1;
}
toString(): string|null {
switch (this.type) {

View File

@ -10,8 +10,8 @@ import * as chars from '../chars';
import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../ml_parser/interpolation_config';
import {escapeRegExp} from '../util';
import {AST, ASTWithSource, AbsoluteSourceSpan, AstVisitor, Binary, BindingPipe, Chain, Conditional, EmptyExpr, ExpressionBinding, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralMapKey, LiteralPrimitive, MethodCall, NonNullAssert, ParseSpan, ParserError, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding, TemplateBindingIdentifier, VariableBinding} from './ast';
import {EOF, Lexer, Token, TokenType, isIdentifier, isQuote} from './lexer';
import {AbsoluteSourceSpan, AST, AstVisitor, ASTWithSource, Binary, BindingPipe, Chain, Conditional, EmptyExpr, ExpressionBinding, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralMapKey, LiteralPrimitive, MethodCall, NonNullAssert, ParserError, ParseSpan, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, TemplateBinding, TemplateBindingIdentifier, VariableBinding} from './ast';
import {EOF, isIdentifier, isQuote, Lexer, Token, TokenType} from './lexer';
export class SplitInterpolation {
constructor(public strings: string[], public expressions: string[], public offsets: number[]) {}
@ -253,7 +253,8 @@ export class Parser {
const parts = input.split(regexp);
if (parts.length > 1) {
this._reportError(
`Got interpolation (${interpolationConfig.start}${interpolationConfig.end}) where expression was expected`,
`Got interpolation (${interpolationConfig.start}${
interpolationConfig.end}) where expression was expected`,
input,
`at column ${this._findInterpolationErrorColumn(parts, 1, interpolationConfig)} in`,
location);
@ -300,7 +301,9 @@ export class _ParseAST {
return i < this.tokens.length ? this.tokens[i] : EOF;
}
get next(): Token { return this.peek(0); }
get next(): Token {
return this.peek(0);
}
get inputIndex(): number {
return (this.index < this.tokens.length) ? this.next.index + this.offset :
@ -310,7 +313,9 @@ export class _ParseAST {
/**
* Returns the absolute offset of the start of the current token.
*/
get currentAbsoluteOffset(): number { return this.absoluteOffset + this.inputIndex; }
get currentAbsoluteOffset(): number {
return this.absoluteOffset + this.inputIndex;
}
span(start: number) {
// `end` is either the
@ -326,10 +331,12 @@ export class _ParseAST {
if (!this.sourceSpanCache.has(serial)) {
this.sourceSpanCache.set(serial, this.span(start).toAbsolute(this.absoluteOffset));
}
return this.sourceSpanCache.get(serial) !;
return this.sourceSpanCache.get(serial)!;
}
advance() { this.index++; }
advance() {
this.index++;
}
consumeOptionalCharacter(code: number): boolean {
if (this.next.isCharacter(code)) {
@ -340,8 +347,12 @@ export class _ParseAST {
}
}
peekKeywordLet(): boolean { return this.next.isKeywordLet(); }
peekKeywordAs(): boolean { return this.next.isKeywordAs(); }
peekKeywordLet(): boolean {
return this.next.isKeywordLet();
}
peekKeywordAs(): boolean {
return this.next.isKeywordAs();
}
expectCharacter(code: number) {
if (this.consumeOptionalCharacter(code)) return;
@ -428,7 +439,9 @@ export class _ParseAST {
return result;
}
parseExpression(): AST { return this.parseConditional(); }
parseExpression(): AST {
return this.parseConditional();
}
parseConditional(): AST {
const start = this.inputIndex;
@ -984,8 +997,8 @@ export class _ParseAST {
(this.rbracesExpected <= 0 || !n.isCharacter(chars.$RBRACE)) &&
(this.rbracketsExpected <= 0 || !n.isCharacter(chars.$RBRACKET))) {
if (this.next.isError()) {
this.errors.push(new ParserError(
this.next.toString() !, this.input, this.locationText(), this.location));
this.errors.push(
new ParserError(this.next.toString()!, this.input, this.locationText(), this.location));
}
this.advance();
n = this.next;
@ -1014,9 +1027,13 @@ class SimpleExpressionChecker implements AstVisitor {
visitFunctionCall(ast: FunctionCall, context: any) {}
visitLiteralArray(ast: LiteralArray, context: any) { this.visitAll(ast.expressions); }
visitLiteralArray(ast: LiteralArray, context: any) {
this.visitAll(ast.expressions);
}
visitLiteralMap(ast: LiteralMap, context: any) { this.visitAll(ast.values); }
visitLiteralMap(ast: LiteralMap, context: any) {
this.visitAll(ast.values);
}
visitBinary(ast: Binary, context: any) {}
@ -1026,13 +1043,17 @@ class SimpleExpressionChecker implements AstVisitor {
visitConditional(ast: Conditional, context: any) {}
visitPipe(ast: BindingPipe, context: any) { this.errors.push('pipes'); }
visitPipe(ast: BindingPipe, context: any) {
this.errors.push('pipes');
}
visitKeyedRead(ast: KeyedRead, context: any) {}
visitKeyedWrite(ast: KeyedWrite, context: any) {}
visitAll(asts: any[]): any[] { return asts.map(node => node.visit(this)); }
visitAll(asts: any[]): any[] {
return asts.map(node => node.visit(this));
}
visitChain(ast: Chain, context: any) {}
@ -1052,5 +1073,7 @@ class IvySimpleExpressionChecker extends SimpleExpressionChecker {
ast.right.visit(this);
}
visitPrefixNot(ast: PrefixNot, context: any) { ast.expression.visit(this); }
visitPrefixNot(ast: PrefixNot, context: any) {
ast.expression.visit(this);
}
}