Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reformat typescript sources #13373

Merged
merged 22 commits into from
Oct 8, 2016
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions build/gulpfile.hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const gulp = require('gulp');
const filter = require('gulp-filter');
const es = require('event-stream');
const gulptslint = require('gulp-tslint');
const tsfmt = require('typescript-formatter');
const tslint = require('tslint');

const all = [
Expand Down Expand Up @@ -159,6 +160,24 @@ const hygiene = exports.hygiene = (some, options) => {
this.emit('data', file);
});

const formatting = es.map(function (file, cb) {

tsfmt.processString(file.path, file.contents.toString('utf8'), {
verify: true,
tsfmt: true,
// verbose: true
}).then(result => {
if (result.error) {
console.error(result.message);
errorCount++;
}
cb(null, file);

}, err => {
cb(err);
});
});

const tsl = es.through(function(file) {
const configuration = tslint.findConfiguration(null, '.');
const options = { configuration, formatter: 'json', rulesDirectory: 'build/lib/tslint' };
Expand All @@ -183,6 +202,7 @@ const hygiene = exports.hygiene = (some, options) => {
.pipe(filter(copyrightFilter))
.pipe(copyrights)
.pipe(filter(tslintFilter))
.pipe(formatting)
.pipe(tsl)
.pipe(es.through(null, function () {
if (errorCount > 0) {
Expand Down
4 changes: 2 additions & 2 deletions extensions/configuration-editing/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'use strict';

import * as vscode from 'vscode';
import {getLocation} from 'jsonc-parser';
import { getLocation } from 'jsonc-parser';

export function activate(context) {

Expand All @@ -15,7 +15,7 @@ export function activate(context) {

}

function registerKeybindingsCompletions() : vscode.Disposable {
function registerKeybindingsCompletions(): vscode.Disposable {
const commands = vscode.commands.getCommands(true);

return vscode.languages.registerCompletionItemProvider({ pattern: '**/keybindings.json' }, {
Expand Down
4 changes: 2 additions & 2 deletions extensions/css/client/src/colorDecorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import {window, workspace, DecorationOptions, DecorationRenderOptions, Disposable, Range, TextDocument, TextEditor} from 'vscode';
import { window, workspace, DecorationOptions, DecorationRenderOptions, Disposable, Range, TextDocument, TextEditor } from 'vscode';

const MAX_DECORATORS = 500;

Expand All @@ -30,7 +30,7 @@ export function activateColorDecorations(decoratorProvider: (uri: string) => The
let colorsDecorationType = window.createTextEditorDecorationType(decorationType);
disposables.push(colorsDecorationType);

let pendingUpdateRequests : { [key:string]: NodeJS.Timer; } = {};
let pendingUpdateRequests: { [key: string]: NodeJS.Timer; } = {};

// we care about all visible editors
window.visibleTextEditors.forEach(editor => {
Expand Down
6 changes: 3 additions & 3 deletions extensions/css/client/src/cssMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import * as path from 'path';

import {languages, window, commands, ExtensionContext} from 'vscode';
import {LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit, Protocol2Code} from 'vscode-languageclient';
import {activateColorDecorations} from './colorDecorators';
import { languages, window, commands, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, Range, TextEdit, Protocol2Code } from 'vscode-languageclient';
import { activateColorDecorations } from './colorDecorators';

import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
Expand Down
8 changes: 4 additions & 4 deletions extensions/css/server/src/cssServerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
TextDocuments, TextDocument, InitializeParams, InitializeResult, RequestType
} from 'vscode-languageserver';

import {getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, LanguageSettings, LanguageService, Stylesheet} from 'vscode-css-languageservice';
import {getLanguageModelCache} from './languageModelCache';
import { getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, LanguageSettings, LanguageService, Stylesheet } from 'vscode-css-languageservice';
import { getLanguageModelCache } from './languageModelCache';

namespace ColorSymbolRequest {
export const type: RequestType<string, Range[], any> = { get method() { return 'css/colorSymbols'; } };
Expand Down Expand Up @@ -62,7 +62,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
};
});

let languageServices : { [id:string]: LanguageService} = {
let languageServices: { [id: string]: LanguageService } = {
css: getCSSLanguageService(),
scss: getSCSSLanguageService(),
less: getLESSLanguageService()
Expand Down Expand Up @@ -90,7 +90,7 @@ function updateConfiguration(settings: Settings) {
documents.all().forEach(triggerValidation);
}

let pendingValidationRequests : { [uri:string]: NodeJS.Timer } = {};
let pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
const validationDelayMs = 200;

// The content of a text document has changed. This event is emitted
Expand Down
10 changes: 5 additions & 5 deletions extensions/css/server/src/languageModelCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import {TextDocument} from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver';

export interface LanguageModelCache<T> {
get(document: TextDocument): T;
onDocumentRemoved(document: TextDocument): void;
dispose(): void;
}

export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T) : LanguageModelCache<T> {
let languageModels: { [uri:string]: {version:number, languageId: string, cTime: number, languageModel: T}} = {};
export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T): LanguageModelCache<T> {
let languageModels: { [uri: string]: { version: number, languageId: string, cTime: number, languageModel: T } } = {};
let nModels = 0;

let cleanupInterval = void 0;
Expand All @@ -32,7 +32,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
}

return {
get(document: TextDocument) : T {
get(document: TextDocument): T {
let version = document.version;
let languageId = document.languageId;
let languageModelInfo = languageModels[document.uri];
Expand All @@ -41,7 +41,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
return languageModelInfo.languageModel;
}
let languageModel = parse(document);
languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now()};
languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now() };
if (!languageModelInfo) {
nModels++;
}
Expand Down
24 changes: 12 additions & 12 deletions extensions/css/server/src/typings/promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ interface Thenable<R> {
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}

/**
Expand All @@ -45,15 +45,15 @@ interface Promise<T> extends Thenable<T> {
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Promise<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;

/**
* Attaches a callback for only the rejection of the Promise.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
catch(onrejected?: (reason: any) => T | Thenable<T>): Promise<T>;
}

interface PromiseConstructor {
Expand All @@ -63,50 +63,50 @@ interface PromiseConstructor {
* a resolve callback used resolve the promise with a value or the result of another promise,
* and a reject callback used to reject the promise with a provided reason or error.
*/
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;

/**
* Creates a Promise that is resolved with an array of results when all of the provided Promises
* resolve, or rejected when any Promise is rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;
all<T>(values: Array<T | Thenable<T>>): Promise<T[]>;

/**
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
* or rejected.
* @param values An array of Promises.
* @returns A new Promise.
*/
race<T>(values: Array<T | Thenable<T>>): Promise<T>;
race<T>(values: Array<T | Thenable<T>>): Promise<T>;

/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject(reason: any): Promise<void>;
reject(reason: any): Promise<void>;

/**
* Creates a new rejected promise for the provided reason.
* @param reason The reason the promise was rejected.
* @returns A new rejected Promise.
*/
reject<T>(reason: any): Promise<T>;
reject<T>(reason: any): Promise<T>;

/**
* Creates a new resolved promise for the provided value.
* @param value A promise.
* @returns A promise whose internal state matches the provided promise.
*/
resolve<T>(value: T | Thenable<T>): Promise<T>;
resolve<T>(value: T | Thenable<T>): Promise<T>;

/**
* Creates a new resolved promise .
* @returns A resolved promise.
*/
resolve(): Promise<void>;
resolve(): Promise<void>;
}

declare var Promise: PromiseConstructor;
2 changes: 1 addition & 1 deletion extensions/html/client/src/htmlEmptyTagsShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export const EMPTY_ELEMENTS:string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
export const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'];
12 changes: 6 additions & 6 deletions extensions/html/client/src/htmlMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import * as path from 'path';

import {languages, ExtensionContext, IndentAction} from 'vscode';
import {LanguageClient, LanguageClientOptions, ServerOptions, TransportKind} from 'vscode-languageclient';
import {EMPTY_ELEMENTS} from './htmlEmptyTagsShared';
import { languages, ExtensionContext, IndentAction } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient';
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';

import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
Expand Down Expand Up @@ -50,7 +50,7 @@ export function activate(context: ExtensionContext) {

languages.setLanguageConfiguration('html', {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|('(?:[^\\\']*(?:\\.)?)*'?)|[^\s<>={}\[\],]+/,
onEnterRules:[
onEnterRules: [
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
Expand All @@ -65,7 +65,7 @@ export function activate(context: ExtensionContext) {

languages.setLanguageConfiguration('handlebars', {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|('(?:[^\\\']*(?:\\.)?)*'?)|[^\s<>={}\[\],]+/,
onEnterRules:[
onEnterRules: [
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
Expand All @@ -80,7 +80,7 @@ export function activate(context: ExtensionContext) {

languages.setLanguageConfiguration('razor', {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|('(?:[^\\\']*(?:\\.)?)*'?)|[^\s<>={}\[\],]+/,
onEnterRules:[
onEnterRules: [
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>$/i,
Expand Down
6 changes: 3 additions & 3 deletions extensions/html/server/src/htmlServerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import {createConnection, IConnection, TextDocuments, InitializeParams, InitializeResult} from 'vscode-languageserver';
import { createConnection, IConnection, TextDocuments, InitializeParams, InitializeResult } from 'vscode-languageserver';

import {HTMLDocument, getLanguageService, CompletionConfiguration, HTMLFormatConfiguration} from 'vscode-html-languageservice';
import {getLanguageModelCache} from './languageModelCache';
import { HTMLDocument, getLanguageService, CompletionConfiguration, HTMLFormatConfiguration } from 'vscode-html-languageservice';
import { getLanguageModelCache } from './languageModelCache';


import * as nls from 'vscode-nls';
Expand Down
10 changes: 5 additions & 5 deletions extensions/html/server/src/languageModelCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import {TextDocument} from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver';

export interface LanguageModelCache<T> {
get(document: TextDocument): T;
onDocumentRemoved(document: TextDocument): void;
dispose(): void;
}

export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T) : LanguageModelCache<T> {
let languageModels: { [uri:string]: {version:number, languageId: string, cTime: number, languageModel: T}} = {};
export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T): LanguageModelCache<T> {
let languageModels: { [uri: string]: { version: number, languageId: string, cTime: number, languageModel: T } } = {};
let nModels = 0;

let cleanupInterval = void 0;
Expand All @@ -32,7 +32,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
}

return {
get(document: TextDocument) : T {
get(document: TextDocument): T {
let version = document.version;
let languageId = document.languageId;
let languageModelInfo = languageModels[document.uri];
Expand All @@ -41,7 +41,7 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
return languageModelInfo.languageModel;
}
let languageModel = parse(document);
languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now()};
languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now() };
if (!languageModelInfo) {
nModels++;
}
Expand Down
Loading