refactor(language-service): reformat using clang-format (#36426)

clang-format was recently updated and any PRs that touch files in the
language service will have to reformat all the files.

Instead of changing the formatting in those PRs, this PR formats all
files in language-service package once and for all.

PR Close #36426
This commit is contained in:
Keen Yee Liau
2020-04-03 20:57:39 -07:00
committed by Kara Erickson
parent 1b4df6484e
commit 1140bbc25c
35 changed files with 686 additions and 412 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AST, AbsoluteSourceSpan, AstPath, AttrAst, Attribute, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, Element, ElementAst, EmptyExpr, ExpressionBinding, HtmlAstPath, NAMED_ENTITIES, Node as HtmlAst, NullTemplateVisitor, ParseSpan, ReferenceAst, TagContentType, TemplateBinding, Text, VariableBinding, getHtmlTagDefinition} from '@angular/compiler';
import {AbsoluteSourceSpan, AST, AstPath, AttrAst, Attribute, BoundDirectivePropertyAst, BoundElementPropertyAst, BoundEventAst, BoundTextAst, Element, ElementAst, EmptyExpr, ExpressionBinding, getHtmlTagDefinition, HtmlAstPath, NAMED_ENTITIES, Node as HtmlAst, NullTemplateVisitor, ParseSpan, ReferenceAst, TagContentType, TemplateBinding, Text, VariableBinding} from '@angular/compiler';
import {$$, $_, isAsciiLetter, isDigit} from '@angular/compiler/src/chars';
import {AstResult} from './common';
@ -216,7 +216,8 @@ export function getTemplateCompletions(
const replacementSpan = getBoundedWordSpan(templateInfo, position);
return result.map(entry => {
return {
...entry, replacementSpan,
...entry,
replacementSpan,
};
});
}
@ -331,7 +332,7 @@ function attributeValueCompletions(info: AstResult, htmlPath: HtmlAstPath): ng.C
elemAst = parent;
}
} else if (templatePath.tail instanceof ElementAst) {
refAst = new ReferenceAst(htmlAttr.name, null !, htmlAttr.value, htmlAttr.valueSpan !);
refAst = new ReferenceAst(htmlAttr.name, null!, htmlAttr.value, htmlAttr.valueSpan!);
elemAst = templatePath.tail;
}
if (refAst && elemAst) {
@ -340,7 +341,7 @@ function attributeValueCompletions(info: AstResult, htmlPath: HtmlAstPath): ng.C
} else {
// HtmlAst contains the `Attribute` node, however the corresponding `AttrAst`
// node is missing from the TemplateAst.
const attrAst = new AttrAst(htmlAttr.name, htmlAttr.value, htmlAttr.valueSpan !);
const attrAst = new AttrAst(htmlAttr.name, htmlAttr.value, htmlAttr.valueSpan!);
attrAst.visit(visitor, null);
}
return visitor.results;
@ -434,7 +435,9 @@ class ExpressionVisitor extends NullTemplateVisitor {
super();
}
get results(): ng.CompletionEntry[] { return Array.from(this.completions.values()); }
get results(): ng.CompletionEntry[] {
return Array.from(this.completions.values());
}
visitDirectiveProperty(ast: BoundDirectivePropertyAst): void {
this.processExpressionCompletions(ast.value);
@ -444,7 +447,9 @@ class ExpressionVisitor extends NullTemplateVisitor {
this.processExpressionCompletions(ast.value);
}
visitEvent(ast: BoundEventAst): void { this.processExpressionCompletions(ast.handler); }
visitEvent(ast: BoundEventAst): void {
this.processExpressionCompletions(ast.handler);
}
visitElement(): void {
// no-op for now
@ -577,7 +582,7 @@ class ExpressionVisitor extends NullTemplateVisitor {
}
} else if (binding instanceof ExpressionBinding) {
if (inSpan(this.position, binding.value?.ast.sourceSpan)) {
this.processExpressionCompletions(binding.value !.ast);
this.processExpressionCompletions(binding.value!.ast);
return;
} else if (!binding.value && this.position > binding.key.span.end) {
// No expression is defined for the value of the key expression binding, but the cursor is
@ -637,7 +642,7 @@ function angularAttributes(info: AstResult, elementName: string): AngularAttribu
if (selector.element && selector.element !== elementName) {
continue;
}
const summary = selectorMap.get(selector) !;
const summary = selectorMap.get(selector)!;
const hasTemplateRef = isStructuralDirective(summary.type);
// attributes are listed in (attribute, value) pairs
for (let i = 0; i < selector.attrs.length; i += 2) {