chore: clang-format master

This commit is contained in:
Tobias Bosch 2016-05-03 18:49:59 -07:00
parent 9485f5a813
commit 0297398f5e
19 changed files with 130 additions and 118 deletions

View File

@ -55,8 +55,7 @@ export class AttrAst implements TemplateAst {
* A binding for an element property (e.g. `[property]="expression"`).
*/
export class BoundElementPropertyAst implements TemplateAst {
constructor(
public name: string, public type: PropertyBindingType,
constructor(public name: string, public type: PropertyBindingType,
public securityContext: SecurityContext, public value: AST, public unit: string,
public sourceSpan: ParseSourceSpan) {}
visit(visitor: TemplateAstVisitor, context: any): any {

View File

@ -131,7 +131,8 @@ function bindAndWriteToRenderer(boundProps: BoundElementPropertyAst[], context:
});
}
function sanitizedValue(boundProp: BoundElementPropertyAst, renderValue: o.Expression): o.Expression {
function sanitizedValue(boundProp: BoundElementPropertyAst,
renderValue: o.Expression): o.Expression {
let enumValue: string;
switch (boundProp.securityContext) {
case SecurityContext.NONE:

View File

@ -57,9 +57,8 @@ export function main() {
expect(registry.getMappedPropName('exotic-unknown')).toEqual('exotic-unknown');
});
it('should return security contexts for elements', () => {
expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL);
});
it('should return security contexts for elements',
() => { expect(registry.securityContext('a', 'href')).toBe(SecurityContext.URL); });
it('should detect properties on namespaced elements',
() => { expect(registry.hasProperty('@svg:g', 'id')).toBeTruthy(); });

View File

@ -8,9 +8,17 @@ import * as path from 'path';
import * as compiler from '@angular/compiler';
import {ViewEncapsulation} from '@angular/core';
import {StaticReflector} from './static_reflector';
import {CompileMetadataResolver, HtmlParser, DirectiveNormalizer, Lexer, Parser,
TemplateParser, DomElementSchemaRegistry, StyleCompiler,
ViewCompiler, TypeScriptEmitter
import {
CompileMetadataResolver,
HtmlParser,
DirectiveNormalizer,
Lexer,
Parser,
TemplateParser,
DomElementSchemaRegistry,
StyleCompiler,
ViewCompiler,
TypeScriptEmitter
} from './compiler_private';
import {Parse5DomAdapter} from '@angular/platform-server';
@ -96,8 +104,7 @@ export class CodeGenerator {
let root = this.ngOptions.basePath;
for (let eachRootDir of this.options.rootDirs || []) {
if (this.ngOptions.trace) {
console.log(
`Check if ${filePath} is under rootDirs element ${eachRootDir}`);
console.log(`Check if ${filePath} is under rootDirs element ${eachRootDir}`);
}
if (path.relative(eachRootDir, filePath).indexOf('.') !== 0) {
root = eachRootDir;
@ -170,7 +177,7 @@ export class CodeGenerator {
new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector),
new compiler.ViewResolver(staticReflector), null, null, staticReflector);
return new CodeGenerator(options, ngOptions, program, compilerHost,
staticReflector, resolver, offlineCompiler, reflectorHost);
return new CodeGenerator(options, ngOptions, program, compilerHost, staticReflector, resolver,
offlineCompiler, reflectorHost);
}
}

View File

@ -25,7 +25,8 @@ export type TemplateParser = _c.TemplateParser;
export var TemplateParser: typeof _c.TemplateParser = _c.TemplateParser;
export type DomElementSchemaRegistry = _c.DomElementSchemaRegistry;
export var DomElementSchemaRegistry: typeof _c.DomElementSchemaRegistry = _c.DomElementSchemaRegistry;
export var DomElementSchemaRegistry: typeof _c.DomElementSchemaRegistry =
_c.DomElementSchemaRegistry;
export type StyleCompiler = _c.StyleCompiler;
export var StyleCompiler: typeof _c.StyleCompiler = _c.StyleCompiler;

View File

@ -9,7 +9,11 @@ import {
import {isBlank} from '@angular/facade/src/lang';
import {ListWrapper} from '@angular/facade/src/collection';
import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler_cli/src/static_reflector';
import {
StaticReflector,
StaticReflectorHost,
StaticSymbol
} from '@angular/compiler_cli/src/static_reflector';
describe('StaticReflector', () => {
let noContext = new StaticSymbol('', '');

View File

@ -16,8 +16,7 @@ export class ViewUtils {
sanitizer: SanitizationService;
private _nextCompTypeId: number = 0;
constructor(
private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string,
constructor(private _renderer: RootRenderer, @Inject(APP_ID) private _appId: string,
sanitizer: SanitizationService) {
this.sanitizer = sanitizer;
}

View File

@ -68,8 +68,8 @@ function declareTests(isJit: boolean) {
let tpl = `<div [attr.onclick]="ctxProp"></div>`;
tcb = tcb.overrideView(SecuredComponent, new ViewMetadata({template: tpl}));
PromiseWrapper.catchError(tcb.createAsync(SecuredComponent), (e) => {
expect(e.message).toContain(
`Template parse errors:\n` + `Binding to event attribute 'onclick' is disallowed ` +
expect(e.message).toContain(`Template parse errors:\n` +
`Binding to event attribute 'onclick' is disallowed ` +
`for security reasons, please use (click)=... `);
async.done();
return null;

View File

@ -4,7 +4,8 @@ import {BaseException} from './facade/exceptions';
import {ListWrapper} from './facade/collection';
// TODO: vsavkin: should reuse segments
export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, commands: any[]): UrlTree {
export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree,
commands: any[]): UrlTree {
if (commands.length === 0) return urlTree;
let normalizedCommands = _normalizeCommands(commands);
@ -13,24 +14,26 @@ export function link(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTr
}
let startingNode = _findStartingNode(normalizedCommands, urlTree, segment, routeTree);
let updated = normalizedCommands.commands.length > 0 ?
_updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) : [];
let updated =
normalizedCommands.commands.length > 0 ?
_updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) :
[];
let newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated);
return new UrlTree(newRoot);
}
function _navigateToRoot(normalizedChange: _NormalizedNavigationCommands): boolean {
return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 && normalizedChange.commands[0] == "/";
return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 &&
normalizedChange.commands[0] == "/";
}
class _NormalizedNavigationCommands {
constructor(public isAbsolute: boolean,
public numberOfDoubleDots: number,
constructor(public isAbsolute: boolean, public numberOfDoubleDots: number,
public commands: any[]) {}
}
function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;''
function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {
if (isString(commands[0]) && commands.length === 1 && commands[0] == "/") {
return new _NormalizedNavigationCommands(true, 0, commands);
}
@ -74,7 +77,8 @@ function _normalizeCommands(commands: any[]): _NormalizedNavigationCommands {;''
return new _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, res);
}
function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree, numberOfDoubleDots: number): UrlSegment {
function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: UrlTree,
numberOfDoubleDots: number): UrlSegment {
let s = segment;
while (s.urlSegments.length === 0) {
s = routeTree.parent(s);
@ -87,11 +91,13 @@ function _findUrlSegment(segment: RouteSegment, routeTree: RouteTree, urlTree: U
return path[path.length - 1 - numberOfDoubleDots];
}
function _findStartingNode(normalizedChange:_NormalizedNavigationCommands, urlTree:UrlTree, segment:RouteSegment, routeTree:RouteTree):TreeNode<UrlSegment> {
function _findStartingNode(normalizedChange: _NormalizedNavigationCommands, urlTree: UrlTree,
segment: RouteSegment, routeTree: RouteTree): TreeNode<UrlSegment> {
if (normalizedChange.isAbsolute) {
return rootNode(urlTree);
} else {
let urlSegment = _findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots);
let urlSegment =
_findUrlSegment(segment, routeTree, urlTree, normalizedChange.numberOfDoubleDots);
return _findMatchingNode(urlSegment, rootNode(urlTree));
}
}
@ -152,7 +158,8 @@ function _update(node: TreeNode<UrlSegment>, commands: any[]): TreeNode<UrlSegme
}
}
function _recurse(urlSegment: UrlSegment, node: TreeNode<UrlSegment>, rest: any[]): TreeNode<UrlSegment> {
function _recurse(urlSegment: UrlSegment, node: TreeNode<UrlSegment>,
rest: any[]): TreeNode<UrlSegment> {
if (rest.length === 0) {
return new TreeNode<UrlSegment>(urlSegment, []);
}

View File

@ -143,8 +143,7 @@ function _matchWithParts(route: RouteMetadata, url: TreeNode<UrlSegment>): _Matc
}
let p = lastSegment.value.parameters;
let parameters =
<{[key: string]: string}>StringMapWrapper.merge(p, positionalParams);
let parameters = <{[key: string]: string}>StringMapWrapper.merge(p, positionalParams);
let axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : [];
return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children,

View File

@ -90,8 +90,8 @@ export class TreeNode<T> {
}
export class UrlSegment {
constructor(public segment: any, public parameters: {[key: string]: any},
public outlet: string) {}
constructor(public segment: any, public parameters: {[key: string]: any}, public outlet: string) {
}
toString(): string {
let outletPrefix = isBlank(this.outlet) ? "" : `${this.outlet}:`;

View File

@ -29,12 +29,7 @@ if (globsIndex < 0) {
args = process.argv.slice(globsIndex + 1);
}
var specFiles =
args.map(function(globstr) {
return glob.sync(globstr, {
cwd: toolsDir
});
})
var specFiles = args.map(function(globstr) { return glob.sync(globstr, {cwd: toolsDir}); })
.reduce(function(specFiles, paths) { return specFiles.concat(paths); }, []);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100;
@ -45,7 +40,5 @@ jrunner.onComplete(function(passed) { process.exit(passed ? 0 : 1); });
jrunner.projectBaseDir = path.resolve(__dirname, '../../');
jrunner.specDir = '';
require('zone.js/dist/jasmine-patch.js');
specFiles.forEach((file) => {
toolsDirRequire(file);
});
specFiles.forEach((file) => { toolsDirRequire(file); });
jrunner.execute();

View File

@ -11,8 +11,7 @@ const OFFLINE_COMPILE = [
'offline_compiler_codegen_typed'
];
function processOutputEmitterCodeGen():
Promise<number> {
function processOutputEmitterCodeGen(): Promise<number> {
return new Promise((resolve, reject) => {
var outDir = 'dist/all/@angular/compiler/test/';
var promises = [];
@ -21,24 +20,21 @@ function processOutputEmitterCodeGen():
var codegen = require('../../all/@angular/compiler/test/' + file + '.js');
if (codegen.emit) {
console.log(` ${file} has changed, regenerating...`);
promises.push(
Promise.resolve(codegen.emit())
promises.push(Promise.resolve(codegen.emit())
.then((code) => { writeFileSync(outDir + file + '.ts', code); }));
}
});
if (promises.length) {
Promise.all(promises)
.then(() => {
var args = [
'--project',
'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json'
];
var args =
['--project', 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json'];
console.log(' compiling changes: tsc ' + args.join(' '));
var tsc = spawn(TSC, args, {stdio: 'pipe'});
tsc.stdout.on('data', (data) => process.stdout.write(data));
tsc.stderr.on('data', (data) => process.stderr.write(data));
tsc.on('close', (code) => code ? reject('Tsc exited with: ' + code) :
resolve(code));
tsc.on('close',
(code) => code ? reject('Tsc exited with: ' + code) : resolve(code));
})
.catch(reportError);
} else {
@ -71,7 +67,13 @@ if (platform == 'node') {
complete: 'Compilation complete. Watching for file changes.',
onChangeCmds: [
processOutputEmitterCodeGen,
['node', 'dist/tools/cjs-jasmine', '--', '{@angular,benchpress}/**/*_spec.js', '@angular/compiler_cli/test/**/*_spec.js']
[
'node',
'dist/tools/cjs-jasmine',
'--',
'{@angular,benchpress}/**/*_spec.js',
'@angular/compiler_cli/test/**/*_spec.js'
]
]
});
} else if (platform == 'browser') {
@ -92,7 +94,8 @@ if (platform == 'node') {
complete: 'Compilation complete. Watching for file changes.',
onChangeCmds: [
// TODO: fix and enable tests for public_api_spec again!
// ['node', 'dist/tools/cjs-jasmine/index-tools', '--', '{metadata,public_api_guard}/**/*{_,.}spec.js']
// ['node', 'dist/tools/cjs-jasmine/index-tools', '--',
// '{metadata,public_api_guard}/**/*{_,.}spec.js']
['node', 'dist/tools/cjs-jasmine/index-tools', '--', 'metadata/**/*{_,.}spec.js']
]
});