Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Bump clang-format and reformat everything. #775

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"chai": "^2.2.0",
"chai-as-promised": "^6.0.0",
"chai-subset": "^1.3.0",
"clang-format": "=1.0.48",
"clang-format": "=1.1.1",
"depcheck": "^0.6.3",
"fs-extra": "^0.30.0",
"gulp": "^3.9.1",
Expand Down
2 changes: 1 addition & 1 deletion src/analysis-format/analysis-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface Position {
column: number;
}

export type Privacy = 'public' | 'private' | 'protected';
export type Privacy = 'public'|'private'|'protected';

export interface Function extends Feature {
/**
Expand Down
11 changes: 6 additions & 5 deletions src/analysis-format/generate-analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import {Behavior as ResolvedPolymerBehavior} from '../polymer/behavior';

import {Analysis, Attribute, Class, Element, ElementLike, ElementMixin, Event, Function, Method, Namespace, Property, SourceRange} from './analysis-format';

export type ElementOrMixin = ResolvedElement | ResolvedMixin;
export type ElementOrMixin = ResolvedElement|ResolvedMixin;

export type Filter = (feature: Feature | ResolvedFunction) => boolean;
export type Filter = (feature: Feature|ResolvedFunction) => boolean;

interface Members {
elements: Set<ResolvedElement>;
Expand Down Expand Up @@ -148,11 +148,12 @@ const schema = JSON.parse(fs.readFileSync(
export class ValidationError extends Error {
errors: jsonschema.ValidationError[];
constructor(result: jsonschema.ValidatorResult) {
const message = `Unable to validate serialized Polymer analysis. ` +
const message =
`Unable to validate serialized Polymer analysis. ` +
`Got ${result.errors.length} errors: ` +
`${
result.errors.map((err) => ' ' + (err.message || err)).join('\n')
}`;
result.errors.map((err) => ' ' + (err.message || err))
.join('\n')}`;
super(message);
this.errors = result.errors;
}
Expand Down
24 changes: 13 additions & 11 deletions src/core/analysis-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ export class AnalysisContext {
*/
private async _analyze(resolvedUrls: ResolvedUrl[]):
Promise<AnalysisContext> {
const analysisComplete = (async() => {
const analysisComplete = (async () => {
// 1. Load and scan all root documents
const scannedDocumentsOrWarnings =
await Promise.all(resolvedUrls.map(async(url) => {
await Promise.all(resolvedUrls.map(async (url) => {
try {
const scannedResult = await this.scan(url);
this._cache.failedDocuments.delete(url);
Expand All @@ -190,7 +190,7 @@ export class AnalysisContext {
}
}));
const scannedDocuments = scannedDocumentsOrWarnings.filter(
(d) => d != null) as ScannedDocument[];
(d) => d != null) as ScannedDocument[];
// 2. Run per-document resolution
const documents = scannedDocuments.map((d) => this.getDocument(d.url));
// TODO(justinfagnani): instead of the above steps, do:
Expand Down Expand Up @@ -247,7 +247,7 @@ export class AnalysisContext {
const document = new Document(scannedDocument, this, analysisResult);
this._cache.analyzedDocuments.set(resolvedUrl, document);
this._cache.analyzedDocumentPromises.getOrCompute(
resolvedUrl, async() => document);
resolvedUrl, async () => document);

document.resolve();
return document;
Expand Down Expand Up @@ -310,13 +310,14 @@ export class AnalysisContext {
*/
private async _scanLocal(resolvedUrl: ResolvedUrl): Promise<ScannedDocument> {
return this._cache.scannedDocumentPromises.getOrCompute(
resolvedUrl, async() => {
resolvedUrl, async () => {
try {
const parsedDoc = await this._parse(resolvedUrl);
const scannedDocument = await this._scanDocument(parsedDoc);

const imports = scannedDocument.getNestedFeatures().filter(
(e) => e instanceof ScannedImport) as ScannedImport[];
const imports =
scannedDocument.getNestedFeatures().filter(
(e) => e instanceof ScannedImport) as ScannedImport[];

// Update dependency graph
const importUrls = imports.map((i) => this.resolveUrl(i.url));
Expand All @@ -335,10 +336,11 @@ export class AnalysisContext {
*/
async scan(resolvedUrl: ResolvedUrl): Promise<ScannedDocument> {
return this._cache.dependenciesScannedPromises.getOrCompute(
resolvedUrl, async() => {
resolvedUrl, async () => {
const scannedDocument = await this._scanLocal(resolvedUrl);
const imports = scannedDocument.getNestedFeatures().filter(
(e) => e instanceof ScannedImport) as ScannedImport[];
const imports =
scannedDocument.getNestedFeatures().filter(
(e) => e instanceof ScannedImport) as ScannedImport[];

// Scan imports
for (const scannedImport of imports) {
Expand Down Expand Up @@ -453,7 +455,7 @@ export class AnalysisContext {
*/
private async _parse(resolvedUrl: ResolvedUrl): Promise<ParsedDocument> {
return this._cache.parsedDocumentPromises.getOrCompute(
resolvedUrl, async() => {
resolvedUrl, async () => {
const content = await this.load(resolvedUrl);
const extension = path.extname(resolvedUrl).substring(1);
return this._parseContents(extension, content, resolvedUrl);
Expand Down
14 changes: 7 additions & 7 deletions src/core/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ export class Analyzer {
*/
async analyze(urls: string[]): Promise<Analysis> {
const previousAnalysisComplete = this._analysisComplete;
this._analysisComplete = (async() => {
this._analysisComplete = (async () => {
const previousContext = await previousAnalysisComplete;
return await previousContext.analyze(this.brandUserInputUrls(urls));
})();
const context = await this._analysisComplete;
const results = new Map(this.brandUserInputUrls(urls).map(
(url) => [url, context.getDocument(context.resolveUrl(url))] as
[string, Document | Warning]));
[string, Document | Warning]));
return new Analysis(results);
}

async analyzePackage(): Promise<Analysis> {
const previousAnalysisComplete = this._analysisComplete;
let _package: Analysis|null = null;
this._analysisComplete = (async() => {
this._analysisComplete = (async () => {
const previousContext = await previousAnalysisComplete;
if (!previousContext.loader.readDirectory) {
throw new Error(
Expand All @@ -117,7 +117,7 @@ export class Analyzer {

const documentsOrWarnings = new Map(filesWithParsers.map(
(url) => [url, newContext.getDocument(newContext.resolveUrl(url))] as
[string, Document | Warning]));
[string, Document | Warning]));
_package = new Analysis(documentsOrWarnings);
return newContext;
})();
Expand All @@ -136,7 +136,7 @@ export class Analyzer {
*/
async filesChanged(urls: string[]): Promise<void> {
const previousAnalysisComplete = this._analysisComplete;
this._analysisComplete = (async() => {
this._analysisComplete = (async () => {
const previousContext = await previousAnalysisComplete;
return await previousContext.filesChanged(this.brandUserInputUrls(urls));
})();
Expand All @@ -152,7 +152,7 @@ export class Analyzer {
*/
async clearCaches(): Promise<void> {
const previousAnalysisComplete = this._analysisComplete;
this._analysisComplete = (async() => {
this._analysisComplete = (async () => {
const previousContext = await previousAnalysisComplete;
return await previousContext.clearCaches();
})();
Expand All @@ -173,7 +173,7 @@ export class Analyzer {
* it.
*/
_fork(options?: ForkOptions): Analyzer {
const contextPromise = (async() => {
const contextPromise = (async () => {
return options ?
(await this._analysisComplete)._fork(undefined, options) :
(await this._analysisComplete);
Expand Down
2 changes: 1 addition & 1 deletion src/core/async-work-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AsyncWorkCache<K, V> {
if (cachedResult) {
return cachedResult;
}
const promise = (async() => {
const promise = (async () => {
// Make sure we wait and return a Promise before doing any work, so that
// the Promise is cached before control flow enters compute().
await Promise.resolve();
Expand Down
3 changes: 2 additions & 1 deletion src/css/css-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class CssParser implements Parser<ParsedCssDocument> {
contents,
ast,
locationOffset: inlineInfo.locationOffset,
astNode: inlineInfo.astNode, isInline,
astNode: inlineInfo.astNode,
isInline,
});
}
}
32 changes: 15 additions & 17 deletions src/demo/polymer-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ async function main() {
}
};

async function getWarnings(analyzer: Analyzer, localPath: string):
Promise<Warning[]> {
const result =
(await analyzer.analyze([localPath])).getDocument(localPath);
if (result instanceof Document) {
return result.getWarnings({imported: false});
} else if (result !== undefined) {
return [result];
} else {
return [];
}
}
async function getWarnings(
analyzer: Analyzer, localPath: string): Promise<Warning[]> {
const result = (await analyzer.analyze([localPath])).getDocument(localPath);
if (result instanceof Document) {
return result.getWarnings({imported: false});
} else if (result !== undefined) {
return [result];
} else {
return [];
}
}

main()
.catch((err) => {
console.error(err.stack || err.message || err);
process.exit(1);
});
main().catch((err) => {
console.error(err.stack || err.message || err);
process.exit(1);
});
4 changes: 2 additions & 2 deletions src/editor-service/ast-from-source-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {ParsedHtmlDocument} from '../html/html-document';
import {comparePositionAndRange, isPositionInsideRange, SourcePosition} from '../model/model';


export type LocationResult = AttributesSection | AttributeValue | TagName |
EndTag | TextNode | ScriptContents | StyleContents | Comment;
export type LocationResult = AttributesSection|AttributeValue|TagName|EndTag|
TextNode|ScriptContents|StyleContents|Comment;

/** In the tagname of a start tag. */
export interface TagName {
Expand Down
3 changes: 2 additions & 1 deletion src/html/html-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export class HtmlParser implements Parser<ParsedHtmlDocument> {
contents,
ast,
locationOffset: inlineInfo.locationOffset,
astNode: inlineInfo.astNode, isInline,
astNode: inlineInfo.astNode,
isInline,
});
}
}
2 changes: 1 addition & 1 deletion src/html/html-style-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class HtmlStyleScanner implements HtmlScanner {
visit: (visitor: HtmlVisitor) => Promise<void>) {
const features: (ScannedImport|ScannedInlineDocument)[] = [];

const visitor = async(node: ASTNode) => {
const visitor = async (node: ASTNode) => {
if (isStyleNode(node)) {
const tagName = node.nodeName;
if (tagName === 'link') {
Expand Down
6 changes: 4 additions & 2 deletions src/javascript/class-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ class ClassFinder implements Visitor {
warnings.push(new Warning({
code: 'class-extends-annotation-no-id',
message: '@extends annotation with no identifier',
severity: Severity.WARNING, sourceRange,
severity: Severity.WARNING,
sourceRange,
parsedDocument: this._document
}));
} else {
Expand Down Expand Up @@ -645,7 +646,8 @@ export function extractPropertiesFromConstructor(
type,
default: defaultValue,
jsdoc: jsdocAnn,
sourceRange: document.sourceRangeForNode(astNode)!, description,
sourceRange: document.sourceRangeForNode(astNode)!,
description,
privacy: getOrInferPrivacy(name, jsdocAnn),
warnings: [],
readOnly: jsdoc.hasTag(jsdocAnn, 'const'),
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/estraverse-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function traverse(ast: babel.Node, visitor: Visitor): void {
function dispatchVisitMethods(
methods: string[], path: NodePath<babel.Node>, visitor: Visitor): void {
for (const method of methods) {
if (typeof(<any>visitor)[method] === 'function') {
if (typeof (<any>visitor)[method] === 'function') {
const result =
(<any>visitor)[method](path.node, path.parent) as VisitResult;
switch (result) {
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/estree-visitor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as babel from 'babel-types';
import {VisitorOption} from './estraverse-shim';

export type VisitResult = VisitorOption | void | null | undefined;
export type VisitResult = VisitorOption|void|null|undefined;

export interface Visitor {
enter?: (node: babel.Node, parent: babel.Node) => VisitResult;
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/esutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export function closureType(
code: 'no-closure-type',
message: `Unable to determine closure type for expression of type ` +
`${node.type}`,
severity: Severity.WARNING, sourceRange,
severity: Severity.WARNING,
sourceRange,
parsedDocument: document,
});
}
Expand Down
12 changes: 9 additions & 3 deletions src/javascript/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ export class ScannedFunction implements Resolvable {
privacy: Privacy;

constructor(
name: string, description: string, summary: string, privacy: Privacy,
astNode: babel.Node, jsdoc: JsDocAnnotation, sourceRange: SourceRange,
name: string,
description: string,
summary: string,
privacy: Privacy,
astNode: babel.Node,
jsdoc: JsDocAnnotation,
sourceRange: SourceRange,
params?: {name: string, type?: string}[],
returnData?: {type?: string, desc: string}, ) {
returnData?: {type?: string, desc: string},
) {
this.name = name;
this.description = description;
this.summary = summary;
Expand Down
2 changes: 1 addition & 1 deletion src/javascript/javascript-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class JavaScriptDocument extends ParsedDocument<Node, Visitor> {
* Applies all visiting callbacks from `visitors`.
*/
const applyScanners =
(callbackName: string, node: Node, parent: Node | null) => {
(callbackName: string, node: Node, parent: Node|null) => {
for (const visitor of visitors) {
if (_shouldSkip(visitor, callbackName, node.type)) {
continue;
Expand Down
10 changes: 6 additions & 4 deletions src/javascript/javascript-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {Parser} from '../parser/parser';

import {JavaScriptDocument} from './javascript-document';

export type SourceType = 'script' | 'module';
export type SourceType = 'script'|'module';

declare class SyntaxError {
message: string;
Expand Down Expand Up @@ -59,7 +59,8 @@ export class JavaScriptParser implements Parser<JavaScriptDocument> {
contents,
ast: null as any,
locationOffset: inlineInfo.locationOffset,
astNode: inlineInfo.astNode, isInline,
astNode: inlineInfo.astNode,
isInline,
parsedAsSourceType: 'script',
});
throw new WarningCarryingException(
Expand All @@ -71,7 +72,8 @@ export class JavaScriptParser implements Parser<JavaScriptDocument> {
contents,
ast: result.program,
locationOffset: inlineInfo.locationOffset,
astNode: inlineInfo.astNode, isInline,
astNode: inlineInfo.astNode,
isInline,
parsedAsSourceType: result.sourceType,
});
}
Expand All @@ -89,7 +91,7 @@ export type ParseResult = {
type: 'success',
sourceType: SourceType,
program: babel.Program,
} | {
}|{
type: 'failure',
warning: {
sourceRange: SourceRange,
Expand Down
Loading