diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 45d4995aa65..2239597b1f3 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -33,11 +33,11 @@ "task": "tslint", "label": "Run tslint", "problemMatcher": [ - "$tslint4" + "$tslint5" ] }, { - "taskName": "Run tests", + "label": "Run tests", "type": "shell", "command": "./scripts/test.sh", "windows": { @@ -50,7 +50,7 @@ } }, { - "taskName": "Run Dev", + "label": "Run Dev", "type": "shell", "command": "./scripts/code.sh", "windows": { diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 27137a20781..056dc86065e 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -123,7 +123,8 @@ const tslintFilter = [ '!**/node_modules/**', '!extensions/typescript/test/colorize-fixtures/**', '!extensions/vscode-api-tests/testWorkspace/**', - '!extensions/**/*.test.ts' + '!extensions/**/*.test.ts', + '!extensions/html/server/lib/jquery.d.ts' ]; const copyrightHeader = [ @@ -133,17 +134,6 @@ const copyrightHeader = [ ' *--------------------------------------------------------------------------------------------*/' ].join('\n'); -function reportFailures(failures) { - failures.forEach(failure => { - const name = failure.name || failure.fileName; - const position = failure.startPosition; - const line = position.lineAndCharacter ? position.lineAndCharacter.line : position.line; - const character = position.lineAndCharacter ? position.lineAndCharacter.character : position.character; - - console.error(`${name}:${line + 1}:${character + 1}:${failure.failure}`); - }); -} - gulp.task('eslint', () => { return vfs.src(all, { base: '.', follow: true, allowEmpty: true }) .pipe(filter(eslintFilter)) @@ -153,12 +143,12 @@ gulp.task('eslint', () => { }); gulp.task('tslint', () => { - const options = { summarizeFailureOutput: true }; + const options = { emitError: false }; return vfs.src(all, { base: '.', follow: true, allowEmpty: true }) .pipe(filter(tslintFilter)) .pipe(gulptslint({ rulesDirectory: 'build/lib/tslint' })) - .pipe(gulptslint.report(reportFailures, options)); + .pipe(gulptslint.report(options)); }); const hygiene = exports.hygiene = (some, options) => { @@ -219,6 +209,17 @@ const hygiene = exports.hygiene = (some, options) => { cb(err); }); }); + + function reportFailures(failures) { + failures.forEach(failure => { + const name = failure.name || failure.fileName; + const position = failure.startPosition; + const line = position.lineAndCharacter ? position.lineAndCharacter.line : position.line; + const character = position.lineAndCharacter ? position.lineAndCharacter.character : position.character; + + console.error(`${name}:${line + 1}:${character + 1}:${failure.failure}`); + }); + } const tsl = es.through(function (file) { const configuration = tslint.Configuration.findConfiguration(null, '.'); diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 78531a2a0ca..bb04933439a 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -452,7 +452,7 @@ gulp.task('upload-vscode-sourcemaps', ['minify-vscode'], () => { const allConfigDetailsPath = path.join(os.tmpdir(), 'configuration.json'); gulp.task('upload-vscode-configuration', ['generate-vscode-configuration'], () => { const branch = process.env.BUILD_SOURCEBRANCH; - if (!branch.endsWith('/master') && !branch.indexOf('/release/') >= 0) { + if (!branch.endsWith('/master') && !branch.startsWith('release/')) { console.log(`Only runs on master and release branches, not ${branch}`); return; } diff --git a/build/lib/tslint/noUnexternalizedStringsRule.js b/build/lib/tslint/noUnexternalizedStringsRule.js index d1d3c76b8ea..2925f0a0c63 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.js +++ b/build/lib/tslint/noUnexternalizedStringsRule.js @@ -88,10 +88,11 @@ var NoUnexternalizedStringsRuleWalker = /** @class */ (function (_super) { var info = this.findDescribingParent(node); // Ignore strings in import and export nodes. if (info && info.isImport && doubleQuoted) { - this.addFailureAtNode(node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, new Lint.Fix(NoUnexternalizedStringsRuleWalker.ImportFailureMessage, [ - this.createReplacement(node.getStart(), 1, '\''), - this.createReplacement(node.getStart() + text.length - 1, 1, '\''), - ])); + var fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), 1, '\''), + Lint.Replacement.replaceFromTo(node.getStart() + text.length - 1, 1, '\''), + ]; + this.addFailureAtNode(node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, fix); return; } var callInfo = info ? info.callInfo : null; @@ -101,8 +102,9 @@ var NoUnexternalizedStringsRuleWalker = /** @class */ (function (_super) { } if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) { var s = node.getText(); - var replacement = new Lint.Replacement(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")"); - var fix = new Lint.Fix('Unexternalitzed string', [replacement]); + var fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), node.getWidth(), "nls.localize('KEY-" + s.substring(1, s.length - 1) + "', " + s + ")"), + ]; this.addFailure(this.createFailure(node.getStart(), node.getWidth(), "Unexternalized string found: " + node.getText(), fix)); return; } diff --git a/build/lib/tslint/noUnexternalizedStringsRule.ts b/build/lib/tslint/noUnexternalizedStringsRule.ts index 172db4d6b12..7b12df97596 100644 --- a/build/lib/tslint/noUnexternalizedStringsRule.ts +++ b/build/lib/tslint/noUnexternalizedStringsRule.ts @@ -104,13 +104,14 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker { let info = this.findDescribingParent(node); // Ignore strings in import and export nodes. if (info && info.isImport && doubleQuoted) { + const fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), 1, '\''), + Lint.Replacement.replaceFromTo(node.getStart() + text.length - 1, 1, '\''), + ]; this.addFailureAtNode( node, NoUnexternalizedStringsRuleWalker.ImportFailureMessage, - new Lint.Fix(NoUnexternalizedStringsRuleWalker.ImportFailureMessage, [ - this.createReplacement(node.getStart(), 1, '\''), - this.createReplacement(node.getStart() + text.length - 1, 1, '\''), - ]) + fix ); return; } @@ -122,8 +123,9 @@ class NoUnexternalizedStringsRuleWalker extends Lint.RuleWalker { if (doubleQuoted && (!callInfo || callInfo.argIndex === -1 || !this.signatures[functionName])) { const s = node.getText(); - const replacement = new Lint.Replacement(node.getStart(), node.getWidth(), `nls.localize('KEY-${s.substring(1, s.length - 1)}', ${s})`); - const fix = new Lint.Fix('Unexternalitzed string', [replacement]); + const fix = [ + Lint.Replacement.replaceFromTo(node.getStart(), node.getWidth(), `nls.localize('KEY-${s.substring(1, s.length - 1)}', ${s})`), + ]; this.addFailure(this.createFailure(node.getStart(), node.getWidth(), `Unexternalized string found: ${node.getText()}`, fix)); return; } diff --git a/build/tfs/linux/.gitignore b/build/tfs/linux/.gitignore index 0f46fa7086a..5ca5f22fc5a 100644 --- a/build/tfs/linux/.gitignore +++ b/build/tfs/linux/.gitignore @@ -1 +1,2 @@ -pat \ No newline at end of file +pat +*.js \ No newline at end of file diff --git a/build/tfs/linux/frozen-check.ts b/build/tfs/linux/frozen-check.ts new file mode 100644 index 00000000000..489a24dc28a --- /dev/null +++ b/build/tfs/linux/frozen-check.ts @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { DocumentClient } from 'documentdb'; + +interface Config { + id: string; + frozen: boolean; +} + +function createDefaultConfig(quality: string): Config { + return { + id: quality, + frozen: false + }; +} + +function getConfig(quality: string): Promise { + const client = new DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT'], { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); + const collection = 'dbs/builds/colls/config'; + const query = { + query: `SELECT TOP 1 * FROM c WHERE c.id = @quality`, + parameters: [ + { name: '@quality', value: quality } + ] + }; + + return new Promise((c, e) => { + client.queryDocuments(collection, query).toArray((err, results) => { + if (err && err.code !== 409) { return e(err); } + + c(!results || results.length === 0 ? createDefaultConfig(quality) : results[0] as any as Config); + }); + }); +} + +getConfig(process.argv[2]) + .then(c => console.log(c.frozen), e => console.error(e)); \ No newline at end of file diff --git a/build/tfs/linux/release.sh b/build/tfs/linux/release.sh index 958a05f56bd..a89eb5cc41c 100755 --- a/build/tfs/linux/release.sh +++ b/build/tfs/linux/release.sh @@ -55,8 +55,12 @@ step "Publish RPM package" \ # SNAP_FILENAME="$(ls $REPO/.build/linux/snap/$ARCH/ | grep .snap)" # SNAP_PATH="$REPO/.build/linux/snap/$ARCH/$SNAP_FILENAME" +IS_FROZEN="$(node build/tfs/linux/frozen-check.js $VSCODE_QUALITY)" + if [ -z "$VSCODE_QUALITY" ]; then echo "VSCODE_QUALITY is not set, skipping repo package publish" +elif [ "$IS_FROZEN" = "true" ]; then + echo "$VSCODE_QUALITY is frozen, skipping repo package publish" else if [ "$BUILD_SOURCEBRANCH" = "master" ] || [ "$BUILD_SOURCEBRANCH" = "refs/heads/master" ]; then if [[ $BUILD_QUEUEDBY = *"Project Collection Service Accounts"* || $BUILD_QUEUEDBY = *"Microsoft.VisualStudio.Services.TFS"* ]]; then diff --git a/extensions/css/client/tsconfig.json b/extensions/css/client/tsconfig.json index e87d1a805a1..dc12dad6cf0 100644 --- a/extensions/css/client/tsconfig.json +++ b/extensions/css/client/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "commonjs", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5", "es2015.promise" ] diff --git a/extensions/css/language-configuration.json b/extensions/css/language-configuration.json index ae86befcd2a..bd3151ea17e 100644 --- a/extensions/css/language-configuration.json +++ b/extensions/css/language-configuration.json @@ -20,5 +20,11 @@ ["(", ")"], ["\"", "\""], ["'", "'"] - ] -} \ No newline at end of file + ], + "folding": { + "markers": { + "start": "^\\s*\\/\\*\\s*#region\\b\\s*(.*?)\\s*\\*\\/", + "end": "^\\s*\\/\\*\\s*#endregion\\b.*\\*\\/" + } + } +} diff --git a/extensions/css/server/tsconfig.json b/extensions/css/server/tsconfig.json index 8e862f02646..6092871c85b 100644 --- a/extensions/css/server/tsconfig.json +++ b/extensions/css/server/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "commonjs", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5" ] diff --git a/extensions/emmet/src/abbreviationActions.ts b/extensions/emmet/src/abbreviationActions.ts index 0d474f1c3f1..0224594a33e 100644 --- a/extensions/emmet/src/abbreviationActions.ts +++ b/extensions/emmet/src/abbreviationActions.ts @@ -17,8 +17,8 @@ interface ExpandAbbreviationInput { filter?: string; } -export function wrapWithAbbreviation(args) { - if (!validate(false)) { +export function wrapWithAbbreviation(args: any) { + if (!validate(false) || !vscode.window.activeTextEditor) { return; } @@ -50,8 +50,8 @@ export function wrapWithAbbreviation(args) { }); } -export function wrapIndividualLinesWithAbbreviation(args) { - if (!validate(false)) { +export function wrapIndividualLinesWithAbbreviation(args: any) { + if (!validate(false) || !vscode.window.activeTextEditor) { return; } @@ -88,7 +88,7 @@ export function wrapIndividualLinesWithAbbreviation(args) { } -export function expandEmmetAbbreviation(args): Thenable { +export function expandEmmetAbbreviation(args: any): Thenable { const syntax = getSyntaxFromArgs(args); if (!syntax || !validate()) { return fallbackTab(); @@ -179,7 +179,7 @@ export function expandEmmetAbbreviation(args): Thenable { }); } -function fallbackTab(): Thenable { +function fallbackTab(): Thenable | undefined { if (vscode.workspace.getConfiguration('emmet')['triggerExpansionOnTab'] === true) { return vscode.commands.executeCommand('tab'); } @@ -226,7 +226,8 @@ export function isValidLocationForEmmetAbbreviation(currentNode: Node, syntax: s const currentHtmlNode = currentNode; if (currentHtmlNode.close) { - return getInnerRange(currentHtmlNode).contains(position); + const innerRange = getInnerRange(currentHtmlNode); + return !!innerRange && innerRange.contains(position); } return false; @@ -247,7 +248,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex // Snippet to replace at multiple cursors are not the same // `editor.insertSnippet` will have to be called for each instance separately // We will not be able to maintain multiple cursors after snippet insertion - let insertPromises = []; + let insertPromises: Thenable[] = []; if (!insertSameSnippet) { expandAbbrList.forEach((expandAbbrInput: ExpandAbbreviationInput) => { let expandedText = expandAbbr(expandAbbrInput); @@ -278,7 +279,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex /** * Expands abbreviation as detailed in given input. */ -function expandAbbr(input: ExpandAbbreviationInput): string { +function expandAbbr(input: ExpandAbbreviationInput): string | undefined { const helper = getEmmetHelper(); const expandOptions = helper.getExpandOptions(input.syntax, getEmmetConfiguration(input.syntax), input.filter); @@ -322,7 +323,7 @@ function expandAbbr(input: ExpandAbbreviationInput): string { } -function getSyntaxFromArgs(args: any): string { +function getSyntaxFromArgs(args: any): string | undefined { let editor = vscode.window.activeTextEditor; if (!editor) { vscode.window.showInformationMessage('No editor is active.'); diff --git a/extensions/emmet/src/balance.ts b/extensions/emmet/src/balance.ts index 22474be22dd..2d4917994ae 100644 --- a/extensions/emmet/src/balance.ts +++ b/extensions/emmet/src/balance.ts @@ -16,11 +16,10 @@ export function balanceIn() { } function balance(out: boolean) { - let editor = vscode.window.activeTextEditor; - if (!validate(false)) { + if (!validate(false) || !vscode.window.activeTextEditor) { return; } - + const editor = vscode.window.activeTextEditor; let rootNode = parseDocument(editor.document); if (!rootNode) { return; @@ -30,7 +29,7 @@ function balance(out: boolean) { let newSelections: vscode.Selection[] = []; editor.selections.forEach(selection => { let range = getRangeFunction(editor.document, selection, rootNode); - newSelections.push(range ? range : selection); + newSelections.push(range); }); editor.selection = newSelections[0]; @@ -40,7 +39,7 @@ function balance(out: boolean) { function getRangeToBalanceOut(document: vscode.TextDocument, selection: vscode.Selection, rootNode: HtmlNode): vscode.Selection { let nodeToBalance = getNode(rootNode, selection.start); if (!nodeToBalance) { - return; + return selection; } if (!nodeToBalance.close) { return new vscode.Selection(nodeToBalance.start, nodeToBalance.end); @@ -55,13 +54,13 @@ function getRangeToBalanceOut(document: vscode.TextDocument, selection: vscode.S if (outerSelection.contains(selection) && !outerSelection.isEqual(selection)) { return outerSelection; } - return; + return selection; } function getRangeToBalanceIn(document: vscode.TextDocument, selection: vscode.Selection, rootNode: HtmlNode): vscode.Selection { let nodeToBalance = getNode(rootNode, selection.start, true); if (!nodeToBalance) { - return; + return selection; } if (selection.start.isEqual(nodeToBalance.start) @@ -71,7 +70,7 @@ function getRangeToBalanceIn(document: vscode.TextDocument, selection: vscode.Se } if (!nodeToBalance.firstChild) { - return; + return selection; } if (selection.start.isEqual(nodeToBalance.firstChild.start) diff --git a/extensions/emmet/src/bufferStream.ts b/extensions/emmet/src/bufferStream.ts index a7a6cd5a0d2..3ab9d9c2eab 100644 --- a/extensions/emmet/src/bufferStream.ts +++ b/extensions/emmet/src/bufferStream.ts @@ -43,20 +43,16 @@ export class DocumentStreamReader { /** * Creates a new stream instance which is limited to given range for given document - * @param {Position} start - * @param {Position} end - * @return {DocumentStreamReader} */ - limit(start, end) { + limit(start: Position, end: Position): DocumentStreamReader { return new DocumentStreamReader(this.document, start, new Range(start, end)); } /** * Returns the next character code in the stream without advancing it. * Will return NaN at the end of the file. - * @returns {Number} */ - peek() { + peek(): number { if (this.eof()) { return NaN; } @@ -67,9 +63,8 @@ export class DocumentStreamReader { /** * Returns the next character in the stream and advances it. * Also returns NaN when no more characters are available. - * @returns {Number} */ - next() { + next(): number { if (this.eof()) { return NaN; } @@ -95,9 +90,8 @@ export class DocumentStreamReader { /** * Backs up the stream n characters. Backing it up further than the * start of the current token will cause things to break, so be careful. - * @param {Number} n */ - backUp(n) { + backUp(n: number) { let row = this.pos.line; let column = this.pos.character; column -= (n || 1); @@ -117,28 +111,22 @@ export class DocumentStreamReader { /** * Get the string between the start of the current token and the * current stream position. - * @returns {String} */ - current() { + current(): string { return this.substring(this.start, this.pos); } /** * Returns contents for given range - * @param {Position} from - * @param {Position} to - * @return {String} */ - substring(from, to) { + substring(from: Position, to: Position): string { return this.document.getText(new Range(from, to)); } /** * Creates error object with current stream state - * @param {String} message - * @return {Error} */ - error(message) { + error(message: string): Error { const err = new Error(`${message} at row ${this.pos.line}, column ${this.pos.character}`); return err; @@ -146,10 +134,8 @@ export class DocumentStreamReader { /** * Returns line length of given row, including line ending - * @param {Number} row - * @return {Number} */ - _lineLength(row) { + _lineLength(row: number): number { if (row === this.document.lineCount - 1) { return this.document.lineAt(row).text.length; } @@ -161,10 +147,8 @@ export class DocumentStreamReader { * and returns a boolean. If the next character in the stream 'matches' * the given argument, it is consumed and returned. * Otherwise, `false` is returned. - * @param {Number|Function} match - * @returns {Boolean} */ - eat(match) { + eat(match: number | Function): boolean { const ch = this.peek(); const ok = typeof match === 'function' ? match(ch) : ch === match; @@ -178,10 +162,8 @@ export class DocumentStreamReader { /** * Repeatedly calls eat with the given argument, until it * fails. Returns true if any characters were eaten. - * @param {Object} match - * @returns {Boolean} */ - eatWhile(match) { + eatWhile(match: number | Function): boolean { const start = this.pos; while (!this.eof() && this.eat(match)) { } return !this.pos.isEqual(start); diff --git a/extensions/emmet/src/defaultCompletionProvider.ts b/extensions/emmet/src/defaultCompletionProvider.ts index 1c825fc21c3..ad6f548bd9f 100644 --- a/extensions/emmet/src/defaultCompletionProvider.ts +++ b/extensions/emmet/src/defaultCompletionProvider.ts @@ -12,7 +12,7 @@ const allowedMimeTypesInScriptTag = ['text/html', 'text/plain', 'text/x-template export class DefaultCompletionItemProvider implements vscode.CompletionItemProvider { - public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable { + public provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Thenable | undefined { const mappedLanguages = getMappingForIncludedLanguages(); const emmetConfig = vscode.workspace.getConfiguration('emmet'); @@ -45,8 +45,8 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi if (abbreviation.startsWith('this.')) { noiseCheckPromise = Promise.resolve(true); } else { - noiseCheckPromise = vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider', document.uri).then((symbols: vscode.SymbolInformation[]) => { - return symbols.find(x => abbreviation === x.name || (abbreviation.startsWith(x.name + '.') && !/>|\*|\+/.test(abbreviation))); + noiseCheckPromise = vscode.commands.executeCommand('vscode.executeDocumentSymbolProvider', document.uri).then((symbols: vscode.SymbolInformation[] | undefined) => { + return symbols && symbols.find(x => abbreviation === x.name || (abbreviation.startsWith(x.name + '.') && !/>|\*|\+/.test(abbreviation))); }); } } @@ -88,7 +88,7 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi * @param document vscode.Textdocument * @param position vscode.Position position of the abbreviation that needs to be expanded */ - private syntaxHelper(syntax: string, document: vscode.TextDocument, position: vscode.Position): string { + private syntaxHelper(syntax: string | undefined, document: vscode.TextDocument, position: vscode.Position): string | undefined { if (!syntax) { return syntax; } diff --git a/extensions/emmet/src/editPoint.ts b/extensions/emmet/src/editPoint.ts index 2028d3295b3..afd73a4ddcb 100644 --- a/extensions/emmet/src/editPoint.ts +++ b/extensions/emmet/src/editPoint.ts @@ -7,40 +7,42 @@ import * as vscode from 'vscode'; import { validate } from './util'; export function fetchEditPoint(direction: string): void { - let editor = vscode.window.activeTextEditor; - if (!validate()) { + if (!validate() || !vscode.window.activeTextEditor) { return; } + const editor = vscode.window.activeTextEditor; let newSelections: vscode.Selection[] = []; editor.selections.forEach(selection => { - let updatedSelection = direction === 'next' ? nextEditPoint(selection.anchor, editor) : prevEditPoint(selection.anchor, editor); - newSelections.push(updatedSelection ? updatedSelection : selection); + let updatedSelection = direction === 'next' ? nextEditPoint(selection, editor) : prevEditPoint(selection, editor); + newSelections.push(updatedSelection); }); editor.selections = newSelections; editor.revealRange(editor.selections[editor.selections.length - 1]); } -function nextEditPoint(position: vscode.Position, editor: vscode.TextEditor): vscode.Selection { - for (let lineNum = position.line; lineNum < editor.document.lineCount; lineNum++) { - let updatedSelection = findEditPoint(lineNum, editor, position, 'next'); +function nextEditPoint(selection: vscode.Selection, editor: vscode.TextEditor): vscode.Selection { + for (let lineNum = selection.anchor.line; lineNum < editor.document.lineCount; lineNum++) { + let updatedSelection = findEditPoint(lineNum, editor, selection.anchor, 'next'); if (updatedSelection) { return updatedSelection; } } + return selection; } -function prevEditPoint(position: vscode.Position, editor: vscode.TextEditor): vscode.Selection { - for (let lineNum = position.line; lineNum >= 0; lineNum--) { - let updatedSelection = findEditPoint(lineNum, editor, position, 'prev'); +function prevEditPoint(selection: vscode.Selection, editor: vscode.TextEditor): vscode.Selection { + for (let lineNum = selection.anchor.line; lineNum >= 0; lineNum--) { + let updatedSelection = findEditPoint(lineNum, editor, selection.anchor, 'prev'); if (updatedSelection) { return updatedSelection; } } + return selection; } -function findEditPoint(lineNum: number, editor: vscode.TextEditor, position: vscode.Position, direction: string): vscode.Selection { +function findEditPoint(lineNum: number, editor: vscode.TextEditor, position: vscode.Position, direction: string): vscode.Selection | undefined { let line = editor.document.lineAt(lineNum); let lineContent = line.text; diff --git a/extensions/emmet/src/evaluateMathExpression.ts b/extensions/emmet/src/evaluateMathExpression.ts index cf7b84d41cc..8a7de6ca423 100644 --- a/extensions/emmet/src/evaluateMathExpression.ts +++ b/extensions/emmet/src/evaluateMathExpression.ts @@ -10,11 +10,11 @@ import evaluate from '@emmetio/math-expression'; import { DocumentStreamReader } from './bufferStream'; export function evaluateMathExpression() { - let editor = vscode.window.activeTextEditor; - if (!editor) { + if (!vscode.window.activeTextEditor) { vscode.window.showInformationMessage('No editor is active'); return; } + const editor = vscode.window.activeTextEditor; const stream = new DocumentStreamReader(editor.document); editor.edit(editBuilder => { editor.selections.forEach(selection => { diff --git a/extensions/emmet/src/imageSizeHelper.ts b/extensions/emmet/src/imageSizeHelper.ts index 2c8f1de5945..1a88f35c110 100644 --- a/extensions/emmet/src/imageSizeHelper.ts +++ b/extensions/emmet/src/imageSizeHelper.ts @@ -19,20 +19,16 @@ const reUrl = /^https?:/; /** * Get size of given image file. Supports files from local filesystem, * as well as URLs - * @param {String} file Path to local file or URL - * @return {Promise} */ -export function getImageSize(file) { +export function getImageSize(file: string) { file = file.replace(/^file:\/\//, ''); return reUrl.test(file) ? getImageSizeFromURL(file) : getImageSizeFromFile(file); } /** * Get image size from file on local file system - * @param {String} file - * @return {Promise} */ -function getImageSizeFromFile(file) { +function getImageSizeFromFile(file: string) { return new Promise((resolve, reject) => { const isDataUrl = file.match(/^data:.+?;base64,/); @@ -46,7 +42,7 @@ function getImageSizeFromFile(file) { } } - sizeOf(file, (err, size) => { + sizeOf(file, (err: any, size: any) => { if (err) { reject(err); } else { @@ -58,15 +54,13 @@ function getImageSizeFromFile(file) { /** * Get image size from given remove URL - * @param {String} url - * @return {Promise} */ -function getImageSizeFromURL(url) { +function getImageSizeFromURL(urlStr: string) { return new Promise((resolve, reject) => { - url = parseUrl(url); + const url = parseUrl(urlStr); const getTransport = url.protocol === 'https:' ? https.get : http.get; - getTransport(url, resp => { + getTransport(url as any, resp => { const chunks = []; let bufSize = 0; @@ -102,11 +96,8 @@ function getImageSizeFromURL(url) { /** * Returns size object for given file name. If file name contains `@Nx` token, * the final dimentions will be downscaled by N - * @param {String} fileName - * @param {Object} size - * @return {Object} */ -function sizeForFileName(fileName, size) { +function sizeForFileName(fileName: string, size: any) { const m = fileName.match(/@(\d+)x\./); const scale = m ? +m[1] : 1; diff --git a/extensions/emmet/src/selectItemHTML.ts b/extensions/emmet/src/selectItemHTML.ts index 1b234e2f349..23647722bcc 100644 --- a/extensions/emmet/src/selectItemHTML.ts +++ b/extensions/emmet/src/selectItemHTML.ts @@ -7,9 +7,9 @@ import * as vscode from 'vscode'; import { getDeepestNode, findNextWord, findPrevWord, getNode } from './util'; import { HtmlNode } from 'EmmetNode'; -export function nextItemHTML(selectionStart: vscode.Position, selectionEnd: vscode.Position, editor: vscode.TextEditor, rootNode: HtmlNode): vscode.Selection { +export function nextItemHTML(selectionStart: vscode.Position, selectionEnd: vscode.Position, editor: vscode.TextEditor, rootNode: HtmlNode): vscode.Selection | undefined { let currentNode = getNode(rootNode, selectionEnd); - let nextNode: HtmlNode; + let nextNode: HtmlNode | undefined = undefined; if (!currentNode) { return; @@ -50,12 +50,12 @@ export function nextItemHTML(selectionStart: vscode.Position, selectionEnd: vsco } } - return getSelectionFromNode(nextNode, editor.document); + return nextNode && getSelectionFromNode(nextNode, editor.document); } -export function prevItemHTML(selectionStart: vscode.Position, selectionEnd: vscode.Position, editor: vscode.TextEditor, rootNode: HtmlNode): vscode.Selection { +export function prevItemHTML(selectionStart: vscode.Position, selectionEnd: vscode.Position, editor: vscode.TextEditor, rootNode: HtmlNode): vscode.Selection | undefined { let currentNode = getNode(rootNode, selectionStart); - let prevNode: HtmlNode; + let prevNode: HtmlNode | undefined = undefined; if (!currentNode) { return; @@ -68,7 +68,7 @@ export function prevItemHTML(selectionStart: vscode.Position, selectionEnd: vsco } else { // Select the child that appears just before the cursor and is not a comment prevNode = currentNode.firstChild; - let oldOption: HtmlNode; + let oldOption: HtmlNode | undefined = undefined; while (prevNode.nextSibling && selectionStart.isAfterOrEqual(prevNode.nextSibling.end)) { if (prevNode && prevNode.type !== 'comment') { oldOption = prevNode; @@ -94,20 +94,25 @@ export function prevItemHTML(selectionStart: vscode.Position, selectionEnd: vsco } + if (!prevNode) { + return undefined; + } + let attrSelection = getPrevAttribute(selectionStart, selectionEnd, editor.document, prevNode); return attrSelection ? attrSelection : getSelectionFromNode(prevNode, editor.document); } -function getSelectionFromNode(node: HtmlNode, document: vscode.TextDocument): vscode.Selection { +function getSelectionFromNode(node: HtmlNode, document: vscode.TextDocument): vscode.Selection | undefined { if (node && node.open) { let selectionStart = (node.open.start).translate(0, 1); let selectionEnd = selectionStart.translate(0, node.name.length); return new vscode.Selection(selectionStart, selectionEnd); } + return undefined; } -function getNextAttribute(selectionStart: vscode.Position, selectionEnd: vscode.Position, document: vscode.TextDocument, node: HtmlNode): vscode.Selection { +function getNextAttribute(selectionStart: vscode.Position, selectionEnd: vscode.Position, document: vscode.TextDocument, node: HtmlNode): vscode.Selection | undefined { if (!node.attributes || node.attributes.length === 0 || node.type === 'comment') { return; @@ -158,7 +163,7 @@ function getNextAttribute(selectionStart: vscode.Position, selectionEnd: vscode. } } -function getPrevAttribute(selectionStart: vscode.Position, selectionEnd: vscode.Position, document: vscode.TextDocument, node: HtmlNode): vscode.Selection { +function getPrevAttribute(selectionStart: vscode.Position, selectionEnd: vscode.Position, document: vscode.TextDocument, node: HtmlNode): vscode.Selection | undefined { if (!node.attributes || node.attributes.length === 0 || node.type === 'comment') { return; diff --git a/extensions/emmet/src/selectItemStylesheet.ts b/extensions/emmet/src/selectItemStylesheet.ts index 09f0d6103a9..367e0320837 100644 --- a/extensions/emmet/src/selectItemStylesheet.ts +++ b/extensions/emmet/src/selectItemStylesheet.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode'; import { getDeepestNode, findNextWord, findPrevWord, getNode } from './util'; import { Node, CssNode, Rule, Property } from 'EmmetNode'; -export function nextItemStylesheet(startOffset: vscode.Position, endOffset: vscode.Position, editor: vscode.TextEditor, rootNode: Node): vscode.Selection { +export function nextItemStylesheet(startOffset: vscode.Position, endOffset: vscode.Position, editor: vscode.TextEditor, rootNode: Node): vscode.Selection | undefined { let currentNode = getNode(rootNode, endOffset, true); if (!currentNode) { currentNode = rootNode; @@ -50,7 +50,7 @@ export function nextItemStylesheet(startOffset: vscode.Position, endOffset: vsco } -export function prevItemStylesheet(startOffset: vscode.Position, endOffset: vscode.Position, editor: vscode.TextEditor, rootNode: CssNode): vscode.Selection { +export function prevItemStylesheet(startOffset: vscode.Position, endOffset: vscode.Position, editor: vscode.TextEditor, rootNode: CssNode): vscode.Selection | undefined { let currentNode = getNode(rootNode, startOffset); if (!currentNode) { currentNode = rootNode; @@ -88,7 +88,7 @@ export function prevItemStylesheet(startOffset: vscode.Position, endOffset: vsco } -function getSelectionFromNode(node: Node, document: vscode.TextDocument): vscode.Selection { +function getSelectionFromNode(node: Node, document: vscode.TextDocument): vscode.Selection | undefined { if (!node) { return; } @@ -98,7 +98,7 @@ function getSelectionFromNode(node: Node, document: vscode.TextDocument): vscode } -function getSelectionFromProperty(node: Node, document: vscode.TextDocument, selectionStart: vscode.Position, selectionEnd: vscode.Position, selectFullValue: boolean, direction: string): vscode.Selection { +function getSelectionFromProperty(node: Node, document: vscode.TextDocument, selectionStart: vscode.Position, selectionEnd: vscode.Position, selectFullValue: boolean, direction: string): vscode.Selection | undefined { if (!node || node.type !== 'property') { return; } diff --git a/extensions/emmet/src/splitJoinTag.ts b/extensions/emmet/src/splitJoinTag.ts index 382bd1841b0..67a403bce29 100644 --- a/extensions/emmet/src/splitJoinTag.ts +++ b/extensions/emmet/src/splitJoinTag.ts @@ -8,11 +8,11 @@ import { HtmlNode } from 'EmmetNode'; import { getNode, parseDocument, validate } from './util'; export function splitJoinTag() { - let editor = vscode.window.activeTextEditor; - if (!validate(false)) { + if (!validate(false) || !vscode.window.activeTextEditor) { return; } + const editor = vscode.window.activeTextEditor; let rootNode = parseDocument(editor.document); if (!rootNode) { return; @@ -20,23 +20,19 @@ export function splitJoinTag() { return editor.edit(editBuilder => { editor.selections.reverse().forEach(selection => { - let textEdit = getRangesToReplace(editor.document, selection, rootNode); - if (textEdit) { + let nodeToUpdate = getNode(rootNode, selection.start); + if (nodeToUpdate) { + let textEdit = getRangesToReplace(editor.document, nodeToUpdate); editBuilder.replace(textEdit.range, textEdit.newText); } }); }); } -function getRangesToReplace(document: vscode.TextDocument, selection: vscode.Selection, rootNode: HtmlNode): vscode.TextEdit { - let nodeToUpdate = getNode(rootNode, selection.start); +function getRangesToReplace(document: vscode.TextDocument, nodeToUpdate: HtmlNode): vscode.TextEdit { let rangeToReplace: vscode.Range; let textToReplaceWith: string; - if (!nodeToUpdate) { - return; - } - if (!nodeToUpdate.close) { // Split Tag let nodeText = document.getText(new vscode.Range(nodeToUpdate.start, nodeToUpdate.end)); diff --git a/extensions/emmet/src/test/abbreviationAction.test.ts b/extensions/emmet/src/test/abbreviationAction.test.ts index 0a43576e2bb..0f599e37b86 100644 --- a/extensions/emmet/src/test/abbreviationAction.test.ts +++ b/extensions/emmet/src/test/abbreviationAction.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection, workspace } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; @@ -221,13 +222,13 @@ m10 .hoo { background: } - } + } ` return withRandomFileEditor(scssContentsNoExpand, 'scss', (editor, doc) => { editor.selections = [ new Selection(1, 3, 1, 3), // outside rule - new Selection(5, 15, 5, 15) // in the value part of property value + new Selection(5, 15, 5, 15) // in the value part of property value ]; return expandEmmetAbbreviation(null).then(() => { assert.equal(editor.document.getText(), scssContentsNoExpand); @@ -344,7 +345,7 @@ suite('Tests for Wrap with Abbreviations', () => { suite('Tests for jsx, xml and xsl', () => { teardown(closeAllEditors); - + test('Expand abbreviation with className instead of class in jsx', () => { return withRandomFileEditor('ul.nav', 'javascriptreact', (editor, doc) => { editor.selection = new Selection(0, 6, 0, 6); diff --git a/extensions/emmet/src/test/editPointSelectItemBalance.test.ts b/extensions/emmet/src/test/editPointSelectItemBalance.test.ts index 427ee166f95..3393fdddc24 100644 --- a/extensions/emmet/src/test/editPointSelectItemBalance.test.ts +++ b/extensions/emmet/src/test/editPointSelectItemBalance.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; diff --git a/extensions/emmet/src/test/incrementDecrement.test.ts b/extensions/emmet/src/test/incrementDecrement.test.ts index a846bc6b782..e1c039dffca 100644 --- a/extensions/emmet/src/test/incrementDecrement.test.ts +++ b/extensions/emmet/src/test/incrementDecrement.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; diff --git a/extensions/emmet/src/test/reflectCssValue.test.ts b/extensions/emmet/src/test/reflectCssValue.test.ts index 228c62ed960..3967503b676 100644 --- a/extensions/emmet/src/test/reflectCssValue.test.ts +++ b/extensions/emmet/src/test/reflectCssValue.test.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; -import { Selection, commands } from 'vscode'; +import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; import { reflectCssValue } from '../reflectCssValue'; diff --git a/extensions/emmet/src/test/tagActions.test.ts b/extensions/emmet/src/test/tagActions.test.ts index 7d13c98fd84..c95bf8064bc 100644 --- a/extensions/emmet/src/test/tagActions.test.ts +++ b/extensions/emmet/src/test/tagActions.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; diff --git a/extensions/emmet/src/test/toggleComment.test.ts b/extensions/emmet/src/test/toggleComment.test.ts index 225fbeb8074..7423a028d4b 100644 --- a/extensions/emmet/src/test/toggleComment.test.ts +++ b/extensions/emmet/src/test/toggleComment.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; diff --git a/extensions/emmet/src/test/updateImageSize.test.ts b/extensions/emmet/src/test/updateImageSize.test.ts index 2fadbe94d58..cc23e3f6651 100644 --- a/extensions/emmet/src/test/updateImageSize.test.ts +++ b/extensions/emmet/src/test/updateImageSize.test.ts @@ -3,15 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import { Selection } from 'vscode'; import { withRandomFileEditor, closeAllEditors } from './testUtils'; import { updateImageSize } from '../updateImageSize'; -import * as path from 'path'; suite('Tests for Emmet actions on html tags', () => { teardown(closeAllEditors); - const filePath = path.join(__dirname, '../../../../resources/linux/code.png'); test('update image css with multiple cursors in css file', () => { const cssContents = ` diff --git a/extensions/emmet/src/toggleComment.ts b/extensions/emmet/src/toggleComment.ts index 1140473881d..e15dbd0c984 100644 --- a/extensions/emmet/src/toggleComment.ts +++ b/extensions/emmet/src/toggleComment.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { getNodesInBetween, getNode, parseDocument, sameNodes, isStyleSheet } from './util'; +import { getNodesInBetween, getNode, parseDocument, sameNodes, isStyleSheet, validate } from './util'; import { Node, Stylesheet, Rule, HtmlNode } from 'EmmetNode'; import parseStylesheet from '@emmetio/css-parser'; import { DocumentStreamReader } from './bufferStream'; @@ -14,14 +14,12 @@ const endCommentStylesheet = '*/'; const startCommentHTML = ''; -export function toggleComment(): Thenable { - let editor = vscode.window.activeTextEditor; - if (!editor) { - vscode.window.showInformationMessage('No editor is active'); +export function toggleComment(): Thenable | undefined { + if (!validate() || !vscode.window.activeTextEditor) { return; } - - let toggleCommentInternal; + const editor = vscode.window.activeTextEditor; + let toggleCommentInternal: (document: vscode.TextDocument, selection: vscode.Selection, rootNode: Node) => vscode.TextEdit[]; if (isStyleSheet(editor.document.languageId)) { toggleCommentInternal = toggleCommentStylesheet; diff --git a/extensions/emmet/src/typings/refs.d.ts b/extensions/emmet/src/typings/refs.d.ts index 0188b6f9ffc..bc057c55878 100644 --- a/extensions/emmet/src/typings/refs.d.ts +++ b/extensions/emmet/src/typings/refs.d.ts @@ -5,4 +5,3 @@ /// /// -/// diff --git a/extensions/emmet/src/updateImageSize.ts b/extensions/emmet/src/updateImageSize.ts index ea57e099e8a..06fbd45a15b 100644 --- a/extensions/emmet/src/updateImageSize.ts +++ b/extensions/emmet/src/updateImageSize.ts @@ -10,7 +10,7 @@ import { TextEditor, Range, Position, window, TextEdit } from 'vscode'; import * as path from 'path'; import { getImageSize } from './imageSizeHelper'; -import { parseDocument, getNode, iterateCSSToken, getCssPropertyFromRule, isStyleSheet } from './util'; +import { parseDocument, getNode, iterateCSSToken, getCssPropertyFromRule, isStyleSheet, validate } from './util'; import { HtmlNode, CssToken, HtmlToken, Attribute, Property } from 'EmmetNode'; import { locateFile } from './locateFile'; import parseStylesheet from '@emmetio/css-parser'; @@ -20,11 +20,10 @@ import { DocumentStreamReader } from './bufferStream'; * Updates size of context image in given editor */ export function updateImageSize() { - let editor = window.activeTextEditor; - if (!editor) { - window.showInformationMessage('No editor is active.'); + if (!validate() || !window.activeTextEditor) { return; } + const editor = window.activeTextEditor; let allUpdatesPromise = editor.selections.reverse().map(selection => { let position = selection.isReversed ? selection.active : selection.anchor; @@ -49,7 +48,7 @@ export function updateImageSize() { /** * Updates image size of context tag of HTML model */ -function updateImageSizeHTML(editor: TextEditor, position: Position): Promise { +function updateImageSizeHTML(editor: TextEditor, position: Position): Promise { const src = getImageSrcHTML(getImageHTMLNode(editor, position)); if (!src) { @@ -70,7 +69,7 @@ function updateImageSizeHTML(editor: TextEditor, position: Position): Promise { - let getPropertyInsiderStyleTag = (editor) => { + const getPropertyInsiderStyleTag = (editor: TextEditor): Property | undefined => { const rootNode = parseDocument(editor.document); const currentNode = getNode(rootNode, position); if (currentNode && currentNode.name === 'style' @@ -79,7 +78,7 @@ function updateImageSizeStyleTag(editor: TextEditor, position: Position): Promis let buffer = new DocumentStreamReader(editor.document, currentNode.open.end, new Range(currentNode.open.end, currentNode.close.start)); let rootNode = parseStylesheet(buffer); const node = getNode(rootNode, position); - return (node && node.type === 'property') ? node : null; + return (node && node.type === 'property') ? node : undefined; } }; @@ -93,7 +92,7 @@ function updateImageSizeCSSFile(editor: TextEditor, position: Position): Promise /** * Updates image size of context rule of stylesheet model */ -function updateImageSizeCSS(editor: TextEditor, position: Position, fetchNode: (editor, position) => Property): Promise { +function updateImageSizeCSS(editor: TextEditor, position: Position, fetchNode: (editor: TextEditor, position: Position) => Property | undefined): Promise { const src = getImageSrcCSS(fetchNode(editor, position), position); @@ -141,10 +140,8 @@ function getImageCSSNode(editor: TextEditor, position: Position): Property { /** * Returns image source from given node - * @param {HtmlNode} node - * @return {string} */ -function getImageSrcHTML(node: HtmlNode): string { +function getImageSrcHTML(node: HtmlNode): string | undefined { const srcAttr = getAttribute(node, 'src'); if (!srcAttr) { return; @@ -155,11 +152,8 @@ function getImageSrcHTML(node: HtmlNode): string { /** * Returns image source from given `url()` token - * @param {Property} node - * @param {Position} - * @return {string} */ -function getImageSrcCSS(node: Property, position: Position): string { +function getImageSrcCSS(node: Property | undefined, position: Position): string | undefined { if (!node) { return; } @@ -213,10 +207,6 @@ function updateHTMLTag(editor: TextEditor, node: HtmlNode, width: number, height /** * Updates size of given CSS rule - * @param {TextEditor} editor - * @param {Property} srcProp - * @param {number} width - * @param {number} height */ function updateCSSNode(editor: TextEditor, srcProp: Property, width: number, height: number): TextEdit[] { const rule = srcProp.parent; @@ -252,36 +242,28 @@ function updateCSSNode(editor: TextEditor, srcProp: Property, width: number, hei /** * Returns attribute object with `attrName` name from given HTML node - * @param {Node} node - * @param {String} attrName - * @return {Object} */ -function getAttribute(node, attrName): Attribute { +function getAttribute(node: HtmlNode, attrName: string): Attribute { attrName = attrName.toLowerCase(); - return node && node.open.attributes.find(attr => attr.name.value.toLowerCase() === attrName); + return node && (node.open as any).attributes.find(attr => attr.name.value.toLowerCase() === attrName); } /** * Returns quote character, used for value of given attribute. May return empty * string if attribute wasn’t quoted - * @param {TextEditor} editor - * @param {Object} attr - * @return {String} + */ -function getAttributeQuote(editor, attr) { +function getAttributeQuote(editor: TextEditor, attr: any): string { const range = new Range(attr.value ? attr.value.end : attr.end, attr.end); return range.isEmpty ? '' : editor.document.getText(range); } /** * Finds 'url' token for given `pos` point in given CSS property `node` - * @param {Node} node - * @param {Position} pos - * @return {Token} */ -function findUrlToken(node, pos: Position) { - for (let i = 0, il = node.parsedValue.length, url; i < il; i++) { - iterateCSSToken(node.parsedValue[i], (token: CssToken) => { +function findUrlToken(node: Property, pos: Position): CssToken | undefined { + for (let i = 0, il = (node as any).parsedValue.length, url; i < il; i++) { + iterateCSSToken((node as any).parsedValue[i], (token: CssToken) => { if (token.type === 'url' && token.start.isBeforeOrEqual(pos) && token.end.isAfterOrEqual(pos)) { url = token; return false; @@ -296,11 +278,8 @@ function findUrlToken(node, pos: Position) { /** * Returns a string that is used to delimit properties in current node’s rule - * @param {TextEditor} editor - * @param {Property} node - * @return {String} */ -function getPropertyDelimitor(editor: TextEditor, node: Property) { +function getPropertyDelimitor(editor: TextEditor, node: Property): string { let anchor; if (anchor = (node.previousSibling || node.parent.contentStartToken)) { return editor.document.getText(new Range(anchor.end, node.start)); diff --git a/extensions/emmet/src/updateTag.ts b/extensions/emmet/src/updateTag.ts index 66a23e074b6..b62f167d70a 100644 --- a/extensions/emmet/src/updateTag.ts +++ b/extensions/emmet/src/updateTag.ts @@ -7,17 +7,17 @@ import * as vscode from 'vscode'; import { HtmlNode } from 'EmmetNode'; import { getNode, parseDocument, validate } from './util'; -export function updateTag(tagName: string): Thenable { - let editor = vscode.window.activeTextEditor; - if (!validate(false)) { +export function updateTag(tagName: string): Thenable | undefined { + if (!validate(false) || !vscode.window.activeTextEditor) { return; } + let editor = vscode.window.activeTextEditor; let rootNode = parseDocument(editor.document); if (!rootNode) { return; } - let rangesToUpdate = []; + let rangesToUpdate: vscode.Range[] = []; editor.selections.reverse().forEach(selection => { rangesToUpdate = rangesToUpdate.concat(getRangesToUpdate(editor, selection, rootNode)); }); diff --git a/extensions/emmet/src/util.ts b/extensions/emmet/src/util.ts index 3903c73190d..450aa136143 100644 --- a/extensions/emmet/src/util.ts +++ b/extensions/emmet/src/util.ts @@ -6,12 +6,12 @@ import * as vscode from 'vscode'; import parse from '@emmetio/html-matcher'; import parseStylesheet from '@emmetio/css-parser'; -import { Node, HtmlNode, CssToken, Property } from 'EmmetNode'; +import { Node, HtmlNode, CssToken, Property, Rule } from 'EmmetNode'; import { DocumentStreamReader } from './bufferStream'; import * as path from 'path'; -let _emmetHelper; -let _currentExtensionsPath = undefined; +let _emmetHelper: any; +let _currentExtensionsPath: string | undefined = undefined; export function getEmmetHelper() { if (!_emmetHelper) { @@ -27,15 +27,15 @@ export function resolveUpdateExtensionsPath() { } let extensionsPath = vscode.workspace.getConfiguration('emmet')['extensionsPath']; if (extensionsPath && !path.isAbsolute(extensionsPath)) { - extensionsPath = path.join(vscode.workspace.rootPath, extensionsPath); + extensionsPath = path.join(vscode.workspace.rootPath || '', extensionsPath); } if (_currentExtensionsPath !== extensionsPath) { _currentExtensionsPath = extensionsPath; - _emmetHelper.updateExtensionsPath(_currentExtensionsPath).then(null, err => vscode.window.showErrorMessage(err)); + _emmetHelper.updateExtensionsPath(_currentExtensionsPath).then(null, (err: string) => vscode.window.showErrorMessage(err)); } } -export const LANGUAGE_MODES: Object = { +export const LANGUAGE_MODES: any = { 'html': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 'jade': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 'slim': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], @@ -62,7 +62,7 @@ export const MAPPED_MODES: Object = { 'php': 'html' }; -export function isStyleSheet(syntax): boolean { +export function isStyleSheet(syntax: string): boolean { let stylesheetSyntaxes = ['css', 'scss', 'sass', 'less', 'stylus']; return (stylesheetSyntaxes.indexOf(syntax) > -1); } @@ -80,7 +80,7 @@ export function validate(allowStylesheet: boolean = true): boolean { } export function getMappingForIncludedLanguages(): any { - let finalMappedModes = {}; + const finalMappedModes = Object.create(null); let includeLanguagesConfig = vscode.workspace.getConfiguration('emmet')['includeLanguages']; let includeLanguages = Object.assign({}, MAPPED_MODES, includeLanguagesConfig ? includeLanguagesConfig : {}); Object.keys(includeLanguages).forEach(syntax => { @@ -94,13 +94,13 @@ export function getMappingForIncludedLanguages(): any { /** * Get the corresponding emmet mode for given vscode language mode * Eg: jsx for typescriptreact/javascriptreact or pug for jade -* If the language is not supported by emmet or has been exlcuded via `exlcudeLanguages` setting, +* If the language is not supported by emmet or has been exlcuded via `exlcudeLanguages` setting, * then nothing is returned -* -* @param language +* +* @param language * @param exlcudedLanguages Array of language ids that user has chosen to exlcude for emmet */ -export function getEmmetMode(language: string, excludedLanguages: string[]): string { +export function getEmmetMode(language: string, excludedLanguages: string[]): string | undefined { if (!language || excludedLanguages.indexOf(language) > -1) { return; } @@ -120,34 +120,29 @@ export function getEmmetMode(language: string, excludedLanguages: string[]): str /** * Parses the given document using emmet parsing modules - * @param document */ -export function parseDocument(document: vscode.TextDocument, showError: boolean = true): Node { +export function parseDocument(document: vscode.TextDocument, showError: boolean = true): Node | undefined { let parseContent = isStyleSheet(document.languageId) ? parseStylesheet : parse; - let rootNode: Node; try { - rootNode = parseContent(new DocumentStreamReader(document)); + return parseContent(new DocumentStreamReader(document)); } catch (e) { if (showError) { vscode.window.showErrorMessage('Emmet: Failed to parse the file'); } } - return rootNode; + return undefined; } /** * Returns node corresponding to given position in the given root node - * @param root - * @param position - * @param includeNodeBoundary */ -export function getNode(root: Node, position: vscode.Position, includeNodeBoundary: boolean = false) { +export function getNode(root: Node | undefined, position: vscode.Position, includeNodeBoundary: boolean = false) { if (!root) { return null; } let currentNode = root.firstChild; - let foundNode: Node = null; + let foundNode: Node | null = null; while (currentNode) { const nodeStart: vscode.Position = currentNode.start; @@ -170,14 +165,14 @@ export function getNode(root: Node, position: vscode.Position, includeNodeBounda * Returns inner range of an html node. * @param currentNode */ -export function getInnerRange(currentNode: HtmlNode): vscode.Range { +export function getInnerRange(currentNode: HtmlNode): vscode.Range | undefined { if (!currentNode.close) { - return; + return undefined; } return new vscode.Range(currentNode.open.end, currentNode.close.start); } -export function getDeepestNode(node: Node): Node { +export function getDeepestNode(node: Node | undefined): Node | undefined { if (!node || !node.children || node.children.length === 0 || !node.children.find(x => x.type !== 'comment')) { return node; } @@ -186,6 +181,7 @@ export function getDeepestNode(node: Node): Node { return getDeepestNode(node.children[i]); } } + return undefined; } export function findNextWord(propertyValue: string, pos: number): [number, number] { @@ -342,10 +338,8 @@ export function getEmmetConfiguration(syntax: string) { /** * Itereates by each child, as well as nested child’ children, in their order * and invokes `fn` for each. If `fn` function returns `false`, iteration stops - * @param {Token} token - * @param {Function} fn */ -export function iterateCSSToken(token: CssToken, fn) { +export function iterateCSSToken(token: CssToken, fn: (x: any) => any) { for (let i = 0, il = token.size; i < il; i++) { if (fn(token.item(i)) === false || iterateCSSToken(token.item(i), fn) === false) { return false; @@ -355,21 +349,16 @@ export function iterateCSSToken(token: CssToken, fn) { /** * Returns `name` CSS property from given `rule` - * @param {Node} rule - * @param {String} name - * @return {Property} */ -export function getCssPropertyFromRule(rule, name): Property { - return rule.children.find(node => node.type === 'property' && node.name === name); +export function getCssPropertyFromRule(rule: Rule, name: string): Property | undefined { + return rule.children.find(node => node.type === 'property' && node.name === name) as Property; } /** * Returns css property under caret in given editor or `null` if such node cannot * be found - * @param {TextEditor} editor - * @return {Property} */ -export function getCssPropertyFromDocument(editor: vscode.TextEditor, position: vscode.Position): Property { +export function getCssPropertyFromDocument(editor: vscode.TextEditor, position: vscode.Position): Property | undefined { const rootNode = parseDocument(editor.document); const node = getNode(rootNode, position); diff --git a/extensions/emmet/tsconfig.json b/extensions/emmet/tsconfig.json index 06d04868a70..3ac3cd9c298 100644 --- a/extensions/emmet/tsconfig.json +++ b/extensions/emmet/tsconfig.json @@ -5,8 +5,8 @@ "es2016" ], "module": "commonjs", - "outDir": "./out" - + "outDir": "./out", + "noUnusedLocals": true }, "exclude": [ "node_modules", diff --git a/extensions/extension-editing/src/extensionLinter.ts b/extensions/extension-editing/src/extensionLinter.ts index 66e82c78191..5d6ec0c4591 100644 --- a/extensions/extension-editing/src/extensionLinter.ts +++ b/extensions/extension-editing/src/extensionLinter.ts @@ -54,6 +54,7 @@ export class ExtensionLinter { private timer: NodeJS.Timer; private markdownIt: MarkdownItType.MarkdownIt; + // @ts-ignore unused property constructor(private context: ExtensionContext) { this.disposables.push( workspace.onDidOpenTextDocument(document => this.queue(document)), @@ -227,7 +228,7 @@ export class ExtensionLinter { } this.diagnosticsCollection.set(document.uri, diagnostics); - }; + } } private locateToken(text: string, begin: number, end: number, token: MarkdownItType.Token, content: string) { diff --git a/extensions/extension-editing/tsconfig.json b/extensions/extension-editing/tsconfig.json index a2b5bcdfddf..6fbf4543c23 100644 --- a/extensions/extension-editing/tsconfig.json +++ b/extensions/extension-editing/tsconfig.json @@ -5,6 +5,7 @@ "es2015" ], "module": "commonjs", + "noUnusedLocals": true, "outDir": "./out" }, "include": [ diff --git a/extensions/git/src/test/git.test.ts b/extensions/git/src/test/git.test.ts index 8a7264e5496..d8c1eb405ad 100644 --- a/extensions/git/src/test/git.test.ts +++ b/extensions/git/src/test/git.test.ts @@ -6,7 +6,6 @@ 'use strict'; import 'mocha'; - import { GitStatusParser } from '../git'; import * as assert from 'assert'; diff --git a/extensions/git/src/typings/refs.d.ts b/extensions/git/src/typings/refs.d.ts index c9849d48e08..12e1d618942 100644 --- a/extensions/git/src/typings/refs.d.ts +++ b/extensions/git/src/typings/refs.d.ts @@ -4,4 +4,4 @@ *--------------------------------------------------------------------------------------------*/ /// -/// +/// \ No newline at end of file diff --git a/extensions/html/client/tsconfig.json b/extensions/html/client/tsconfig.json index 31c07df105b..d2f8f6376fe 100644 --- a/extensions/html/client/tsconfig.json +++ b/extensions/html/client/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "commonjs", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5", "es2015.promise" ] diff --git a/extensions/html/server/src/modes/cssMode.ts b/extensions/html/server/src/modes/cssMode.ts index 42125569e6c..f787b9c2742 100644 --- a/extensions/html/server/src/modes/cssMode.ts +++ b/extensions/html/server/src/modes/cssMode.ts @@ -68,4 +68,4 @@ export function getCSSMode(documentRegions: LanguageModelCache(entry.isWriteAccess ? DocumentHighlightKind.Write : DocumentHighlightKind.Text) }; }); - }; + } return null; }, findDocumentSymbols(document: TextDocument): SymbolInformation[] { @@ -286,7 +286,7 @@ export function getJavascriptMode(documentRegions: LanguageModelCache \ No newline at end of file diff --git a/extensions/html/server/src/utils/edits.ts b/extensions/html/server/src/utils/edits.ts index 5983d9014fb..f29dd174f67 100644 --- a/extensions/html/server/src/utils/edits.ts +++ b/extensions/html/server/src/utils/edits.ts @@ -15,6 +15,7 @@ export function applyEdits(document: TextDocument, edits: TextEdit[]): string { } return startDiff; }); + // @ts-ignore unused local let lastOffset = text.length; sortedEdits.forEach(e => { let startOffset = document.offsetAt(e.range.start); diff --git a/extensions/html/server/tsconfig.json b/extensions/html/server/tsconfig.json index 31c07df105b..d2f8f6376fe 100644 --- a/extensions/html/server/tsconfig.json +++ b/extensions/html/server/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "commonjs", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5", "es2015.promise" ] diff --git a/extensions/javascript/package.json b/extensions/javascript/package.json index 866167e1ba6..b3b68dedd5f 100644 --- a/extensions/javascript/package.json +++ b/extensions/javascript/package.json @@ -95,7 +95,7 @@ }, { "language": "javascriptreact", - "path": "./snippets/javascriptreact.json" + "path": "./snippets/javascript.json" } ], "jsonValidation": [ diff --git a/extensions/javascript/snippets/javascriptreact.json b/extensions/javascript/snippets/javascriptreact.json deleted file mode 100644 index 5cbc2a0418d..00000000000 --- a/extensions/javascript/snippets/javascriptreact.json +++ /dev/null @@ -1,164 +0,0 @@ -{ - "define module": { - "prefix": "define", - "body": [ - "define([", - "\t'require',", - "\t'${1:dependency}'", - "], function(require, ${2:factory}) {", - "\t'use strict';", - "\t$0", - "});" - ], - "description": "define module" - }, - "For Loop": { - "prefix": "for", - "body": [ - "for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {", - "\tconst ${3:element} = ${2:array}[${1:index}];", - "\t$0", - "}" - ], - "description": "For Loop" - }, - "For-Each Loop": { - "prefix": "foreach", - "body": [ - "${1:array}.forEach(${2:element} => {", - "\t$0", - "});" - ], - "description": "For-Each Loop" - }, - "For-In Loop": { - "prefix": "forin", - "body": [ - "for (const ${1:key} in ${2:object}) {", - "\tif (${2:object}.hasOwnProperty(${1:key})) {", - "\t\tconst ${3:element} = ${2:object}[${1:key}];", - "\t\t$0", - "\t}", - "}" - ], - "description": "For-In Loop" - }, - "For-Of Loop": { - "prefix": "forof", - "body": [ - "for (const ${1:iterator} of ${2:object}) {", - "\t$0", - "}" - ], - "description": "For-Of Loop" - }, - "Function Statement": { - "prefix": "function", - "body": [ - "function ${1:name}(${2:params}) {", - "\t$0", - "}" - ], - "description": "Function Statement" - }, - "If Statement": { - "prefix": "if", - "body": [ - "if (${1:condition}) {", - "\t$0", - "}" - ], - "description": "If Statement" - }, - "If-Else Statement": { - "prefix": "ifelse", - "body": [ - "if (${1:condition}) {", - "\t$0", - "} else {", - "\t", - "}" - ], - "description": "If-Else Statement" - }, - "New Statement": { - "prefix": "new", - "body": [ - "const ${1:name} = new ${2:type}(${3:arguments});$0" - ], - "description": "New Statement" - }, - "Switch Statement": { - "prefix": "switch", - "body": [ - "switch (${1:key}) {", - "\tcase ${2:value}:", - "\t\t$0", - "\t\tbreak;", - "", - "\tdefault:", - "\t\tbreak;", - "}" - ], - "description": "Switch Statement" - }, - "While Statement": { - "prefix": "while", - "body": [ - "while (${1:condition}) {", - "\t$0", - "}" - ], - "description": "While Statement" - }, - "Do-While Statement": { - "prefix": "dowhile", - "body": [ - "do {", - "\t$0", - "} while (${1:condition});" - ], - "description": "Do-While Statement" - }, - "Try-Catch Statement": { - "prefix": "trycatch", - "body": [ - "try {", - "\t$0", - "} catch (${1:error}) {", - "\t", - "}" - ], - "description": "Try-Catch Statement" - }, - "Set Timeout Function": { - "prefix": "settimeout", - "body": [ - "setTimeout(() => {", - "\t$0", - "}, ${1:timeout});" - ], - "description": "Set Timeout Function" - }, - "Import external module.": { - "prefix": "import statement", - "body": [ - "import { $0 } from \"${1:module}\";" - ], - "description": "Import external module." - }, - "Region Start": { - "prefix": "#region", - "body": [ - "//#region $0" - ], - "description": "Folding Region Start" - }, - "Region End": { - "prefix": "#endregion", - "body": [ - "//#endregion" - ], - "description": "Folding Region End" - } -} diff --git a/extensions/javascript/src/features/bowerJSONContribution.ts b/extensions/javascript/src/features/bowerJSONContribution.ts index ffc26905082..a3c7b17e46d 100644 --- a/extensions/javascript/src/features/bowerJSONContribution.ts +++ b/extensions/javascript/src/features/bowerJSONContribution.ts @@ -30,8 +30,8 @@ export class BowerJSONContribution implements IJSONContribution { return [{ language: 'json', pattern: '**/bower.json' }, { language: 'json', pattern: '**/.bower.json' }]; } - public collectDefaultSuggestions(resource: string, collector: ISuggestionsCollector): Thenable { - let defaultValue = { + public collectDefaultSuggestions(_resource: string, collector: ISuggestionsCollector): Thenable { + const defaultValue = { 'name': '${1:name}', 'description': '${2:description}', 'authors': ['${3:author}'], @@ -39,37 +39,37 @@ export class BowerJSONContribution implements IJSONContribution { 'main': '${5:pathToMain}', 'dependencies': {} }; - let proposal = new CompletionItem(localize('json.bower.default', 'Default bower.json')); + const proposal = new CompletionItem(localize('json.bower.default', 'Default bower.json')); proposal.kind = CompletionItemKind.Class; proposal.insertText = new SnippetString(JSON.stringify(defaultValue, null, '\t')); collector.add(proposal); return Promise.resolve(null); } - public collectPropertySuggestions(resource: string, location: Location, currentWord: string, addValue: boolean, isLast: boolean, collector: ISuggestionsCollector): Thenable | null { + public collectPropertySuggestions(_resource: string, location: Location, currentWord: string, addValue: boolean, isLast: boolean, collector: ISuggestionsCollector): Thenable | null { if ((location.matches(['dependencies']) || location.matches(['devDependencies']))) { if (currentWord.length > 0) { - let queryUrl = 'https://bower.herokuapp.com/packages/search/' + encodeURIComponent(currentWord); + const queryUrl = 'https://bower.herokuapp.com/packages/search/' + encodeURIComponent(currentWord); return this.xhr({ url: queryUrl }).then((success) => { if (success.status === 200) { try { - let obj = JSON.parse(success.responseText); + const obj = JSON.parse(success.responseText); if (Array.isArray(obj)) { - let results = <{ name: string; description: string; }[]>obj; + const results = <{ name: string; description: string; }[]>obj; for (let i = 0; i < results.length; i++) { - let name = results[i].name; - let description = results[i].description || ''; - let insertText = new SnippetString().appendText(JSON.stringify(name)); + const name = results[i].name; + const description = results[i].description || ''; + const insertText = new SnippetString().appendText(JSON.stringify(name)); if (addValue) { insertText.appendText(': ').appendPlaceholder('latest'); if (!isLast) { insertText.appendText(','); } } - let proposal = new CompletionItem(name); + const proposal = new CompletionItem(name); proposal.kind = CompletionItemKind.Property; proposal.insertText = insertText; proposal.filterText = JSON.stringify(name); @@ -85,13 +85,14 @@ export class BowerJSONContribution implements IJSONContribution { collector.error(localize('json.bower.error.repoaccess', 'Request to the bower repository failed: {0}', success.responseText)); return 0; } + return undefined; }, (error) => { collector.error(localize('json.bower.error.repoaccess', 'Request to the bower repository failed: {0}', error.responseText)); return 0; }); } else { this.topRanked.forEach((name) => { - let insertText = new SnippetString().appendText(JSON.stringify(name)); + const insertText = new SnippetString().appendText(JSON.stringify(name)); if (addValue) { insertText.appendText(': ').appendPlaceholder('latest'); if (!isLast) { @@ -99,7 +100,7 @@ export class BowerJSONContribution implements IJSONContribution { } } - let proposal = new CompletionItem(name); + const proposal = new CompletionItem(name); proposal.kind = CompletionItemKind.Property; proposal.insertText = insertText; proposal.filterText = JSON.stringify(name); @@ -113,10 +114,10 @@ export class BowerJSONContribution implements IJSONContribution { return null; } - public collectValueSuggestions(resource: string, location: Location, collector: ISuggestionsCollector): Thenable { + public collectValueSuggestions(_resource: string, location: Location, collector: ISuggestionsCollector): Thenable { if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) { // not implemented. Could be do done calling the bower command. Waiting for web API: https://github.com/bower/registry/issues/26 - let proposal = new CompletionItem(localize('json.bower.latest.version', 'latest')); + const proposal = new CompletionItem(localize('json.bower.latest.version', 'latest')); proposal.insertText = new SnippetString('"${1:latest}"'); proposal.filterText = '""'; proposal.kind = CompletionItemKind.Value; @@ -135,18 +136,18 @@ export class BowerJSONContribution implements IJSONContribution { } return null; }); - }; + } return null; } private getInfo(pack: string): Thenable { - let queryUrl = 'https://bower.herokuapp.com/packages/' + encodeURIComponent(pack); + const queryUrl = 'https://bower.herokuapp.com/packages/' + encodeURIComponent(pack); return this.xhr({ url: queryUrl }).then((success) => { try { - let obj = JSON.parse(success.responseText); + const obj = JSON.parse(success.responseText); if (obj && obj.url) { let url: string = obj.url; if (url.indexOf('git://') === 0) { @@ -161,14 +162,14 @@ export class BowerJSONContribution implements IJSONContribution { // ignore } return void 0; - }, (error) => { + }, () => { return void 0; }); } - public getInfoContribution(resource: string, location: Location): Thenable | null { + public getInfoContribution(_resource: string, location: Location): Thenable | null { if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']))) { - let pack = location.path[location.path.length - 1]; + const pack = location.path[location.path.length - 1]; if (typeof pack === 'string') { return this.getInfo(pack).then(documentation => { if (documentation) { diff --git a/extensions/javascript/src/features/jsonContributions.ts b/extensions/javascript/src/features/jsonContributions.ts index 1e31adad9d6..81f8a66f2c2 100644 --- a/extensions/javascript/src/features/jsonContributions.ts +++ b/extensions/javascript/src/features/jsonContributions.ts @@ -32,10 +32,10 @@ export interface IJSONContribution { } export function addJSONProviders(xhr: XHRRequest): Disposable { - let contributions = [new PackageJSONContribution(xhr), new BowerJSONContribution(xhr)]; - let subscriptions: Disposable[] = []; + const contributions = [new PackageJSONContribution(xhr), new BowerJSONContribution(xhr)]; + const subscriptions: Disposable[] = []; contributions.forEach(contribution => { - let selector = contribution.getDocumentSelector(); + const selector = contribution.getDocumentSelector(); subscriptions.push(languages.registerCompletionItemProvider(selector, new JSONCompletionItemProvider(contribution), '"', ':')); subscriptions.push(languages.registerHoverProvider(selector, new JSONHoverProvider(contribution))); }); @@ -47,20 +47,20 @@ export class JSONHoverProvider implements HoverProvider { constructor(private jsonContribution: IJSONContribution) { } - public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable | null { - let fileName = basename(document.fileName); - let offset = document.offsetAt(position); - let location = getLocation(document.getText(), offset); + public provideHover(document: TextDocument, position: Position, _token: CancellationToken): Thenable | null { + const fileName = basename(document.fileName); + const offset = document.offsetAt(position); + const location = getLocation(document.getText(), offset); if (!location.previousNode) { return null; } const node = location.previousNode; if (node && node.offset <= offset && offset <= node.offset + node.length) { - let promise = this.jsonContribution.getInfoContribution(fileName, location); + const promise = this.jsonContribution.getInfoContribution(fileName, location); if (promise) { return promise.then(htmlContent => { - let range = new Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length)); - let result: Hover = { + const range = new Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length)); + const result: Hover = { contents: htmlContent || [], range: range }; @@ -77,9 +77,9 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { constructor(private jsonContribution: IJSONContribution) { } - public resolveCompletionItem(item: CompletionItem, token: CancellationToken): Thenable { + public resolveCompletionItem(item: CompletionItem, _token: CancellationToken): Thenable { if (this.jsonContribution.resolveSuggestion) { - let resolver = this.jsonContribution.resolveSuggestion(item); + const resolver = this.jsonContribution.resolveSuggestion(item); if (resolver) { return resolver; } @@ -87,28 +87,28 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { return Promise.resolve(item); } - public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Thenable | null { + public provideCompletionItems(document: TextDocument, position: Position, _token: CancellationToken): Thenable | null { - let fileName = basename(document.fileName); + const fileName = basename(document.fileName); - let currentWord = this.getCurrentWord(document, position); + const currentWord = this.getCurrentWord(document, position); let overwriteRange: Range; - let items: CompletionItem[] = []; + const items: CompletionItem[] = []; let isIncomplete = false; - let offset = document.offsetAt(position); - let location = getLocation(document.getText(), offset); + const offset = document.offsetAt(position); + const location = getLocation(document.getText(), offset); - let node = location.previousNode; + const node = location.previousNode; if (node && node.offset <= offset && offset <= node.offset + node.length && (node.type === 'property' || node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) { overwriteRange = new Range(document.positionAt(node.offset), document.positionAt(node.offset + node.length)); } else { overwriteRange = new Range(document.positionAt(offset - currentWord.length), position); } - let proposed: { [key: string]: boolean } = {}; - let collector: ISuggestionsCollector = { + const proposed: { [key: string]: boolean } = {}; + const collector: ISuggestionsCollector = { add: (suggestion: CompletionItem) => { if (!proposed[suggestion.label]) { proposed[suggestion.label] = true; @@ -124,8 +124,8 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { let collectPromise: Thenable | null = null; if (location.isAtPropertyKey) { - let addValue = !location.previousNode || !location.previousNode.columnOffset; - let isLast = this.isLast(document, position); + const addValue = !location.previousNode || !location.previousNode.columnOffset; + const isLast = this.isLast(document, position); collectPromise = this.jsonContribution.collectPropertySuggestions(fileName, location, currentWord, addValue, isLast, collector); } else { if (location.path.length === 0) { @@ -146,8 +146,8 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { } private getCurrentWord(document: TextDocument, position: Position) { - var i = position.character - 1; - var text = document.lineAt(position.line).text; + let i = position.character - 1; + const text = document.lineAt(position.line).text; while (i >= 0 && ' \t\n\r\v":{[,'.indexOf(text.charAt(i)) === -1) { i--; } @@ -155,7 +155,7 @@ export class JSONCompletionItemProvider implements CompletionItemProvider { } private isLast(document: TextDocument, position: Position): boolean { - let scanner = createScanner(document.getText(), true); + const scanner = createScanner(document.getText(), true); scanner.setPosition(document.offsetAt(position)); let nextToken = scanner.scan(); if (nextToken === SyntaxKind.StringLiteral && scanner.getTokenError() === ScanError.UnexpectedEndOfString) { diff --git a/extensions/javascript/src/features/packageJSONContribution.ts b/extensions/javascript/src/features/packageJSONContribution.ts index 3f891ee46ee..5b09fb0c9d1 100644 --- a/extensions/javascript/src/features/packageJSONContribution.ts +++ b/extensions/javascript/src/features/packageJSONContribution.ts @@ -13,7 +13,7 @@ import { textToMarkedString } from './markedTextUtil'; import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); -let LIMIT = 40; +const LIMIT = 40; export class PackageJSONContribution implements IJSONContribution { @@ -31,8 +31,8 @@ export class PackageJSONContribution implements IJSONContribution { public constructor(private xhr: XHRRequest) { } - public collectDefaultSuggestions(fileName: string, result: ISuggestionsCollector): Thenable { - let defaultValue = { + public collectDefaultSuggestions(_fileName: string, result: ISuggestionsCollector): Thenable { + const defaultValue = { 'name': '${1:name}', 'description': '${2:description}', 'authors': '${3:author}', @@ -40,7 +40,7 @@ export class PackageJSONContribution implements IJSONContribution { 'main': '${5:pathToMain}', 'dependencies': {} }; - let proposal = new CompletionItem(localize('json.package.default', 'Default package.json')); + const proposal = new CompletionItem(localize('json.package.default', 'Default package.json')); proposal.kind = CompletionItemKind.Module; proposal.insertText = new SnippetString(JSON.stringify(defaultValue, null, '\t')); result.add(proposal); @@ -48,7 +48,7 @@ export class PackageJSONContribution implements IJSONContribution { } public collectPropertySuggestions( - resource: string, + _resource: string, location: Location, currentWord: string, addValue: boolean, @@ -65,21 +65,21 @@ export class PackageJSONContribution implements IJSONContribution { }).then((success) => { if (success.status === 200) { try { - let obj = JSON.parse(success.responseText); + const obj = JSON.parse(success.responseText); if (obj && Array.isArray(obj.rows)) { - let results = <{ key: string[]; }[]>obj.rows; + const results = <{ key: string[]; }[]>obj.rows; for (let i = 0; i < results.length; i++) { - let keys = results[i].key; + const keys = results[i].key; if (Array.isArray(keys) && keys.length > 0) { - let name = keys[0]; - let insertText = new SnippetString().appendText(JSON.stringify(name)); + const name = keys[0]; + const insertText = new SnippetString().appendText(JSON.stringify(name)); if (addValue) { insertText.appendText(': "').appendTabstop().appendText('"'); if (!isLast) { insertText.appendText(','); } } - let proposal = new CompletionItem(name); + const proposal = new CompletionItem(name); proposal.kind = CompletionItemKind.Property; proposal.insertText = insertText; proposal.filterText = JSON.stringify(name); @@ -98,20 +98,21 @@ export class PackageJSONContribution implements IJSONContribution { collector.error(localize('json.npm.error.repoaccess', 'Request to the NPM repository failed: {0}', success.responseText)); return 0; } + return undefined; }, (error) => { collector.error(localize('json.npm.error.repoaccess', 'Request to the NPM repository failed: {0}', error.responseText)); return 0; }); } else { this.mostDependedOn.forEach((name) => { - let insertText = new SnippetString().appendText(JSON.stringify(name)); + const insertText = new SnippetString().appendText(JSON.stringify(name)); if (addValue) { insertText.appendText(': "').appendTabstop().appendText('"'); if (!isLast) { insertText.appendText(','); } } - let proposal = new CompletionItem(name); + const proposal = new CompletionItem(name); proposal.kind = CompletionItemKind.Property; proposal.insertText = insertText; proposal.filterText = JSON.stringify(name); @@ -126,20 +127,20 @@ export class PackageJSONContribution implements IJSONContribution { } public collectValueSuggestions( - fileName: string, + _fileName: string, location: Location, result: ISuggestionsCollector ): Thenable | null { if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) { - let currentKey = location.path[location.path.length - 1]; + const currentKey = location.path[location.path.length - 1]; if (typeof currentKey === 'string') { - let queryUrl = 'http://registry.npmjs.org/' + encodeURIComponent(currentKey).replace('%40', '@'); + const queryUrl = 'http://registry.npmjs.org/' + encodeURIComponent(currentKey).replace('%40', '@'); return this.xhr({ url: queryUrl }).then((success) => { try { - let obj = JSON.parse(success.responseText); - let latest = obj && obj['dist-tags'] && obj['dist-tags']['latest']; + const obj = JSON.parse(success.responseText); + const latest = obj && obj['dist-tags'] && obj['dist-tags']['latest']; if (latest) { let name = JSON.stringify(latest); let proposal = new CompletionItem(name); @@ -166,7 +167,7 @@ export class PackageJSONContribution implements IJSONContribution { // ignore } return 0; - }, (error) => { + }, () => { return 0; }); } @@ -186,24 +187,24 @@ export class PackageJSONContribution implements IJSONContribution { } return null; }); - }; + } return null; } private getInfo(pack: string): Thenable { - let queryUrl = 'http://registry.npmjs.org/' + encodeURIComponent(pack).replace('%40', '@'); + const queryUrl = 'http://registry.npmjs.org/' + encodeURIComponent(pack).replace('%40', '@'); return this.xhr({ url: queryUrl }).then((success) => { try { - let obj = JSON.parse(success.responseText); + const obj = JSON.parse(success.responseText); if (obj) { - let result: string[] = []; + const result: string[] = []; if (obj.description) { result.push(obj.description); } - let latest = obj && obj['dist-tags'] && obj['dist-tags']['latest']; + const latest = obj && obj['dist-tags'] && obj['dist-tags']['latest']; if (latest) { result.push(localize('json.npm.version.hover', 'Latest version: {0}', latest)); } @@ -213,14 +214,14 @@ export class PackageJSONContribution implements IJSONContribution { // ignore } return []; - }, (error) => { + }, () => { return []; }); } - public getInfoContribution(fileName: string, location: Location): Thenable | null { + public getInfoContribution(_fileName: string, location: Location): Thenable | null { if ((location.matches(['dependencies', '*']) || location.matches(['devDependencies', '*']) || location.matches(['optionalDependencies', '*']) || location.matches(['peerDependencies', '*']))) { - let pack = location.path[location.path.length - 1]; + const pack = location.path[location.path.length - 1]; if (typeof pack === 'string') { return this.getInfo(pack).then(infos => { if (infos.length) { diff --git a/extensions/javascript/src/javascriptMain.ts b/extensions/javascript/src/javascriptMain.ts index 5c982339cd5..ed2552b87f0 100644 --- a/extensions/javascript/src/javascriptMain.ts +++ b/extensions/javascript/src/javascriptMain.ts @@ -16,12 +16,12 @@ export function activate(context: ExtensionContext): any { nls.config({ locale: env.language }); configureHttpRequest(); - workspace.onDidChangeConfiguration(e => configureHttpRequest()); + workspace.onDidChangeConfiguration(() => configureHttpRequest()); context.subscriptions.push(addJSONProviders(httpRequest.xhr)); } function configureHttpRequest() { - let httpSettings = workspace.getConfiguration('http'); + const httpSettings = workspace.getConfiguration('http'); httpRequest.configure(httpSettings.get('proxy', ''), httpSettings.get('proxyStrictSSL', true)); } diff --git a/extensions/javascript/tsconfig.json b/extensions/javascript/tsconfig.json index c0601facf73..32325af1b23 100644 --- a/extensions/javascript/tsconfig.json +++ b/extensions/javascript/tsconfig.json @@ -6,6 +6,10 @@ "lib": [ "es2015" ], + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "strict": true }, "include": [ diff --git a/extensions/json/client/src/jsonMain.ts b/extensions/json/client/src/jsonMain.ts index b0bc742a1f2..3c9218017c9 100644 --- a/extensions/json/client/src/jsonMain.ts +++ b/extensions/json/client/src/jsonMain.ts @@ -50,6 +50,7 @@ interface Settings { }; } +// @ts-ignore unused type interface JSONSettings { schemas: JSONSchemaSettings[]; } @@ -260,8 +261,8 @@ function getSettings(): Settings { folderPath = folderPath + '/'; } collectSchemaSettings(folderSchemas, folderUri.fsPath, folderPath + '*'); - }; - }; + } + } } return settings; } diff --git a/extensions/json/client/tsconfig.json b/extensions/json/client/tsconfig.json index 31c07df105b..d2f8f6376fe 100644 --- a/extensions/json/client/tsconfig.json +++ b/extensions/json/client/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "commonjs", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5", "es2015.promise" ] diff --git a/extensions/json/server/tsconfig.json b/extensions/json/server/tsconfig.json index deecf69b8b4..e085b24514b 100644 --- a/extensions/json/server/tsconfig.json +++ b/extensions/json/server/tsconfig.json @@ -5,6 +5,7 @@ "sourceMap": true, "sourceRoot": "../src", "outDir": "./out", + "noUnusedLocals": true, "lib": [ "es5", "es2015.promise" ] diff --git a/extensions/merge-conflict/src/codelensProvider.ts b/extensions/merge-conflict/src/codelensProvider.ts index ca54a189a7a..32b1cb9e381 100644 --- a/extensions/merge-conflict/src/codelensProvider.ts +++ b/extensions/merge-conflict/src/codelensProvider.ts @@ -13,7 +13,7 @@ export default class MergeConflictCodeLensProvider implements vscode.CodeLensPro private config: interfaces.IExtensionConfiguration; private tracker: interfaces.IDocumentMergeConflictTracker; - constructor(private context: vscode.ExtensionContext, trackerService: interfaces.IDocumentMergeConflictTrackerService) { + constructor(trackerService: interfaces.IDocumentMergeConflictTrackerService) { this.tracker = trackerService.createTracker('codelens'); } @@ -46,7 +46,7 @@ export default class MergeConflictCodeLensProvider implements vscode.CodeLensPro } } - async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise { + async provideCodeLenses(document: vscode.TextDocument, _token: vscode.CancellationToken): Promise { if (!this.config || !this.config.enableCodeLens) { return null; diff --git a/extensions/merge-conflict/src/commandHandler.ts b/extensions/merge-conflict/src/commandHandler.ts index 50ce36885b9..1a737cfaf3f 100644 --- a/extensions/merge-conflict/src/commandHandler.ts +++ b/extensions/merge-conflict/src/commandHandler.ts @@ -24,7 +24,7 @@ export default class CommandHandler implements vscode.Disposable { private disposables: vscode.Disposable[] = []; private tracker: interfaces.IDocumentMergeConflictTracker; - constructor(private context: vscode.ExtensionContext, trackerService: interfaces.IDocumentMergeConflictTrackerService) { + constructor(trackerService: interfaces.IDocumentMergeConflictTrackerService) { this.tracker = trackerService.createTracker('commands'); } @@ -62,19 +62,19 @@ export default class CommandHandler implements vscode.Disposable { return this.accept(interfaces.CommitType.Both, editor, ...args); } - acceptAllCurrent(editor: vscode.TextEditor, ...args: any[]): Promise { + acceptAllCurrent(editor: vscode.TextEditor): Promise { return this.acceptAll(interfaces.CommitType.Current, editor); } - acceptAllIncoming(editor: vscode.TextEditor, ...args: any[]): Promise { + acceptAllIncoming(editor: vscode.TextEditor): Promise { return this.acceptAll(interfaces.CommitType.Incoming, editor); } - acceptAllBoth(editor: vscode.TextEditor, ...args: any[]): Promise { + acceptAllBoth(editor: vscode.TextEditor): Promise { return this.acceptAll(interfaces.CommitType.Both, editor); } - async compare(editor: vscode.TextEditor, conflict: interfaces.IDocumentMergeConflict | null, ...args: any[]) { + async compare(editor: vscode.TextEditor, conflict: interfaces.IDocumentMergeConflict | null) { const fileName = path.basename(editor.document.uri.fsPath); // No conflict, command executed from command palette @@ -102,15 +102,15 @@ export default class CommandHandler implements vscode.Disposable { vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, title); } - navigateNext(editor: vscode.TextEditor, ...args: any[]): Promise { + navigateNext(editor: vscode.TextEditor): Promise { return this.navigate(editor, NavigationDirection.Forwards); } - navigatePrevious(editor: vscode.TextEditor, ...args: any[]): Promise { + navigatePrevious(editor: vscode.TextEditor): Promise { return this.navigate(editor, NavigationDirection.Backwards); } - async acceptSelection(editor: vscode.TextEditor, ...args: any[]): Promise { + async acceptSelection(editor: vscode.TextEditor): Promise { let conflict = await this.findConflictContainingSelection(editor); if (!conflict) { diff --git a/extensions/merge-conflict/src/contentProvider.ts b/extensions/merge-conflict/src/contentProvider.ts index 446ab052f22..37e5923e135 100644 --- a/extensions/merge-conflict/src/contentProvider.ts +++ b/extensions/merge-conflict/src/contentProvider.ts @@ -4,21 +4,11 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; import * as vscode from 'vscode'; -import * as interfaces from './interfaces'; export default class MergeConflictContentProvider implements vscode.TextDocumentContentProvider, vscode.Disposable { static scheme = 'merge-conflict.conflict-diff'; - constructor(private context: vscode.ExtensionContext) { - } - - begin(config: interfaces.IExtensionConfiguration) { - this.context.subscriptions.push( - vscode.workspace.registerTextDocumentContentProvider(MergeConflictContentProvider.scheme, this) - ); - } - dispose() { } diff --git a/extensions/merge-conflict/src/documentMergeConflict.ts b/extensions/merge-conflict/src/documentMergeConflict.ts index f1714c98163..3bf94a16ea7 100644 --- a/extensions/merge-conflict/src/documentMergeConflict.ts +++ b/extensions/merge-conflict/src/documentMergeConflict.ts @@ -13,7 +13,7 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict public commonAncestors: interfaces.IMergeRegion[]; public splitter: vscode.Range; - constructor(document: vscode.TextDocument, descriptor: interfaces.IDocumentMergeConflictDescriptor) { + constructor(descriptor: interfaces.IDocumentMergeConflictDescriptor) { this.range = descriptor.range; this.current = descriptor.current; this.incoming = descriptor.incoming; @@ -27,7 +27,7 @@ export class DocumentMergeConflict implements interfaces.IDocumentMergeConflict this.applyEdit(type, editor, edit); return Promise.resolve(true); - }; + } return editor.edit((edit) => this.applyEdit(type, editor, edit)); } diff --git a/extensions/merge-conflict/src/documentTracker.ts b/extensions/merge-conflict/src/documentTracker.ts index 83c578122fc..f70cd91f185 100644 --- a/extensions/merge-conflict/src/documentTracker.ts +++ b/extensions/merge-conflict/src/documentTracker.ts @@ -116,7 +116,7 @@ export default class DocumentMergeConflictTracker implements vscode.Disposable, this.cache.clear(); } - private getConflictsOrEmpty(document: vscode.TextDocument, origins: string[]): interfaces.IDocumentMergeConflict[] { + private getConflictsOrEmpty(document: vscode.TextDocument, _origins: string[]): interfaces.IDocumentMergeConflict[] { const containsConflict = MergeConflictParser.containsConflict(document); if (!containsConflict) { diff --git a/extensions/merge-conflict/src/mergeConflictParser.ts b/extensions/merge-conflict/src/mergeConflictParser.ts index 4ff9a58e07c..84a4607ac14 100644 --- a/extensions/merge-conflict/src/mergeConflictParser.ts +++ b/extensions/merge-conflict/src/mergeConflictParser.ts @@ -81,7 +81,7 @@ export class MergeConflictParser { return conflictDescriptors .filter(Boolean) - .map(descriptor => new DocumentMergeConflict(document, descriptor)); + .map(descriptor => new DocumentMergeConflict(descriptor)); } private static scanItemTolMergeConflictDescriptor(document: vscode.TextDocument, scanned: IScanMergedConflict): interfaces.IDocumentMergeConflictDescriptor | null { diff --git a/extensions/merge-conflict/src/services.ts b/extensions/merge-conflict/src/services.ts index 320adb3e53e..f3eb0e0630e 100644 --- a/extensions/merge-conflict/src/services.ts +++ b/extensions/merge-conflict/src/services.ts @@ -26,9 +26,9 @@ export default class ServiceWrapper implements vscode.Disposable { this.services.push( documentTracker, - new CommandHandler(this.context, documentTracker), - new CodeLensProvider(this.context, documentTracker), - new ContentProvider(this.context), + new CommandHandler(documentTracker), + new CodeLensProvider(documentTracker), + new ContentProvider(), new Decorator(this.context, documentTracker), ); diff --git a/extensions/merge-conflict/tsconfig.json b/extensions/merge-conflict/tsconfig.json index b67b8ea9a1d..545f2260b61 100644 --- a/extensions/merge-conflict/tsconfig.json +++ b/extensions/merge-conflict/tsconfig.json @@ -6,6 +6,10 @@ ], "module": "commonjs", "outDir": "./out", + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, "strict": true, "experimentalDecorators": true }, diff --git a/extensions/php/src/features/completionItemProvider.ts b/extensions/php/src/features/completionItemProvider.ts index a430aa3f154..05a0f9f29bc 100644 --- a/extensions/php/src/features/completionItemProvider.ts +++ b/extensions/php/src/features/completionItemProvider.ts @@ -12,7 +12,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider public triggerCharacters = ['.', ':', '$']; - public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise { + public provideCompletionItems(document: TextDocument, position: Position, _token: CancellationToken): Promise { let result: CompletionItem[] = []; let shouldProvideCompletionItems = workspace.getConfiguration('php').get('suggest.basic', true); @@ -27,7 +27,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider } var added: any = {}; - var createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry): CompletionItem { + var createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry | null): CompletionItem { var proposal: CompletionItem = new CompletionItem(name); proposal.kind = kind; if (entry) { @@ -85,7 +85,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider var text = document.getText(); if (prefix[0] === '$') { var variableMatch = /\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/g; - var match: RegExpExecArray = null; + var match: RegExpExecArray | null = null; while (match = variableMatch.exec(text)) { var word = match[0]; if (!added[word]) { @@ -95,7 +95,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider } } var functionMatch = /function\s+([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*\(/g; - var match: RegExpExecArray = null; + var match: RegExpExecArray | null = null; while (match = functionMatch.exec(text)) { var word = match[1]; if (!added[word]) { diff --git a/extensions/php/src/features/hoverProvider.ts b/extensions/php/src/features/hoverProvider.ts index 1e300e2fccd..f40d210b133 100644 --- a/extensions/php/src/features/hoverProvider.ts +++ b/extensions/php/src/features/hoverProvider.ts @@ -11,15 +11,15 @@ import { textToMarkedString } from './utils/markedTextUtil'; export default class PHPHoverProvider implements HoverProvider { - public provideHover(document: TextDocument, position: Position, token: CancellationToken): Hover { + public provideHover(document: TextDocument, position: Position, _token: CancellationToken): Hover | undefined { let enable = workspace.getConfiguration('php').get('suggest.basic', true); if (!enable) { - return null; + return undefined; } let wordRange = document.getWordRangeAtPosition(position); if (!wordRange) { - return; + return undefined; } let name = document.getText(wordRange); @@ -30,5 +30,7 @@ export default class PHPHoverProvider implements HoverProvider { let contents: MarkedString[] = [textToMarkedString(entry.description), { language: 'php', value: signature }]; return new Hover(contents, wordRange); } + + return undefined; } } diff --git a/extensions/php/src/features/signatureHelpProvider.ts b/extensions/php/src/features/signatureHelpProvider.ts index b52392cfca4..b3f6c12a306 100644 --- a/extensions/php/src/features/signatureHelpProvider.ts +++ b/extensions/php/src/features/signatureHelpProvider.ts @@ -69,7 +69,7 @@ class BackwardIterator { export default class PHPSignatureHelpProvider implements SignatureHelpProvider { - public provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken): Promise { + public provideSignatureHelp(document: TextDocument, position: Position, _token: CancellationToken): Promise | null { let enable = workspace.getConfiguration('php').get('suggest.basic', true); if (!enable) { return null; @@ -95,7 +95,7 @@ export default class PHPSignatureHelpProvider implements SignatureHelpProvider { let signatureInfo = new SignatureInformation(ident + paramsString, entry.description); var re = /\w*\s+\&?\$[\w_\.]+|void/g; - var match: RegExpExecArray = null; + var match: RegExpExecArray | null = null; while ((match = re.exec(paramsString)) !== null) { signatureInfo.parameters.push({ label: match[0], documentation: '' }); } diff --git a/extensions/php/src/features/utils/async.ts b/extensions/php/src/features/utils/async.ts index f9c86930453..78ba0aa582a 100644 --- a/extensions/php/src/features/utils/async.ts +++ b/extensions/php/src/features/utils/async.ts @@ -29,9 +29,9 @@ export interface ITask { */ export class Throttler { - private activePromise: Promise; - private queuedPromise: Promise; - private queuedPromiseFactory: ITask>; + private activePromise: Promise | null; + private queuedPromise: Promise | null; + private queuedPromiseFactory: ITask> | null; constructor() { this.activePromise = null; @@ -47,26 +47,26 @@ export class Throttler { var onComplete = () => { this.queuedPromise = null; - var result = this.queue(this.queuedPromiseFactory); + var result = this.queue(this.queuedPromiseFactory!); this.queuedPromiseFactory = null; return result; }; - this.queuedPromise = new Promise((resolve, reject) => { - this.activePromise.then(onComplete, onComplete).then(resolve); + this.queuedPromise = new Promise((resolve) => { + this.activePromise!.then(onComplete, onComplete).then(resolve); }); } return new Promise((resolve, reject) => { - this.queuedPromise.then(resolve, reject); + this.queuedPromise!.then(resolve, reject); }); } this.activePromise = promiseFactory(); return new Promise((resolve, reject) => { - this.activePromise.then((result: T) => { + this.activePromise!.then((result: T) => { this.activePromise = null; resolve(result); }, (err: any) => { @@ -103,10 +103,10 @@ export class Throttler { export class Delayer { public defaultDelay: number; - private timeout: NodeJS.Timer; - private completionPromise: Promise; - private onResolve: (value: T | Thenable) => void; - private task: ITask; + private timeout: NodeJS.Timer | null; + private completionPromise: Promise | null; + private onResolve: ((value: T | Thenable | undefined) => void) | null; + private task: ITask | null; constructor(defaultDelay: number) { this.defaultDelay = defaultDelay; @@ -121,13 +121,13 @@ export class Delayer { this.cancelTimeout(); if (!this.completionPromise) { - this.completionPromise = new Promise((resolve, reject) => { + this.completionPromise = new Promise((resolve) => { this.onResolve = resolve; }).then(() => { this.completionPromise = null; this.onResolve = null; - var result = this.task(); + var result = this.task!(); this.task = null; return result; @@ -136,7 +136,7 @@ export class Delayer { this.timeout = setTimeout(() => { this.timeout = null; - this.onResolve(null); + this.onResolve!(undefined); }, delay); return this.completionPromise; diff --git a/extensions/php/src/features/validationProvider.ts b/extensions/php/src/features/validationProvider.ts index 712164af0f9..4f7f8cadbb7 100644 --- a/extensions/php/src/features/validationProvider.ts +++ b/extensions/php/src/features/validationProvider.ts @@ -16,7 +16,7 @@ let localize = nls.loadMessageBundle(); export class LineDecoder { private stringDecoder: NodeStringDecoder; - private remaining: string; + private remaining: string | null; constructor(encoding: string = 'utf8') { this.stringDecoder = new StringDecoder(encoding); @@ -55,7 +55,7 @@ export class LineDecoder { return result; } - public end(): string { + public end(): string | null { return this.remaining; } } @@ -88,17 +88,17 @@ export default class PHPValidationProvider { private static FileArgs: string[] = ['-l', '-n', '-d', 'display_errors=On', '-d', 'log_errors=Off', '-f']; private validationEnabled: boolean; - private executableIsUserDefined: boolean; - private executable: string; + private executableIsUserDefined: boolean | undefined; + private executable: string | undefined; private trigger: RunTrigger; private pauseValidation: boolean; - private documentListener: vscode.Disposable; + private documentListener: vscode.Disposable | null; private diagnosticCollection: vscode.DiagnosticCollection; private delayers: { [key: string]: ThrottledDelayer }; constructor(private workspaceStore: vscode.Memento) { - this.executable = null; + this.executable = undefined; this.validationEnabled = true; this.trigger = RunTrigger.onSave; this.pauseValidation = false; @@ -145,7 +145,7 @@ export default class PHPValidationProvider { } this.trigger = RunTrigger.from(section.get('validate.run', RunTrigger.strings.onSave)); } - if (this.executableIsUserDefined !== true && this.workspaceStore.get(CheckedExecutablePath, undefined) !== void 0) { + if (this.executableIsUserDefined !== true && this.workspaceStore.get(CheckedExecutablePath, undefined) !== void 0) { vscode.commands.executeCommand('setContext', 'php.untrustValidationExecutableContext', true); } this.delayers = Object.create(null); @@ -195,7 +195,7 @@ export default class PHPValidationProvider { }; if (this.executableIsUserDefined !== void 0 && !this.executableIsUserDefined) { - let checkedExecutablePath = this.workspaceStore.get(CheckedExecutablePath, undefined); + let checkedExecutablePath = this.workspaceStore.get(CheckedExecutablePath, undefined); if (!checkedExecutablePath || checkedExecutablePath !== this.executable) { vscode.window.showInformationMessage( localize('php.useExecutablePath', 'Do you allow {0} (defined as a workspace setting) to be executed to lint PHP files?', this.executable), @@ -224,7 +224,7 @@ export default class PHPValidationProvider { } private doValidate(textDocument: vscode.TextDocument): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { let executable = this.executable || 'php'; let decoder = new LineDecoder(); let diagnostics: vscode.Diagnostic[] = []; @@ -286,7 +286,7 @@ export default class PHPValidationProvider { } private showError(error: any, executable: string): void { - let message: string = null; + let message: string | null = null; if (error.code === 'ENOENT') { if (this.executable) { message = localize('wrongExecutable', 'Cannot validate since {0} is not a valid php executable. Use the setting \'php.validate.executablePath\' to configure the PHP executable.', executable); @@ -296,6 +296,8 @@ export default class PHPValidationProvider { } else { message = error.message ? error.message : localize('unknownReason', 'Failed to run php using path: {0}. Reason is unknown.', executable); } - vscode.window.showInformationMessage(message); + if (message) { + vscode.window.showInformationMessage(message); + } } } diff --git a/extensions/php/tsconfig.json b/extensions/php/tsconfig.json index a2b5bcdfddf..7e9b0d127b4 100644 --- a/extensions/php/tsconfig.json +++ b/extensions/php/tsconfig.json @@ -5,7 +5,12 @@ "es2015" ], "module": "commonjs", - "outDir": "./out" + "outDir": "./out", + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strict": true }, "include": [ "src/**/*" diff --git a/extensions/python/tsconfig.json b/extensions/python/tsconfig.json index a2b5bcdfddf..b16347a7524 100644 --- a/extensions/python/tsconfig.json +++ b/extensions/python/tsconfig.json @@ -5,7 +5,8 @@ "es2015" ], "module": "commonjs", - "outDir": "./out" + "outDir": "./out", + "strict": true }, "include": [ "src/**/*" diff --git a/extensions/typescript/package.json b/extensions/typescript/package.json index 4072ea07c34..6d2e4f19230 100644 --- a/extensions/typescript/package.json +++ b/extensions/typescript/package.json @@ -530,7 +530,7 @@ }, { "language": "typescriptreact", - "path": "./snippets/typescriptreact.json" + "path": "./snippets/typescript.json" } ], "jsonValidation": [ diff --git a/extensions/typescript/snippets/typescriptreact.json b/extensions/typescript/snippets/typescriptreact.json deleted file mode 100644 index b5627443402..00000000000 --- a/extensions/typescript/snippets/typescriptreact.json +++ /dev/null @@ -1,278 +0,0 @@ -{ - "Constructor": { - "prefix": "ctor", - "body": [ - "/**", - " *", - " */", - "constructor() {", - "\tsuper();", - "\t$0", - "}" - ], - "description": "Constructor" - }, - "Class Definition": { - "prefix": "class", - "body": [ - "class ${1:name} {", - "\tconstructor(${2:parameters}) {", - "\t\t$0", - "\t}", - "}" - ], - "description": "Class Definition" - }, - "Public Method Definition": { - "prefix": "public method", - "body": [ - "/**", - " * ${1:name}", - " */", - "public ${1:name}() {", - "\t$0", - "}" - ], - "description": "Public Method Definition" - }, - "Private Method Definition": { - "prefix": "private method", - "body": [ - "private ${1:name}() {", - "\t$0", - "}" - ], - "description": "Private Method Definition" - }, - "Import external module.": { - "prefix": "import statement", - "body": [ - "import { $0 } from \"${1:module}\";" - ], - "description": "Import external module." - }, - "Property getter": { - "prefix": "get", - "body": [ - "", - "public get ${1:value}() : ${2:string} {", - "\t${3:return $0}", - "}", - "" - ], - "description": "Property getter" - }, - "Log to the console": { - "prefix": "log", - "body": [ - "console.log($1);", - "$0" - ], - "description": "Log to the console" - }, - "Define a full property": { - "prefix": "prop", - "body": [ - "", - "private _${1:value} : ${2:string};", - "public get ${1:value}() : ${2:string} {", - "\treturn this._${1:value};", - "}", - "public set ${1:value}(v : ${2:string}) {", - "\tthis._${1:value} = v;", - "}", - "" - ], - "description": "Define a full property" - }, - "Triple-slash reference": { - "prefix": "ref", - "body": [ - "/// ", - "$0" - ], - "description": "Triple-slash reference" - }, - "Return false": { - "prefix": "ret0", - "body": [ - "return false;$0" - ], - "description": "Return false" - }, - "Return true": { - "prefix": "ret1", - "body": [ - "return true;$0" - ], - "description": "Return true" - }, - "Return statement": { - "prefix": "ret", - "body": [ - "return $1;$0" - ], - "description": "Return statement" - }, - "Property setter": { - "prefix": "set", - "body": [ - "", - "public set ${1:value}(v : ${2:string}) {", - "\tthis.$3 = v;", - "}", - "" - ], - "description": "Property setter" - }, - "Throw Exception": { - "prefix": "throw", - "body": [ - "throw \"$1\";", - "$0" - ], - "description": "Throw Exception" - }, - "For Loop": { - "prefix": "for", - "body": [ - "for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {", - "\tconst ${3:element} = ${2:array}[${1:index}];", - "\t$0", - "}" - ], - "description": "For Loop" - }, - "For-Each Loop using =>": { - "prefix": "foreach =>", - "body": [ - "${1:array}.forEach(${2:element} => {", - "\t$0", - "});" - ], - "description": "For-Each Loop using =>" - }, - "For-In Loop": { - "prefix": "forin", - "body": [ - "for (const ${1:key} in ${2:object}) {", - "\tif (${2:object}.hasOwnProperty(${1:key})) {", - "\t\tconst ${3:element} = ${2:object}[${1:key}];", - "\t\t$0", - "\t}", - "}" - ], - "description": "For-In Loop" - }, - "For-Of Loop": { - "prefix": "forof", - "body": [ - "for (const ${1:iterator} of ${2:object}) {", - "\t$0", - "}" - ], - "description": "For-Of Loop" - }, - "Function Statement": { - "prefix": "function", - "body": [ - "function ${1:name}(${2:params}:${3:type}) {", - "\t$0", - "}" - ], - "description": "Function Statement" - }, - "If Statement": { - "prefix": "if", - "body": [ - "if (${1:condition}) {", - "\t$0", - "}" - ], - "description": "If Statement" - }, - "If-Else Statement": { - "prefix": "ifelse", - "body": [ - "if (${1:condition}) {", - "\t$0", - "} else {", - "\t", - "}" - ], - "description": "If-Else Statement" - }, - "New Statement": { - "prefix": "new", - "body": [ - "const ${1:name} = new ${2:type}(${3:arguments});$0" - ], - "description": "New Statement" - }, - "Switch Statement": { - "prefix": "switch", - "body": [ - "switch (${1:key}) {", - "\tcase ${2:value}:", - "\t\t$0", - "\t\tbreak;", - "", - "\tdefault:", - "\t\tbreak;", - "}" - ], - "description": "Switch Statement" - }, - "While Statement": { - "prefix": "while", - "body": [ - "while (${1:condition}) {", - "\t$0", - "}" - ], - "description": "While Statement" - }, - "Do-While Statement": { - "prefix": "dowhile", - "body": [ - "do {", - "\t$0", - "} while (${1:condition});" - ], - "description": "Do-While Statement" - }, - "Try-Catch Statement": { - "prefix": "trycatch", - "body": [ - "try {", - "\t$0", - "} catch (${1:error}) {", - "\t", - "}" - ], - "description": "Try-Catch Statement" - }, - "Set Timeout Function": { - "prefix": "settimeout", - "body": [ - "setTimeout(() => {", - "\t$0", - "}, ${1:timeout});" - ], - "description": "Set Timeout Function" - }, - "Region Start": { - "prefix": "#region", - "body": [ - "//#region $0" - ], - "description": "Folding Region Start" - }, - "Region End": { - "prefix": "#endregion", - "body": [ - "//#endregion" - ], - "description": "Folding Region End" - } -} diff --git a/extensions/typescript/src/features/codeActionProvider.ts b/extensions/typescript/src/features/codeActionProvider.ts index 1c085d65e93..644ad445616 100644 --- a/extensions/typescript/src/features/codeActionProvider.ts +++ b/extensions/typescript/src/features/codeActionProvider.ts @@ -3,38 +3,50 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionContext, Command, commands } from 'vscode'; +import * as vscode from 'vscode'; import * as Proto from '../protocol'; import { ITypeScriptServiceClient } from '../typescriptService'; import { vsRangeToTsFileRange } from '../utils/convert'; import FormattingConfigurationManager from './formattingConfigurationManager'; import { applyCodeAction } from '../utils/codeAction'; +import { CommandManager, Command } from '../utils/commandManager'; interface NumberSet { [key: number]: boolean; } -export default class TypeScriptCodeActionProvider implements CodeActionProvider { - private commandId: string; +class ApplyCodeActionCommand implements Command { + public static readonly ID: string = '_typescript.applyCodeAction'; + public readonly id: string = ApplyCodeActionCommand.ID; + + constructor( + private readonly client: ITypeScriptServiceClient + ) { } + + execute(action: Proto.CodeAction, file: string): void { + applyCodeAction(this.client, action, file); + } +} + +export default class TypeScriptCodeActionProvider implements vscode.CodeActionProvider { private _supportedCodeActions?: Thenable; constructor( private readonly client: ITypeScriptServiceClient, private readonly formattingConfigurationManager: FormattingConfigurationManager, - mode: string + commandManager: CommandManager ) { - this.commandId = `_typescript.applyCodeAction.${mode}`; - commands.registerCommand(this.commandId, this.onCodeAction, this); + commandManager.register(new ApplyCodeActionCommand(this.client)); } public async provideCodeActions( - document: TextDocument, - range: Range, - context: CodeActionContext, - token: CancellationToken - ): Promise { + document: vscode.TextDocument, + range: vscode.Range, + context: vscode.CodeActionContext, + token: vscode.CancellationToken + ): Promise { if (!this.client.apiVersion.has213Features()) { return []; } @@ -73,22 +85,18 @@ export default class TypeScriptCodeActionProvider implements CodeActionProvider return this._supportedCodeActions; } - private async getSupportedActionsForContext(context: CodeActionContext): Promise> { + private async getSupportedActionsForContext(context: vscode.CodeActionContext): Promise> { const supportedActions = await this.supportedCodeActions; return new Set(context.diagnostics .map(diagnostic => +diagnostic.code) .filter(code => supportedActions[code])); } - private getCommandForAction(action: Proto.CodeAction, file: string): Command { + private getCommandForAction(action: Proto.CodeAction, file: string): vscode.Command { return { title: action.description, - command: this.commandId, + command: ApplyCodeActionCommand.ID, arguments: [action, file] }; } - - private onCodeAction(action: Proto.CodeAction, file: string): Promise { - return applyCodeAction(this.client, action, file); - } } \ No newline at end of file diff --git a/extensions/typescript/src/features/completionItemProvider.ts b/extensions/typescript/src/features/completionItemProvider.ts index 376bf8fd3f2..29e40633eea 100644 --- a/extensions/typescript/src/features/completionItemProvider.ts +++ b/extensions/typescript/src/features/completionItemProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CompletionItem, TextDocument, Position, CompletionItemKind, CompletionItemProvider, CancellationToken, TextEdit, Range, SnippetString, workspace, ProviderResult, CompletionContext, commands, Uri, MarkdownString } from 'vscode'; +import { CompletionItem, TextDocument, Position, CompletionItemKind, CompletionItemProvider, CancellationToken, TextEdit, Range, SnippetString, workspace, ProviderResult, CompletionContext, Uri, MarkdownString } from 'vscode'; import { ITypeScriptServiceClient } from '../typescriptService'; import TypingsStatus from '../utils/typingsStatus'; @@ -16,6 +16,7 @@ import { tsTextSpanToVsRange, vsPositionToTsFileLocation } from '../utils/conver import * as nls from 'vscode-nls'; import { applyCodeAction } from '../utils/codeAction'; import * as languageModeIds from '../utils/languageModeIds'; +import { CommandManager, Command } from '../utils/commandManager'; let localize = nls.loadMessageBundle(); @@ -125,6 +126,24 @@ class MyCompletionItem extends CompletionItem { } } +class ApplyCompletionCodeActionCommand implements Command { + public static readonly ID = '_typescript.applyCompletionCodeAction'; + public readonly id = ApplyCompletionCodeActionCommand.ID; + + public constructor( + private readonly client: ITypeScriptServiceClient + ) { } + + public async execute(file: string, codeActions: CodeAction[]): Promise { + for (const action of codeActions) { + if (!(await applyCodeAction(this.client, action, file))) { + return false; + } + } + return true; + } +} + interface Configuration { useCodeSnippetsOnMethodSuggest: boolean; nameSuggestions: boolean; @@ -141,15 +160,12 @@ namespace Configuration { } export default class TypeScriptCompletionItemProvider implements CompletionItemProvider { - private readonly commandId: string; - constructor( private client: ITypeScriptServiceClient, - mode: string, - private typingsStatus: TypingsStatus + private readonly typingsStatus: TypingsStatus, + commandManager: CommandManager ) { - this.commandId = `_typescript.applyCompletionCodeAction.${mode}`; - commands.registerCommand(this.commandId, this.applyCompletionCodeAction, this); + commandManager.register(new ApplyCompletionCodeActionCommand(this.client)); } public async provideCompletionItems( @@ -311,7 +327,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP if (detail.codeActions && detail.codeActions.length) { item.command = { title: '', - command: this.commandId, + command: ApplyCompletionCodeActionCommand.ID, arguments: [filepath, detail.codeActions] }; } @@ -378,16 +394,6 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP return new SnippetString(codeSnippet); } - private async applyCompletionCodeAction(file: string, codeActions: CodeAction[]): Promise { - for (const action of codeActions) { - if (!(await applyCodeAction(this.client, action, file))) { - return false; - } - } - return true; - } - - private getConfiguration(resource: Uri): Configuration { // Use shared setting for js and ts const typeScriptConfig = workspace.getConfiguration('typescript', resource); diff --git a/extensions/typescript/src/features/jsDocCompletionProvider.ts b/extensions/typescript/src/features/jsDocCompletionProvider.ts index 656ba554831..267acadb93f 100644 --- a/extensions/typescript/src/features/jsDocCompletionProvider.ts +++ b/extensions/typescript/src/features/jsDocCompletionProvider.ts @@ -10,6 +10,7 @@ import { DocCommandTemplateResponse } from '../protocol'; import * as nls from 'vscode-nls'; import { vsPositionToTsFileLocation } from '../utils/convert'; +import { Command, CommandManager } from '../utils/commandManager'; const localize = nls.loadMessageBundle(); const configurationNamespace = 'jsDocCompletion'; @@ -45,11 +46,14 @@ class JsDocCompletionItem extends CompletionItem { } } -export class JsDocCompletionProvider implements CompletionItemProvider { +export default class JsDocCompletionProvider implements CompletionItemProvider { constructor( private client: ITypeScriptServiceClient, - ) { } + commandManager: CommandManager + ) { + commandManager.register(new TryCompleteJsDocCommand(client)); + } public provideCompletionItems( document: TextDocument, @@ -77,19 +81,20 @@ export class JsDocCompletionProvider implements CompletionItemProvider { } } -export class TryCompleteJsDocCommand { - static COMMAND_NAME = '_typeScript.tryCompleteJsDoc'; +class TryCompleteJsDocCommand implements Command { + public static readonly COMMAND_NAME = '_typeScript.tryCompleteJsDoc'; + public readonly id = TryCompleteJsDocCommand.COMMAND_NAME; constructor( - private lazyClient: () => ITypeScriptServiceClient + private readonly client: ITypeScriptServiceClient ) { } /** * Try to insert a jsdoc comment, using a template provide by typescript * if possible, otherwise falling back to a default comment format. */ - public async tryCompleteJsDoc(resource: Uri, start: Position, shouldGetJSDocFromTSServer: boolean): Promise { - const file = this.lazyClient().normalizePath(resource); + public async execute(resource: Uri, start: Position, shouldGetJSDocFromTSServer: boolean): Promise { + const file = this.client.normalizePath(resource); if (!file) { return false; } @@ -113,7 +118,7 @@ export class TryCompleteJsDocCommand { private tryInsertJsDocFromTemplate(editor: TextEditor, file: string, position: Position): Promise { const args = vsPositionToTsFileLocation(file, position); return Promise.race([ - this.lazyClient().execute('docCommentTemplate', args), + this.client.execute('docCommentTemplate', args), new Promise((_, reject) => setTimeout(reject, 250)) ]).then((res: DocCommandTemplateResponse) => { if (!res || !res.body) { diff --git a/extensions/typescript/src/features/refactorProvider.ts b/extensions/typescript/src/features/refactorProvider.ts index 4a3a3588040..932b56544fc 100644 --- a/extensions/typescript/src/features/refactorProvider.ts +++ b/extensions/typescript/src/features/refactorProvider.ts @@ -5,35 +5,113 @@ 'use strict'; -import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionContext, Command, commands, workspace, WorkspaceEdit, window, QuickPickItem, Selection } from 'vscode'; +import * as vscode from 'vscode'; import * as Proto from '../protocol'; import { ITypeScriptServiceClient } from '../typescriptService'; import { tsTextSpanToVsRange, vsRangeToTsFileRange, tsLocationToVsPosition } from '../utils/convert'; import FormattingOptionsManager from './formattingConfigurationManager'; +import { CommandManager, Command } from '../utils/commandManager'; -export default class TypeScriptRefactorProvider implements CodeActionProvider { - private doRefactorCommandId: string; - private selectRefactorCommandId: string; +class ApplyRefactoringCommand implements Command { + public static readonly ID = '_typescript.applyRefactoring'; + public readonly id = ApplyRefactoringCommand.ID; constructor( private readonly client: ITypeScriptServiceClient, - private formattingOptionsManager: FormattingOptionsManager, - mode: string - ) { - this.doRefactorCommandId = `_typescript.applyRefactoring.${mode}`; - this.selectRefactorCommandId = `_typescript.selectRefactoring.${mode}`; + private formattingOptionsManager: FormattingOptionsManager + ) { } - commands.registerCommand(this.doRefactorCommandId, this.doRefactoring, this); - commands.registerCommand(this.selectRefactorCommandId, this.selectRefactoring, this); + public async execute( + document: vscode.TextDocument, + file: string, + refactor: string, + action: string, + range: vscode.Range + ): Promise { + await this.formattingOptionsManager.ensureFormatOptionsForDocument(document, undefined); + + const args: Proto.GetEditsForRefactorRequestArgs = { + ...vsRangeToTsFileRange(file, range), + refactor, + action + }; + + const response = await this.client.execute('getEditsForRefactor', args); + if (!response || !response.body || !response.body.edits.length) { + return false; + } + + const edit = this.toWorkspaceEdit(response.body.edits); + if (!(await vscode.workspace.applyEdit(edit))) { + return false; + } + + const renameLocation = response.body.renameLocation; + if (renameLocation) { + if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri.fsPath === file) { + const pos = tsLocationToVsPosition(renameLocation); + vscode.window.activeTextEditor.selection = new vscode.Selection(pos, pos); + await vscode.commands.executeCommand('editor.action.rename'); + } + } + return true; + } + + private toWorkspaceEdit(edits: Proto.FileCodeEdits[]): vscode.WorkspaceEdit { + const workspaceEdit = new vscode.WorkspaceEdit(); + for (const edit of edits) { + for (const textChange of edit.textChanges) { + workspaceEdit.replace(this.client.asUrl(edit.fileName), + tsTextSpanToVsRange(textChange), + textChange.newText); + } + } + return workspaceEdit; + } +} + +class SelectRefactorCommand implements Command { + public static readonly ID = '_typescript.selectRefactoring'; + public readonly id = SelectRefactorCommand.ID; + + constructor( + private readonly doRefactoring: ApplyRefactoringCommand + ) { } + + public async execute( + document: vscode.TextDocument, + file: string, + info: Proto.ApplicableRefactorInfo, + range: vscode.Range + ): Promise { + const selected = await vscode.window.showQuickPick(info.actions.map((action): vscode.QuickPickItem => ({ + label: action.name, + description: action.description + }))); + if (!selected) { + return false; + } + return this.doRefactoring.execute(document, file, info.name, selected.label, range); + } +} + +export default class TypeScriptRefactorProvider implements vscode.CodeActionProvider { + constructor( + private readonly client: ITypeScriptServiceClient, + formattingOptionsManager: FormattingOptionsManager, + commandManager: CommandManager + ) { + const doRefactoringCommand = commandManager.register(new ApplyRefactoringCommand(this.client, formattingOptionsManager)); + commandManager.register(new SelectRefactorCommand(doRefactoringCommand)); } public async provideCodeActions( - document: TextDocument, - range: Range, - _context: CodeActionContext, - token: CancellationToken - ): Promise { + document: vscode.TextDocument, + range: vscode.Range, + _context: vscode.CodeActionContext, + token: vscode.CancellationToken + ): Promise { if (!this.client.apiVersion.has240Features()) { return []; } @@ -50,19 +128,19 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider { return []; } - const actions: Command[] = []; + const actions: vscode.Command[] = []; for (const info of response.body) { if (info.inlineable === false) { actions.push({ title: info.description, - command: this.selectRefactorCommandId, + command: SelectRefactorCommand.ID, arguments: [document, file, info, range] }); } else { for (const action of info.actions) { actions.push({ title: action.description, - command: this.doRefactorCommandId, + command: ApplyRefactoringCommand.ID, arguments: [document, file, info.name, action.name, range] }); } @@ -73,57 +151,4 @@ export default class TypeScriptRefactorProvider implements CodeActionProvider { return []; } } - - private toWorkspaceEdit(edits: Proto.FileCodeEdits[]): WorkspaceEdit { - const workspaceEdit = new WorkspaceEdit(); - for (const edit of edits) { - for (const textChange of edit.textChanges) { - workspaceEdit.replace(this.client.asUrl(edit.fileName), - tsTextSpanToVsRange(textChange), - textChange.newText); - } - } - return workspaceEdit; - } - - private async selectRefactoring(document: TextDocument, file: string, info: Proto.ApplicableRefactorInfo, range: Range): Promise { - const selected = await window.showQuickPick(info.actions.map((action): QuickPickItem => ({ - label: action.name, - description: action.description - }))); - if (!selected) { - return false; - } - return this.doRefactoring(document, file, info.name, selected.label, range); - } - - private async doRefactoring(document: TextDocument, file: string, refactor: string, action: string, range: Range): Promise { - await this.formattingOptionsManager.ensureFormatOptionsForDocument(document, undefined); - - const args: Proto.GetEditsForRefactorRequestArgs = { - ...vsRangeToTsFileRange(file, range), - refactor, - action - }; - - const response = await this.client.execute('getEditsForRefactor', args); - if (!response || !response.body || !response.body.edits.length) { - return false; - } - - const edit = this.toWorkspaceEdit(response.body.edits); - if (!(await workspace.applyEdit(edit))) { - return false; - } - - const renameLocation = response.body.renameLocation; - if (renameLocation) { - if (window.activeTextEditor && window.activeTextEditor.document.uri.fsPath === file) { - const pos = tsLocationToVsPosition(renameLocation); - window.activeTextEditor.selection = new Selection(pos, pos); - await commands.executeCommand('editor.action.rename'); - } - } - return true; - } } \ No newline at end of file diff --git a/extensions/typescript/src/features/workspaceSymbolProvider.ts b/extensions/typescript/src/features/workspaceSymbolProvider.ts index a25f2a9e3a2..b344f5498ce 100644 --- a/extensions/typescript/src/features/workspaceSymbolProvider.ts +++ b/extensions/typescript/src/features/workspaceSymbolProvider.ts @@ -24,7 +24,8 @@ function getSymbolKind(item: Proto.NavtoItem): SymbolKind { export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbolProvider { public constructor( private client: ITypeScriptServiceClient, - private modeId: string) { } + private modeIds: string[] + ) { } public async provideWorkspaceSymbols(search: string, token: CancellationToken): Promise { // typescript wants to have a resource even when asking @@ -34,14 +35,14 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo const editor = window.activeTextEditor; if (editor) { const document = editor.document; - if (document && document.languageId === this.modeId) { + if (document && this.modeIds.indexOf(document.languageId) >= 0) { uri = document.uri; } } if (!uri) { const documents = workspace.textDocuments; for (const document of documents) { - if (document.languageId === this.modeId) { + if (this.modeIds.indexOf(document.languageId) >= 0) { uri = document.uri; break; } diff --git a/extensions/typescript/src/typescriptMain.ts b/extensions/typescript/src/typescriptMain.ts index 009247e7961..91f6780b2cd 100644 --- a/extensions/typescript/src/typescriptMain.ts +++ b/extensions/typescript/src/typescriptMain.ts @@ -25,7 +25,6 @@ import TypeScriptServiceClient from './typescriptServiceClient'; import { ITypeScriptServiceClientHost } from './typescriptService'; import BufferSyncSupport from './features/bufferSyncSupport'; -import { JsDocCompletionProvider, TryCompleteJsDocCommand } from './features/jsDocCompletionProvider'; import TypeScriptTaskProviderManager from './features/taskProvider'; import * as ProjectStatus from './utils/projectStatus'; @@ -36,6 +35,7 @@ import { openOrCreateConfigFile, isImplicitProjectConfigFile } from './utils/tsc import { tsLocationToVsPosition } from './utils/convert'; import FormattingConfigurationManager from './features/formattingConfigurationManager'; import * as languageModeIds from './utils/languageModeIds'; +import { CommandManager, Command } from './utils/commandManager'; interface LanguageDescription { id: string; @@ -45,16 +45,6 @@ interface LanguageDescription { isExternal?: boolean; } -enum ProjectConfigAction { - None, - CreateConfig, - LearnMore -} - -interface ProjectConfigMessageItem extends MessageItem { - id: ProjectConfigAction; -} - const standardLanguageDescriptions: LanguageDescription[] = [ { id: 'typescript', @@ -69,14 +59,107 @@ const standardLanguageDescriptions: LanguageDescription[] = [ } ]; +class ReloadTypeScriptProjectsCommand implements Command { + public readonly id = 'typescript.reloadProjects'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost + ) { } + + public execute() { + this.lazyClientHost().reloadProjects(); + } +} + +class ReloadJavaScriptProjectsCommand implements Command { + public readonly id = 'javascript.reloadProjects'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost + ) { } + + public execute() { + this.lazyClientHost().reloadProjects(); + } +} + +class SelectTypeScriptVersionCommand implements Command { + public readonly id = 'typescript.selectTypeScriptVersion'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost + ) { } + + public execute() { + this.lazyClientHost().serviceClient.onVersionStatusClicked(); + } +} + +class OpenTsServerLogCommand implements Command { + public readonly id = 'typescript.openTsServerLog'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost + ) { } + + public execute() { + this.lazyClientHost().serviceClient.openTsServerLogFile(); + } +} + +class RestartTsServerCommand implements Command { + public readonly id = 'typescript.restartTsServer'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost + ) { } + + public execute() { + this.lazyClientHost().serviceClient.restartTsServer(); + } +} + +class TypeScriptGoToProjectConfigCommand implements Command { + public readonly id = 'typescript.goToProjectConfig'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost, + ) { } + + public execute() { + const editor = window.activeTextEditor; + if (editor) { + this.lazyClientHost().goToProjectConfig(true, editor.document.uri); + } + } +} + +class JavaScriptGoToProjectConfigCommand implements Command { + public readonly id = 'javascript.goToProjectConfig'; + + public constructor( + private readonly lazyClientHost: () => TypeScriptServiceClientHost, + ) { } + + public execute() { + const editor = window.activeTextEditor; + if (editor) { + this.lazyClientHost().goToProjectConfig(false, editor.document.uri); + } + } +} + export function activate(context: ExtensionContext): void { const plugins = getContributedTypeScriptServerPlugins(); + const commandManager = new CommandManager(); + context.subscriptions.push(commandManager); + const lazyClientHost = (() => { let clientHost: TypeScriptServiceClientHost | undefined; return () => { if (!clientHost) { - clientHost = new TypeScriptServiceClientHost(standardLanguageDescriptions, context.workspaceState, plugins); + clientHost = new TypeScriptServiceClientHost(standardLanguageDescriptions, context.workspaceState, plugins, commandManager); context.subscriptions.push(clientHost); const host = clientHost; @@ -92,42 +175,16 @@ export function activate(context: ExtensionContext): void { }; })(); - - context.subscriptions.push(commands.registerCommand('typescript.reloadProjects', () => { - lazyClientHost().reloadProjects(); - })); - - context.subscriptions.push(commands.registerCommand('javascript.reloadProjects', () => { - lazyClientHost().reloadProjects(); - })); - - context.subscriptions.push(commands.registerCommand('typescript.selectTypeScriptVersion', () => { - lazyClientHost().serviceClient.onVersionStatusClicked(); - })); - - context.subscriptions.push(commands.registerCommand('typescript.openTsServerLog', () => { - lazyClientHost().serviceClient.openTsServerLogFile(); - })); - - context.subscriptions.push(commands.registerCommand('typescript.restartTsServer', () => { - lazyClientHost().serviceClient.restartTsServer(); - })); + commandManager.register(new ReloadTypeScriptProjectsCommand(lazyClientHost)); + commandManager.register(new ReloadJavaScriptProjectsCommand(lazyClientHost)); + commandManager.register(new SelectTypeScriptVersionCommand(lazyClientHost)); + commandManager.register(new OpenTsServerLogCommand(lazyClientHost)); + commandManager.register(new RestartTsServerCommand(lazyClientHost)); + commandManager.register(new TypeScriptGoToProjectConfigCommand(lazyClientHost)); + commandManager.register(new JavaScriptGoToProjectConfigCommand(lazyClientHost)); context.subscriptions.push(new TypeScriptTaskProviderManager(() => lazyClientHost().serviceClient)); - const goToProjectConfig = (isTypeScript: boolean) => { - const editor = window.activeTextEditor; - if (editor) { - lazyClientHost().goToProjectConfig(isTypeScript, editor.document.uri); - } - }; - context.subscriptions.push(commands.registerCommand('typescript.goToProjectConfig', goToProjectConfig.bind(null, true))); - context.subscriptions.push(commands.registerCommand('javascript.goToProjectConfig', goToProjectConfig.bind(null, false))); - - const jsDocCompletionCommand = new TryCompleteJsDocCommand(() => lazyClientHost().serviceClient); - context.subscriptions.push(commands.registerCommand(TryCompleteJsDocCommand.COMMAND_NAME, jsDocCompletionCommand.tryCompleteJsDoc, jsDocCompletionCommand)); - - const EMPTY_ELEMENTS: string[] = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']; context.subscriptions.push(languages.setLanguageConfiguration('jsx-tags', { @@ -154,7 +211,7 @@ export function activate(context: ExtensionContext): void { return true; } return false; - }; + } const openListener = workspace.onDidOpenTextDocument(didOpenTextDocument); for (let textDocument of workspace.textDocuments) { if (didOpenTextDocument(textDocument)) { @@ -187,7 +244,8 @@ class LanguageProvider { constructor( private readonly client: TypeScriptServiceClient, - private readonly description: LanguageDescription + private readonly description: LanguageDescription, + private readonly commandManager: CommandManager ) { this.formattingOptionsManager = new FormattingConfigurationManager(client); this.bufferSyncSupport = new BufferSyncSupport(client, description.modeIds, { @@ -238,8 +296,9 @@ class LanguageProvider { const selector = this.description.modeIds; const config = workspace.getConfiguration(this.id); - const completionItemProvider = new (await import('./features/completionItemProvider')).default(client, this.description.id, this.typingsStatus); - this.disposables.push(languages.registerCompletionItemProvider(selector, completionItemProvider, '.', '"', '\'', '/', '@')); + this.disposables.push(languages.registerCompletionItemProvider(selector, + new (await import('./features/completionItemProvider')).default(client, this.typingsStatus, this.commandManager), + '.', '"', '\'', '/', '@')); this.disposables.push(languages.registerCompletionItemProvider(selector, new (await import('./features/directiveCommentCompletionProvider')).default(client), '@')); @@ -253,7 +312,7 @@ class LanguageProvider { this.disposables.push(formattingProviderManager); this.toUpdateOnConfigurationChanged.push(formattingProviderManager); - this.disposables.push(languages.registerCompletionItemProvider(selector, new JsDocCompletionProvider(client), '*')); + this.disposables.push(languages.registerCompletionItemProvider(selector, new (await import('./features/jsDocCompletionProvider')).default(client, this.commandManager), '*')); this.disposables.push(languages.registerHoverProvider(selector, new (await import('./features/hoverProvider')).default(client))); this.disposables.push(languages.registerDefinitionProvider(selector, new (await import('./features/definitionProvider')).default(client))); this.disposables.push(languages.registerDocumentHighlightProvider(selector, new (await import('./features/documentHighlightProvider')).default(client))); @@ -261,24 +320,24 @@ class LanguageProvider { this.disposables.push(languages.registerDocumentSymbolProvider(selector, new (await import('./features/documentSymbolProvider')).default(client))); this.disposables.push(languages.registerSignatureHelpProvider(selector, new (await import('./features/signatureHelpProvider')).default(client), '(', ',')); this.disposables.push(languages.registerRenameProvider(selector, new (await import('./features/renameProvider')).default(client))); - this.disposables.push(languages.registerCodeActionsProvider(selector, new (await import('./features/codeActionProvider')).default(client, this.formattingOptionsManager, this.description.id))); - this.disposables.push(languages.registerCodeActionsProvider(selector, new (await import('./features/refactorProvider')).default(client, this.formattingOptionsManager, this.description.id))); + this.disposables.push(languages.registerCodeActionsProvider(selector, new (await import('./features/codeActionProvider')).default(client, this.formattingOptionsManager, this.commandManager))); + this.disposables.push(languages.registerCodeActionsProvider(selector, new (await import('./features/refactorProvider')).default(client, this.formattingOptionsManager, this.commandManager))); this.registerVersionDependentProviders(); - for (const modeId of this.description.modeIds) { - this.disposables.push(languages.registerWorkspaceSymbolProvider(new (await import('./features/workspaceSymbolProvider')).default(client, modeId))); + const referenceCodeLensProvider = new (await import('./features/referencesCodeLensProvider')).default(client, this.description.id); + referenceCodeLensProvider.updateConfiguration(); + this.toUpdateOnConfigurationChanged.push(referenceCodeLensProvider); + this.disposables.push(languages.registerCodeLensProvider(selector, referenceCodeLensProvider)); - const referenceCodeLensProvider = new (await import('./features/referencesCodeLensProvider')).default(client, modeId); - referenceCodeLensProvider.updateConfiguration(); - this.toUpdateOnConfigurationChanged.push(referenceCodeLensProvider); - this.disposables.push(languages.registerCodeLensProvider(selector, referenceCodeLensProvider)); + const implementationCodeLensProvider = new (await import('./features/implementationsCodeLensProvider')).default(client, this.description.id); + implementationCodeLensProvider.updateConfiguration(); + this.toUpdateOnConfigurationChanged.push(implementationCodeLensProvider); + this.disposables.push(languages.registerCodeLensProvider(selector, implementationCodeLensProvider)); - const implementationCodeLensProvider = new (await import('./features/implementationsCodeLensProvider')).default(client, modeId); - implementationCodeLensProvider.updateConfiguration(); - this.toUpdateOnConfigurationChanged.push(implementationCodeLensProvider); - this.disposables.push(languages.registerCodeLensProvider(selector, implementationCodeLensProvider)); + this.disposables.push(languages.registerWorkspaceSymbolProvider(new (await import('./features/workspaceSymbolProvider')).default(client, this.description.modeIds))); - if (!this.description.isExternal) { + if (!this.description.isExternal) { + for (const modeId of this.description.modeIds) { this.disposables.push(languages.setLanguageConfiguration(modeId, { indentationRules: { // ^(.*\*/)?\s*\}.*$ @@ -442,7 +501,8 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost { constructor( descriptions: LanguageDescription[], workspaceState: Memento, - plugins: TypeScriptServerPlugin[] + plugins: TypeScriptServerPlugin[], + private commandManager: CommandManager ) { const handleProjectCreateOrDelete = () => { this.client.execute('reloadProjects', null, false); @@ -467,7 +527,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost { this.languagePerId = new Map(); for (const description of descriptions) { - const manager = new LanguageProvider(this.client, description); + const manager = new LanguageProvider(this.client, description, this.commandManager); this.languages.push(manager); this.disposables.push(manager); this.languagePerId.set(description.id, manager); @@ -491,7 +551,7 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost { diagnosticSource: 'ts-plugins', isExternal: true }; - const manager = new LanguageProvider(this.client, description); + const manager = new LanguageProvider(this.client, description, this.commandManager); this.languages.push(manager); this.disposables.push(manager); this.languagePerId.set(description.id, manager); @@ -566,6 +626,16 @@ class TypeScriptServiceClientHost implements ITypeScriptServiceClientHost { return; } + enum ProjectConfigAction { + None, + CreateConfig, + LearnMore + } + + interface ProjectConfigMessageItem extends MessageItem { + id: ProjectConfigAction; + } + const selected = await window.showInformationMessage( (isTypeScriptProject ? localize('typescript.noTypeScriptProjectConfig', 'File is not part of a TypeScript project') diff --git a/extensions/typescript/src/typescriptServiceClient.ts b/extensions/typescript/src/typescriptServiceClient.ts index 60c1adbf66e..fb4f732e7ce 100644 --- a/extensions/typescript/src/typescriptServiceClient.ts +++ b/extensions/typescript/src/typescriptServiceClient.ts @@ -375,6 +375,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient this.isRestarting = false; }); + // tslint:disable-next-line:no-unused-expression new Reader( childProcess.stdout, (msg) => { this.dispatchMessage(msg); }, diff --git a/extensions/typescript/src/utils/commandManager.ts b/extensions/typescript/src/utils/commandManager.ts new file mode 100644 index 00000000000..4f3e6a8f3d3 --- /dev/null +++ b/extensions/typescript/src/utils/commandManager.ts @@ -0,0 +1,36 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as vscode from 'vscode'; + +export interface Command { + readonly id: string; + + execute(...args: any[]): void; +} + +export class CommandManager { + private readonly commands = new Map(); + + public dispose() { + for (const registration of this.commands.values()) { + registration.dispose(); + } + this.commands.clear(); + } + + private registerCommand(id: string, impl: (...args: any[]) => void, thisArg?: any) { + if (this.commands.has(id)) { + return; + } + + this.commands.set(id, vscode.commands.registerCommand(id, impl, thisArg)); + } + + public register(command: T): T { + this.registerCommand(command.id, command.execute, command); + return command; + } +} \ No newline at end of file diff --git a/extensions/typescript/src/utils/tsconfig.ts b/extensions/typescript/src/utils/tsconfig.ts index db3cb65e798..a495afc5590 100644 --- a/extensions/typescript/src/utils/tsconfig.ts +++ b/extensions/typescript/src/utils/tsconfig.ts @@ -36,22 +36,22 @@ function getEmptyConfig( }`); } -export function openOrCreateConfigFile( +export async function openOrCreateConfigFile( isTypeScriptProject: boolean, rootPath: string, config: TypeScriptServiceConfiguration -): Thenable { +): Promise { const configFile = vscode.Uri.file(path.join(rootPath, isTypeScriptProject ? 'tsconfig.json' : 'jsconfig.json')); const col = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.viewColumn : undefined; - return vscode.workspace.openTextDocument(configFile) - .then(doc => { - return vscode.window.showTextDocument(doc, col); - }, async () => { - const doc = await vscode.workspace.openTextDocument(configFile.with({ scheme: 'untitled' })); - const editor = await vscode.window.showTextDocument(doc, col); - if (editor.document.getText().length === 0) { - await editor.insertSnippet(getEmptyConfig(isTypeScriptProject, config)); - } - return editor; - }); + try { + const doc = await vscode.workspace.openTextDocument(configFile); + return vscode.window.showTextDocument(doc, col); + } catch { + const doc = await vscode.workspace.openTextDocument(configFile.with({ scheme: 'untitled' })); + const editor = await vscode.window.showTextDocument(doc, col); + if (editor.document.getText().length === 0) { + await editor.insertSnippet(getEmptyConfig(isTypeScriptProject, config)); + } + return editor; + } } \ No newline at end of file diff --git a/extensions/vscode-api-tests/src/commands.test.ts b/extensions/vscode-api-tests/src/commands.test.ts index 0d92795d241..45da4f2df48 100644 --- a/extensions/vscode-api-tests/src/commands.test.ts +++ b/extensions/vscode-api-tests/src/commands.test.ts @@ -5,6 +5,7 @@ 'use strict'; +import 'mocha'; import * as assert from 'assert'; import { join } from 'path'; import { commands, workspace, window, Uri, ViewColumn, Range, Position } from 'vscode'; diff --git a/extensions/vscode-api-tests/src/configuration.test.ts b/extensions/vscode-api-tests/src/configuration.test.ts index 65dc52e4537..ffd8b53e06c 100644 --- a/extensions/vscode-api-tests/src/configuration.test.ts +++ b/extensions/vscode-api-tests/src/configuration.test.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import 'mocha'; import * as assert from 'assert'; import * as vscode from 'vscode'; diff --git a/extensions/vscode-api-tests/src/languages.test.ts b/extensions/vscode-api-tests/src/languages.test.ts index 321b1b772f2..01dea3ddc3f 100644 --- a/extensions/vscode-api-tests/src/languages.test.ts +++ b/extensions/vscode-api-tests/src/languages.test.ts @@ -78,12 +78,12 @@ suite('languages namespace tests', () => { }); return workspace.openTextDocument(uri).then(doc => { - return commands.executeCommand('vscode.executeCompletionItemProvider', uri, new Position(1, 0)); - }).then((result: CompletionList) => { + return commands.executeCommand('vscode.executeCompletionItemProvider', uri, new Position(1, 0)); + }).then((result: CompletionList | undefined) => { r1.dispose(); assert.ok(ran); - console.log(result.items); - assert.equal(result.items[0].label, 'foo'); + console.log(result!.items); + assert.equal(result!.items[0].label, 'foo'); }); }); }); diff --git a/extensions/vscode-api-tests/src/typings/ref.d.ts b/extensions/vscode-api-tests/src/typings/ref.d.ts index 3bc58fa959d..77807029165 100644 --- a/extensions/vscode-api-tests/src/typings/ref.d.ts +++ b/extensions/vscode-api-tests/src/typings/ref.d.ts @@ -4,5 +4,4 @@ *--------------------------------------------------------------------------------------------*/ /// -/// /// diff --git a/extensions/vscode-api-tests/src/window.test.ts b/extensions/vscode-api-tests/src/window.test.ts index c197808fd9e..2a2f92c90e7 100644 --- a/extensions/vscode-api-tests/src/window.test.ts +++ b/extensions/vscode-api-tests/src/window.test.ts @@ -350,7 +350,7 @@ suite('window namespace tests', () => { }); test('showWorkspaceFolderPick', function () { - const p = (window).showWorkspaceFolderPick(undefined); + const p = window.showWorkspaceFolderPick(undefined); return commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem').then(() => { return p.then(workspace => { diff --git a/extensions/vscode-api-tests/tsconfig.json b/extensions/vscode-api-tests/tsconfig.json index 26c357e374b..a8cae381174 100644 --- a/extensions/vscode-api-tests/tsconfig.json +++ b/extensions/vscode-api-tests/tsconfig.json @@ -3,11 +3,12 @@ "module": "commonjs", "target": "ES5", "outDir": "out", + "noUnusedLocals": true, "lib": [ "es2015" ], "sourceMap": true, - "strictNullChecks": true + "strict": true }, "include": [ "src/**/*" diff --git a/extensions/vscode-colorize-tests/src/colorizer.test.ts b/extensions/vscode-colorize-tests/src/colorizer.test.ts index e3a34a27524..7fb9ae02e62 100644 --- a/extensions/vscode-colorize-tests/src/colorizer.test.ts +++ b/extensions/vscode-colorize-tests/src/colorizer.test.ts @@ -5,6 +5,7 @@ 'use strict'; +import 'mocha'; import * as assert from 'assert'; import { commands, Uri } from 'vscode'; import { join, basename, normalize, dirname } from 'path'; diff --git a/extensions/vscode-colorize-tests/src/typings/ref.d.ts b/extensions/vscode-colorize-tests/src/typings/ref.d.ts index 0f121ddcf43..8ea9f802a47 100644 --- a/extensions/vscode-colorize-tests/src/typings/ref.d.ts +++ b/extensions/vscode-colorize-tests/src/typings/ref.d.ts @@ -3,5 +3,4 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/// /// diff --git a/extensions/vscode-colorize-tests/tsconfig.json b/extensions/vscode-colorize-tests/tsconfig.json index 610a5da7c03..a8cae381174 100644 --- a/extensions/vscode-colorize-tests/tsconfig.json +++ b/extensions/vscode-colorize-tests/tsconfig.json @@ -3,6 +3,7 @@ "module": "commonjs", "target": "ES5", "outDir": "out", + "noUnusedLocals": true, "lib": [ "es2015" ], diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a07afb10466..c7ff262ecec 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -591,7 +591,7 @@ "xterm": { "version": "2.9.1", "from": "Tyriar/xterm.js#vscode-release/1.19", - "resolved": "git+https://github.com/Tyriar/xterm.js.git#004d47b7255f0d5eea4093e6a336a2da3157bc8d" + "resolved": "git+https://github.com/Tyriar/xterm.js.git#d242c552cb5c88125ac257ccaebed7fe336d9266" }, "yauzl": { "version": "2.8.0", diff --git a/package.json b/package.json index bf4175a7465..97d41337a00 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "gulp-shell": "^0.5.2", "gulp-sourcemaps": "^1.11.0", "gulp-tsb": "2.0.4", - "gulp-tslint": "^7.0.1", + "gulp-tslint": "^8.1.2", "gulp-uglify": "^3.0.0", "gulp-util": "^3.0.6", "gulp-vinyl-zip": "^1.2.2", @@ -107,7 +107,7 @@ "rimraf": "^2.2.8", "sinon": "^1.17.2", "source-map": "^0.4.4", - "tslint": "^4.3.1", + "tslint": "^5.8.0", "typescript": "2.6.1", "typescript-formatter": "4.0.1", "uglify-es": "^3.0.18", diff --git a/src/tsconfig.json b/src/tsconfig.json index ed888ce8a0f..2d516dd2313 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -10,6 +10,8 @@ "experimentalDecorators": true, "declaration": true, "noImplicitReturns": true, + "noUnusedLocals": true, + "noImplicitThis": true, "baseUrl": ".", "typeRoots": [ "typings" diff --git a/src/vs/base/browser/builder.ts b/src/vs/base/browser/builder.ts index 4ab3711618e..d7e54d6b39b 100644 --- a/src/vs/base/browser/builder.ts +++ b/src/vs/base/browser/builder.ts @@ -559,9 +559,9 @@ export class Builder implements IDisposable { /** * Registers listener on event types on the current element. */ - public on(type: string, fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; - public on(typeArray: string[], fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; - public on(arg1: any, fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder { + public on(type: string, fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; + public on(typeArray: string[], fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; + public on(arg1: any, fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder { // Event Type Array if (types.isArray(arg1)) { @@ -575,7 +575,7 @@ export class Builder implements IDisposable { let type = arg1; // Add Listener - let unbind: IDisposable = DOM.addDisposableListener(this.currentElement, type, (e: Event) => { + let unbind: IDisposable = DOM.addDisposableListener(this.currentElement, type, (e) => { fn(e, this, unbind); // Pass in Builder as Second Argument }, useCapture || false); @@ -641,9 +641,9 @@ export class Builder implements IDisposable { * Registers listener on event types on the current element and removes * them after first invocation. */ - public once(type: string, fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; - public once(typesArray: string[], fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; - public once(arg1: any, fn: (e: Event, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder { + public once(type: string, fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; + public once(typesArray: string[], fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder; + public once(arg1: any, fn: (e: E, builder: Builder, unbind: IDisposable) => void, listenerToUnbindContainer?: IDisposable[], useCapture?: boolean): Builder { // Event Type Array if (types.isArray(arg1)) { @@ -657,7 +657,7 @@ export class Builder implements IDisposable { let type = arg1; // Add Listener - let unbind: IDisposable = DOM.addDisposableListener(this.currentElement, type, (e: Event) => { + let unbind: IDisposable = DOM.addDisposableListener(this.currentElement, type, (e) => { fn(e, this, unbind); // Pass in Builder as Second Argument unbind.dispose(); }, useCapture || false); diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts index b8af134f20e..8087c77656e 100644 --- a/src/vs/base/browser/dom.ts +++ b/src/vs/base/browser/dom.ts @@ -413,18 +413,18 @@ class AnimationFrameQueueItem implements IDisposable { /** * Add a throttled listener. `handler` is fired at most every 16ms or with the next animation frame (if browser supports it). */ -export interface IEventMerger { - (lastEvent: R, currentEvent: Event): R; +export interface IEventMerger { + (lastEvent: R, currentEvent: E): R; } const MINIMUM_TIME_MS = 16; -const DEFAULT_EVENT_MERGER: IEventMerger = function (lastEvent: Event, currentEvent: Event) { +const DEFAULT_EVENT_MERGER: IEventMerger = function (lastEvent: Event, currentEvent: Event) { return currentEvent; }; -class TimeoutThrottledDomListener extends Disposable { +class TimeoutThrottledDomListener extends Disposable { - constructor(node: any, type: string, handler: (event: R) => void, eventMerger: IEventMerger = DEFAULT_EVENT_MERGER, minimumTimeMs: number = MINIMUM_TIME_MS) { + constructor(node: any, type: string, handler: (event: R) => void, eventMerger: IEventMerger = DEFAULT_EVENT_MERGER, minimumTimeMs: number = MINIMUM_TIME_MS) { super(); let lastEvent: R = null; @@ -452,8 +452,8 @@ class TimeoutThrottledDomListener extends Disposable { } } -export function addDisposableThrottledListener(node: any, type: string, handler: (event: R) => void, eventMerger?: IEventMerger, minimumTimeMs?: number): IDisposable { - return new TimeoutThrottledDomListener(node, type, handler, eventMerger, minimumTimeMs); +export function addDisposableThrottledListener(node: any, type: string, handler: (event: R) => void, eventMerger?: IEventMerger, minimumTimeMs?: number): IDisposable { + return new TimeoutThrottledDomListener(node, type, handler, eventMerger, minimumTimeMs); } export function getComputedStyle(el: HTMLElement): CSSStyleDeclaration { diff --git a/src/vs/base/browser/globalMouseMoveMonitor.ts b/src/vs/base/browser/globalMouseMoveMonitor.ts index 3e2e2fc289e..09b2f37842e 100644 --- a/src/vs/base/browser/globalMouseMoveMonitor.ts +++ b/src/vs/base/browser/globalMouseMoveMonitor.ts @@ -96,7 +96,7 @@ export class GlobalMouseMoveMonitor extends Disposable { for (let i = 0; i < windowChain.length; i++) { this.hooks.push(dom.addDisposableThrottledListener(windowChain[i].window.document, 'mousemove', (data: R) => this.mouseMoveCallback(data), - (lastEvent: R, currentEvent: MouseEvent) => this.mouseMoveEventMerger(lastEvent, currentEvent) + (lastEvent: R, currentEvent) => this.mouseMoveEventMerger(lastEvent, currentEvent as MouseEvent) )); this.hooks.push(dom.addDisposableListener(windowChain[i].window.document, 'mouseup', (e: MouseEvent) => this.stopMonitoring(true))); } diff --git a/src/vs/base/browser/htmlContentRenderer.ts b/src/vs/base/browser/htmlContentRenderer.ts index bf8dfd41504..1a0097aadf8 100644 --- a/src/vs/base/browser/htmlContentRenderer.ts +++ b/src/vs/base/browser/htmlContentRenderer.ts @@ -50,8 +50,6 @@ export function renderFormattedText(formattedText: string, options: RenderOption export function renderMarkdown(markdown: IMarkdownString, options: RenderOptions = {}): HTMLElement { const element = createElement(options); - const { codeBlockRenderer, actionCallback } = options; - // signal to code-block render that the // element has been created let signalInnerHTML: Function; diff --git a/src/vs/base/browser/keyboardEvent.ts b/src/vs/base/browser/keyboardEvent.ts index 6f90f1b1b07..22b92dbb28f 100644 --- a/src/vs/base/browser/keyboardEvent.ts +++ b/src/vs/base/browser/keyboardEvent.ts @@ -163,7 +163,7 @@ function extractKeyCode(e: KeyboardEvent): KeyCode { return KeyCodeUtils.fromString(char); } return KEY_CODE_MAP[e.keyCode] || KeyCode.Unknown; -}; +} export interface IKeyboardEvent { readonly browserEvent: KeyboardEvent; diff --git a/src/vs/base/browser/ui/findinput/findInput.ts b/src/vs/base/browser/ui/findinput/findInput.ts index 958297431e2..fe0788dbf3a 100644 --- a/src/vs/base/browser/ui/findinput/findInput.ts +++ b/src/vs/base/browser/ui/findinput/findInput.ts @@ -268,8 +268,7 @@ export class FindInput extends Widget { placeholder: this.placeholder || '', ariaLabel: this.label || '', validationOptions: { - validation: this.validation || null, - showMessage: true + validation: this.validation || null }, inputBackground: this.inputBackground, inputForeground: this.inputForeground, diff --git a/src/vs/base/browser/ui/inputbox/inputBox.ts b/src/vs/base/browser/ui/inputbox/inputBox.ts index 378ec0c525d..8dfb882931c 100644 --- a/src/vs/base/browser/ui/inputbox/inputBox.ts +++ b/src/vs/base/browser/ui/inputbox/inputBox.ts @@ -54,7 +54,6 @@ export interface IMessage { export interface IInputValidationOptions { validation: IInputValidator; - showMessage?: boolean; } export enum MessageType { @@ -90,7 +89,6 @@ export class InputBox extends Widget { private placeholder: string; private ariaLabel: string; private validation: IInputValidator; - private showValidationMessage: boolean; private state = 'idle'; private cachedHeight: number; @@ -135,7 +133,6 @@ export class InputBox extends Widget { if (this.options.validationOptions) { this.validation = this.options.validationOptions.validation; - this.showValidationMessage = this.options.validationOptions.showMessage || false; } this.element = dom.append(container, $('.monaco-inputbox.idle')); @@ -497,7 +494,6 @@ export class InputBox extends Widget { this.placeholder = null; this.ariaLabel = null; this.validation = null; - this.showValidationMessage = null; this.state = null; this.actionbar = null; diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 5742fa0dc35..16f8e590c29 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -52,7 +52,7 @@ interface IRenderedElement { index: number; } -class TraitRenderer implements IRenderer +class TraitRenderer implements IRenderer { private rendered: IRenderedElement[] = []; @@ -107,8 +107,8 @@ class Trait implements ISpliceable, IDisposable { get trait(): string { return this._trait; } @memoize - get renderer(): TraitRenderer { - return new TraitRenderer(this); + get renderer(): TraitRenderer { + return new TraitRenderer(this); } constructor(private _trait: string) { diff --git a/src/vs/base/browser/ui/progressbar/progressbar.ts b/src/vs/base/browser/ui/progressbar/progressbar.ts index ea34e06e1cb..19e5657414c 100644 --- a/src/vs/base/browser/ui/progressbar/progressbar.ts +++ b/src/vs/base/browser/ui/progressbar/progressbar.ts @@ -40,7 +40,6 @@ export class ProgressBar { private toUnbind: IDisposable[]; private workedVal: number; private element: Builder; - private animationRunning: boolean; private bit: HTMLElement; private totalWork: number; private animationStopToken: ValueCallback; @@ -64,11 +63,6 @@ export class ProgressBar { builder.div({ 'class': css_progress_bit }).on([DOM.EventType.ANIMATION_START, DOM.EventType.ANIMATION_END, DOM.EventType.ANIMATION_ITERATION], (e: Event) => { switch (e.type) { - case DOM.EventType.ANIMATION_START: - case DOM.EventType.ANIMATION_END: - this.animationRunning = e.type === DOM.EventType.ANIMATION_START; - break; - case DOM.EventType.ANIMATION_ITERATION: if (this.animationStopToken) { this.animationStopToken(null); diff --git a/src/vs/base/browser/ui/sash/sash.ts b/src/vs/base/browser/ui/sash/sash.ts index 4d35abcf1ac..2569e53d3ab 100644 --- a/src/vs/base/browser/ui/sash/sash.ts +++ b/src/vs/base/browser/ui/sash/sash.ts @@ -12,7 +12,7 @@ import { isIPad } from 'vs/base/browser/browser'; import { isMacintosh } from 'vs/base/common/platform'; import types = require('vs/base/common/types'); import DOM = require('vs/base/browser/dom'); -import { Gesture, EventType, GestureEvent } from 'vs/base/browser/touch'; +import { EventType, GestureEvent } from 'vs/base/browser/touch'; import { EventEmitter } from 'vs/base/common/eventEmitter'; import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; import Event, { Emitter } from 'vs/base/common/event'; @@ -51,7 +51,6 @@ export enum Orientation { export class Sash extends EventEmitter { private $e: Builder; - private gesture: Gesture; private layoutProvider: ISashLayoutProvider; private isDisabled: boolean; private hidden: boolean; @@ -67,8 +66,6 @@ export class Sash extends EventEmitter { this.$e.addClass('mac'); } - this.gesture = new Gesture(this.$e.getHTMLElement()); - this.$e.on(DOM.EventType.MOUSE_DOWN, (e) => { this.onMouseDown(e as MouseEvent); }); this.$e.on(DOM.EventType.DBLCLICK, (e) => { this.emit('reset', e as MouseEvent); }); this.$e.on(EventType.Start, (e) => { this.onTouchStart(e as GestureEvent); }); @@ -141,9 +138,6 @@ export class Sash extends EventEmitter { let $window = $(window); let containerCSSClass = `${this.getOrientation()}-cursor-container${isMacintosh ? '-mac' : ''}`; - let lastCurrentX = startX; - let lastCurrentY = startY; - $window.on('mousemove', (e) => { DOM.EventHelper.stop(e, false); let mouseMoveEvent = new StandardMouseEvent(e as MouseEvent); @@ -155,9 +149,6 @@ export class Sash extends EventEmitter { currentY: mouseMoveEvent.posy }; - lastCurrentX = mouseMoveEvent.posx; - lastCurrentY = mouseMoveEvent.posy; - this.emit('change', event); }).once('mouseup', (e) => { DOM.EventHelper.stop(e, false); @@ -191,9 +182,6 @@ export class Sash extends EventEmitter { currentY: startY }); - let lastCurrentX = startX; - let lastCurrentY = startY; - listeners.push(DOM.addDisposableListener(this.$e.getHTMLElement(), EventType.Change, (event: GestureEvent) => { if (types.isNumber(event.pageX) && types.isNumber(event.pageY)) { this.emit('change', { @@ -202,9 +190,6 @@ export class Sash extends EventEmitter { startY: startY, currentY: event.pageY }); - - lastCurrentX = event.pageX; - lastCurrentY = event.pageY; } })); diff --git a/src/vs/base/browser/ui/selectBox/selectBox.ts b/src/vs/base/browser/ui/selectBox/selectBox.ts index 04a0d41fdb0..76e76cd5be3 100644 --- a/src/vs/base/browser/ui/selectBox/selectBox.ts +++ b/src/vs/base/browser/ui/selectBox/selectBox.ts @@ -36,7 +36,6 @@ export class SelectBox extends Widget { private selectElement: HTMLSelectElement; private options: string[]; private selected: number; - private container: HTMLElement; private _onDidSelect: Emitter; private toDispose: IDisposable[]; private selectBackground: Color; @@ -113,7 +112,6 @@ export class SelectBox extends Widget { } public render(container: HTMLElement): void { - this.container = container; dom.addClass(container, 'select-container'); container.appendChild(this.selectElement); this.setOptions(this.options, this.selected); diff --git a/src/vs/base/browser/ui/splitview/panelview.ts b/src/vs/base/browser/ui/splitview/panelview.ts index 68cb92ea81f..00e111e5668 100644 --- a/src/vs/base/browser/ui/splitview/panelview.ts +++ b/src/vs/base/browser/ui/splitview/panelview.ts @@ -338,7 +338,7 @@ export class PanelView implements IDisposable { readonly onDidSashChange: Event; - constructor(private container: HTMLElement, options: IPanelViewOptions = {}) { + constructor(container: HTMLElement, options: IPanelViewOptions = {}) { this.dnd = !!options.dnd; this.el = append(container, $('.monaco-panel-view')); this.splitview = new SplitView(this.el); diff --git a/src/vs/base/browser/ui/splitview/splitview.ts b/src/vs/base/browser/ui/splitview/splitview.ts index 5a94710ca9c..64c18622cb4 100644 --- a/src/vs/base/browser/ui/splitview/splitview.ts +++ b/src/vs/base/browser/ui/splitview/splitview.ts @@ -76,8 +76,7 @@ export class SplitView implements IDisposable { get length(): number { return this.viewItems.length; } - - constructor(private container: HTMLElement, options: ISplitViewOptions = {}) { + constructor(container: HTMLElement, options: ISplitViewOptions = {}) { this.orientation = types.isUndefined(options.orientation) ? Orientation.VERTICAL : options.orientation; this.el = document.createElement('div'); diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index e2120526002..86bde35d804 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -510,7 +510,7 @@ export class Queue extends Limiter { * A helper to organize queues per resource. The ResourceQueue makes sure to manage queues per resource * by disposing them once the queue is empty. */ -export class ResourceQueue { +export class ResourceQueue { private queues: { [path: string]: Queue }; constructor() { @@ -672,11 +672,11 @@ export class RunOnceScheduler { export function nfcall(fn: Function, ...args: any[]): Promise; export function nfcall(fn: Function, ...args: any[]): TPromise; export function nfcall(fn: Function, ...args: any[]): any { - return new TPromise((c, e) => fn(...args, (err, result) => err ? e(err) : c(result)), () => null); + return new TPromise((c, e) => fn(...args, (err: any, result: any) => err ? e(err) : c(result)), () => null); } export function ninvoke(thisArg: any, fn: Function, ...args: any[]): Promise; export function ninvoke(thisArg: any, fn: Function, ...args: any[]): TPromise; export function ninvoke(thisArg: any, fn: Function, ...args: any[]): any { - return new TPromise((c, e) => fn.call(thisArg, ...args, (err, result) => err ? e(err) : c(result)), () => null); + return new TPromise((c, e) => fn.call(thisArg, ...args, (err: any, result: any) => err ? e(err) : c(result)), () => null); } diff --git a/src/vs/base/common/collections.ts b/src/vs/base/common/collections.ts index 20e27735d7d..70b2e7310f8 100644 --- a/src/vs/base/common/collections.ts +++ b/src/vs/base/common/collections.ts @@ -31,7 +31,7 @@ export function values(from: IStringDictionary | INumberDictionary): T[ const result: T[] = []; for (let key in from) { if (hasOwnProperty.call(from, key)) { - result.push(from[key]); + result.push((from as any)[key]); } } return result; @@ -54,8 +54,8 @@ export function size(from: IStringDictionary | INumberDictionary): numb export function forEach(from: IStringDictionary | INumberDictionary, callback: (entry: { key: any; value: T; }, remove: Function) => any): void { for (let key in from) { if (hasOwnProperty.call(from, key)) { - const result = callback({ key: key, value: from[key] }, function () { - delete from[key]; + const result = callback({ key: key, value: (from as any)[key] }, function () { + delete (from as any)[key]; }); if (result === false) { return; @@ -72,7 +72,7 @@ export function remove(from: IStringDictionary | INumberDictionary, key if (!hasOwnProperty.call(from, key)) { return false; } - delete from[key]; + delete (from as any)[key]; return true; } diff --git a/src/vs/base/common/decorators.ts b/src/vs/base/common/decorators.ts index 0690c2b4662..8f7578c29fc 100644 --- a/src/vs/base/common/decorators.ts +++ b/src/vs/base/common/decorators.ts @@ -62,7 +62,7 @@ export function debounce(delay: number): Function { return createDecorator((fn, key) => { const timerKey = `$debounce$${key}`; - return function (...args: any[]) { + return function (this: any, ...args: any[]) { clearTimeout(this[timerKey]); this[timerKey] = setTimeout(() => fn.apply(this, args), delay); }; diff --git a/src/vs/base/common/diff/diff2.ts b/src/vs/base/common/diff/diff2.ts index d0b99788b9f..3bb52c68b94 100644 --- a/src/vs/base/common/diff/diff2.ts +++ b/src/vs/base/common/diff/diff2.ts @@ -57,8 +57,6 @@ export class LcsDiff2 { private ids_for_x: number[]; private ids_for_y: number[]; - private hashFunc: IHashFunction; - private resultX: boolean[]; private resultY: boolean[]; private forwardPrev: number[]; @@ -72,14 +70,6 @@ export class LcsDiff2 { this.ids_for_x = []; this.ids_for_y = []; - if (hashFunc) { - this.hashFunc = hashFunc; - } else { - this.hashFunc = function (sequence, index) { - return sequence[index]; - }; - } - this.resultX = []; this.resultY = []; this.forwardPrev = []; diff --git a/src/vs/base/common/functional.ts b/src/vs/base/common/functional.ts index f4f84befbd1..a352dc9d7df 100644 --- a/src/vs/base/common/functional.ts +++ b/src/vs/base/common/functional.ts @@ -10,7 +10,7 @@ export function not(fn: Function): Function { return (...args) => !fn(...args); } -export function once(fn: T): T { +export function once(this: any, fn: T): T { const _this = this; let didCall = false; let result: any; diff --git a/src/vs/base/common/mime.ts b/src/vs/base/common/mime.ts index 6868a298966..ff9872c075d 100644 --- a/src/vs/base/common/mime.ts +++ b/src/vs/base/common/mime.ts @@ -37,7 +37,7 @@ let userRegisteredAssociations: ITextMimeAssociationItem[] = []; /** * Associate a text mime to the registry. */ -export function registerTextMime(association: ITextMimeAssociation): void { +export function registerTextMime(association: ITextMimeAssociation, warnOnOverwrite = false): void { // Register const associationItem = toTextMimeAssociationItem(association); @@ -49,7 +49,7 @@ export function registerTextMime(association: ITextMimeAssociation): void { } // Check for conflicts unless this is a user configured association - if (!associationItem.userConfigured) { + if (warnOnOverwrite && !associationItem.userConfigured) { registeredAssociations.forEach(a => { if (a.mime === associationItem.mime || a.userConfigured) { return; // same mime or userConfigured is ok diff --git a/src/vs/base/common/objects.ts b/src/vs/base/common/objects.ts index e2be7bda662..308c65519a6 100644 --- a/src/vs/base/common/objects.ts +++ b/src/vs/base/common/objects.ts @@ -15,8 +15,8 @@ export function clone(obj: T): T { // See https://github.com/Microsoft/TypeScript/issues/10990 return obj as any; } - const result = (Array.isArray(obj)) ? [] : {}; - Object.keys(obj).forEach(key => { + const result: any = Array.isArray(obj) ? [] : {}; + Object.keys(obj).forEach((key: keyof T) => { if (obj[key] && typeof obj[key] === 'object') { result[key] = clone(obj[key]); } else { @@ -30,8 +30,8 @@ export function deepClone(obj: T): T { if (!obj || typeof obj !== 'object') { return obj; } - const result = (Array.isArray(obj)) ? [] : {}; - Object.getOwnPropertyNames(obj).forEach(key => { + const result: any = Array.isArray(obj) ? [] : {}; + Object.getOwnPropertyNames(obj).forEach((key: keyof T) => { if (obj[key] && typeof obj[key] === 'object') { result[key] = deepClone(obj[key]); } else { @@ -73,7 +73,7 @@ function _cloneAndChange(obj: any, changer: (orig: any) => any, encounteredObjec const r2 = {}; for (let i2 in obj) { if (hasOwnProperty.call(obj, i2)) { - r2[i2] = _cloneAndChange(obj[i2], changer, encounteredObjects); + (r2 as any)[i2] = _cloneAndChange(obj[i2], changer, encounteredObjects); } } encounteredObjects.pop(); @@ -231,7 +231,7 @@ export function derive(baseClass: any, derivedClass: any): void { } // Cast to any due to Bug 16188:PropertyDescriptor set and get function should be optional. - Object.defineProperty(derivedClass.prototype, 'constructor', { value: derivedClass, writable: true, configurable: true, enumerable: true }); + Object.defineProperty(derivedClass.prototype, 'constructor', { value: derivedClass, writable: true, configurable: true, enumerable: true }); } /** diff --git a/src/vs/base/common/paging.ts b/src/vs/base/common/paging.ts index de3319b5038..286fa69d08f 100644 --- a/src/vs/base/common/paging.ts +++ b/src/vs/base/common/paging.ts @@ -51,7 +51,7 @@ export class PagedModel implements IPagedModel { get length(): number { return this.pager.total; } - constructor(private arg: IPager | T[], private pageTimeout: number = 500) { + constructor(arg: IPager | T[], private pageTimeout: number = 500) { this.pager = isArray(arg) ? singlePagePager(arg) : arg; this.pages = [{ isResolved: true, promise: null, promiseIndexes: new Set(), elements: this.pager.firstPage.slice() }]; diff --git a/src/vs/base/common/parsers.ts b/src/vs/base/common/parsers.ts index 0aa919598e2..48938d10a4e 100644 --- a/src/vs/base/common/parsers.ts +++ b/src/vs/base/common/parsers.ts @@ -50,10 +50,10 @@ export interface IProblemReporter { } export class NullProblemReporter implements IProblemReporter { - info(message: string): void { }; - warn(message: string): void { }; - error(message: string): void { }; - fatal(message: string): void { }; + info(message: string): void { } + warn(message: string): void { } + error(message: string): void { } + fatal(message: string): void { } status: ValidationStatus = new ValidationStatus(); } @@ -112,7 +112,7 @@ export abstract class Parser { } protected static merge(destination: T, source: T, overwrite: boolean): void { - Object.keys(source).forEach((key) => { + Object.keys(source).forEach((key: keyof T) => { let destValue = destination[key]; let sourceValue = source[key]; if (Types.isUndefined(sourceValue)) { @@ -163,7 +163,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { } resolveAny(value: T): T; - resolveAny(value: any): any { + resolveAny(value: any): any { if (Types.isString(value)) { return this.resolveString(value); } else if (Types.isArray(value)) { @@ -197,7 +197,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables { } private __resolveAnyLiteral(values: T): T; - private __resolveAnyLiteral(values: any): any { + private __resolveAnyLiteral(values: any): any { let result: IStringDictionary | string[]> = Object.create(null); Object.keys(values).forEach(key => { let value = values[key]; diff --git a/src/vs/base/common/uri.ts b/src/vs/base/common/uri.ts index f6dcab7e786..d99a0e403db 100644 --- a/src/vs/base/common/uri.ts +++ b/src/vs/base/common/uri.ts @@ -450,7 +450,7 @@ function _asFormatted(uri: URI, skipEncoding: boolean): string { } parts.push(encoder(path.substring(lastIdx, idx)), _slash); lastIdx = idx + 1; - }; + } } if (query) { parts.push('?', encoder(query)); diff --git a/src/vs/base/node/event.ts b/src/vs/base/node/event.ts index 3cc1c275122..037701d2431 100644 --- a/src/vs/base/node/event.ts +++ b/src/vs/base/node/event.ts @@ -9,10 +9,10 @@ import Event, { Emitter } from 'vs/base/common/event'; import { EventEmitter } from 'events'; export function fromEventEmitter(emitter: EventEmitter, eventName: string, map: (...args: any[]) => T = id => id): Event { - const fn = (...args) => result.fire(map(...args)); + const fn = (...args: any[]) => result.fire(map(...args)); const onFirstListenerAdd = () => emitter.on(eventName, fn); const onLastListenerRemove = () => emitter.removeListener(eventName, fn); const result = new Emitter({ onFirstListenerAdd, onLastListenerRemove }); return result.event; -}; +} diff --git a/src/vs/base/parts/ipc/common/ipc.electron.ts b/src/vs/base/parts/ipc/common/ipc.electron.ts index f9f773a330c..1223020a9ff 100644 --- a/src/vs/base/parts/ipc/common/ipc.electron.ts +++ b/src/vs/base/parts/ipc/common/ipc.electron.ts @@ -18,7 +18,7 @@ export class Protocol implements IMessagePassingProtocol { private _onMessage: Event; get onMessage(): Event { return this._onMessage; } - constructor(private sender: Sender, private onMessageEvent: Event) { + constructor(private sender: Sender, onMessageEvent: Event) { const emitter = new Emitter(); onMessageEvent(msg => emitter.fire(msg)); this._onMessage = emitter.event; diff --git a/src/vs/base/parts/ipc/test/node/testService.ts b/src/vs/base/parts/ipc/test/node/testService.ts index 36c2120d22f..0a970bfe735 100644 --- a/src/vs/base/parts/ipc/test/node/testService.ts +++ b/src/vs/base/parts/ipc/test/node/testService.ts @@ -61,7 +61,7 @@ export class TestService implements ITestService { } progress(batch); process.nextTick(send); - }; + } process.nextTick(send); }); } @@ -94,7 +94,7 @@ export class TestChannel implements ITestChannel { export class TestServiceClient implements ITestService { private _onMarco: Event; - get onMarco(): Event { return this._onMarco; }; + get onMarco(): Event { return this._onMarco; } constructor(private channel: ITestChannel) { this._onMarco = eventFromCall(channel, 'event:marco'); diff --git a/src/vs/base/parts/quickopen/common/quickOpenScorer.ts b/src/vs/base/parts/quickopen/common/quickOpenScorer.ts index 5636beb5f50..75b33c6ebf6 100644 --- a/src/vs/base/parts/quickopen/common/quickOpenScorer.ts +++ b/src/vs/base/parts/quickopen/common/quickOpenScorer.ts @@ -352,7 +352,7 @@ export function scoreItem(item: T, query: IPreparedQuery, fuzzy: boolean, acc return itemScore; } -function doScoreItem(label: string, description: string, path: string, query: IPreparedQuery, fuzzy: boolean): IItemScore { +function doScoreItem(label: string, description: string, path: string, query: IPreparedQuery, fuzzy: boolean): IItemScore { // 1.) treat identity matches on full path highest if (path && isEqual(query.value, path, true)) { diff --git a/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts b/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts index 9710b98a982..464967ff845 100644 --- a/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts +++ b/src/vs/base/parts/quickopen/test/common/quickOpenScorer.test.ts @@ -210,7 +210,7 @@ suite('Quick Open Scorer', () => { }); test('scoreItem - avoid match scattering (bug #36119)', function () { - const resource = URI.file('projects/ui/cula/ats/target.mk');; + const resource = URI.file('projects/ui/cula/ats/target.mk'); const pathRes = scoreItem(resource, 'tcltarget.mk', true, ResourceAccessor, cache); assert.ok(pathRes.score); diff --git a/src/vs/base/parts/tree/browser/treeImpl.ts b/src/vs/base/parts/tree/browser/treeImpl.ts index 14273a292ca..0397e0171f4 100644 --- a/src/vs/base/parts/tree/browser/treeImpl.ts +++ b/src/vs/base/parts/tree/browser/treeImpl.ts @@ -64,8 +64,6 @@ const defaultStyles: _.ITreeStyles = { export class Tree extends Events.EventEmitter implements _.ITree { private container: HTMLElement; - private configuration: _.ITreeConfiguration; - private options: _.ITreeOptions; private context: _.ITreeContext; private model: Model.TreeModel; @@ -87,16 +85,14 @@ export class Tree extends Events.EventEmitter implements _.ITree { this.toDispose.push(this._onDispose, this._onHighlightChange); this.container = container; - this.configuration = configuration; - this.options = options; - mixin(this.options, defaultStyles, false); + mixin(options, defaultStyles, false); - this.options.twistiePixels = typeof this.options.twistiePixels === 'number' ? this.options.twistiePixels : 32; - this.options.showTwistie = this.options.showTwistie === false ? false : true; - this.options.indentPixels = typeof this.options.indentPixels === 'number' ? this.options.indentPixels : 12; - this.options.alwaysFocused = this.options.alwaysFocused === true ? true : false; - this.options.useShadows = this.options.useShadows === false ? false : true; - this.options.paddingOnRow = this.options.paddingOnRow === false ? false : true; + options.twistiePixels = typeof options.twistiePixels === 'number' ? options.twistiePixels : 32; + options.showTwistie = options.showTwistie === false ? false : true; + options.indentPixels = typeof options.indentPixels === 'number' ? options.indentPixels : 12; + options.alwaysFocused = options.alwaysFocused === true ? true : false; + options.useShadows = options.useShadows === false ? false : true; + options.paddingOnRow = options.paddingOnRow === false ? false : true; this.context = new TreeContext(this, configuration, options); this.model = new Model.TreeModel(this.context); diff --git a/src/vs/base/parts/tree/browser/treeModel.ts b/src/vs/base/parts/tree/browser/treeModel.ts index f35afe2704e..cfeafa0b078 100644 --- a/src/vs/base/parts/tree/browser/treeModel.ts +++ b/src/vs/base/parts/tree/browser/treeModel.ts @@ -206,8 +206,6 @@ export class Item extends Events.EventEmitter { public firstChild: Item; public lastChild: Item; - private userContent: HTMLElement; - private height: number; private depth: number; @@ -238,7 +236,6 @@ export class Item extends Events.EventEmitter { this.firstChild = null; this.lastChild = null; - this.userContent = null; this.traits = {}; this.depth = 0; this.expanded = this.context.dataSource.shouldAutoexpand && this.context.dataSource.shouldAutoexpand(this.context.tree, element); diff --git a/src/vs/base/parts/tree/browser/treeView.ts b/src/vs/base/parts/tree/browser/treeView.ts index ac5ba32ad5c..2aea91d703f 100644 --- a/src/vs/base/parts/tree/browser/treeView.ts +++ b/src/vs/base/parts/tree/browser/treeView.ts @@ -392,8 +392,6 @@ export class TreeView extends HeightMap { private isRefreshing = false; private refreshingPreviousChildrenIds: { [id: string]: string[] } = {}; - - private dragAndDropListeners: { (): void; }[]; private currentDragAndDropData: _.IDragAndDropData; private currentDropElement: any; private currentDropElementReaction: _.IDragOverReaction; @@ -437,7 +435,6 @@ export class TreeView extends HeightMap { this.modelListeners = []; this.viewListeners = []; - this.dragAndDropListeners = []; this.model = null; this.items = {}; diff --git a/src/vs/base/parts/tree/test/browser/treeModel.test.ts b/src/vs/base/parts/tree/test/browser/treeModel.test.ts index 07ac8c71a4d..39e90566539 100644 --- a/src/vs/base/parts/tree/test/browser/treeModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeModel.test.ts @@ -1439,7 +1439,7 @@ suite('TreeModel - Dynamic data model', () => { var gotTimes = 0; var gotListener = dataModel.addListener('gotChildren', (element) => { gotTimes++; }); - + // @ts-ignore unused local var p1, p2; var p1Completes = []; @@ -1517,7 +1517,7 @@ suite('TreeModel - Dynamic data model', () => { var gotTimes = 0; var getListener = dataModel.addListener('getChildren', (element) => { getTimes++; }); var gotListener = dataModel.addListener('gotChildren', (element) => { gotTimes++; }); - + // @ts-ignore unused local var p1, p2; var p1Complete; @@ -1741,7 +1741,7 @@ suite('TreeModel - bugs', () => { }).done(() => { // teardown - while (listeners.length > 0) { listeners.pop()(); }; + while (listeners.length > 0) { listeners.pop()(); } listeners = null; model.dispose(); model = null; diff --git a/src/vs/base/test/browser/builder.test.ts b/src/vs/base/test/browser/builder.test.ts index 99c3f4ec4ee..b6e496b7277 100644 --- a/src/vs/base/test/browser/builder.test.ts +++ b/src/vs/base/test/browser/builder.test.ts @@ -22,7 +22,7 @@ let withElementsBySelector = function (selector: string, offdom: boolean = false return new MultiBuilder(builders); }; -let withBuilder = function (builder, offdom) { +let withBuilder = function (builder: Builder, offdom: boolean) { if (builder instanceof MultiBuilder) { return new MultiBuilder(builder); } @@ -107,7 +107,7 @@ suite('Builder', () => { assert(allDivs instanceof MultiBuilder); for (let key in b) { - if (b.hasOwnProperty(key) && Types.isFunction(b[key])) { + if (b.hasOwnProperty(key) && Types.isFunction((b as any)[key])) { assert(allDivs.hasOwnProperty(key)); } } @@ -121,7 +121,7 @@ suite('Builder', () => { assert(noElement instanceof MultiBuilder); for (let key in b) { - if (b.hasOwnProperty(key) && Types.isFunction(b[key])) { + if (b.hasOwnProperty(key) && Types.isFunction((b as any)[key])) { assert(noElement.hasOwnProperty(key)); } } @@ -381,15 +381,15 @@ suite('Builder', () => { test('Builder Multibuilder fn call that returns Multibuilder', function () { let b = Build.withElementById(fixtureId); - b.div(function (div) { + b.div(function (div: Builder) { div.span(); }); - b.div(function (div) { + b.div(function (div: Builder) { div.span(); }); - b.div(function (div) { + b.div(function (div: Builder) { div.span(); }); @@ -402,13 +402,13 @@ suite('Builder', () => { test('Builder.p() and other elements', function () { let b = Build.withElementById(fixtureId); b.empty(); - b.div(function (div) { + b.div(function (div: Builder) { assert(div !== b); assert.strictEqual('div', div.getHTMLElement().nodeName.toLowerCase()); - div.p(function (p) { - p.ul(function (ul) { - ul.li(function (li) { + div.p(function (p: Builder) { + p.ul(function (ul: Builder) { + ul.li(function (li: Builder) { li.span({ id: 'builderspan', innerHtml: 'Foo Bar' @@ -485,10 +485,10 @@ suite('Builder', () => { test('Builder.p() and other elements', function () { let b = Build.withElementById(fixtureId); - b.element('div', function (div) { - div.element('p', function (p) { - p.element('ul', function (ul) { - ul.element('li', function (li) { + b.element('div', function (div: Builder) { + div.element('p', function (p: Builder) { + p.element('ul', function (ul: Builder) { + ul.element('li', function (li: Builder) { li.element('span', { id: 'builderspan', innerHtml: 'Foo Bar' @@ -908,7 +908,7 @@ suite('Builder', () => { assert(b.children().length === 0); let divB; - b.div(function (div) { + b.div(function (div: Builder) { divB = div.clone(); div.span(); }); @@ -1018,7 +1018,7 @@ suite('Builder', () => { type: 'button' }); - let listeners = []; + let listeners: Builder[] = []; let counter = 0; b.on(DomUtils.EventType.CLICK, function (e) { counter++; @@ -1042,7 +1042,7 @@ suite('Builder', () => { type: 'button' }); - let listeners = []; + let listeners: Builder[] = []; let counter = 0; b.on(DomUtils.EventType.CLICK, function (e) { counter++; @@ -1064,8 +1064,8 @@ suite('Builder', () => { }); test('Builder.empty()', function () { - let inputs = []; - let bindings = []; + let inputs: Builder[] = []; + let bindings: Builder[] = []; let b = Build.withElementById(fixtureId); let counter1 = 0; @@ -1076,33 +1076,33 @@ suite('Builder', () => { let counter6 = 0; let counter7 = 0; - b.div(function (div) { + b.div(function (div: Builder) { div.bind('Foo Bar'); div.setProperty('Foo', 'Bar'); bindings.push(div.clone()); div.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { counter1++; assert(counter1 <= 1); }); inputs.push(div.clone()); - div.p(function (p) { + div.p(function (p: Builder) { p.bind('Foo Bar'); p.setProperty('Foo', 'Bar'); bindings.push(p.clone()); p.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { counter2++; assert(counter2 <= 1); }); inputs.push(p.clone()); - p.ul(function (ul) { + p.ul(function (ul: Builder) { ul.bind('Foo Bar'); ul.setProperty('Foo', 'Bar'); bindings.push(ul.clone()); @@ -1115,7 +1115,7 @@ suite('Builder', () => { }); inputs.push(ul.clone()); - ul.li(function (li) { + ul.li(function (li: Builder) { li.bind('Foo Bar'); li.setProperty('Foo', 'Bar'); bindings.push(li.clone()); @@ -1220,7 +1220,7 @@ suite('Builder', () => { let old = DomUtils.addDisposableListener; try { - (DomUtils as any).addDisposableListener = function (node, type, handler) { + (DomUtils as any).addDisposableListener = function (node: any, type: any, handler: any) { let unbind: IDisposable = old.call(null, node, type, handler); return { @@ -1231,13 +1231,13 @@ suite('Builder', () => { }; }; - b.div(function (div) { - div.p(function (p) { + b.div(function (div: Builder) { + div.p(function (p: Builder) { p.span().on([DomUtils.EventType.CLICK, DomUtils.EventType.KEY_DOWN], function (e) { }); p.img().on([DomUtils.EventType.KEY_PRESS, DomUtils.EventType.MOUSE_OUT], function (e) { }, null, true); // useCapture - p.a(function (a) { + p.a(function (a: Builder) { a.span().on([DomUtils.EventType.CLICK, DomUtils.EventType.KEY_DOWN], function (e) { }); }).on([DomUtils.EventType.SELECT, DomUtils.EventType.BLUR], function (e) { }); }); @@ -1251,8 +1251,8 @@ suite('Builder', () => { }); test('Builder.destroy()', function () { - let inputs = []; - let bindings = []; + let inputs: Builder[] = []; + let bindings: Builder[] = []; let b = Build.withElementById(fixtureId); let counter1 = 0; @@ -1263,7 +1263,7 @@ suite('Builder', () => { let counter6 = 0; let counter7 = 0; - b.div(function (div) { + b.div(function (div: Builder) { div.bind('Foo Bar'); div.setProperty('Foo', 'Bar'); bindings.push(div.clone()); @@ -1276,7 +1276,7 @@ suite('Builder', () => { }, null, true); // useCapture inputs.push(div.clone()); - div.p(function (p) { + div.p(function (p: Builder) { p.bind('Foo Bar'); p.setProperty('Foo', 'Bar'); bindings.push(p.clone()); @@ -1289,7 +1289,7 @@ suite('Builder', () => { }); inputs.push(p.clone()); - p.ul(function (ul) { + p.ul(function (ul: Builder) { ul.bind('Foo Bar'); ul.setProperty('Foo', 'Bar'); bindings.push(ul.clone()); @@ -1302,14 +1302,14 @@ suite('Builder', () => { }); inputs.push(ul.clone()); - ul.li(function (li) { + ul.li(function (li: Builder) { li.bind('Foo Bar'); li.setProperty('Foo', 'Bar'); bindings.push(li.clone()); li.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { counter4++; assert(counter4 <= 1); }); @@ -1407,7 +1407,7 @@ suite('Builder', () => { let old = DomUtils.addDisposableListener; try { - (DomUtils as any).addDisposableListener = function (node, type, handler) { + (DomUtils as any).addDisposableListener = function (node: any, type: any, handler: any) { let unbind: IDisposable = old.call(null, node, type, handler); return { @@ -1418,13 +1418,13 @@ suite('Builder', () => { }; }; - b.div(function (div) { - div.p(function (p) { + b.div(function (div: Builder) { + div.p(function (p: Builder) { p.span().on([DomUtils.EventType.CLICK, DomUtils.EventType.KEY_DOWN], function (e) { }); p.img().on([DomUtils.EventType.KEY_PRESS, DomUtils.EventType.MOUSE_OUT], function (e) { }); - p.a(function (a) { + p.a(function (a: Builder) { a.span().on([DomUtils.EventType.CLICK, DomUtils.EventType.KEY_DOWN], function (e) { }); }).on([DomUtils.EventType.SELECT, DomUtils.EventType.BLUR], function (e) { }); }); @@ -1441,13 +1441,13 @@ suite('Builder', () => { test('Builder.empty() MultiBuilder', function () { let b = Build.withElementById(fixtureId); - let inputs = []; + let inputs: Builder[] = []; let firstCounter = 0; - b.div(function (div) { + b.div(function (div: Builder) { div.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { firstCounter++; }); @@ -1455,10 +1455,10 @@ suite('Builder', () => { }); let secondCounter = 0; - b.div(function (div) { + b.div(function (div: Builder) { div.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { secondCounter++; }); @@ -1466,10 +1466,10 @@ suite('Builder', () => { }); let thirdCounter = 0; - b.div(function (div) { + b.div(function (div: Builder) { div.element('input', { type: 'button' - }).on(DomUtils.EventType.CLICK, function (e) { + }).on(DomUtils.EventType.CLICK, function () { thirdCounter++; }); diff --git a/src/vs/base/test/browser/dom.test.ts b/src/vs/base/test/browser/dom.test.ts index 4b8239985f1..012be3b61be 100644 --- a/src/vs/base/test/browser/dom.test.ts +++ b/src/vs/base/test/browser/dom.test.ts @@ -86,11 +86,11 @@ suite('dom', () => { //}); test('safeStringify', function () { - let obj1 = { + let obj1: any = { friend: null }; - let obj2 = { + let obj2: any = { friend: null }; @@ -100,7 +100,7 @@ suite('dom', () => { let arr: any = [1]; arr.push(arr); - let circular = { + let circular: any = { a: 42, b: null, c: [ diff --git a/src/vs/base/test/common/arrays.test.ts b/src/vs/base/test/common/arrays.test.ts index 59de9d7a5a4..ca7a9bc7996 100644 --- a/src/vs/base/test/common/arrays.test.ts +++ b/src/vs/base/test/common/arrays.test.ts @@ -202,7 +202,7 @@ suite('Arrays', () => { }); test('top', function () { - const cmp = (a, b) => { + const cmp = (a: number, b: number) => { assert.strictEqual(typeof a, 'number', 'typeof a'); assert.strictEqual(typeof b, 'number', 'typeof b'); return a - b; @@ -218,7 +218,7 @@ suite('Arrays', () => { }); test('topAsync', function (done) { - const cmp = (a, b) => { + const cmp = (a: number, b: number) => { assert.strictEqual(typeof a, 'number', 'typeof a'); assert.strictEqual(typeof b, 'number', 'typeof b'); return a - b; diff --git a/src/vs/base/test/common/assert.test.ts b/src/vs/base/test/common/assert.test.ts index 8ccd53a455f..a28f77f0fe8 100644 --- a/src/vs/base/test/common/assert.test.ts +++ b/src/vs/base/test/common/assert.test.ts @@ -23,7 +23,7 @@ suite('Assert', () => { assert.throws(function () { ok(null, 'Foo Bar'); - }, function (e) { + }, function (e: Error) { return e.message.indexOf('Foo Bar') >= 0; }); diff --git a/src/vs/base/test/common/async.test.ts b/src/vs/base/test/common/async.test.ts index 08b5eef4fd2..3eeede50e2d 100644 --- a/src/vs/base/test/common/async.test.ts +++ b/src/vs/base/test/common/async.test.ts @@ -472,7 +472,7 @@ suite('Async', () => { test('Queue - order is kept', function (done) { let queue = new Async.Queue(); - let res = []; + let res: number[] = []; let f1 = () => TPromise.as(true).then(() => res.push(1)); let f2 = () => TPromise.timeout(10).then(() => res.push(2)); @@ -498,7 +498,7 @@ suite('Async', () => { test('Queue - errors bubble individually but not cause stop', function (done) { let queue = new Async.Queue(); - let res = []; + let res: number[] = []; let error = false; let f1 = () => TPromise.as(true).then(() => res.push(1)); @@ -525,7 +525,7 @@ suite('Async', () => { test('Queue - order is kept (chained)', function (done) { let queue = new Async.Queue(); - let res = []; + let res: number[] = []; let f1 = () => TPromise.as(true).then(() => res.push(1)); let f2 = () => TPromise.timeout(10).then(() => res.push(2)); @@ -560,7 +560,7 @@ suite('Async', () => { done(); }); - let res = []; + let res: number[] = []; let f1 = () => TPromise.timeout(10).then(() => res.push(2)); let f2 = () => TPromise.timeout(20).then(() => res.push(4)); diff --git a/src/vs/base/test/common/event.test.ts b/src/vs/base/test/common/event.test.ts index c11572642b1..fb2386be509 100644 --- a/src/vs/base/test/common/event.test.ts +++ b/src/vs/base/test/common/event.test.ts @@ -399,7 +399,7 @@ suite('Event utils', () => { suite('buffer', () => { test('should buffer events', () => { - const result = []; + const result: number[] = []; const emitter = new Emitter(); const event = emitter.event; const bufferedEvent = buffer(event); @@ -421,7 +421,7 @@ suite('Event utils', () => { }); test('should buffer events on next tick', () => { - const result = []; + const result: number[] = []; const emitter = new Emitter(); const event = emitter.event; const bufferedEvent = buffer(event, true); @@ -445,7 +445,7 @@ suite('Event utils', () => { }); test('should fire initial buffer events', () => { - const result = []; + const result: number[] = []; const emitter = new Emitter(); const event = emitter.event; const bufferedEvent = buffer(event, false, [-2, -1, 0]); @@ -463,7 +463,7 @@ suite('Event utils', () => { suite('echo', () => { test('should echo events', () => { - const result = []; + const result: number[] = []; const emitter = new Emitter(); const event = emitter.event; const echoEvent = echo(event); @@ -485,8 +485,8 @@ suite('Event utils', () => { }); test('should echo events for every listener', () => { - const result1 = []; - const result2 = []; + const result1: number[] = []; + const result2: number[] = []; const emitter = new Emitter(); const event = emitter.event; const echoEvent = echo(event); @@ -524,7 +524,7 @@ suite('Event utils', () => { suite('EventMultiplexer', () => { test('works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); m.event(r => result.push(r)); @@ -538,7 +538,7 @@ suite('Event utils', () => { }); test('multiplexer dispose works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); m.event(r => result.push(r)); @@ -558,7 +558,7 @@ suite('Event utils', () => { }); test('event dispose works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); m.event(r => result.push(r)); @@ -578,7 +578,7 @@ suite('Event utils', () => { }); test('mutliplexer event dispose works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); m.event(r => result.push(r)); @@ -598,7 +598,7 @@ suite('Event utils', () => { }); test('hot start works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); m.event(r => result.push(r)); @@ -616,7 +616,7 @@ suite('Event utils', () => { }); test('cold start works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); const e1 = new Emitter(); @@ -635,7 +635,7 @@ suite('Event utils', () => { }); test('late add works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); const e1 = new Emitter(); @@ -656,7 +656,7 @@ suite('Event utils', () => { }); test('add dispose works', () => { - const result = []; + const result: number[] = []; const m = new EventMultiplexer(); const e1 = new Emitter(); diff --git a/src/vs/base/test/common/filters.test.ts b/src/vs/base/test/common/filters.test.ts index 2480ab7171d..45018c5a8e4 100644 --- a/src/vs/base/test/common/filters.test.ts +++ b/src/vs/base/test/common/filters.test.ts @@ -5,7 +5,7 @@ 'use strict'; import * as assert from 'assert'; -import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, nextTypoPermutation, fuzzyScoreGraceful } from 'vs/base/common/filters'; +import { IFilter, or, matchesPrefix, matchesStrictPrefix, matchesCamelCase, matchesSubString, matchesContiguousSubString, matchesWords, fuzzyScore, nextTypoPermutation, fuzzyScoreGraceful, IMatch } from 'vs/base/common/filters'; function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, highlights?: { start: number; end: number; }[]) { let r = filter(word, wordToMatchAgainst); @@ -15,15 +15,16 @@ function filterOk(filter: IFilter, word: string, wordToMatchAgainst: string, hig } } -function filterNotOk(filter, word, suggestion) { +function filterNotOk(filter: IFilter, word: string, suggestion: string) { assert(!filter(word, suggestion)); } suite('Filters', () => { test('or', function () { - let filter, counters; - let newFilter = function (i, r) { - return function () { counters[i]++; return r; }; + let filter: IFilter; + let counters: number[]; + let newFilter = function (i: number, r: boolean): IFilter { + return function (): IMatch[] { counters[i]++; return r as any; }; }; counters = [0, 0]; diff --git a/src/vs/base/test/common/objects.test.ts b/src/vs/base/test/common/objects.test.ts index 48379430d93..3ee70c7d407 100644 --- a/src/vs/base/test/common/objects.test.ts +++ b/src/vs/base/test/common/objects.test.ts @@ -7,12 +7,12 @@ import * as assert from 'assert'; import objects = require('vs/base/common/objects'); -let check = (one, other, msg) => { +let check = (one: any, other: any, msg: string) => { assert(objects.equals(one, other), msg); assert(objects.equals(other, one), '[reverse] ' + msg); }; -let checkNot = (one, other, msg) => { +let checkNot = (one: any, other: any, msg: string) => { assert(!objects.equals(one, other), msg); assert(!objects.equals(other, one), '[reverse] ' + msg); }; @@ -92,11 +92,11 @@ suite('Objects', () => { }); test('safeStringify', function () { - let obj1 = { + let obj1: any = { friend: null }; - let obj2 = { + let obj2: any = { friend: null }; @@ -106,7 +106,7 @@ suite('Objects', () => { let arr: any = [1]; arr.push(arr); - let circular = { + let circular: any = { a: 42, b: null, c: [ diff --git a/src/vs/base/test/common/types.test.ts b/src/vs/base/test/common/types.test.ts index 81c3be204fd..205c0b088c7 100644 --- a/src/vs/base/test/common/types.test.ts +++ b/src/vs/base/test/common/types.test.ts @@ -184,7 +184,7 @@ suite('Types', () => { function isFoo(f) { } assert.throws(() => types.validateConstraints([new foo()], [isFoo])); - function isFoo2(f) { return true; }; + function isFoo2(f) { return true; } types.validateConstraints([new foo()], [isFoo2]); assert.throws(() => types.validateConstraints([1, true], [types.isNumber, types.isString])); @@ -198,7 +198,7 @@ suite('Types', () => { assert(types.create(zeroConstructor) instanceof zeroConstructor); assert(types.isObject(types.create(zeroConstructor))); - let manyArgConstructor = function (foo, bar) { + let manyArgConstructor = function (this: any, foo, bar) { this.foo = foo; this.bar = bar; }; diff --git a/src/vs/base/test/common/utils.ts b/src/vs/base/test/common/utils.ts index f69d864e509..0dc656251c2 100644 --- a/src/vs/base/test/common/utils.ts +++ b/src/vs/base/test/common/utils.ts @@ -85,6 +85,6 @@ export function onError(error: Error, done: () => void): void { done(); } -export function toResource(path) { +export function toResource(this: any, path: string) { return URI.file(paths.join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path)); } diff --git a/src/vs/base/test/common/winjs.polyfill.promise.test.ts b/src/vs/base/test/common/winjs.polyfill.promise.test.ts index a11908fe9ad..5114888d419 100644 --- a/src/vs/base/test/common/winjs.polyfill.promise.test.ts +++ b/src/vs/base/test/common/winjs.polyfill.promise.test.ts @@ -65,30 +65,30 @@ suite('Polyfill Promise', function () { ([Promise, PolyfillPromise]).forEach(PromiseCtor => { test(PromiseCtor.name + ', resolved value', function () { - return new PromiseCtor(resolve => resolve(1)).then(value => assert.equal(value, 1)); + return new PromiseCtor((resolve: Function) => resolve(1)).then((value: number) => assert.equal(value, 1)); }); test(PromiseCtor.name + ', rejected value', function () { - return new PromiseCtor((_, reject) => reject(1)).then(null, value => assert.equal(value, 1)); + return new PromiseCtor((_: Function, reject: Function) => reject(1)).then(null, (value: number) => assert.equal(value, 1)); }); test(PromiseCtor.name + ', catch', function () { - return new PromiseCtor((_, reject) => reject(1)).catch(value => assert.equal(value, 1)); + return new PromiseCtor((_: Function, reject: Function) => reject(1)).catch((value: number) => assert.equal(value, 1)); }); test(PromiseCtor.name + ', static-resolve', function () { - return PromiseCtor.resolve(42).then(value => assert.equal(value, 42)); + return PromiseCtor.resolve(42).then((value: number) => assert.equal(value, 42)); }); test(PromiseCtor.name + ', static-reject', function () { - return PromiseCtor.reject(42).then(null, value => assert.equal(value, 42)); + return PromiseCtor.reject(42).then(null, (value: number) => assert.equal(value, 42)); }); test(PromiseCtor.name + ', static-all, 1', function () { return PromiseCtor.all([ PromiseCtor.resolve(1), PromiseCtor.resolve(2) - ]).then(values => { + ]).then((values: number[]) => { assert.deepEqual(values, [1, 2]); }); }); @@ -98,7 +98,7 @@ suite('Polyfill Promise', function () { PromiseCtor.resolve(1), 3, PromiseCtor.resolve(2) - ]).then(values => { + ]).then((values: number[]) => { assert.deepEqual(values, [1, 3, 2]); }); }); @@ -108,7 +108,7 @@ suite('Polyfill Promise', function () { PromiseCtor.resolve(1), PromiseCtor.reject(13), PromiseCtor.reject(12), - ]).catch(values => { + ]).catch((values: number) => { assert.deepEqual(values, 13); }); }); @@ -117,7 +117,7 @@ suite('Polyfill Promise', function () { return PromiseCtor.race([ PromiseCtor.resolve(1), PromiseCtor.resolve(2), - ]).then(value => { + ]).then((value: number) => { assert.deepEqual(value, 1); }); }); @@ -126,7 +126,7 @@ suite('Polyfill Promise', function () { return PromiseCtor.race([ PromiseCtor.reject(-1), PromiseCtor.resolve(2), - ]).catch(value => { + ]).catch((value: number) => { assert.deepEqual(value, -1); }); }); @@ -135,7 +135,7 @@ suite('Polyfill Promise', function () { return PromiseCtor.race([ PromiseCtor.resolve(1), PromiseCtor.reject(2), - ]).then(value => { + ]).then((value: number) => { assert.deepEqual(value, 1); }); }); @@ -143,7 +143,7 @@ suite('Polyfill Promise', function () { test(PromiseCtor.name + ', throw in ctor', function () { return new PromiseCtor(() => { throw new Error('sooo bad'); - }).catch(err => { + }).catch((err: Error) => { assert.equal(err.message, 'sooo bad'); }); }); diff --git a/src/vs/base/test/node/flow.test.ts b/src/vs/base/test/node/flow.test.ts index 0988096b322..f1edf9c98de 100644 --- a/src/vs/base/test/node/flow.test.ts +++ b/src/vs/base/test/node/flow.test.ts @@ -13,45 +13,45 @@ const sequence = flow.sequence; const parallel = flow.parallel; suite('Flow', () => { - function assertCounterEquals(counter, expected): void { + function assertCounterEquals(counter: number, expected: number): void { assert.ok(counter === expected, 'Expected ' + expected + ' assertions, but got ' + counter); } - function syncThrowsError(callback): void { + function syncThrowsError(callback: any): void { callback(new Error('foo'), null); } - function syncSequenceGetThrowsError(value, callback) { + function syncSequenceGetThrowsError(value: any, callback: any) { sequence( function onError(error) { callback(error, null); }, - function getFirst() { + function getFirst(this: any) { syncThrowsError(this); }, - function handleFirst(first) { + function handleFirst(first: number) { //Foo } ); } - function syncGet(value, callback): void { + function syncGet(value: any, callback: any): void { callback(null, value); } - function syncGetError(value, callback): void { + function syncGetError(value: any, callback: any): void { callback(new Error(''), null); } - function asyncGet(value, callback): void { + function asyncGet(value: any, callback: any): void { process.nextTick(function () { callback(null, value); }); } - function asyncGetError(value, callback): void { + function asyncGetError(value: any, callback: any): void { process.nextTick(function () { callback(new Error(''), null); }); @@ -72,7 +72,7 @@ suite('Flow', () => { }); test('loopByFunctionSync', function (done: () => void) { - const elements = function (callback) { + const elements = function (callback: Function) { callback(null, ['1', '2', '3']); }; @@ -87,7 +87,7 @@ suite('Flow', () => { }); test('loopByFunctionAsync', function (done: () => void) { - const elements = function (callback) { + const elements = function (callback: Function) { process.nextTick(function () { callback(null, ['1', '2', '3']); }); @@ -176,23 +176,23 @@ suite('Flow', () => { errorCount++; }, - function getFirst() { + function getFirst(this: any) { syncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; syncGet('2', this); }, - function handleSecond(second) { + function handleSecond(this: any, second: any) { assert.deepEqual('2', second); assertionCount++; syncGet(null, this); }, - function handleThird(third) { + function handleThird(third: any) { assert.ok(!third); assertionCount++; @@ -212,23 +212,23 @@ suite('Flow', () => { errorCount++; }, - function getFirst() { + function getFirst(this: any) { asyncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; asyncGet('2', this); }, - function handleSecond(second) { + function handleSecond(this: any, second: number) { assert.deepEqual('2', second); assertionCount++; asyncGet(null, this); }, - function handleThird(third) { + function handleThird(third: number) { assert.ok(!third); assertionCount++; @@ -252,17 +252,17 @@ suite('Flow', () => { done(); }, - function getFirst() { + function getFirst(this: any) { syncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; syncGet('2', this); }, - function handleSecond(second) { + function handleSecond(second: number) { if (true) { throw new Error(''); } @@ -270,7 +270,7 @@ suite('Flow', () => { // syncGet(null, this); }, - function handleThird(third) { + function handleThird(third: number) { throw new Error('We should not be here'); } ); @@ -289,17 +289,17 @@ suite('Flow', () => { done(); }, - function getFirst() { + function getFirst(this: any) { syncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; syncGetError('2', this); }, - function handleSecond(second) { + function handleSecond(second: number) { throw new Error('We should not be here'); } ); @@ -318,17 +318,17 @@ suite('Flow', () => { done(); }, - function getFirst() { + function getFirst(this: any) { asyncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; asyncGet('2', this); }, - function handleSecond(second) { + function handleSecond(second: number) { if (true) { throw new Error(''); } @@ -336,7 +336,7 @@ suite('Flow', () => { // asyncGet(null, this); }, - function handleThird(third) { + function handleThird(third: number) { throw new Error('We should not be here'); } ); @@ -355,17 +355,17 @@ suite('Flow', () => { done(); }, - function getFirst() { + function getFirst(this: any) { asyncGet('1', this); }, - function handleFirst(first) { + function handleFirst(this: any, first: number) { assert.deepEqual('1', first); assertionCount++; asyncGetError('2', this); }, - function handleSecond(second) { + function handleSecond(second: number) { throw new Error('We should not be here'); } ); @@ -377,7 +377,7 @@ suite('Flow', () => { done(); }, - function getFirst() { + function getFirst(this: any) { syncSequenceGetThrowsError('1', this); } ); @@ -392,16 +392,16 @@ suite('Flow', () => { errorCount++; }, - function getFirst() { + function getFirst(this: any) { this(true); }, - function getSecond(result) { + function getSecond(this: any, result: boolean) { assert.equal(result, true); this(false); }, - function last(result) { + function last(result: boolean) { assert.equal(result, false); assertionCount++; diff --git a/src/vs/base/test/node/glob.test.ts b/src/vs/base/test/node/glob.test.ts index 702e20f36d8..de91bfb6ab5 100644 --- a/src/vs/base/test/node/glob.test.ts +++ b/src/vs/base/test/node/glob.test.ts @@ -416,7 +416,7 @@ suite('Glob', () => { assert.strictEqual(glob.match(expression, 'test.js', () => siblings), null); - expression = { + expression = { '**/*.js': { } }; diff --git a/src/vs/code/electron-browser/contrib/nodeCachedDataCleaner.ts b/src/vs/code/electron-browser/contrib/nodeCachedDataCleaner.ts index 1b36710b748..2f56affc386 100644 --- a/src/vs/code/electron-browser/contrib/nodeCachedDataCleaner.ts +++ b/src/vs/code/electron-browser/contrib/nodeCachedDataCleaner.ts @@ -12,9 +12,6 @@ import { readdir, rimraf, stat } from 'vs/base/node/pfs'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import product from 'vs/platform/node/product'; -declare type OnNodeCachedDataArgs = [{ errorCode: string, path: string, detail?: string }, { path: string, length: number }]; -declare const MonacoEnvironment: { onNodeCachedData: OnNodeCachedDataArgs[] }; - export class NodeCachedDataCleaner { private static _DataMaxAge = product.nameLong.indexOf('Insiders') >= 0 diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 31834208d4b..5683665f46b 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -76,7 +76,7 @@ export class CodeApplication { @ILogService private logService: ILogService, @IEnvironmentService private environmentService: IEnvironmentService, @ILifecycleService private lifecycleService: ILifecycleService, - @IConfigurationService private configurationService: ConfigurationService, + @IConfigurationService configurationService: ConfigurationService, @IStorageService private storageService: IStorageService, @IHistoryMainService private historyService: IHistoryMainService ) { @@ -393,6 +393,7 @@ export class CodeApplication { // Ensure Windows foreground love module try { + // tslint:disable-next-line:no-unused-expression require.__$__nodeRequire('windows-foreground-love'); } catch (e) { if (!this.environmentService.isBuilt) { diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index fb916b8f73d..9d48e22e95d 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -22,7 +22,7 @@ import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel, getPathLabel } import { KeybindingsResolver } from 'vs/code/electron-main/keyboard'; import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows'; import { IHistoryMainService } from 'vs/platform/history/common/history'; -import { IWorkspaceIdentifier, IWorkspacesMainService, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, getWorkspaceLabel, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; interface IExtensionViewlet { id: string; @@ -71,8 +71,7 @@ export class CodeMenu { @IWindowsMainService private windowsService: IWindowsMainService, @IEnvironmentService private environmentService: IEnvironmentService, @ITelemetryService private telemetryService: ITelemetryService, - @IHistoryMainService private historyService: IHistoryMainService, - @IWorkspacesMainService private workspacesService: IWorkspacesMainService + @IHistoryMainService private historyService: IHistoryMainService ) { this.extensionViewlets = []; this.nativeTabMenuItems = []; diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index d06769cc905..4a11a3a662f 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -458,7 +458,7 @@ export class CodeWindow implements ICodeWindow { this._win.removeAllListeners('swipe'); } } - }; + } private registerNavigationListenerOn(command: 'swipe' | 'app-command', back: 'left' | 'browser-backward', forward: 'right' | 'browser-forward', acrossEditors: boolean) { this._win.on(command as 'swipe' /* | 'app-command' */, (e: Electron.Event, cmd: string) => { @@ -833,7 +833,7 @@ export class CodeWindow implements ICodeWindow { if (notify) { this.send('vscode:showInfoMessage', nls.localize('hiddenMenuBar', "You can still access the menu bar by pressing the **Alt** key.")); - }; + } break; case ('hidden'): @@ -847,7 +847,7 @@ export class CodeWindow implements ICodeWindow { this._win.setAutoHideMenuBar(false); }); break; - }; + } } public onWindowTitleDoubleClick(): void { diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 148986ecca9..f0d030a42ef 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -143,7 +143,7 @@ export class WindowsManager implements IWindowsMainService { @IEnvironmentService private environmentService: IEnvironmentService, @ILifecycleService private lifecycleService: ILifecycleService, @IBackupMainService private backupService: IBackupMainService, - @ITelemetryService private telemetryService: ITelemetryService, + @ITelemetryService telemetryService: ITelemetryService, @IConfigurationService private configurationService: IConfigurationService, @IHistoryMainService private historyService: IHistoryMainService, @IWorkspacesMainService private workspacesService: IWorkspacesMainService, @@ -152,7 +152,7 @@ export class WindowsManager implements IWindowsMainService { this.windowsState = this.storageService.getItem(WindowsManager.windowsStateStorageKey) || { openedWindows: [] }; this.fileDialog = new FileDialog(environmentService, telemetryService, storageService, this); - this.workspacesManager = new WorkspacesManager(workspacesService, lifecycleService, backupService, environmentService, this); + this.workspacesManager = new WorkspacesManager(workspacesService, backupService, environmentService, this); this.migrateLegacyWindowState(); } @@ -1672,7 +1672,6 @@ class WorkspacesManager { constructor( private workspacesService: IWorkspacesMainService, - private lifecycleService: ILifecycleService, private backupService: IBackupMainService, private environmentService: IEnvironmentService, private windowsMainService: IWindowsMainService diff --git a/src/vs/editor/browser/controller/pointerHandler.ts b/src/vs/editor/browser/controller/pointerHandler.ts index 35b948c6634..2c7548ff84b 100644 --- a/src/vs/editor/browser/controller/pointerHandler.ts +++ b/src/vs/editor/browser/controller/pointerHandler.ts @@ -28,7 +28,7 @@ function gestureChangeEventMerger(lastEvent: IThrottledGestureEvent, currentEven r.translationX += lastEvent.translationX; } return r; -}; +} /** * Basically IE10 and IE11 diff --git a/src/vs/editor/browser/controller/textAreaHandler.ts b/src/vs/editor/browser/controller/textAreaHandler.ts index a060f7863b1..d4428d9ce78 100644 --- a/src/vs/editor/browser/controller/textAreaHandler.ts +++ b/src/vs/editor/browser/controller/textAreaHandler.ts @@ -54,8 +54,6 @@ export class TextAreaHandler extends ViewPart { private readonly _viewController: ViewController; private readonly _viewHelper: ITextAreaHandlerHelper; - - private _pixelRatio: number; private _accessibilitySupport: platform.AccessibilitySupport; private _contentLeft: number; private _contentWidth: number; @@ -86,7 +84,6 @@ export class TextAreaHandler extends ViewPart { const conf = this._context.configuration.editor; - this._pixelRatio = conf.pixelRatio; this._accessibilitySupport = conf.accessibilitySupport; this._contentLeft = conf.layoutInfo.contentLeft; this._contentWidth = conf.layoutInfo.contentWidth; @@ -306,9 +303,6 @@ export class TextAreaHandler extends ViewPart { if (e.lineHeight) { this._lineHeight = conf.lineHeight; } - if (e.pixelRatio) { - this._pixelRatio = conf.pixelRatio; - } if (e.accessibilitySupport) { this._accessibilitySupport = conf.accessibilitySupport; this._textAreaInput.writeScreenReaderContent('strategy changed'); diff --git a/src/vs/editor/browser/editorDom.ts b/src/vs/editor/browser/editorDom.ts index 504c830dda1..b483b681901 100644 --- a/src/vs/editor/browser/editorDom.ts +++ b/src/vs/editor/browser/editorDom.ts @@ -135,10 +135,10 @@ export class EditorMouseEventFactory { } public onMouseMoveThrottled(target: HTMLElement, callback: (e: EditorMouseEvent) => void, merger: EditorMouseEventMerger, minimumTimeMs: number): IDisposable { - let myMerger: dom.IEventMerger = (lastEvent: EditorMouseEvent, currentEvent: MouseEvent): EditorMouseEvent => { + let myMerger: dom.IEventMerger = (lastEvent: EditorMouseEvent, currentEvent: MouseEvent): EditorMouseEvent => { return merger(lastEvent, this._create(currentEvent)); }; - return dom.addDisposableThrottledListener(target, 'mousemove', callback, myMerger, minimumTimeMs); + return dom.addDisposableThrottledListener(target, 'mousemove', callback, myMerger, minimumTimeMs); } } @@ -168,7 +168,7 @@ export class GlobalEditorMouseMoveMonitor extends Disposable { this._globalMouseMoveMonitor.stopMonitoring(true); }, true); - let myMerger: dom.IEventMerger = (lastEvent: EditorMouseEvent, currentEvent: MouseEvent): EditorMouseEvent => { + let myMerger: dom.IEventMerger = (lastEvent: EditorMouseEvent, currentEvent: MouseEvent): EditorMouseEvent => { return merger(lastEvent, new EditorMouseEvent(currentEvent, this._editorViewDomNode)); }; diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index 1a53e3d9814..72997183743 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -90,6 +90,7 @@ export class View extends ViewEventHandler { private overflowGuardContainer: FastDomNode; // Actual mutable state + // @ts-ignore unused property private _isDisposed: boolean; private _renderAnimationFrame: IDisposable; diff --git a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts index a2b218246e1..a07ae843924 100644 --- a/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts +++ b/src/vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight.ts @@ -16,6 +16,7 @@ import { editorLineHighlight, editorLineHighlightBorder } from 'vs/editor/common export class CurrentLineHighlightOverlay extends DynamicViewOverlay { private _context: ViewContext; private _lineHeight: number; + // @ts-ignore unused property private _readOnly: boolean; private _renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; private _selectionIsEmpty: boolean; diff --git a/src/vs/editor/browser/viewParts/rulers/rulers.ts b/src/vs/editor/browser/viewParts/rulers/rulers.ts index 6a5e95b0b8c..036ff988cb7 100644 --- a/src/vs/editor/browser/viewParts/rulers/rulers.ts +++ b/src/vs/editor/browser/viewParts/rulers/rulers.ts @@ -20,7 +20,6 @@ export class Rulers extends ViewPart { public domNode: FastDomNode; private _renderedRulers: FastDomNode[]; private _rulers: number[]; - private _height: number; private _typicalHalfwidthCharacterWidth: number; constructor(context: ViewContext) { @@ -31,7 +30,6 @@ export class Rulers extends ViewPart { this.domNode.setClassName('view-rulers'); this._renderedRulers = []; this._rulers = this._context.configuration.editor.viewInfo.rulers; - this._height = this._context.configuration.editor.layoutInfo.contentHeight; this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; } @@ -44,7 +42,6 @@ export class Rulers extends ViewPart { public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean { if (e.viewInfo || e.layoutInfo || e.fontInfo) { this._rulers = this._context.configuration.editor.viewInfo.rulers; - this._height = this._context.configuration.editor.layoutInfo.contentHeight; this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; return true; } diff --git a/src/vs/editor/browser/widget/diffReview.ts b/src/vs/editor/browser/widget/diffReview.ts index 22b17b5f9fb..7764188fe0b 100644 --- a/src/vs/editor/browser/widget/diffReview.ts +++ b/src/vs/editor/browser/widget/diffReview.ts @@ -764,6 +764,7 @@ registerThemingParticipant((theme, collector) => { }); @editorAction +// @ts-ignore @editorAction uses the class class DiffReviewNext extends EditorAction { constructor() { super({ @@ -787,6 +788,7 @@ class DiffReviewNext extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class DiffReviewPrev extends EditorAction { constructor() { super({ diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index 4881d847e08..f9dc3df6ff3 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -1036,7 +1036,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo class EditorContextKeysManager extends Disposable { private _editor: CommonCodeEditor; - + // @ts-ignore unused property private _editorId: IContextKey; private _editorFocus: IContextKey; private _editorTextFocus: IContextKey; diff --git a/src/vs/editor/common/controller/coreCommands.ts b/src/vs/editor/common/controller/coreCommands.ts index 33661420850..f3a8e446f63 100644 --- a/src/vs/editor/common/controller/coreCommands.ts +++ b/src/vs/editor/common/controller/coreCommands.ts @@ -114,7 +114,7 @@ export namespace EditorScroll_ { value?: number; revealCursor?: boolean; select?: boolean; - }; + } export function parse(args: RawArguments): ParsedArguments { let direction: Direction; @@ -224,7 +224,7 @@ export namespace RevealLine_ { export interface RawArguments { lineNumber?: number; at?: string; - }; + } /** * Values for reveal line 'at' argument @@ -1650,7 +1650,7 @@ export namespace CoreEditingCommands { }); } - +// @ts-ignore unused namespace namespace Config { function findFocusedEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor { diff --git a/src/vs/editor/common/controller/cursorMoveCommands.ts b/src/vs/editor/common/controller/cursorMoveCommands.ts index a0f5c443432..c3320572991 100644 --- a/src/vs/editor/common/controller/cursorMoveCommands.ts +++ b/src/vs/editor/common/controller/cursorMoveCommands.ts @@ -670,7 +670,7 @@ export namespace CursorMove { select?: boolean; by?: string; value?: number; - }; + } export function parse(args: RawArguments): ParsedArguments { if (!args.to) { @@ -753,7 +753,7 @@ export namespace CursorMove { unit: Unit; select: boolean; value: number; - }; + } export const enum Direction { Left, @@ -772,7 +772,7 @@ export namespace CursorMove { ViewPortBottom, ViewPortIfOutside, - }; + } export const enum Unit { None, @@ -780,6 +780,6 @@ export namespace CursorMove { WrappedLine, Character, HalfLine, - }; + } } diff --git a/src/vs/editor/common/core/uint.ts b/src/vs/editor/common/core/uint.ts index b68709f2ce2..924b783a4a5 100644 --- a/src/vs/editor/common/core/uint.ts +++ b/src/vs/editor/common/core/uint.ts @@ -7,6 +7,7 @@ export class Uint8Matrix { private _data: Uint8Array; + // @ts-ignore unused property private _rows: number; private _cols: number; diff --git a/src/vs/editor/common/editorContextKeys.ts b/src/vs/editor/common/editorContextKeys.ts index 8843cf821d4..c17abc56f0f 100644 --- a/src/vs/editor/common/editorContextKeys.ts +++ b/src/vs/editor/common/editorContextKeys.ts @@ -42,4 +42,4 @@ export namespace EditorContextKeys { export const hasDocumentFormattingProvider = new RawContextKey('editorHasDocumentFormattingProvider', undefined); export const hasDocumentSelectionFormattingProvider = new RawContextKey('editorHasDocumentSelectionFormattingProvider', undefined); export const hasSignatureHelpProvider = new RawContextKey('editorHasSignatureHelpProvider', undefined); -}; +} diff --git a/src/vs/editor/common/model/indentRanges.ts b/src/vs/editor/common/model/indentRanges.ts index 8217f69b354..a3fdce186ba 100644 --- a/src/vs/editor/common/model/indentRanges.ts +++ b/src/vs/editor/common/model/indentRanges.ts @@ -191,7 +191,7 @@ export class RangesCollector { } -interface PreviousRegion { indent: number; line: number; marker: boolean; }; +interface PreviousRegion { indent: number; line: number; marker: boolean; } export function computeRanges(model: ITextModel, offSide: boolean, markers?: FoldingMarkers, foldingRegionsLimit = MAX_FOLDING_REGIONS_FOR_INDENT_LIMIT): IndentRanges { const tabSize = model.getOptions().tabSize; diff --git a/src/vs/editor/common/model/intervalTree.ts b/src/vs/editor/common/model/intervalTree.ts index c07fdd33ba2..7fa9b78ce63 100644 --- a/src/vs/editor/common/model/intervalTree.ts +++ b/src/vs/editor/common/model/intervalTree.ts @@ -425,7 +425,7 @@ function adjustMarkerBeforeColumn(markerOffset: number, markerStickToPreviousCha return true; } return markerStickToPreviousCharacter; -}; +} /** * This is a lot more complicated than strictly necessary to maintain the same behaviour diff --git a/src/vs/editor/common/modes/supports/indentRules.ts b/src/vs/editor/common/modes/supports/indentRules.ts index b88860741b1..607c3ad1be3 100644 --- a/src/vs/editor/common/modes/supports/indentRules.ts +++ b/src/vs/editor/common/modes/supports/indentRules.ts @@ -12,7 +12,7 @@ export const enum IndentConsts { DECREASE_MASK = 0b00000010, INDENT_NEXTLINE_MASK = 0b00000100, UNINDENT_MASK = 0b00001000, -}; +} export class IndentRulesSupport { diff --git a/src/vs/editor/common/modes/supports/onEnter.ts b/src/vs/editor/common/modes/supports/onEnter.ts index 2287829bb1d..be11c521278 100644 --- a/src/vs/editor/common/modes/supports/onEnter.ts +++ b/src/vs/editor/common/modes/supports/onEnter.ts @@ -24,6 +24,7 @@ interface IProcessedBracketPair { export class OnEnterSupport { private readonly _brackets: IProcessedBracketPair[]; + // @ts-ignore unused property private readonly _indentationRules: IndentationRule; private readonly _regExpRules: OnEnterRule[]; diff --git a/src/vs/editor/common/services/editorWorkerServiceImpl.ts b/src/vs/editor/common/services/editorWorkerServiceImpl.ts index eb0fc71a160..ed44a216e56 100644 --- a/src/vs/editor/common/services/editorWorkerServiceImpl.ts +++ b/src/vs/editor/common/services/editorWorkerServiceImpl.ts @@ -114,6 +114,7 @@ class WordBasedCompletionItemProvider implements modes.ISuggestSupport { private readonly _workerManager: WorkerManager; private readonly _configurationService: ITextResourceConfigurationService; + // @ts-ignore unused injected service private readonly _modeService: IModeService; private readonly _modelService: IModelService; diff --git a/src/vs/editor/common/services/languagesRegistry.ts b/src/vs/editor/common/services/languagesRegistry.ts index 0159f694c70..33a9ecd1c6f 100644 --- a/src/vs/editor/common/services/languagesRegistry.ts +++ b/src/vs/editor/common/services/languagesRegistry.ts @@ -36,13 +36,16 @@ export class LanguagesRegistry { private _nameMap: { [name: string]: LanguageIdentifier; }; private _lowercaseNameMap: { [name: string]: LanguageIdentifier; }; - constructor(useModesRegistry = true) { + private _warnOnOverwrite: boolean; + + constructor(useModesRegistry = true, warnOnOverwrite = false) { this._nextLanguageId = 1; this._languages = {}; this._mimeTypesMap = {}; this._nameMap = {}; this._lowercaseNameMap = {}; this._languageIds = []; + this._warnOnOverwrite = warnOnOverwrite; if (useModesRegistry) { this._registerLanguages(ModesRegistry.getLanguages()); @@ -100,10 +103,10 @@ export class LanguagesRegistry { this._languages[langId] = resolvedLanguage; } - LanguagesRegistry._mergeLanguage(resolvedLanguage, lang); + this._mergeLanguage(resolvedLanguage, lang); } - private static _mergeLanguage(resolvedLanguage: IResolvedLanguage, lang: ILanguageExtensionPoint): void { + private _mergeLanguage(resolvedLanguage: IResolvedLanguage, lang: ILanguageExtensionPoint): void { const langId = lang.id; let primaryMime: string = null; @@ -124,21 +127,21 @@ export class LanguagesRegistry { if (Array.isArray(lang.extensions)) { for (let extension of lang.extensions) { - mime.registerTextMime({ id: langId, mime: primaryMime, extension: extension }); + mime.registerTextMime({ id: langId, mime: primaryMime, extension: extension }, this._warnOnOverwrite); resolvedLanguage.extensions.push(extension); } } if (Array.isArray(lang.filenames)) { for (let filename of lang.filenames) { - mime.registerTextMime({ id: langId, mime: primaryMime, filename: filename }); + mime.registerTextMime({ id: langId, mime: primaryMime, filename: filename }, this._warnOnOverwrite); resolvedLanguage.filenames.push(filename); } } if (Array.isArray(lang.filenamePatterns)) { for (let filenamePattern of lang.filenamePatterns) { - mime.registerTextMime({ id: langId, mime: primaryMime, filepattern: filenamePattern }); + mime.registerTextMime({ id: langId, mime: primaryMime, filepattern: filenamePattern }, this._warnOnOverwrite); } } @@ -150,7 +153,7 @@ export class LanguagesRegistry { try { let firstLineRegex = new RegExp(firstLineRegexStr); if (!strings.regExpLeadsToEndlessLoop(firstLineRegex)) { - mime.registerTextMime({ id: langId, mime: primaryMime, firstline: firstLineRegex }); + mime.registerTextMime({ id: langId, mime: primaryMime, firstline: firstLineRegex }, this._warnOnOverwrite); } } catch (err) { // Most likely, the regex was bad diff --git a/src/vs/editor/common/services/modeServiceImpl.ts b/src/vs/editor/common/services/modeServiceImpl.ts index d75ed1aafb6..70cfd572e22 100644 --- a/src/vs/editor/common/services/modeServiceImpl.ts +++ b/src/vs/editor/common/services/modeServiceImpl.ts @@ -21,10 +21,10 @@ export class ModeServiceImpl implements IModeService { private readonly _onDidCreateMode: Emitter = new Emitter(); public readonly onDidCreateMode: Event = this._onDidCreateMode.event; - constructor() { + constructor(warnOnOverwrite = false) { this._instantiatedModes = {}; - this._registry = new LanguagesRegistry(); + this._registry = new LanguagesRegistry(true, warnOnOverwrite); } protected _onReady(): TPromise { diff --git a/src/vs/editor/common/services/resourceConfigurationImpl.ts b/src/vs/editor/common/services/resourceConfigurationImpl.ts index 6124db46a06..00c24a097a8 100644 --- a/src/vs/editor/common/services/resourceConfigurationImpl.ts +++ b/src/vs/editor/common/services/resourceConfigurationImpl.ts @@ -28,8 +28,8 @@ export class TextResourceConfigurationService extends Disposable implements ITex this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(e))); } - getConfiguration(resource: URI, section?: string): T - getConfiguration(resource: URI, at?: IPosition, section?: string): T + getConfiguration(resource: URI, section?: string): T; + getConfiguration(resource: URI, at?: IPosition, section?: string): T; getConfiguration(resource: URI, arg2?: any, arg3?: any): T { const position: IPosition = Position.isIPosition(arg2) ? arg2 : null; const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0); diff --git a/src/vs/editor/common/services/webWorker.ts b/src/vs/editor/common/services/webWorker.ts index f44ecfe24db..670357d8030 100644 --- a/src/vs/editor/common/services/webWorker.ts +++ b/src/vs/editor/common/services/webWorker.ts @@ -84,7 +84,7 @@ class MonacoWebWorkerImpl extends EditorWorkerClient implements MonacoWebWork }; }; - let foreignProxy = {}; + let foreignProxy = {} as T; for (let i = 0; i < foreignMethods.length; i++) { foreignProxy[foreignMethods[i]] = createProxyMethod(foreignMethods[i], proxyMethodRequest); } diff --git a/src/vs/editor/common/viewLayout/viewLineRenderer.ts b/src/vs/editor/common/viewLayout/viewLineRenderer.ts index 2160e5ebff1..f0923f2e775 100644 --- a/src/vs/editor/common/viewLayout/viewLineRenderer.ts +++ b/src/vs/editor/common/viewLayout/viewLineRenderer.ts @@ -618,7 +618,6 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render { let _charIndex = charIndex; let _tabsCharDelta = tabsCharDelta; - let _charOffsetInPart = charOffsetInPart; for (; _charIndex < partEndIndex; _charIndex++) { const charCode = lineContent.charCodeAt(_charIndex); @@ -626,13 +625,10 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render if (charCode === CharCode.Tab) { let insertSpacesCount = tabSize - (_charIndex + _tabsCharDelta) % tabSize; _tabsCharDelta += insertSpacesCount - 1; - _charOffsetInPart += insertSpacesCount - 1; partContentCnt += insertSpacesCount; } else { partContentCnt++; } - - _charOffsetInPart++; } } diff --git a/src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts b/src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts index ac3d45aee32..666bfdafc1f 100644 --- a/src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts +++ b/src/vs/editor/contrib/bracketMatching/common/bracketMatching.ts @@ -20,6 +20,7 @@ import { editorBracketMatchBackground, editorBracketMatchBorder } from 'vs/edito import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations'; @editorAction +// @ts-ignore @editorAction uses the class class SelectBracketAction extends EditorAction { constructor() { super({ diff --git a/src/vs/editor/contrib/caretOperations/common/caretOperations.ts b/src/vs/editor/contrib/caretOperations/common/caretOperations.ts index 96e935bd69d..c31ae66f389 100644 --- a/src/vs/editor/contrib/caretOperations/common/caretOperations.ts +++ b/src/vs/editor/contrib/caretOperations/common/caretOperations.ts @@ -36,6 +36,7 @@ class MoveCaretAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class MoveCaretLeftAction extends MoveCaretAction { constructor() { super(true, { @@ -48,6 +49,7 @@ class MoveCaretLeftAction extends MoveCaretAction { } @editorAction +// @ts-ignore @editorAction uses the class class MoveCaretRightAction extends MoveCaretAction { constructor() { super(false, { diff --git a/src/vs/editor/contrib/caretOperations/common/transpose.ts b/src/vs/editor/contrib/caretOperations/common/transpose.ts index 5ca66ce287d..28bab72bba4 100644 --- a/src/vs/editor/contrib/caretOperations/common/transpose.ts +++ b/src/vs/editor/contrib/caretOperations/common/transpose.ts @@ -13,6 +13,7 @@ import { editorAction, EditorAction, ServicesAccessor } from 'vs/editor/common/e import { ReplaceCommand } from 'vs/editor/common/commands/replaceCommand'; @editorAction +// @ts-ignore @editorAction uses the class class TransposeLettersAction extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/clipboard/browser/clipboard.ts b/src/vs/editor/contrib/clipboard/browser/clipboard.ts index 84cb6cc3167..828d4ff7d4c 100644 --- a/src/vs/editor/contrib/clipboard/browser/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/browser/clipboard.ts @@ -64,6 +64,7 @@ abstract class ExecCommandAction extends EditorAction { } @conditionalEditorAction(supportsCut) +// @ts-ignore @editorAction uses the class class ExecCommandCutAction extends ExecCommandAction { constructor() { @@ -102,6 +103,7 @@ class ExecCommandCutAction extends ExecCommandAction { } @conditionalEditorAction(supportsCopy) +// @ts-ignore @editorAction uses the class class ExecCommandCopyAction extends ExecCommandAction { constructor() { @@ -141,6 +143,7 @@ class ExecCommandCopyAction extends ExecCommandAction { } @conditionalEditorAction(supportsPaste) +// @ts-ignore @editorAction uses the class class ExecCommandPasteAction extends ExecCommandAction { constructor() { @@ -170,6 +173,7 @@ class ExecCommandPasteAction extends ExecCommandAction { } @conditionalEditorAction(supportsCopyWithSyntaxHighlighting) +// @ts-ignore @editorAction uses the class class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction { constructor() { diff --git a/src/vs/editor/contrib/codelens/browser/codelensWidget.ts b/src/vs/editor/contrib/codelens/browser/codelensWidget.ts index ac7b103cd55..b98a31d4fa7 100644 --- a/src/vs/editor/contrib/codelens/browser/codelensWidget.ts +++ b/src/vs/editor/contrib/codelens/browser/codelensWidget.ts @@ -65,6 +65,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget { private readonly _disposables: IDisposable[] = []; private readonly _editor: editorBrowser.ICodeEditor; + // @ts-ignore unused property private _symbolRange: Range; private _widgetPosition: editorBrowser.IContentWidgetPosition; private _commands: { [id: string]: Command } = Object.create(null); diff --git a/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts b/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts index d2c7c854f55..1b461696a68 100644 --- a/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts +++ b/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts @@ -66,7 +66,7 @@ export class ColorPickerBody extends Disposable { private saturationBox: SaturationBox; private hueStrip: Strip; private opacityStrip: Strip; - + // @ts-ignore unused property constructor(private container: HTMLElement, private model: ColorPickerModel, private pixelRatio: number) { super(); diff --git a/src/vs/editor/contrib/comment/common/comment.ts b/src/vs/editor/contrib/comment/common/comment.ts index 898e1aa89d0..e722543179f 100644 --- a/src/vs/editor/contrib/comment/common/comment.ts +++ b/src/vs/editor/contrib/comment/common/comment.ts @@ -43,6 +43,7 @@ abstract class CommentLineAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class ToggleCommentLineAction extends CommentLineAction { constructor() { super(Type.Toggle, { @@ -59,6 +60,7 @@ class ToggleCommentLineAction extends CommentLineAction { } @editorAction +// @ts-ignore @editorAction uses the class class AddLineCommentAction extends CommentLineAction { constructor() { super(Type.ForceAdd, { @@ -75,6 +77,7 @@ class AddLineCommentAction extends CommentLineAction { } @editorAction +// @ts-ignore @editorAction uses the class class RemoveLineCommentAction extends CommentLineAction { constructor() { super(Type.ForceRemove, { @@ -91,6 +94,7 @@ class RemoveLineCommentAction extends CommentLineAction { } @editorAction +// @ts-ignore @editorAction uses the class class BlockCommentAction extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts index 2a726ea915e..8f08c79e111 100644 --- a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts @@ -218,6 +218,7 @@ export class ContextMenuController implements IEditorContribution { } @editorAction +// @ts-ignore @editorAction uses the class class ShowContextMenu extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/find/test/common/findController.test.ts b/src/vs/editor/contrib/find/test/common/findController.test.ts index 323f3f0ce42..4a0f9c37130 100644 --- a/src/vs/editor/contrib/find/test/common/findController.test.ts +++ b/src/vs/editor/contrib/find/test/common/findController.test.ts @@ -71,11 +71,11 @@ function fromRange(rng: Range): number[] { suite('FindController', () => { let queryState: { [key: string]: any; } = {}; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(IStorageService, { get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], store: (key: string, value: any) => { queryState[key] = value; } - }); + } as IStorageService); test('issue #1857: F3, Find Next, acts like "Find Under Cursor"', () => { withMockCodeEditor([ @@ -392,11 +392,11 @@ suite('FindController query options persistence', () => { queryState['editor.matchCase'] = false; queryState['editor.wholeWord'] = false; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(IStorageService, { get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], store: (key: string, value: any) => { queryState[key] = value; } - }); + } as IStorageService); test('matchCase', () => { withMockCodeEditor([ diff --git a/src/vs/editor/contrib/folding/browser/folding.ts b/src/vs/editor/contrib/folding/browser/folding.ts index 05adf3343c6..60df213b7ba 100644 --- a/src/vs/editor/contrib/folding/browser/folding.ts +++ b/src/vs/editor/contrib/folding/browser/folding.ts @@ -363,6 +363,7 @@ function foldingArgumentsConstraint(args: any) { } @editorAction +// @ts-ignore @editorAction uses the class class UnfoldAction extends FoldingAction { constructor() { @@ -407,6 +408,7 @@ class UnfoldAction extends FoldingAction { } @editorAction +// @ts-ignore @editorAction uses the class class UnFoldRecursivelyAction extends FoldingAction { constructor() { @@ -428,6 +430,7 @@ class UnFoldRecursivelyAction extends FoldingAction { } @editorAction +// @ts-ignore @editorAction uses the class class FoldAction extends FoldingAction { constructor() { @@ -472,6 +475,7 @@ class FoldAction extends FoldingAction { } @editorAction +// @ts-ignore @editorAction uses the class class FoldRecursivelyAction extends FoldingAction { constructor() { @@ -498,6 +502,7 @@ class FoldRecursivelyAction extends FoldingAction { } @editorAction +// @ts-ignore @editorAction uses the class class FoldAllAction extends FoldingAction { constructor() { @@ -519,6 +524,7 @@ class FoldAllAction extends FoldingAction { } @editorAction +// @ts-ignore @editorAction uses the class class UnfoldAllAction extends FoldingAction { constructor() { @@ -565,4 +571,4 @@ for (let i = 1; i <= 9; i++) { } }) ); -}; +} diff --git a/src/vs/editor/contrib/folding/common/foldingModel.ts b/src/vs/editor/contrib/folding/common/foldingModel.ts index f0eb43ed984..fbf7c034ec1 100644 --- a/src/vs/editor/contrib/folding/common/foldingModel.ts +++ b/src/vs/editor/contrib/folding/common/foldingModel.ts @@ -32,8 +32,8 @@ export class FoldingModel { private _updateEventEmitter = new Emitter(); - public get regions(): FoldingRegion[] { return this._regions; }; - public get onDidChange(): Event { return this._updateEventEmitter.event; }; + public get regions(): FoldingRegion[] { return this._regions; } + public get onDidChange(): Event { return this._updateEventEmitter.event; } public get textModel() { return this._textModel; } constructor(textModel: IModel, decorationProvider: IDecorationProvider) { @@ -198,7 +198,7 @@ export class FoldingModel { let index = this._ranges.findRange(lineNumber); if (index >= 0) { return this._regions[index]; - }; + } } return null; } diff --git a/src/vs/editor/contrib/folding/common/hiddenRangeModel.ts b/src/vs/editor/contrib/folding/common/hiddenRangeModel.ts index aa008c4a74d..0f8b93af245 100644 --- a/src/vs/editor/contrib/folding/common/hiddenRangeModel.ts +++ b/src/vs/editor/contrib/folding/common/hiddenRangeModel.ts @@ -16,7 +16,7 @@ export class HiddenRangeModel { private _foldingModelListener: IDisposable; private _updateEventEmitter = new Emitter(); - public get onDidChange(): Event { return this._updateEventEmitter.event; }; + public get onDidChange(): Event { return this._updateEventEmitter.event; } public get hiddenRanges() { return this._hiddenRanges; } public constructor(model: FoldingModel) { @@ -50,7 +50,7 @@ export class HiddenRangeModel { updateHiddenAreas = true; newHiddenAreas.push(new Range(range.startLineNumber + 1, 1, range.endLineNumber, 1)); } - }; + } if (updateHiddenAreas || i < this._hiddenRanges.length) { this.applyHiddenRanges(newHiddenAreas); } diff --git a/src/vs/editor/contrib/format/browser/formatActions.ts b/src/vs/editor/contrib/format/browser/formatActions.ts index 73fec82fbe7..f663af59899 100644 --- a/src/vs/editor/contrib/format/browser/formatActions.ts +++ b/src/vs/editor/contrib/format/browser/formatActions.ts @@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { editorAction, ServicesAccessor, EditorAction, commonEditorContribution } from 'vs/editor/common/editorCommonExtensions'; +import { editorAction, ServicesAccessor, EditorAction, commonEditorContribution, IActionOptions } from 'vs/editor/common/editorCommonExtensions'; import { OnTypeFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry } from 'vs/editor/common/modes'; import { getOnTypeFormattingEdits, getDocumentFormattingEdits, getDocumentRangeFormattingEdits, NoProviderError } from '../common/format'; import { EditOperationsCommand } from '../common/formatCommand'; @@ -54,6 +54,7 @@ function alertFormattingEdits(edits: editorCommon.ISingleEditOperation[]): void } @commonEditorContribution +// @ts-ignore @editorAction uses the class class FormatOnType implements editorCommon.IEditorContribution { private static ID = 'editor.contrib.autoFormat'; @@ -180,6 +181,7 @@ class FormatOnType implements editorCommon.IEditorContribution { } @commonEditorContribution +// @ts-ignore @editorAction uses the class class FormatOnPaste implements editorCommon.IEditorContribution { private static ID = 'editor.contrib.formatOnPaste'; @@ -364,7 +366,7 @@ CommandsRegistry.registerCommand('editor.action.format', accessor => { if (editor) { return new class extends AbstractFormatAction { constructor() { - super({}); + super({} as IActionOptions); } _getFormattingEdits(editor: editorCommon.ICommonCodeEditor): TPromise { const model = editor.getModel(); diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts index bb47505032e..872ce48705f 100644 --- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts +++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts @@ -27,6 +27,7 @@ import { DefinitionAction, DefinitionActionConfig } from './goToDeclarationComma import { ClickLinkGesture, ClickLinkMouseEvent, ClickLinkKeyboardEvent } from 'vs/editor/contrib/goToDeclaration/browser/clickLinkGesture'; @editorContribution +// @ts-ignore @editorAction uses the class class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorContribution { private static ID = 'editor.contrib.gotodefinitionwithmouse'; diff --git a/src/vs/editor/contrib/gotoError/browser/gotoError.ts b/src/vs/editor/contrib/gotoError/browser/gotoError.ts index 8b6111b2c13..24a5d2dd690 100644 --- a/src/vs/editor/contrib/gotoError/browser/gotoError.ts +++ b/src/vs/editor/contrib/gotoError/browser/gotoError.ts @@ -504,6 +504,7 @@ class MarkerController implements editorCommon.IEditorContribution { } @editorAction +// @ts-ignore @editorAction uses the class class NextMarkerAction extends MarkerNavigationAction { constructor() { super(true, { @@ -520,6 +521,7 @@ class NextMarkerAction extends MarkerNavigationAction { } @editorAction +// @ts-ignore @editorAction uses the class class PrevMarkerAction extends MarkerNavigationAction { constructor() { super(false, { diff --git a/src/vs/editor/contrib/hover/browser/hover.ts b/src/vs/editor/contrib/hover/browser/hover.ts index 179eb9d2973..b7854831ac9 100644 --- a/src/vs/editor/contrib/hover/browser/hover.ts +++ b/src/vs/editor/contrib/hover/browser/hover.ts @@ -170,6 +170,7 @@ export class ModesHoverController implements editorCommon.IEditorContribution { } @editorAction +// @ts-ignore @editorAction uses the class class ShowHoverAction extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts b/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts index 3e9084e361a..4e5eba2cf32 100644 --- a/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts +++ b/src/vs/editor/contrib/inPlaceReplace/common/inPlaceReplace.ts @@ -34,7 +34,6 @@ class InPlaceReplaceController implements IEditorContribution { }); private editor: ICommonCodeEditor; - private requestIdPool: number; private currentRequest: TPromise; private decorationRemover: TPromise; private decorationIds: string[]; @@ -46,7 +45,6 @@ class InPlaceReplaceController implements IEditorContribution { ) { this.editor = editor; this.editorWorkerService = editorWorkerService; - this.requestIdPool = 0; this.currentRequest = TPromise.as(null); this.decorationRemover = TPromise.as(null); this.decorationIds = []; @@ -141,6 +139,7 @@ class InPlaceReplaceController implements IEditorContribution { } @editorAction +// @ts-ignore @editorAction uses the class class InPlaceReplaceUp extends EditorAction { constructor() { @@ -166,6 +165,7 @@ class InPlaceReplaceUp extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class InPlaceReplaceDown extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/indentation/common/indentation.ts b/src/vs/editor/contrib/indentation/common/indentation.ts index 41fb47db826..5530c97ef8e 100644 --- a/src/vs/editor/contrib/indentation/common/indentation.ts +++ b/src/vs/editor/contrib/indentation/common/indentation.ts @@ -333,6 +333,7 @@ export class ReindentLinesAction extends EditorAction { export class AutoIndentOnPasteCommand implements ICommand { private _edits: TextEdit[]; + // @ts-ignore @editorAction unused property private _newEol: EndOfLineSequence; private _initialSelection: Selection; diff --git a/src/vs/editor/contrib/linesOperations/common/linesOperations.ts b/src/vs/editor/contrib/linesOperations/common/linesOperations.ts index 2a81b32df9c..05eeac34347 100644 --- a/src/vs/editor/contrib/linesOperations/common/linesOperations.ts +++ b/src/vs/editor/contrib/linesOperations/common/linesOperations.ts @@ -49,6 +49,7 @@ abstract class AbstractCopyLinesAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class CopyLinesUpAction extends AbstractCopyLinesAction { constructor() { super(false, { @@ -66,6 +67,7 @@ class CopyLinesUpAction extends AbstractCopyLinesAction { } @editorAction +// @ts-ignore @editorAction uses the class class CopyLinesDownAction extends AbstractCopyLinesAction { constructor() { super(true, { @@ -110,6 +112,7 @@ abstract class AbstractMoveLinesAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class MoveLinesUpAction extends AbstractMoveLinesAction { constructor() { super(false, { @@ -127,6 +130,7 @@ class MoveLinesUpAction extends AbstractMoveLinesAction { } @editorAction +// @ts-ignore @editorAction uses the class class MoveLinesDownAction extends AbstractMoveLinesAction { constructor() { super(true, { @@ -166,6 +170,7 @@ abstract class AbstractSortLinesAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class SortLinesAscendingAction extends AbstractSortLinesAction { constructor() { super(false, { @@ -178,6 +183,7 @@ class SortLinesAscendingAction extends AbstractSortLinesAction { } @editorAction +// @ts-ignore @editorAction uses the class class SortLinesDescendingAction extends AbstractSortLinesAction { constructor() { super(true, { @@ -276,6 +282,7 @@ abstract class AbstractRemoveLinesAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class DeleteLinesAction extends AbstractRemoveLinesAction { constructor() { @@ -329,6 +336,7 @@ export class IndentLinesAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class OutdentLinesAction extends EditorAction { constructor() { super({ diff --git a/src/vs/editor/contrib/links/browser/links.ts b/src/vs/editor/contrib/links/browser/links.ts index 4c6eceb7ff6..3b5c1d3532e 100644 --- a/src/vs/editor/contrib/links/browser/links.ts +++ b/src/vs/editor/contrib/links/browser/links.ts @@ -16,7 +16,6 @@ import { IOpenerService } from 'vs/platform/opener/common/opener'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { editorAction, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions'; import { LinkProviderRegistry } from 'vs/editor/common/modes'; -import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { ICodeEditor, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { getLinks, Link } from 'vs/editor/contrib/links/common/links'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; @@ -148,19 +147,16 @@ class LinkDetector implements editorCommon.IEditorContribution { private activeLinkDecorationId: string; private openerService: IOpenerService; private messageService: IMessageService; - private editorWorkerService: IEditorWorkerService; private currentOccurrences: { [decorationId: string]: LinkOccurrence; }; constructor( editor: ICodeEditor, @IOpenerService openerService: IOpenerService, - @IMessageService messageService: IMessageService, - @IEditorWorkerService editorWorkerService: IEditorWorkerService + @IMessageService messageService: IMessageService ) { this.editor = editor; this.openerService = openerService; this.messageService = messageService; - this.editorWorkerService = editorWorkerService; this.listenersToRemove = []; let clickLinkGesture = new ClickLinkGesture(editor); @@ -389,6 +385,7 @@ class LinkDetector implements editorCommon.IEditorContribution { } @editorAction +// @ts-ignore @editorAction uses the class class OpenLinkAction extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/multicursor/common/multicursor.ts b/src/vs/editor/contrib/multicursor/common/multicursor.ts index f43996b53b7..f044ba0f0cf 100644 --- a/src/vs/editor/contrib/multicursor/common/multicursor.ts +++ b/src/vs/editor/contrib/multicursor/common/multicursor.ts @@ -105,6 +105,7 @@ export class InsertCursorBelow extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class InsertCursorAtEndOfEachLineSelected extends EditorAction { constructor() { diff --git a/src/vs/editor/contrib/multicursor/test/common/multicursor.test.ts b/src/vs/editor/contrib/multicursor/test/common/multicursor.test.ts index 93c8377b9d0..438ca8dd54f 100644 --- a/src/vs/editor/contrib/multicursor/test/common/multicursor.test.ts +++ b/src/vs/editor/contrib/multicursor/test/common/multicursor.test.ts @@ -53,11 +53,11 @@ function fromRange(rng: Range): number[] { suite('Multicursor selection', () => { let queryState: { [key: string]: any; } = {}; let serviceCollection = new ServiceCollection(); - serviceCollection.set(IStorageService, { + serviceCollection.set(IStorageService, { get: (key: string) => queryState[key], getBoolean: (key: string) => !!queryState[key], store: (key: string, value: any) => { queryState[key] = value; } - }); + } as IStorageService); test('issue #8817: Cursor position changes when you cancel multicursor', () => { withMockCodeEditor([ diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts index 7eef331e345..e04bf9fbaf7 100644 --- a/src/vs/editor/contrib/rename/browser/rename.ts +++ b/src/vs/editor/contrib/rename/browser/rename.ts @@ -6,7 +6,7 @@ 'use strict'; import * as nls from 'vs/nls'; -import { isPromiseCanceledError, onUnexpectedExternalError, illegalArgument } from 'vs/base/common/errors'; +import { isPromiseCanceledError, illegalArgument } from 'vs/base/common/errors'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import Severity from 'vs/base/common/severity'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -52,9 +52,6 @@ export function rename(model: IReadOnlyModel, position: Position, newName: strin rejects.push(result.rejectReason); } return undefined; - }, err => { - onUnexpectedExternalError(err); - return TPromise.wrapError(new Error('provider failed')); }); } return undefined; @@ -154,7 +151,7 @@ class RenameController implements IEditorContribution { const renameOperation = rename(this.editor.getModel(), this.editor.getPosition(), newName).then(result => { if (result.rejectReason) { - this._messageService.show(Severity.Error, result.rejectReason); + this._messageService.show(Severity.Info, result.rejectReason); return undefined; } edit.add(result.edits); diff --git a/src/vs/editor/contrib/smartSelect/common/smartSelect.ts b/src/vs/editor/contrib/smartSelect/common/smartSelect.ts index 47b9d0f2f0b..eb7f99d771c 100644 --- a/src/vs/editor/contrib/smartSelect/common/smartSelect.ts +++ b/src/vs/editor/contrib/smartSelect/common/smartSelect.ts @@ -164,6 +164,7 @@ abstract class AbstractSmartSelect extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class GrowSelectionAction extends AbstractSmartSelect { constructor() { super(true, { @@ -181,6 +182,7 @@ class GrowSelectionAction extends AbstractSmartSelect { } @editorAction +// @ts-ignore @editorAction uses the class class ShrinkSelectionAction extends AbstractSmartSelect { constructor() { super(false, { diff --git a/src/vs/editor/contrib/snippet/test/browser/snippetController2.old.test.ts b/src/vs/editor/contrib/snippet/test/browser/snippetController2.old.test.ts index fc12236bd33..cffb2fd232f 100644 --- a/src/vs/editor/contrib/snippet/test/browser/snippetController2.old.test.ts +++ b/src/vs/editor/contrib/snippet/test/browser/snippetController2.old.test.ts @@ -40,7 +40,7 @@ suite('SnippetController', () => { '\t', '}' ]; - }; + } withMockCodeEditor(lines, {}, (editor, cursor) => { editor.getModel().updateOptions({ diff --git a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts index 67874ded11c..aa88e693c8c 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestWidget.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestWidget.ts @@ -222,7 +222,7 @@ class SuggestionDetails { this.header = append(this.body, $('.header')); this.close = append(this.header, $('span.close')); - this.close.title = nls.localize('readLess', "Read less...{0}", triggerKeybindingLabel); + this.close.title = nls.localize('readLess', "Read less...{0}", this.triggerKeybindingLabel); this.type = append(this.header, $('p.type')); this.docs = append(this.body, $('p.docs')); diff --git a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts index 7f563dc6e31..2017bae8de2 100644 --- a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts @@ -491,6 +491,7 @@ class WordHighlightNavigationAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class NextWordHighlightAction extends WordHighlightNavigationAction { constructor() { super(true, { @@ -507,6 +508,7 @@ class NextWordHighlightAction extends WordHighlightNavigationAction { } @editorAction +// @ts-ignore @editorAction uses the class class PrevWordHighlightAction extends WordHighlightNavigationAction { constructor() { super(false, { diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts index b60bdaf2f80..c35a8d0a5b6 100644 --- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts @@ -335,6 +335,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } @editorAction +// @ts-ignore @editorAction uses the class class ShowAccessibilityHelpAction extends EditorAction { constructor() { super({ diff --git a/src/vs/editor/standalone/browser/inspectTokens/inspectTokens.ts b/src/vs/editor/standalone/browser/inspectTokens/inspectTokens.ts index cbcd2a853d2..50f8cab07b9 100644 --- a/src/vs/editor/standalone/browser/inspectTokens/inspectTokens.ts +++ b/src/vs/editor/standalone/browser/inspectTokens/inspectTokens.ts @@ -83,6 +83,7 @@ class InspectTokensController extends Disposable implements IEditorContribution } @editorAction +// @ts-ignore @editorAction uses the class class InspectTokens extends EditorAction { constructor() { @@ -169,7 +170,6 @@ class InspectTokensWidget extends Disposable implements IContentWidget { public allowEditorOverflow = true; private _editor: ICodeEditor; - private _standaloneThemeService: IStandaloneThemeService; private _modeService: IModeService; private _tokenizationSupport: ITokenizationSupport; private _model: IModel; @@ -182,7 +182,6 @@ class InspectTokensWidget extends Disposable implements IContentWidget { ) { super(); this._editor = editor; - this._standaloneThemeService = standaloneThemeService; this._modeService = modeService; this._model = this._editor.getModel(); this._domNode = document.createElement('div'); diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index 7b0a82667a1..a6c1766d569 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -458,10 +458,10 @@ export class SimpleConfigurationService implements IConfigurationService { return this._configuration; } - getConfiguration(): T - getConfiguration(section: string): T - getConfiguration(overrides: IConfigurationOverrides): T - getConfiguration(section: string, overrides: IConfigurationOverrides): T + getConfiguration(): T; + getConfiguration(section: string): T; + getConfiguration(overrides: IConfigurationOverrides): T; + getConfiguration(section: string, overrides: IConfigurationOverrides): T; getConfiguration(arg1?: any, arg2?: any): any { const section = typeof arg1 === 'string' ? arg1 : void 0; const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {}; diff --git a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts index 7ff286ade85..bb23be19f3c 100644 --- a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts @@ -306,7 +306,6 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon export class StandaloneDiffEditor extends DiffEditorWidget implements IStandaloneDiffEditor { private _contextViewService: IEditorContextViewService; - private _standaloneKeybindingService: StandaloneKeybindingService; constructor( domElement: HTMLElement, @@ -328,10 +327,6 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon super(domElement, options, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, messageService); - if (keybindingService instanceof StandaloneKeybindingService) { - this._standaloneKeybindingService = keybindingService; - } - this._contextViewService = contextViewService; this._register(toDispose); diff --git a/src/vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast.ts b/src/vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast.ts index 17197a6f7d3..3b48b9eab9e 100644 --- a/src/vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast.ts +++ b/src/vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast.ts @@ -10,6 +10,7 @@ import { editorAction, EditorAction, ServicesAccessor } from 'vs/editor/common/e import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService'; @editorAction +// @ts-ignore @editorAction uses the class class ToggleHighContrast extends EditorAction { private _originalThemeName: string; diff --git a/src/vs/editor/test/browser/controller/imeTester.ts b/src/vs/editor/test/browser/controller/imeTester.ts index ef3fb620995..6d80c9f7d5f 100644 --- a/src/vs/editor/test/browser/controller/imeTester.ts +++ b/src/vs/editor/test/browser/controller/imeTester.ts @@ -17,6 +17,7 @@ import * as browser from 'vs/base/browser/browser'; class SingleLineTestModel implements ISimpleModel { private _line: string; + // @ts-ignore unused property private _eol: string; constructor(line: string) { diff --git a/src/vs/editor/test/browser/controller/textAreaState.test.ts b/src/vs/editor/test/browser/controller/textAreaState.test.ts index ed247b98709..f63f52aadc3 100644 --- a/src/vs/editor/test/browser/controller/textAreaState.test.ts +++ b/src/vs/editor/test/browser/controller/textAreaState.test.ts @@ -588,6 +588,7 @@ suite('TextAreaState', () => { }); }); +// @ts-ignore unused class class SimpleModel implements ISimpleModel { private _lines: string[]; diff --git a/src/vs/editor/test/common/core/editorState.test.ts b/src/vs/editor/test/common/core/editorState.test.ts index d629a01987d..f5ca66e9dd4 100644 --- a/src/vs/editor/test/common/core/editorState.test.ts +++ b/src/vs/editor/test/common/core/editorState.test.ts @@ -91,13 +91,13 @@ suite('Editor Core - Editor State', () => { function createEditor({ model, position, selection, scroll }: IStubEditorState = {}): ICommonCodeEditor { let mappedModel = model ? { uri: model.uri ? model.uri : URI.parse('http://dummy.org'), getVersionId: () => model.version } : null; - return { + return { getModel: (): IModel => mappedModel, getPosition: (): Position => position, getSelection: (): Selection => selection, getScrollLeft: (): number => scroll && scroll.left, getScrollTop: (): number => scroll && scroll.top - }; + } as ICommonCodeEditor; } }); diff --git a/src/vs/editor/test/common/mocks/mockCodeEditor.ts b/src/vs/editor/test/common/mocks/mockCodeEditor.ts index 33621c3d209..599112cbb1c 100644 --- a/src/vs/editor/test/common/mocks/mockCodeEditor.ts +++ b/src/vs/editor/test/common/mocks/mockCodeEditor.ts @@ -29,7 +29,7 @@ export class MockCodeEditor extends CommonCodeEditor { public focus(): void { } public isFocused(): boolean { return this._isFocused; } - public hasWidgetFocus(): boolean { return true; }; + public hasWidgetFocus(): boolean { return true; } protected _enableEmptySelectionClipboard(): boolean { return false; } protected _scheduleAtNextAnimationFrame(callback: () => void): IDisposable { throw new Error('Notimplemented'); } diff --git a/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts b/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts index 20bbda92be7..290e750f645 100644 --- a/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts +++ b/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts @@ -25,21 +25,8 @@ suite('ViewModelDecorations', () => { assert.equal(viewModel.getLineContent(4), 'will be '); assert.equal(viewModel.getLineContent(5), 'wrapped'); - let dec1: string; - let dec2: string; - let dec3: string; - let dec4: string; - let dec5: string; - let dec6: string; - let dec7: string; - let dec8: string; - let dec9: string; - let dec10: string; - let dec11: string; - let dec12: string; - let dec13: string; - let dec14: string; - let dec15: string; + //@ts-ignore + let dec1, dec2, dec3, dec4, dec5, dec6, dec7, dec8, dec9, dec10, dec11, dec12, dec13, dec14, dec15: string; model.changeDecorations((accessor) => { let createOpts = (id: string) => { return { @@ -280,6 +267,7 @@ suite('ViewModelDecorations', () => { assert.equal(viewModel.getLineContent(4), 'will be '); assert.equal(viewModel.getLineContent(5), 'wrapped'); + // @ts-ignore unused local let dec1: string; model.changeDecorations((accessor) => { dec1 = accessor.addDecoration( diff --git a/src/vs/platform/actions/common/menu.ts b/src/vs/platform/actions/common/menu.ts index 1ea2c643b7f..6d0273668c0 100644 --- a/src/vs/platform/actions/common/menu.ts +++ b/src/vs/platform/actions/common/menu.ts @@ -21,6 +21,7 @@ export class Menu implements IMenu { private _onDidChange = new Emitter(); constructor( + // @ts-ignore unused property private _id: MenuId, startupSignal: TPromise, @ICommandService private _commandService: ICommandService, diff --git a/src/vs/platform/backup/electron-main/backupMainService.ts b/src/vs/platform/backup/electron-main/backupMainService.ts index 9ea43c880e6..ceb1a0e5cbc 100644 --- a/src/vs/platform/backup/electron-main/backupMainService.ts +++ b/src/vs/platform/backup/electron-main/backupMainService.ts @@ -14,7 +14,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IFilesConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files'; import { ILogService } from 'vs/platform/log/common/log'; -import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspacesMainService, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; +import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; export class BackupMainService implements IBackupMainService { @@ -28,8 +28,7 @@ export class BackupMainService implements IBackupMainService { constructor( @IEnvironmentService environmentService: IEnvironmentService, @IConfigurationService private configurationService: IConfigurationService, - @ILogService private logService: ILogService, - @IWorkspacesMainService private workspacesService: IWorkspacesMainService + @ILogService private logService: ILogService ) { this.backupHome = environmentService.backupHome; this.workspacesJsonPath = environmentService.backupWorkspacesPath; diff --git a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts index 96f8242c326..ae7618cefd3 100644 --- a/src/vs/platform/backup/test/electron-main/backupMainService.test.ts +++ b/src/vs/platform/backup/test/electron-main/backupMainService.test.ts @@ -22,7 +22,6 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/ import { LogMainService } from 'vs/platform/log/common/log'; import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { createHash } from 'crypto'; -import { WorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService'; import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices'; suite('BackupMainService', () => { @@ -31,12 +30,11 @@ suite('BackupMainService', () => { const backupWorkspacesPath = path.join(backupHome, 'workspaces.json'); const environmentService = new EnvironmentService(parseArgs(process.argv), process.execPath); - const logService = new LogMainService(environmentService); class TestBackupMainService extends BackupMainService { constructor(backupHome: string, backupWorkspacesPath: string, configService: TestConfigurationService) { - super(environmentService, configService, new LogMainService(environmentService), new WorkspacesMainService(environmentService, logService)); + super(environmentService, configService, new LogMainService(environmentService)); this.backupHome = backupHome; this.workspacesJsonPath = backupWorkspacesPath; diff --git a/src/vs/platform/commands/test/commandService.test.ts b/src/vs/platform/commands/test/commandService.test.ts index c4f39187914..2cc8f0ce2af 100644 --- a/src/vs/platform/commands/test/commandService.test.ts +++ b/src/vs/platform/commands/test/commandService.test.ts @@ -95,6 +95,7 @@ suite('CommandService', function () { let callCounter = 0; let reg = CommandsRegistry.registerCommand('bar', () => callCounter += 1); + // @ts-ignore unused local let resolve: Function; let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService { onReady() { diff --git a/src/vs/platform/configuration/common/configuration.ts b/src/vs/platform/configuration/common/configuration.ts index 0fb11cd76f5..6ebb51245d6 100644 --- a/src/vs/platform/configuration/common/configuration.ts +++ b/src/vs/platform/configuration/common/configuration.ts @@ -153,7 +153,7 @@ export function addToValueTree(settingsTreeRoot: any, key: string, value: any, c return; } curr = obj; - }; + } if (typeof curr === 'object') { curr[last] = value; // workaround https://github.com/Microsoft/vscode/issues/13606 diff --git a/src/vs/platform/configuration/common/configurationModels.ts b/src/vs/platform/configuration/common/configurationModels.ts index 4385e72b323..6ae3de36627 100644 --- a/src/vs/platform/configuration/common/configurationModels.ts +++ b/src/vs/platform/configuration/common/configurationModels.ts @@ -55,7 +55,7 @@ export class ConfigurationModel implements IConfigurationModel { addToValueTree(override.contents, key, value, e => { throw new Error(e); }); } - public override(identifier: string): ConfigurationModel { + public override(identifier: string): ConfigurationModel { const overrideContents = this.getContentsForOverrideIdentifer(identifier); if (!overrideContents || typeof overrideContents !== 'object' || !Object.keys(overrideContents).length) { @@ -385,7 +385,7 @@ export class Configuration { }); } - private getConsolidateConfigurationModel(overrides: IConfigurationOverrides, workspace: Workspace): ConfigurationModel { + private getConsolidateConfigurationModel(overrides: IConfigurationOverrides, workspace: Workspace): ConfigurationModel { let configurationModel = this.getConsolidatedConfigurationModelForResource(overrides, workspace); return overrides.overrideIdentifier ? configurationModel.override(overrides.overrideIdentifier) : configurationModel; } @@ -529,8 +529,8 @@ export class ConfigurationChangeEvent extends AbstractConfigurationChangeEvent i return this._changedConfigurationByResource; } - change(event: ConfigurationChangeEvent): ConfigurationChangeEvent - change(keys: string[], resource?: URI): ConfigurationChangeEvent + change(event: ConfigurationChangeEvent): ConfigurationChangeEvent; + change(keys: string[], resource?: URI): ConfigurationChangeEvent; change(arg1: any, arg2?: any): ConfigurationChangeEvent { if (arg1 instanceof ConfigurationChangeEvent) { this._changedConfiguration = this._changedConfiguration.merge(arg1._changedConfiguration); diff --git a/src/vs/platform/configuration/common/configurationRegistry.ts b/src/vs/platform/configuration/common/configurationRegistry.ts index 7861b3428dd..f0eb0575667 100644 --- a/src/vs/platform/configuration/common/configurationRegistry.ts +++ b/src/vs/platform/configuration/common/configurationRegistry.ts @@ -232,7 +232,7 @@ class ConfigurationRegistry implements IConfigurationRegistry { if (subNodes) { subNodes.forEach(register); } - }; + } register(configuration); } diff --git a/src/vs/platform/configuration/node/configurationService.ts b/src/vs/platform/configuration/node/configurationService.ts index 43ad33bce80..baa6c14f8d0 100644 --- a/src/vs/platform/configuration/node/configurationService.ts +++ b/src/vs/platform/configuration/node/configurationService.ts @@ -56,10 +56,10 @@ export class ConfigurationService extends Disposable implements IConfigurationSe return this.configuration.toData(); } - getConfiguration(): T - getConfiguration(section: string): T - getConfiguration(overrides: IConfigurationOverrides): T - getConfiguration(section: string, overrides: IConfigurationOverrides): T + getConfiguration(): T; + getConfiguration(section: string): T; + getConfiguration(overrides: IConfigurationOverrides): T; + getConfiguration(section: string, overrides: IConfigurationOverrides): T; getConfiguration(arg1?: any, arg2?: any): any { const section = typeof arg1 === 'string' ? arg1 : void 0; const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {}; @@ -70,10 +70,10 @@ export class ConfigurationService extends Disposable implements IConfigurationSe return this.configuration.getValue(key, overrides, null); } - updateValue(key: string, value: any): TPromise - updateValue(key: string, value: any, overrides: IConfigurationOverrides): TPromise - updateValue(key: string, value: any, target: ConfigurationTarget): TPromise - updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): TPromise + updateValue(key: string, value: any): TPromise; + updateValue(key: string, value: any, overrides: IConfigurationOverrides): TPromise; + updateValue(key: string, value: any, target: ConfigurationTarget): TPromise; + updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): TPromise; updateValue(key: string, value: any, arg3?: any, arg4?: any): TPromise { return TPromise.wrapError(new Error('not supported')); } diff --git a/src/vs/platform/contextkey/browser/contextKeyService.ts b/src/vs/platform/contextkey/browser/contextKeyService.ts index f12ad44deeb..3ae51a0edea 100644 --- a/src/vs/platform/contextkey/browser/contextKeyService.ts +++ b/src/vs/platform/contextkey/browser/contextKeyService.ts @@ -37,7 +37,11 @@ export class Context implements IContext { public removeValue(key: string): boolean { // console.log('REMOVE ' + key + ' FROM ' + this._id); - return delete this._value[key]; + if (key in this._value) { + delete this._value[key]; + return true; + } + return false; } public getValue(key: string): T { diff --git a/src/vs/platform/extensionManagement/common/extensionEnablementService.ts b/src/vs/platform/extensionManagement/common/extensionEnablementService.ts index 2ea8728e026..4db312fd0a1 100644 --- a/src/vs/platform/extensionManagement/common/extensionEnablementService.ts +++ b/src/vs/platform/extensionManagement/common/extensionEnablementService.ts @@ -29,6 +29,7 @@ export class ExtensionEnablementService implements IExtensionEnablementService { @IStorageService private storageService: IStorageService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IEnvironmentService private environmentService: IEnvironmentService, + // @ts-ignore unused injected service @IExtensionManagementService private extensionManagementService: IExtensionManagementService ) { extensionManagementService.onDidUninstallExtension(this.onDidUninstallExtension, this, this.disposables); diff --git a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts index 013d6ecdff0..d219de90a51 100644 --- a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts @@ -292,6 +292,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService { @IRequestService private requestService: IRequestService, @IEnvironmentService private environmentService: IEnvironmentService, @ITelemetryService private telemetryService: ITelemetryService, + // @ts-ignore unused injected service @IConfigurationService private configurationService: IConfigurationService ) { const config = product.extensionsGallery; diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index 687d47ab967..837dd1497b7 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -101,6 +101,7 @@ export class ExtensionManagementService implements IExtensionManagementService { onDidUninstallExtension: Event = this._onDidUninstallExtension.event; constructor( + // @ts-ignore unused injected service @IEnvironmentService private environmentService: IEnvironmentService, @IChoiceService private choiceService: IChoiceService, @IExtensionGalleryService private galleryService: IExtensionGalleryService diff --git a/src/vs/platform/instantiation/common/instantiationService.ts b/src/vs/platform/instantiation/common/instantiationService.ts index fd3adf8e44e..052e2eba90a 100644 --- a/src/vs/platform/instantiation/common/instantiationService.ts +++ b/src/vs/platform/instantiation/common/instantiationService.ts @@ -62,7 +62,7 @@ export class InstantiationService implements IInstantiationService { } } - createInstance(param: any, ...rest: any[]): any { + createInstance(param: any, ...rest: any[]): any { if (param instanceof SyncDescriptor) { // sync diff --git a/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts b/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts index fc7287a3167..da3a17eb8b0 100644 --- a/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts +++ b/src/vs/platform/instantiation/test/common/instantiationServiceMock.ts @@ -39,11 +39,11 @@ export class TestInstantiationService extends InstantiationService { return this._create(service, { mock: true }); } - public stub(service?: ServiceIdentifier, ctor?: any): T - public stub(service?: ServiceIdentifier, obj?: any): T - public stub(service?: ServiceIdentifier, ctor?: any, property?: string, value?: any): sinon.SinonStub - public stub(service?: ServiceIdentifier, obj?: any, property?: string, value?: any): sinon.SinonStub - public stub(service?: ServiceIdentifier, property?: string, value?: any): sinon.SinonStub + public stub(service?: ServiceIdentifier, ctor?: any): T; + public stub(service?: ServiceIdentifier, obj?: any): T; + public stub(service?: ServiceIdentifier, ctor?: any, property?: string, value?: any): sinon.SinonStub; + public stub(service?: ServiceIdentifier, obj?: any, property?: string, value?: any): sinon.SinonStub; + public stub(service?: ServiceIdentifier, property?: string, value?: any): sinon.SinonStub; public stub(serviceIdentifier?: ServiceIdentifier, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub { let service = typeof arg2 !== 'string' ? arg2 : void 0; let serviceMock: IServiceMock = { id: serviceIdentifier, service: service }; @@ -70,10 +70,10 @@ export class TestInstantiationService extends InstantiationService { return stubObject; } - public stubPromise(service?: ServiceIdentifier, fnProperty?: string, value?: any): T | sinon.SinonStub - public stubPromise(service?: ServiceIdentifier, ctor?: any, fnProperty?: string, value?: any): sinon.SinonStub - public stubPromise(service?: ServiceIdentifier, obj?: any, fnProperty?: string, value?: any): sinon.SinonStub - public stubPromise(arg1?: any, arg2?: any, arg3?: any, arg4?: any): sinon.SinonStub { + public stubPromise(service?: ServiceIdentifier, fnProperty?: string, value?: any): T | sinon.SinonStub; + public stubPromise(service?: ServiceIdentifier, ctor?: any, fnProperty?: string, value?: any): sinon.SinonStub; + public stubPromise(service?: ServiceIdentifier, obj?: any, fnProperty?: string, value?: any): sinon.SinonStub; + public stubPromise(arg1?: any, arg2?: any, arg3?: any, arg4?: any): sinon.SinonStub { arg3 = typeof arg2 === 'string' ? TPromise.as(arg3) : arg3; arg4 = typeof arg2 !== 'string' && typeof arg3 === 'string' ? TPromise.as(arg4) : arg4; return this.stub(arg1, arg2, arg3, arg4); @@ -85,9 +85,9 @@ export class TestInstantiationService extends InstantiationService { return spy; } - private _create(serviceMock: IServiceMock, options: SinonOptions, reset?: boolean): any - private _create(ctor: any, options: SinonOptions): any - private _create(arg1: any, options: SinonOptions, reset: boolean = false): any { + private _create(serviceMock: IServiceMock, options: SinonOptions, reset?: boolean): any; + private _create(ctor: any, options: SinonOptions): any; + private _create(arg1: any, options: SinonOptions, reset: boolean = false): any { if (this.isServiceMock(arg1)) { let service = this._getOrCreateService(arg1, options, reset); this._serviceCollection.set(arg1.id, service); diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index a050b92656c..62a40264836 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -14,6 +14,7 @@ import { OS } from 'vs/base/common/platform'; import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem'; class MockKeybindingContextKey implements IContextKey { + // @ts-ignore unused property private _key: string; private _defaultValue: T; private _value: T; diff --git a/src/vs/platform/lifecycle/common/lifecycle.ts b/src/vs/platform/lifecycle/common/lifecycle.ts index 0a413c08ce9..3f2cd9cde69 100644 --- a/src/vs/platform/lifecycle/common/lifecycle.ts +++ b/src/vs/platform/lifecycle/common/lifecycle.ts @@ -47,8 +47,9 @@ export enum StartupKind { export enum LifecyclePhase { Starting = 1, - Running = 2, - ShuttingDown = 3 + Restoring = 2, + Running = 3, + ShuttingDown = 4 } /** @@ -70,9 +71,10 @@ export interface ILifecycleService { readonly phase: LifecyclePhase; /** - * An event that fire when the lifecycle phase has changed + * Returns a promise that resolves when a certain lifecycle phase + * has started. */ - readonly onDidChangePhase: Event; + when(phase: LifecyclePhase): Thenable; /** * Fired before shutdown happens. Allows listeners to veto against the @@ -92,8 +94,8 @@ export interface ILifecycleService { export const NullLifecycleService: ILifecycleService = { _serviceBrand: null, phase: LifecyclePhase.Running, + when() { return Promise.resolve(); }, startupKind: StartupKind.NewWindow, - onDidChangePhase: Event.None, onWillShutdown: Event.None, onShutdown: Event.None }; @@ -127,4 +129,4 @@ export function handleVetos(vetos: (boolean | TPromise)[], onError: (er } return TPromise.join(promises).then(() => lazyValue); -} \ No newline at end of file +} diff --git a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts index 592396b8e50..28bf62c5654 100644 --- a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts +++ b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts @@ -7,7 +7,6 @@ import { ipcMain as ipc, app } from 'electron'; import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ILogService } from 'vs/platform/log/common/log'; import { IStorageService } from 'vs/platform/storage/node/storage'; import Event, { Emitter } from 'vs/base/common/event'; @@ -94,7 +93,6 @@ export class LifecycleService implements ILifecycleService { onBeforeWindowUnload: Event = this._onBeforeWindowUnload.event; constructor( - @IEnvironmentService private environmentService: IEnvironmentService, @ILogService private logService: ILogService, @IStorageService private storageService: IStorageService ) { diff --git a/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts b/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts index 2522b642f74..67f985b052e 100644 --- a/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/appInsightsAppender.test.ts @@ -9,8 +9,8 @@ import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppen interface IAppInsightsEvent { eventName: string; - properties?: { string?: string; }; - measurements?: { string?: number; }; + properties?: { [x: string]: string; }; + measurements?: { [x: string]: number; }; } class AppInsightsMock { @@ -34,7 +34,7 @@ class AppInsightsMock { this.exceptions.push(exception); } - public sendPendingData(callback): void { + public sendPendingData(_callback: any): void { // called on dispose } } @@ -85,7 +85,7 @@ suite('AIAdapter', () => { } assert(reallyLongPropertyValue.length > 1024); - var data = {}; + var data = Object.create(null); data[reallyLongPropertyName] = '1234'; data['reallyLongPropertyValue'] = reallyLongPropertyValue; adapter.log('testEvent', data); diff --git a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts index 2e558045818..ff36faa14f5 100644 --- a/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/commonProperties.test.ts @@ -12,10 +12,10 @@ import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; suite('Telemetry - common properties', function () { - const commit = void 0; - const version = void 0; - const source = void 0; - let storageService; + const commit: string = void 0; + const version: string = void 0; + const source: string = void 0; + let storageService: StorageService; setup(() => { storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id); diff --git a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts index 69d2f789bb6..341ba75b477 100644 --- a/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts +++ b/src/vs/platform/telemetry/test/electron-browser/telemetryService.test.ts @@ -40,16 +40,16 @@ class TestTelemetryAppender implements ITelemetryAppender { } class ErrorTestingSettings { - public personalInfo; - public importantInfo; - public filePrefix; - public dangerousPathWithoutImportantInfo; - public dangerousPathWithImportantInfo; - public missingModelPrefix; - public missingModelMessage; - public noSuchFilePrefix; - public noSuchFileMessage; - public stack; + public personalInfo: string; + public importantInfo: string; + public filePrefix: string; + public dangerousPathWithoutImportantInfo: string; + public dangerousPathWithImportantInfo: string; + public missingModelPrefix: string; + public missingModelMessage: string; + public noSuchFilePrefix: string; + public noSuchFileMessage: string; + public stack: string[]; constructor() { this.personalInfo = 'DANGEROUS/PATH'; @@ -203,7 +203,7 @@ suite('TelemetryService', () => { }); })); - test('Error events', sinon.test(function () { + test('Error events', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -262,7 +262,7 @@ suite('TelemetryService', () => { // } // })); - test('Handle global errors', sinon.test(function () { + test('Handle global errors', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; @@ -289,7 +289,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Uncaught Error Telemetry removes PII from filename', sinon.test(function () { + test('Uncaught Error Telemetry removes PII from filename', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; let settings = new ErrorTestingSettings(); @@ -318,7 +318,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Unexpected Error Telemetry removes PII', sinon.test(function () { + test('Unexpected Error Telemetry removes PII', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); try { @@ -348,7 +348,7 @@ suite('TelemetryService', () => { } })); - test('Uncaught Error Telemetry removes PII', sinon.test(function () { + test('Uncaught Error Telemetry removes PII', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; let settings = new ErrorTestingSettings(); @@ -374,7 +374,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(function () { + test('Unexpected Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -409,7 +409,7 @@ suite('TelemetryService', () => { } })); - test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function () { + test('Uncaught Error Telemetry removes PII but preserves Code file path', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; let settings = new ErrorTestingSettings(); @@ -437,7 +437,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function () { + test('Unexpected Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -472,7 +472,7 @@ suite('TelemetryService', () => { } })); - test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function () { + test('Uncaught Error Telemetry removes PII but preserves Code file path when PIIPath is configured', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; let settings = new ErrorTestingSettings(); @@ -500,7 +500,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function () { + test('Unexpected Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -535,7 +535,7 @@ suite('TelemetryService', () => { } })); - test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function () { + test('Uncaught Error Telemetry removes PII but preserves Missing Model error message', sinon.test(function (this: any) { let errorStub = sinon.stub(); window.onerror = errorStub; let settings = new ErrorTestingSettings(); @@ -564,7 +564,7 @@ suite('TelemetryService', () => { service.dispose(); })); - test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(function () { + test('Unexpected Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -599,7 +599,7 @@ suite('TelemetryService', () => { } })); - test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(function () { + test('Uncaught Error Telemetry removes PII but preserves No Such File error message', sinon.test(function (this: any) { let origErrorHandler = Errors.errorHandler.getUnexpectedErrorHandler(); Errors.setUnexpectedErrorHandler(() => { }); @@ -684,7 +684,7 @@ suite('TelemetryService', () => { getValue(key) { return getConfigurationValue(this.getConfiguration(), key); }, - updateValue() { + updateValue(): TPromise { return null; }, inspect(key: string) { @@ -698,7 +698,7 @@ suite('TelemetryService', () => { }, keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; }, onDidChangeConfiguration: emitter.event, - reloadConfiguration() { return null; }, + reloadConfiguration(): TPromise { return null; }, getConfigurationData() { return null; } }); diff --git a/src/vs/platform/theme/common/styler.ts b/src/vs/platform/theme/common/styler.ts index 03ae2a5dc63..0e7ca7a5177 100644 --- a/src/vs/platform/theme/common/styler.ts +++ b/src/vs/platform/theme/common/styler.ts @@ -133,7 +133,7 @@ export interface IQuickOpenStyleOverrides extends IListStyleOverrides, IInputBox widgetShadow?: ColorIdentifier; pickerGroupForeground?: ColorIdentifier; pickerGroupBorder?: ColorIdentifier; -}; +} export function attachQuickOpenStyler(widget: IThemable, themeService: IThemeService, style?: IQuickOpenStyleOverrides): IDisposable { return attachStyler(themeService, { diff --git a/src/vs/platform/update/common/updateIpc.ts b/src/vs/platform/update/common/updateIpc.ts index 0dd76ca51f6..bd42c38e018 100644 --- a/src/vs/platform/update/common/updateIpc.ts +++ b/src/vs/platform/update/common/updateIpc.ts @@ -63,7 +63,7 @@ export class UpdateChannelClient implements IUpdateService { get onStateChange(): Event { return this._onStateChange.event; } private _state: State = State.Uninitialized; - get state(): State { return this._state; }; + get state(): State { return this._state; } constructor(private channel: IUpdateChannel) { // always set this._state as the state changes diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 80a76149dee..8b1a745eb63 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -22,7 +22,7 @@ export interface INativeOpenDialogOptions { windowId?: number; forceNewWindow?: boolean; - dialogOptions?: Electron.OpenDialogOptions; + dialogOptions?: OpenDialogOptions; telemetryEventName?: string; telemetryExtraData?: ITelemetryData; @@ -33,6 +33,63 @@ export interface IEnterWorkspaceResult { backupPath: string; } +export interface CrashReporterStartOptions { + companyName?: string; + submitURL: string; + productName?: string; + uploadToServer?: boolean; + ignoreSystemCrashHandler?: boolean; + extra?: any; + crashesDirectory?: string; +} + +export interface OpenDialogOptions { + title?: string; + defaultPath?: string; + buttonLabel?: string; + filters?: FileFilter[]; + properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'>; + message?: string; +} + +export interface FileFilter { + extensions: string[]; + name: string; +} + +export interface MessageBoxOptions { + type?: string; + buttons?: string[]; + defaultId?: number; + title?: string; + message: string; + detail?: string; + checkboxLabel?: string; + checkboxChecked?: boolean; + cancelId?: number; + noLink?: boolean; + normalizeAccessKeys?: boolean; +} + +export interface SaveDialogOptions { + title?: string; + defaultPath?: string; + buttonLabel?: string; + filters?: FileFilter[]; + message?: string; + nameFieldLabel?: string; + showsTagField?: boolean; +} + +export interface OpenDialogOptions { + title?: string; + defaultPath?: string; + buttonLabel?: string; + filters?: FileFilter[]; + properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory' | 'promptToCreate' | 'noResolveAliases' | 'treatPackageAsDirectory'>; + message?: string; +} + export interface IWindowsService { _serviceBrand: any; @@ -96,7 +153,7 @@ export interface IWindowsService { openExternal(url: string): TPromise; // TODO: this is a bit backwards - startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise; + startCrashReporter(config: CrashReporterStartOptions): TPromise; } export const IWindowService = createDecorator('windowService'); @@ -136,10 +193,10 @@ export interface IWindowService { unmaximizeWindow(): TPromise; onWindowTitleDoubleClick(): TPromise; show(): TPromise; - showMessageBoxSync(options: Electron.MessageBoxOptions): number; - showMessageBox(options: Electron.MessageBoxOptions): TPromise; - showSaveDialog(options: Electron.SaveDialogOptions, callback?: (fileName: string) => void): string; - showOpenDialog(options: Electron.OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; + showMessageBoxSync(options: MessageBoxOptions): number; + showMessageBox(options: MessageBoxOptions): TPromise; + showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string; + showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; } export type MenuBarVisibility = 'default' | 'visible' | 'toggle' | 'hidden'; diff --git a/src/vs/platform/windows/common/windowsIpc.ts b/src/vs/platform/windows/common/windowsIpc.ts index 1fae89198a3..2000965fadf 100644 --- a/src/vs/platform/windows/common/windowsIpc.ts +++ b/src/vs/platform/windows/common/windowsIpc.ts @@ -8,7 +8,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import Event, { buffer } from 'vs/base/common/event'; import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc'; -import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult } from './windows'; +import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions } from 'vs/platform/windows/common/windows'; import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces'; import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { ICommandAction } from 'vs/platform/actions/common/actions'; @@ -59,7 +59,7 @@ export interface IWindowsChannel extends IChannel { call(command: 'log', arg: [string, string[]]): TPromise; call(command: 'showItemInFolder', arg: string): TPromise; call(command: 'openExternal', arg: string): TPromise; - call(command: 'startCrashReporter', arg: Electron.CrashReporterStartOptions): TPromise; + call(command: 'startCrashReporter', arg: CrashReporterStartOptions): TPromise; call(command: string, arg?: any): TPromise; } @@ -101,7 +101,7 @@ export class WindowsChannel implements IWindowsChannel { } return this.service.createAndEnterWorkspace(arg[0], folders, arg[2]); - }; + } case 'saveAndEnterWorkspace': return this.service.saveAndEnterWorkspace(arg[0], arg[1]); case 'toggleFullScreen': return this.service.toggleFullScreen(arg); case 'setRepresentedFilename': return this.service.setRepresentedFilename(arg[0], arg[1]); @@ -320,7 +320,7 @@ export class WindowsChannelClient implements IWindowsService { return this.channel.call('openExternal', url); } - startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise { + startCrashReporter(config: CrashReporterStartOptions): TPromise { return this.channel.call('startCrashReporter', config); } diff --git a/src/vs/platform/workspaces/common/workspacesIpc.ts b/src/vs/platform/workspaces/common/workspacesIpc.ts index 859de28bbd7..981405a1190 100644 --- a/src/vs/platform/workspaces/common/workspacesIpc.ts +++ b/src/vs/platform/workspaces/common/workspacesIpc.ts @@ -34,7 +34,7 @@ export class WorkspacesChannel implements IWorkspacesChannel { } return this.service.createWorkspace(folders); - }; + } } return void 0; diff --git a/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts b/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts index bc0a15a0496..fc728e9f5df 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts @@ -11,6 +11,7 @@ import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostC @extHostNamedCustomer(MainContext.MainThreadCredentials) export class MainThreadCredentials implements MainThreadCredentialsShape { + // @ts-ignore unused property private _proxy: ExtHostCredentialsShape; constructor( diff --git a/src/vs/workbench/api/electron-browser/mainThreadDocuments.ts b/src/vs/workbench/api/electron-browser/mainThreadDocuments.ts index d0fcfb8b158..9293b819709 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDocuments.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDocuments.ts @@ -66,7 +66,6 @@ export class BoundModelReferenceCollection { export class MainThreadDocuments implements MainThreadDocumentsShape { private _modelService: IModelService; - private _modeService: IModeService; private _textModelResolverService: ITextModelService; private _textFileService: ITextFileService; private _fileService: IFileService; @@ -89,7 +88,6 @@ export class MainThreadDocuments implements MainThreadDocumentsShape { @IUntitledEditorService untitledEditorService: IUntitledEditorService, ) { this._modelService = modelService; - this._modeService = modeService; this._textModelResolverService = textModelResolverService; this._textFileService = textFileService; this._fileService = fileService; diff --git a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts index 56d4e237cd7..be7ea0e06c6 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts @@ -64,7 +64,7 @@ namespace delta { } }); return { removed, added }; - }; + } export function ofMaps(before: Map, after: Map): { removed: V[], added: V[] } { const removed: V[] = []; @@ -80,7 +80,7 @@ namespace delta { } }); return { removed, added }; - }; + } } class EditorSnapshot { diff --git a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts index d538ccaefae..e962c85b7ac 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts @@ -69,7 +69,7 @@ export class HeapService implements IHeapService { trackRecursive(p: TPromise): TPromise; trackRecursive(obj: T): T; - trackRecursive(obj: any): any { + trackRecursive(obj: any): any { if (TPromise.is(obj)) { return obj.then(result => this.trackRecursive(result)); } else { diff --git a/src/vs/workbench/api/electron-browser/mainThreadMessageService.ts b/src/vs/workbench/api/electron-browser/mainThreadMessageService.ts index 9bf93689c11..090834e9b6a 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadMessageService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadMessageService.ts @@ -11,14 +11,13 @@ import { Action } from 'vs/base/common/actions'; import { TPromise as Promise } from 'vs/base/common/winjs.base'; import { MainThreadMessageServiceShape, MainContext, IExtHostContext, MainThreadMessageOptions } from '../node/extHost.protocol'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; -import { IExtensionService, IExtensionDescription } from 'vs/platform/extensions/common/extensions'; +import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; @extHostNamedCustomer(MainContext.MainThreadMessageService) export class MainThreadMessageService implements MainThreadMessageServiceShape { constructor( extHostContext: IExtHostContext, - @IExtensionService private readonly _extensionService: IExtensionService, @IMessageService private readonly _messageService: IMessageService, @IChoiceService private readonly _choiceService: IChoiceService ) { diff --git a/src/vs/workbench/api/electron-browser/mainThreadSCM.ts b/src/vs/workbench/api/electron-browser/mainThreadSCM.ts index e90753d4ce3..928279007a2 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSCM.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSCM.ts @@ -121,6 +121,7 @@ class MainThreadSCMProvider implements ISCMProvider { private _label: string, private _rootUri: URI | undefined, @ISCMService scmService: ISCMService, + // @ts-ignore unused injected service @ICommandService private commandService: ICommandService ) { } @@ -256,6 +257,7 @@ export class MainThreadSCM implements MainThreadSCMShape { constructor( extHostContext: IExtHostContext, + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService, @ISCMService private scmService: ISCMService, @ICommandService private commandService: ICommandService diff --git a/src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts b/src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts index ad86c4e3abb..553016983c3 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts @@ -103,6 +103,7 @@ class TreeViewDataProvider implements ITreeViewDataProvider { this._onDispose.fire(); } + // @ts-ignore unused property private clearChildren(treeItemHandle: TreeItemHandle): void { const children = this.childrenMap.get(treeItemHandle); if (children) { @@ -132,6 +133,7 @@ class TreeViewDataProvider implements ITreeViewDataProvider { } } + // @ts-ignore unused property private populateElementsToExpand(elements: ITreeItem[], toExpand: ITreeItem[]) { for (const element of elements) { if (element.collapsibleState === TreeItemCollapsibleState.Expanded) { diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index c9ab705aacf..18e06d646ee 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -11,12 +11,10 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { TPromise } from 'vs/base/common/winjs.base'; import { MainThreadWorkspaceShape, ExtHostWorkspaceShape, ExtHostContext, MainContext, IExtHostContext } from '../node/extHost.protocol'; -import { IFileService } from 'vs/platform/files/common/files'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IRelativePattern } from 'vs/base/common/glob'; -import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; @extHostNamedCustomer(MainContext.MainThreadWorkspace) export class MainThreadWorkspace implements MainThreadWorkspaceShape { @@ -30,9 +28,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { @ISearchService private readonly _searchService: ISearchService, @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, @ITextFileService private readonly _textFileService: ITextFileService, - @IConfigurationService private _configurationService: IConfigurationService, - @IFileService private readonly _fileService: IFileService, - @IWorkspaceEditingService private _workspaceEditingService: IWorkspaceEditingService + @IConfigurationService private _configurationService: IConfigurationService ) { this._proxy = extHostContext.get(ExtHostContext.ExtHostWorkspace); this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose); diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index fb2762dcc0b..275da883ed8 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -142,7 +142,7 @@ export function createApiFactory( // namespace: commands const commands: typeof vscode.commands = { - registerCommand(id: string, command: (...args: any[]) => T | Thenable, thisArgs?: any): vscode.Disposable { + registerCommand(id: string, command: (...args: any[]) => T | Thenable, thisArgs?: any): vscode.Disposable { return extHostCommands.registerCommand(id, command, thisArgs); }, registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => void, thisArg?: any): vscode.Disposable { diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index ea75a41995c..be6a4e437c7 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -574,7 +574,7 @@ export namespace IdObject { } export type IWorkspaceSymbol = IdObject & modes.SymbolInformation; -export interface IWorkspaceSymbols extends IdObject { symbols: IWorkspaceSymbol[]; }; +export interface IWorkspaceSymbols extends IdObject { symbols: IWorkspaceSymbol[]; } export interface ExtHostLanguageFeaturesShape { $provideDocumentSymbols(handle: number, resource: URI): TPromise; diff --git a/src/vs/workbench/api/node/extHostCredentials.ts b/src/vs/workbench/api/node/extHostCredentials.ts index de7a8ef0181..26f31d13803 100644 --- a/src/vs/workbench/api/node/extHostCredentials.ts +++ b/src/vs/workbench/api/node/extHostCredentials.ts @@ -13,7 +13,7 @@ export class ExtHostCredentials implements ExtHostCredentialsShape { constructor(mainContext: IMainContext) { this._proxy = mainContext.get(MainContext.MainThreadCredentials); - }; + } readSecret(service: string, account: string): Thenable { return this._proxy.$readSecret(service, account); diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 3b5bb8f8b44..b2fd9b556e1 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -460,8 +460,15 @@ class RenameAdapter { edits: undefined, rejectReason: err }; + } else if (err instanceof Error && typeof err.message === 'string') { + return { + edits: undefined, + rejectReason: err.message + }; + } else { + // generic error + return TPromise.wrapError(err); } - return TPromise.wrapError(err); }); } } @@ -707,9 +714,7 @@ class LinkProviderAdapter { class ColorProviderAdapter { constructor( - private _proxy: MainThreadLanguageFeaturesShape, private _documents: ExtHostDocuments, - private _colorFormatCache: Map, private _provider: vscode.DocumentColorProvider ) { } @@ -756,7 +761,6 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape { private _heapService: ExtHostHeapService; private _diagnostics: ExtHostDiagnostics; private _adapter = new Map(); - private _colorFormatCache = new Map(); constructor( mainContext: IMainContext, @@ -1039,7 +1043,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape { registerColorProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentColorProvider): vscode.Disposable { const handle = this._nextHandle(); - this._adapter.set(handle, new ColorProviderAdapter(this._proxy, this._documents, this._colorFormatCache, provider)); + this._adapter.set(handle, new ColorProviderAdapter(this._documents, provider)); this._proxy.$registerDocumentColorProvider(handle, selector); return this._createDisposable(handle); } diff --git a/src/vs/workbench/api/node/extHostMessageService.ts b/src/vs/workbench/api/node/extHostMessageService.ts index 5a4e176f26d..d0698c554bc 100644 --- a/src/vs/workbench/api/node/extHostMessageService.ts +++ b/src/vs/workbench/api/node/extHostMessageService.ts @@ -9,8 +9,7 @@ import vscode = require('vscode'); import { MainContext, MainThreadMessageServiceShape, MainThreadMessageOptions, IMainContext } from './extHost.protocol'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; - -function isMessageItem(item: any): item is vscode.MessageItem { +function isMessageItem(item: any): item is vscode.MessageItem { return item && item.title; } diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 60e89ff1ea6..09538e65693 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -19,9 +19,6 @@ import * as types from 'vs/workbench/api/node/extHostTypes'; import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import * as vscode from 'vscode'; -interface StringMap { - [key: string]: V; -} /* namespace ProblemPattern { @@ -431,7 +428,7 @@ export class ExtHostTask implements ExtHostTaskShape { this._extHostWorkspace = extHostWorkspace; this._handleCounter = 0; this._handlers = new Map(); - }; + } public registerTaskProvider(extension: IExtensionDescription, provider: vscode.TaskProvider): vscode.Disposable { if (!provider) { @@ -463,4 +460,4 @@ export class ExtHostTask implements ExtHostTaskShape { private nextHandle(): number { return this._handleCounter++; } -} \ No newline at end of file +} diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 295c065c43c..787ea4d739d 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -410,7 +410,7 @@ export namespace Suggest { return result; } -}; +} export namespace ParameterInformation { export function from(info: types.ParameterInformation): modes.ParameterInformation { diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 616ce83c24c..126fd66d08c 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -1131,6 +1131,7 @@ export enum TaskPanelKind { export class TaskGroup implements vscode.TaskGroup { private _id: string; + // @ts-ignore unused property private _label: string; public static Clean: TaskGroup = new TaskGroup('clean', 'Clean'); diff --git a/src/vs/workbench/browser/actions/toggleTabsVisibility.ts b/src/vs/workbench/browser/actions/toggleTabsVisibility.ts new file mode 100644 index 00000000000..029eb47b5f0 --- /dev/null +++ b/src/vs/workbench/browser/actions/toggleTabsVisibility.ts @@ -0,0 +1,40 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { TPromise } from 'vs/base/common/winjs.base'; +import nls = require('vs/nls'); +import { Registry } from 'vs/platform/registry/common/platform'; +import { Action } from 'vs/base/common/actions'; +import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; +import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; + +export class ToggleTabsVisibilityAction extends Action { + + public static ID = 'workbench.action.toggleTabsVisibility'; + public static LABEL = nls.localize('toggleTabs', "Toggle Tab Visibility"); + + private static tabsVisibleKey = 'workbench.editor.showTabs'; + + constructor( + id: string, + label: string, + @IConfigurationService private configurationService: IConfigurationService + ) { + super(id, label); + } + + public run(): TPromise { + const visibility = this.configurationService.getValue(ToggleTabsVisibilityAction.tabsVisibleKey); + const newVisibilityValue = !visibility; + + return this.configurationService.updateValue(ToggleTabsVisibilityAction.tabsVisibleKey, newVisibilityValue); + } +} + +const registry = Registry.as(Extensions.WorkbenchActions); +registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleTabsVisibilityAction, ToggleTabsVisibilityAction.ID, ToggleTabsVisibilityAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_W }), 'View: Toggle Tab Visibility', nls.localize('view', "View")); \ No newline at end of file diff --git a/src/vs/workbench/browser/actions/workspaceActions.ts b/src/vs/workbench/browser/actions/workspaceActions.ts index 66c115330a4..07f7c530ddc 100644 --- a/src/vs/workbench/browser/actions/workspaceActions.ts +++ b/src/vs/workbench/browser/actions/workspaceActions.ts @@ -14,7 +14,7 @@ import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/p import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; import URI from 'vs/base/common/uri'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; -import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; +import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { WORKSPACE_FILTER, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { isLinux } from 'vs/base/common/platform'; @@ -204,7 +204,6 @@ export class AddRootFolderAction extends BaseWorkspacesAction { @IWindowService windowService: IWindowService, @IWorkspaceContextService contextService: IWorkspaceContextService, @IEnvironmentService environmentService: IEnvironmentService, - @IInstantiationService private instantiationService: IInstantiationService, @IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService, @IViewletService private viewletService: IViewletService, @IHistoryService historyService: IHistoryService diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 1669b748f72..9a4245d5b17 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -710,7 +710,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal // change part size along the main axis public resizePart(part: Parts, sizeChange: number): void { - const visibleEditors = this.editorService.getVisibleEditors().length; + const panelPosition = this.partService.getPanelPosition(); const sizeChangePxWidth = this.workbenchSize.width * (sizeChange / 100); const sizeChangePxHeight = this.workbenchSize.height * (sizeChange / 100); @@ -720,24 +720,37 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal case Parts.SIDEBAR_PART: this.sidebarWidth = this.sidebarWidth + sizeChangePxWidth; // Sidebar can not become smaller than MIN_PART_WIDTH - if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < visibleEditors * MIN_EDITOR_PART_WIDTH)) { - this.sidebarWidth = (this.workbenchSize.width - visibleEditors * MIN_EDITOR_PART_WIDTH); + if (this.layoutEditorGroupsVertically && (this.workbenchSize.width - this.sidebarWidth < this.editorCountForWidth * MIN_EDITOR_PART_WIDTH)) { + this.sidebarWidth = (this.workbenchSize.width - this.editorCountForWidth * MIN_EDITOR_PART_WIDTH); } doLayout = true; break; case Parts.PANEL_PART: - this.panelHeight = this.panelHeight + sizeChangePxHeight; - this.panelWidth = this.panelWidth + sizeChangePxWidth; + if (panelPosition === Position.BOTTOM) { + this.panelHeight = this.panelHeight + sizeChangePxHeight; + } else if (panelPosition === Position.RIGHT) { + this.panelWidth = this.panelWidth + sizeChangePxWidth; + } + doLayout = true; break; case Parts.EDITOR_PART: // If we have one editor we can cheat and resize sidebar with the negative delta - const visibleEditorCount = this.editorService.getVisibleEditors().length; + // If the sidebar is not visible and panel is, resize panel main axis with negative Delta + if (this.editorCountForWidth === 1) { + if (this.partService.isVisible(Parts.SIDEBAR_PART)) { + this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth; + doLayout = true; + } else if (this.partService.isVisible(Parts.PANEL_PART)) { + if (panelPosition === Position.BOTTOM) { + this.panelHeight = this.panelHeight - sizeChangePxHeight; + } else if (panelPosition === Position.RIGHT) { + this.panelWidth = this.panelWidth - sizeChangePxWidth; + } + doLayout = true; + } - if (visibleEditorCount === 1) { - this.sidebarWidth = this.sidebarWidth - sizeChangePxWidth; - doLayout = true; } else { const stacks = this.editorGroupService.getStacksModel(); const activeGroup = stacks.positionOfGroup(stacks.activeGroup); diff --git a/src/vs/workbench/browser/part.ts b/src/vs/workbench/browser/part.ts index 71e32226b2a..ad324177d50 100644 --- a/src/vs/workbench/browser/part.ts +++ b/src/vs/workbench/browser/part.ts @@ -111,7 +111,7 @@ const TITLE_HEIGHT = 35; export class PartLayout { - constructor(private container: Builder, private options: IPartOptions, private titleArea: Builder, private contentArea: Builder) { + constructor(container: Builder, private options: IPartOptions, titleArea: Builder, private contentArea: Builder) { } public layout(dimension: Dimension): Dimension[] { diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts index 0046b57dc47..299431306fe 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarPart.ts @@ -20,8 +20,6 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IBadge } from 'vs/workbench/services/activity/common/activity'; import { IPartService, Position as SideBarPosition } from 'vs/workbench/services/part/common/partService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IExtensionService } from 'vs/platform/extensions/common/extensions'; -import { IStorageService } from 'vs/platform/storage/common/storage'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; @@ -54,8 +52,6 @@ export class ActivitybarPart extends Part { constructor( id: string, @IViewletService private viewletService: IViewletService, - @IExtensionService private extensionService: IExtensionService, - @IStorageService private storageService: IStorageService, @IContextMenuService private contextMenuService: IContextMenuService, @IInstantiationService private instantiationService: IInstantiationService, @IPartService private partService: IPartService, @@ -181,7 +177,7 @@ export class ActivitybarPart extends Part { } public getPinned(): string[] { - return this.viewletService.getViewlets().map(v => v.id).filter(id => this.compositeBar.isPinned(id));; + return this.viewletService.getViewlets().map(v => v.id).filter(id => this.compositeBar.isPinned(id)); } /** diff --git a/src/vs/workbench/browser/parts/compositebar/compositeBarActions.ts b/src/vs/workbench/browser/parts/compositebar/compositeBarActions.ts index 94db53d020d..aa36133c7ba 100644 --- a/src/vs/workbench/browser/parts/compositebar/compositeBarActions.ts +++ b/src/vs/workbench/browser/parts/compositebar/compositeBarActions.ts @@ -291,7 +291,9 @@ export class CompositeOverflowActivityAction extends ActivityAction { } export class CompositeOverflowActivityActionItem extends ActivityActionItem { + // @ts-ignore unused property private name: string; + // @ts-ignore unused property private cssClass: string; private actions: Action[]; @@ -302,6 +304,7 @@ export class CompositeOverflowActivityActionItem extends ActivityActionItem { private getBadge: (compositeId: string) => IBadge, private getCompositeOpenAction: (compositeId: string) => Action, colors: ICompositeBarColors, + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService, @IContextMenuService private contextMenuService: IContextMenuService, @IThemeService themeService: IThemeService diff --git a/src/vs/workbench/browser/parts/editor/editorActions.ts b/src/vs/workbench/browser/parts/editor/editorActions.ts index aff43d76e7b..7dce52b6198 100644 --- a/src/vs/workbench/browser/parts/editor/editorActions.ts +++ b/src/vs/workbench/browser/parts/editor/editorActions.ts @@ -113,7 +113,6 @@ export class JoinTwoGroupsAction extends Action { constructor( id: string, label: string, - @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IEditorGroupService private editorGroupService: IEditorGroupService ) { super(id, label); diff --git a/src/vs/workbench/browser/parts/editor/editorPicker.ts b/src/vs/workbench/browser/parts/editor/editorPicker.ts index fe160365da8..979df653a59 100644 --- a/src/vs/workbench/browser/parts/editor/editorPicker.ts +++ b/src/vs/workbench/browser/parts/editor/editorPicker.ts @@ -20,7 +20,6 @@ import { Position } from 'vs/platform/editor/common/editor'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { EditorInput, toResource, IEditorGroup, IEditorStacksModel } from 'vs/workbench/common/editor'; import { compareItemsByScore, scoreItem, ScorerCache, prepareQuery } from 'vs/base/parts/quickopen/common/quickOpenScorer'; @@ -91,7 +90,6 @@ export abstract class BaseEditorPicker extends QuickOpenHandler { constructor( @IInstantiationService protected instantiationService: IInstantiationService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IWorkbenchEditorService protected editorService: IWorkbenchEditorService, @IEditorGroupService protected editorGroupService: IEditorGroupService ) { diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 6f3ef39d9fb..28dcafe4a0f 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -795,7 +795,6 @@ export class ChangeModeAction extends Action { @IQuickOpenService private quickOpenService: IQuickOpenService, @IPreferencesService private preferencesService: IPreferencesService, @IInstantiationService private instantiationService: IInstantiationService, - @ICommandService private commandService: ICommandService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService ) { super(actionId, actionLabel); diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index 641e62414b7..bfc099a30fb 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -31,7 +31,6 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle import { IWorkbenchEditorService, DelegatingWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IEditorInput } from 'vs/platform/editor/common/editor'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -55,10 +54,9 @@ export class TextDiffEditor extends BaseTextEditor { @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService ) { - super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, modeService, textFileService, editorGroupService); + super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); } public getTitle(): string { diff --git a/src/vs/workbench/browser/parts/editor/textEditor.ts b/src/vs/workbench/browser/parts/editor/textEditor.ts index 13522be113f..dc250322285 100644 --- a/src/vs/workbench/browser/parts/editor/textEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textEditor.ts @@ -24,7 +24,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Scope } from 'vs/workbench/common/memento'; import { getCodeEditor } from 'vs/editor/common/services/codeEditorService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService, SaveReason, AutoSaveMode } from 'vs/workbench/services/textfile/common/textfiles'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; @@ -32,12 +31,6 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; const TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'textEditorViewState'; -interface ITextEditorViewState { - 0?: IEditorViewState; - 1?: IEditorViewState; - 2?: IEditorViewState; -} - export interface IEditorConfiguration { editor: object; diffEditor: object; @@ -60,7 +53,6 @@ export abstract class BaseTextEditor extends BaseEditor { @IStorageService private storageService: IStorageService, @ITextResourceConfigurationService private _configurationService: ITextResourceConfigurationService, @IThemeService protected themeService: IThemeService, - @IModeService private modeService: IModeService, @ITextFileService private _textFileService: ITextFileService, @IEditorGroupService protected editorGroupService: IEditorGroupService ) { diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index 7d723508d2a..cfabfc41b0e 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -20,7 +20,6 @@ import { ITextResourceConfigurationService } from 'vs/editor/common/services/res import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { once } from 'vs/base/common/event'; import { ScrollType } from 'vs/editor/common/editorCommon'; @@ -40,10 +39,9 @@ export class TextResourceEditor extends BaseTextEditor { @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService, @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService ) { - super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, modeService, textFileService, editorGroupService); + super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); } public getTitle(): string { diff --git a/src/vs/workbench/browser/parts/editor/webviewEditor.ts b/src/vs/workbench/browser/parts/editor/webviewEditor.ts index d31c6b57bd3..a1809c369d2 100644 --- a/src/vs/workbench/browser/parts/editor/webviewEditor.ts +++ b/src/vs/workbench/browser/parts/editor/webviewEditor.ts @@ -14,11 +14,6 @@ export interface HtmlPreviewEditorViewState { scrollYPercentage: number; } -interface HtmlPreviewEditorViewStates { - 0?: HtmlPreviewEditorViewState; - 1?: HtmlPreviewEditorViewState; - 2?: HtmlPreviewEditorViewState; -} /** * This class is only intended to be subclassed and not instantiated. diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 1412c3cc68d..d40e65a496d 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -98,7 +98,6 @@ export class QuickOpenController extends Component implements IQuickOpenService private promisesToCompleteOnHide: ValueCallback[]; private previousActiveHandlerDescriptor: QuickOpenHandlerDescriptor; private actionProvider = new ContributableActionProvider(); - private previousValue = ''; private visibilityChangeTimeoutHandle: number; private closeOnFocusLost: boolean; private editorHistoryHandler: EditorHistoryHandler; @@ -107,10 +106,8 @@ export class QuickOpenController extends Component implements IQuickOpenService @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IMessageService private messageService: IMessageService, @ITelemetryService private telemetryService: ITelemetryService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IContextKeyService private contextKeyService: IContextKeyService, @IConfigurationService private configurationService: IConfigurationService, - @IHistoryService private historyService: IHistoryService, @IInstantiationService private instantiationService: IInstantiationService, @IPartService private partService: IPartService, @IListService private listService: IListService, @@ -551,8 +548,6 @@ export class QuickOpenController extends Component implements IQuickOpenService let inputSelection = options ? options.inputSelection : void 0; let autoFocus = options ? options.autoFocus : void 0; - this.previousValue = prefix; - const promiseCompletedOnHide = new TPromise(c => { this.promisesToCompleteOnHide.push(c); }); @@ -747,7 +742,6 @@ export class QuickOpenController extends Component implements IQuickOpenService } private onType(value: string): void { - this.previousValue = value; // look for a handler const registry = Registry.as(Extensions.Quickopen); @@ -1176,7 +1170,6 @@ class EditorHistoryHandler { constructor( @IHistoryService private historyService: IHistoryService, @IInstantiationService private instantiationService: IInstantiationService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IFileService private fileService: IFileService ) { this.scorerCache = Object.create(null); @@ -1265,7 +1258,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { @IWorkspaceContextService contextService: IWorkspaceContextService, @IConfigurationService private configurationService: IConfigurationService, @IEnvironmentService environmentService: IEnvironmentService, - @IFileService private fileService: IFileService + @IFileService fileService: IFileService ) { super(editorService); diff --git a/src/vs/workbench/browser/parts/views/treeView.ts b/src/vs/workbench/browser/parts/views/treeView.ts index cf1490e2597..b4d452928aa 100644 --- a/src/vs/workbench/browser/parts/views/treeView.ts +++ b/src/vs/workbench/browser/parts/views/treeView.ts @@ -41,6 +41,7 @@ export class TreeView extends ViewsViewletPanel { private dataProviderElementChangeListener: IDisposable; constructor( + // @ts-ignore unused property private options: IViewletViewOptions, @IMessageService private messageService: IMessageService, @IKeybindingService keybindingService: IKeybindingService, diff --git a/src/vs/workbench/browser/parts/views/viewsRegistry.ts b/src/vs/workbench/browser/parts/views/viewsRegistry.ts index e39b999ec43..b5c6f618b02 100644 --- a/src/vs/workbench/browser/parts/views/viewsRegistry.ts +++ b/src/vs/workbench/browser/parts/views/viewsRegistry.ts @@ -122,7 +122,7 @@ export const ViewsRegistry: IViewsRegistry = new class { this._onViewsDeregistered.fire(viewsToDeregister); } - registerTreeViewDataProvider(id: string, factory: ITreeViewDataProvider) { + registerTreeViewDataProvider(id: string, factory: ITreeViewDataProvider) { if (!this.isDataProviderRegistered(id)) { // TODO: throw error } diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 8c7cf7bea1e..7921f37fff7 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -15,7 +15,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { Action } from 'vs/base/common/actions'; import { KeyMod } from 'vs/base/common/keyCodes'; import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen'; -import { QuickOpenEntry, IHighlight, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel'; +import { QuickOpenEntry, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; import { IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -323,35 +323,6 @@ export interface ICommand { icon?: string; } -class CommandEntry extends QuickOpenEntry { - - constructor(private quickOpenService: IQuickOpenService, private prefix: string, private command: ICommand, highlights: IHighlight[]) { - super(highlights); - this.command = command; - } - - public getIcon(): string { - return this.command.icon || null; - } - - public getLabel(): string { - return this.command.aliases[0]; - } - - public getAriaLabel(): string { - return nls.localize('entryAriaLabel', "{0}, command", this.getLabel()); - } - - public run(mode: Mode, context: IEntryRunContext): boolean { - if (mode === Mode.PREVIEW) { - return false; - } - - this.quickOpenService.show(`${this.prefix} ${this.command.aliases[0]} `); - return false; - } -} - export interface ICommandQuickOpenHandlerOptions { prefix: string; commands: ICommand[]; diff --git a/src/vs/workbench/common/editor/textEditorModel.ts b/src/vs/workbench/common/editor/textEditorModel.ts index 37c60e19f44..3a600630689 100644 --- a/src/vs/workbench/common/editor/textEditorModel.ts +++ b/src/vs/workbench/common/editor/textEditorModel.ts @@ -70,11 +70,7 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd protected createTextEditorModel(value: string | IRawTextSource, resource?: URI, modeId?: string): TPromise { const firstLineText = this.getFirstLineText(value); const mode = this.getOrCreateMode(this.modeService, modeId, firstLineText); - - // To avoid flickering, give the mode at most 50ms to load. If the mode doesn't load in 50ms, proceed creating the model with a mode promise - return TPromise.any([TPromise.timeout(50), mode]).then(() => { - return this.doCreateTextEditorModel(value, mode, resource); - }); + return TPromise.as(this.doCreateTextEditorModel(value, mode, resource)); } private doCreateTextEditorModel(value: string | IRawTextSource, mode: TPromise, resource: URI): EditorModel { @@ -166,4 +162,4 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd super.dispose(); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/electron-browser/actions.ts b/src/vs/workbench/electron-browser/actions.ts index 780ce0463c2..1cca1e27f11 100644 --- a/src/vs/workbench/electron-browser/actions.ts +++ b/src/vs/workbench/electron-browser/actions.ts @@ -156,7 +156,6 @@ export class ToggleMenuBarAction extends Action { constructor( id: string, label: string, - @IMessageService private messageService: IMessageService, @IConfigurationService private configurationService: IConfigurationService ) { super(id, label); @@ -341,11 +340,9 @@ export class ShowStartupPerformance extends Action { console.log(`Empty Workspace: ${metrics.emptyWorkbench}`); let nodeModuleLoadTime: number; - let nodeModuleLoadDetails: any[]; if (this.environmentService.performance) { const nodeModuleTimes = this.analyzeNodeModulesLoadTimes(); nodeModuleLoadTime = nodeModuleTimes.duration; - nodeModuleLoadDetails = nodeModuleTimes.table; } (console).table(this.getStartupMetricsTable(nodeModuleLoadTime)); diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index 35d0909e560..91a80298351 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -253,6 +253,12 @@ if (product.quality !== 'stable') { 'description': 'Indicates the amount to boost the "literal" component of the query. Temporary.', 'default': 10 }; + + workbenchProperties['workbench.settings.experimentalFuzzySearchAutoIngestFeedback'] = { + 'type': 'boolean', + 'description': 'Indicates whether feedback from this client should be automatically ingested.', + 'default': false + }; } if (isMacintosh) { diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index d66e577ad6a..33a9e506427 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -165,21 +165,30 @@ export class WorkbenchShell { const [instantiationService, serviceCollection] = this.initServiceCollection(parent.getHTMLElement()); // Workbench - this.workbench = instantiationService.createInstance(Workbench, parent.getHTMLElement(), workbenchContainer.getHTMLElement(), this.configuration, serviceCollection); - this.workbench.startup({ - onWorkbenchStarted: (info: IWorkbenchStartedInfo) => { + this.workbench = instantiationService.createInstance(Workbench, parent.getHTMLElement(), workbenchContainer.getHTMLElement(), this.configuration, serviceCollection, this.lifecycleService); + try { + this.workbench.startup({ + onWorkbenchStarted: (info: IWorkbenchStartedInfo) => { - // run workbench started logic - this.onWorkbenchStarted(info); + // run workbench started logic + this.onWorkbenchStarted(info); - // start cached data manager - instantiationService.createInstance(NodeCachedDataManager); + // start cached data manager + instantiationService.createInstance(NodeCachedDataManager); - // Set lifecycle phase to `Runnning` so that other contributions - // can now do something - this.lifecycleService.phase = LifecyclePhase.Running; - } - }); + // Set lifecycle phase to `Runnning` so that other contributions + // can now do something + this.lifecycleService.phase = LifecyclePhase.Running; + } + }); + } catch (error) { + + // Print out error + console.error(toErrorMessage(error, true)); + + // Rethrow + throw error; + } // Window this.workbench.getInstantiationService().createInstance(ElectronWindow, this.container); diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 84f5d2302b9..d345792b727 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -27,7 +27,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration'; import { IWindowsService, IWindowService, IWindowSettings, IPath, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { ITitleService } from 'vs/workbench/services/title/common/titleService'; import { IWorkbenchThemeService, VS_HC_THEME, VS_DARK_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService'; @@ -39,7 +38,6 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions'; import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import { Themable } from 'vs/workbench/common/theme'; import { ipcRenderer as ipc, webFrame } from 'electron'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction } from 'vs/platform/actions/common/actions'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; @@ -86,13 +84,10 @@ export class ElectronWindow extends Themable { @IViewletService private viewletService: IViewletService, @IContextMenuService private contextMenuService: IContextMenuService, @IKeybindingService private keybindingService: IKeybindingService, - @IEnvironmentService private environmentService: IEnvironmentService, @ITelemetryService private telemetryService: ITelemetryService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService, @IFileService private fileService: IFileService, - @IMenuService private menuService: IMenuService, - @IContextKeyService private contextKeyService: IContextKeyService + @IMenuService private menuService: IMenuService ) { super(themeService); @@ -126,7 +121,7 @@ export class ElectronWindow extends Themable { }); // Support runAction event - ipc.on('vscode:runAction', (event, request: IRunActionInWindowRequest) => { + ipc.on('vscode:runAction', (_event: any, request: IRunActionInWindowRequest) => { const args: any[] = []; // If we run an action from the touchbar, we fill in the currently active resource @@ -157,7 +152,7 @@ export class ElectronWindow extends Themable { }); // Support resolve keybindings event - ipc.on('vscode:resolveKeybindings', (event, rawActionIds: string) => { + ipc.on('vscode:resolveKeybindings', (_event: any, rawActionIds: string) => { let actionIds: string[] = []; try { actionIds = JSON.parse(rawActionIds); @@ -173,7 +168,7 @@ export class ElectronWindow extends Themable { }, () => errors.onUnexpectedError); }); - ipc.on('vscode:reportError', (event, error) => { + ipc.on('vscode:reportError', (_event: any, error: string) => { if (error) { const errorParsed = JSON.parse(error); errorParsed.mainProcess = true; @@ -182,36 +177,36 @@ export class ElectronWindow extends Themable { }); // Support openFiles event for existing and new files - ipc.on('vscode:openFiles', (event, request: IOpenFileRequest) => this.onOpenFiles(request)); + ipc.on('vscode:openFiles', (_event: any, request: IOpenFileRequest) => this.onOpenFiles(request)); // Support addFolders event if we have a workspace opened - ipc.on('vscode:addFolders', (event, request: IAddFoldersRequest) => this.onAddFolders(request)); + ipc.on('vscode:addFolders', (_event: any, request: IAddFoldersRequest) => this.onAddFolders(request)); // Message support - ipc.on('vscode:showInfoMessage', (event, message: string) => { + ipc.on('vscode:showInfoMessage', (_event: any, message: string) => { this.messageService.show(Severity.Info, message); }); // Support toggling auto save - ipc.on('vscode.toggleAutoSave', event => { + ipc.on('vscode.toggleAutoSave', () => { this.toggleAutoSave(); }); // Fullscreen Events - ipc.on('vscode:enterFullScreen', event => { + ipc.on('vscode:enterFullScreen', () => { this.partService.joinCreation().then(() => { browser.setFullscreen(true); }); }); - ipc.on('vscode:leaveFullScreen', event => { + ipc.on('vscode:leaveFullScreen', () => { this.partService.joinCreation().then(() => { browser.setFullscreen(false); }); }); // High Contrast Events - ipc.on('vscode:enterHighContrast', event => { + ipc.on('vscode:enterHighContrast', () => { const windowConfig = this.configurationService.getConfiguration('window'); if (windowConfig && windowConfig.autoDetectHighContrast) { this.partService.joinCreation().then(() => { @@ -220,7 +215,7 @@ export class ElectronWindow extends Themable { } }); - ipc.on('vscode:leaveHighContrast', event => { + ipc.on('vscode:leaveHighContrast', () => { const windowConfig = this.configurationService.getConfiguration('window'); if (windowConfig && windowConfig.autoDetectHighContrast) { this.partService.joinCreation().then(() => { @@ -230,12 +225,12 @@ export class ElectronWindow extends Themable { }); // keyboard layout changed event - ipc.on('vscode:keyboardLayoutChanged', event => { + ipc.on('vscode:keyboardLayoutChanged', () => { KeyboardMapperFactory.INSTANCE._onKeyboardLayoutChanged(); }); // keyboard layout changed event - ipc.on('vscode:accessibilitySupportChanged', (event, accessibilitySupportEnabled: boolean) => { + ipc.on('vscode:accessibilitySupportChanged', (_event: any, accessibilitySupportEnabled: boolean) => { browser.setAccessibilitySupport(accessibilitySupportEnabled ? platform.AccessibilitySupport.Enabled : platform.AccessibilitySupport.Disabled); }); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 75d3cc04331..3216812ad1e 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -20,7 +20,6 @@ import { time } from 'vs/base/common/performance'; import errors = require('vs/base/common/errors'); import { BackupFileService } from 'vs/workbench/services/backup/node/backupFileService'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; -import { toErrorMessage } from 'vs/base/common/errorMessage'; import { Registry } from 'vs/platform/registry/common/platform'; import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform'; import { Position as EditorPosition, IResourceDiffInput, IUntitledResourceInput, IEditor, IResourceInput } from 'vs/platform/editor/common/editor'; @@ -79,7 +78,8 @@ import { ProgressService2 } from 'vs/workbench/services/progress/browser/progres import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; -import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle'; +import { ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; +import { LifecycleService } from 'vs/workbench/services/lifecycle/electron-browser/lifecycleService'; import { IWindowService, IWindowConfiguration as IWindowSettings, IWindowConfiguration, IPath } from 'vs/platform/windows/common/windows'; import { IMessageService } from 'vs/platform/message/common/message'; import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar'; @@ -87,7 +87,6 @@ import { IMenuService, SyncActionDescriptor } from 'vs/platform/actions/common/a import { MenuService } from 'vs/platform/actions/common/menuService'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions'; import { OpenRecentAction, ToggleDevToolsAction, ReloadWindowAction, ShowPreviousWindowTab, MoveWindowTabToNewWindow, MergeAllWindowTabs, ShowNextWindowTab, ToggleWindowTabsBar } from 'vs/workbench/electron-browser/actions'; import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; @@ -217,13 +216,12 @@ export class Workbench implements IPartService { container: HTMLElement, configuration: IWindowConfiguration, serviceCollection: ServiceCollection, + private lifecycleService: LifecycleService, @IInstantiationService private instantiationService: IInstantiationService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IStorageService private storageService: IStorageService, - @ILifecycleService private lifecycleService: ILifecycleService, @IMessageService private messageService: IMessageService, @IConfigurationService private configurationService: WorkspaceService, - @ITelemetryService private telemetryService: ITelemetryService, @IEnvironmentService private environmentService: IEnvironmentService, @IWindowService private windowService: IWindowService ) { @@ -268,135 +266,135 @@ export class Workbench implements IPartService { * once. Use the shutdown function to free up resources created by the workbench on startup. */ public startup(callbacks?: IWorkbenchCallbacks): void { - try { - this.workbenchStarted = true; - this.callbacks = callbacks; + this.workbenchStarted = true; + this.callbacks = callbacks; - // Create Workbench - this.createWorkbench(); + // Create Workbench + this.createWorkbench(); - // Install some global actions - this.createGlobalActions(); + // Install some global actions + this.createGlobalActions(); - // Services - this.initServices(); - if (this.callbacks && this.callbacks.onServicesCreated) { - this.callbacks.onServicesCreated(); + // Services + this.initServices(); + if (this.callbacks && this.callbacks.onServicesCreated) { + this.callbacks.onServicesCreated(); + } + + // Contexts + this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService); + this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService); + this.inZenMode = InZenModeContext.bindTo(this.contextKeyService); + this.sideBarVisibleContext = SidebarVisibleContext.bindTo(this.contextKeyService); + + // Register Listeners + this.registerListeners(); + + // Settings + this.initSettings(); + + // Create Workbench and Parts + this.renderWorkbench(); + + // Workbench Layout + this.createWorkbenchLayout(); + + // Restore Parts + this.restoreParts().done(startedInfo => { + this.workbenchCreated = true; + this.creationPromiseComplete(true); + + if (this.callbacks && this.callbacks.onWorkbenchStarted) { + this.callbacks.onWorkbenchStarted(startedInfo); + } + }); + } + + private restoreParts(): TPromise { + const restorePromises: TPromise[] = []; + + // Restore Editors + const editorRestoreStopWatch = StopWatch.create(); + const editorRestoreClock = time('restore:editors'); + const restoredEditors: string[] = []; + restorePromises.push(this.resolveEditorsToOpen().then(inputs => { + this.lifecycleService.phase = LifecyclePhase.Restoring; + + let editorOpenPromise: TPromise; + if (inputs.length) { + editorOpenPromise = this.editorService.openEditors(inputs.map(input => { return { input, position: EditorPosition.ONE }; })); + } else { + editorOpenPromise = this.editorPart.restoreEditors(); } - // Contexts - this.messagesVisibleContext = MessagesVisibleContext.bindTo(this.contextKeyService); - this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService); - this.inZenMode = InZenModeContext.bindTo(this.contextKeyService); - this.sideBarVisibleContext = SidebarVisibleContext.bindTo(this.contextKeyService); + return editorOpenPromise.then(editors => { + this.handleEditorBackground(); // make sure we show the proper background in the editor area - // Register Listeners - this.registerListeners(); + editorRestoreClock.stop(); + editorRestoreStopWatch.stop(); - // Settings - this.initSettings(); - - // Create Workbench and Parts - this.renderWorkbench(); - - // Workbench Layout - this.createWorkbenchLayout(); - - // Load composites and editors in parallel - const compositeAndEditorPromises: TPromise[] = []; - - // Restore last opened viewlet - let viewletRestoreStopWatch: StopWatch; - let viewletIdToRestore: string; - if (!this.sideBarHidden) { - this.sideBarVisibleContext.set(true); - - if (this.shouldRestoreLastOpenedViewlet()) { - viewletIdToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE); - } - - if (!viewletIdToRestore) { - viewletIdToRestore = this.viewletService.getDefaultViewletId(); - } - - viewletRestoreStopWatch = StopWatch.create(); - const viewletRestoreClock = time('restore:viewlet'); - compositeAndEditorPromises.push(this.viewletService.openViewlet(viewletIdToRestore).then(() => { - viewletRestoreStopWatch.stop(); - viewletRestoreClock.stop(); - })); - } - - // Load Panel - const panelRegistry = Registry.as(PanelExtensions.Panels); - const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId()); - if (!this.panelHidden && !!panelId) { - compositeAndEditorPromises.push(this.panelPart.openPanel(panelId, false)); - } - - // Load Editors - const editorRestoreStopWatch = StopWatch.create(); - const editorRestoreClock = time('restore:editors'); - const restoredEditors: string[] = []; - compositeAndEditorPromises.push(this.resolveEditorsToOpen().then(inputs => { - let editorOpenPromise: TPromise; - if (inputs.length) { - editorOpenPromise = this.editorService.openEditors(inputs.map(input => { return { input, position: EditorPosition.ONE }; })); - } else { - editorOpenPromise = this.editorPart.restoreEditors(); - } - - return editorOpenPromise.then(editors => { - this.handleEditorBackground(); // make sure we show the proper background in the editor area - editorRestoreClock.stop(); - editorRestoreStopWatch.stop(); - for (const editor of editors) { - if (editor) { - if (editor.input) { - restoredEditors.push(editor.input.getName()); - } else { - restoredEditors.push(`other:${editor.getId()}`); - } + for (const editor of editors) { + if (editor) { + if (editor.input) { + restoredEditors.push(editor.input.getName()); + } else { + restoredEditors.push(`other:${editor.getId()}`); } } - }); - })); + } + }); + })); - if (this.storageService.getBoolean(Workbench.zenModeActiveSettingKey, StorageScope.WORKSPACE, false)) { - this.toggleZenMode(true); + // Restore Sidebar + let viewletRestoreStopWatch: StopWatch; + let viewletIdToRestore: string; + if (!this.sideBarHidden) { + this.sideBarVisibleContext.set(true); + + if (this.shouldRestoreLastOpenedViewlet()) { + viewletIdToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE); } - // Flag workbench as created once done - const workbenchDone = (error?: Error) => { - this.workbenchCreated = true; - this.creationPromiseComplete(true); + if (!viewletIdToRestore) { + viewletIdToRestore = this.viewletService.getDefaultViewletId(); + } - if (this.callbacks && this.callbacks.onWorkbenchStarted) { - this.callbacks.onWorkbenchStarted({ - customKeybindingsCount: this.keybindingService.customKeybindingsCount(), - restoreViewletDuration: viewletRestoreStopWatch ? Math.round(viewletRestoreStopWatch.elapsed()) : 0, - restoreEditorsDuration: Math.round(editorRestoreStopWatch.elapsed()), - pinnedViewlets: this.activitybarPart.getPinned(), - restoredViewlet: viewletIdToRestore, - restoredEditors - }); - } - - if (error) { - errors.onUnexpectedError(error); - } - }; - - // Join viewlet, panel and editor promises - TPromise.join(compositeAndEditorPromises).then(() => workbenchDone(), error => workbenchDone(error)); - } catch (error) { - - // Print out error - console.error(toErrorMessage(error, true)); - - // Rethrow - throw error; + viewletRestoreStopWatch = StopWatch.create(); + const viewletRestoreClock = time('restore:viewlet'); + restorePromises.push(this.viewletService.openViewlet(viewletIdToRestore).then(() => { + viewletRestoreStopWatch.stop(); + viewletRestoreClock.stop(); + })); } + + // Restore Panel + const panelRegistry = Registry.as(PanelExtensions.Panels); + const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId()); + if (!this.panelHidden && !!panelId) { + restorePromises.push(this.panelPart.openPanel(panelId, false)); + } + + // Restore Zen Mode if active + if (this.storageService.getBoolean(Workbench.zenModeActiveSettingKey, StorageScope.WORKSPACE, false)) { + this.toggleZenMode(true); + } + + const onRestored = (error?: Error): IWorkbenchStartedInfo => { + if (error) { + errors.onUnexpectedError(error); + } + + return { + customKeybindingsCount: this.keybindingService.customKeybindingsCount(), + restoreViewletDuration: viewletRestoreStopWatch ? Math.round(viewletRestoreStopWatch.elapsed()) : 0, + restoreEditorsDuration: Math.round(editorRestoreStopWatch.elapsed()), + pinnedViewlets: this.activitybarPart.getPinned(), + restoredViewlet: viewletIdToRestore, + restoredEditors + }; + }; + + return TPromise.join(restorePromises).then(() => onRestored(), error => onRestored(error)); } private createGlobalActions(): void { diff --git a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts index 5decaa73b37..32a8c8227fc 100644 --- a/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts +++ b/src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts @@ -15,14 +15,8 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor import { Registry } from 'vs/platform/registry/common/platform'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; -import { IEditorService } from 'vs/platform/editor/common/editor'; import product from 'vs/platform/node/product'; -interface ILegacyUse { - file: string; - lineNumber: number; -} - function ignore(code: string, value: T = null): (err: any) => TPromise { return err => err.code === code ? TPromise.as(value) : TPromise.wrapError(err); } @@ -42,8 +36,7 @@ class InstallAction extends Action { constructor( id: string, label: string, - @IMessageService private messageService: IMessageService, - @IEditorService private editorService: IEditorService + @IMessageService private messageService: IMessageService ) { super(id, label); } diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts index aaf8113fe70..6df4199bc2a 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts @@ -278,6 +278,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { } @editorAction +// @ts-ignore @editorAction uses the class class ShowAccessibilityHelpAction extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts b/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts index a37c93ea70f..983302f0396 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/inspectKeybindings.ts @@ -13,6 +13,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { IUntitledResourceInput } from 'vs/platform/editor/common/editor'; @editorAction +// @ts-ignore @editorAction uses the class class InspectKeyMap extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/textMate/inspectTMScopes.ts b/src/vs/workbench/parts/codeEditor/electron-browser/textMate/inspectTMScopes.ts index e28e657d8d7..27065a87ebb 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/textMate/inspectTMScopes.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/textMate/inspectTMScopes.ts @@ -102,6 +102,7 @@ class InspectTMScopesController extends Disposable implements IEditorContributio } @editorAction +// @ts-ignore @editorAction uses the class class InspectTMScopes extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts b/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts index 1b8da02242b..7065e678a6d 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/toggleWordWrap.ts @@ -131,6 +131,7 @@ function applyWordWrapState(editor: ICommonCodeEditor, state: IWordWrapState): v } @editorAction +// @ts-ignore @editorAction uses the class class ToggleWordWrapAction extends EditorAction { constructor() { @@ -175,6 +176,7 @@ class ToggleWordWrapAction extends EditorAction { } @commonEditorContribution +// @ts-ignore @editorAction uses the class class ToggleWordWrapController extends Disposable implements IEditorContribution { private static _ID = 'editor.contrib.toggleWordWrapController'; diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/wordWrapMigration.ts b/src/vs/workbench/parts/codeEditor/electron-browser/wordWrapMigration.ts index e2e99c99949..641f87730cc 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/wordWrapMigration.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/wordWrapMigration.ts @@ -55,6 +55,7 @@ class WordWrapMigrationStorage { } @editorContribution +// @ts-ignore @editorAction uses the class class WordWrapMigrationController extends Disposable implements IEditorContribution { private static ID = 'editor.contrib.wordWrapMigrationController'; diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index dbe837021a9..10b38d0a753 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -77,6 +77,7 @@ export class ConfigureAction extends AbstractDebugAction { constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @IMessageService private messageService: IMessageService ) { diff --git a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts index 44289a6b188..14c6c3ef0f3 100644 --- a/src/vs/workbench/parts/debug/browser/debugEditorActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugEditorActions.ts @@ -16,6 +16,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; @editorAction +// @ts-ignore @editorAction uses the class class ToggleBreakpointAction extends EditorAction { constructor() { super({ @@ -68,6 +69,7 @@ function addColumnBreakpoint(accessor: ServicesAccessor, editor: ICommonCodeEdit } @editorAction +// @ts-ignore @editorAction uses the class class ToggleColumnBreakpointAction extends EditorAction { constructor() { super({ @@ -89,6 +91,7 @@ class ToggleColumnBreakpointAction extends EditorAction { // TODO@Isidor merge two column breakpoints actions together @editorAction +// @ts-ignore @editorAction uses the class class ToggleColumnBreakpointContextMenuAction extends EditorAction { constructor() { super({ @@ -109,6 +112,7 @@ class ToggleColumnBreakpointContextMenuAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class ConditionalBreakpointAction extends EditorAction { constructor() { @@ -132,6 +136,7 @@ class ConditionalBreakpointAction extends EditorAction { @editorAction +// @ts-ignore @editorAction uses the class class RunToCursorAction extends EditorAction { constructor() { @@ -175,6 +180,7 @@ class RunToCursorAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class SelectionToReplAction extends EditorAction { constructor() { @@ -202,6 +208,7 @@ class SelectionToReplAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class SelectionToWatchExpressionsAction extends EditorAction { constructor() { @@ -227,6 +234,7 @@ class SelectionToWatchExpressionsAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class ShowDebugHoverAction extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts index 5ce5e8bb14b..b85b020bf9b 100644 --- a/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts +++ b/src/vs/workbench/parts/debug/browser/debugQuickOpen.ts @@ -80,6 +80,7 @@ export class DebugQuickOpenHandler extends Quickopen.QuickOpenHandler { private autoFocusIndex: number; constructor( + // @ts-ignore unused injected service @IQuickOpenService private quickOpenService: IQuickOpenService, @IDebugService private debugService: IDebugService, @IWorkspaceContextService private contextService: IWorkspaceContextService, diff --git a/src/vs/workbench/parts/debug/browser/exceptionWidget.ts b/src/vs/workbench/parts/debug/browser/exceptionWidget.ts index cbb4c4e8bd9..e69433687b7 100644 --- a/src/vs/workbench/parts/debug/browser/exceptionWidget.ts +++ b/src/vs/workbench/parts/debug/browser/exceptionWidget.ts @@ -27,8 +27,11 @@ export class ExceptionWidget extends ZoneWidget { private _backgroundColor: Color; + // @ts-ignore unused property constructor(editor: ICodeEditor, private exceptionInfo: IExceptionInfo, private lineNumber: number, + // @ts-ignore unused injected service @IContextViewService private contextViewService: IContextViewService, + // @ts-ignore unused injected service @IDebugService private debugService: IDebugService, @IThemeService themeService: IThemeService, @IInstantiationService private instantiationService: IInstantiationService diff --git a/src/vs/workbench/parts/debug/browser/linkDetector.ts b/src/vs/workbench/parts/debug/browser/linkDetector.ts index ac31e70c14a..246c70b41f0 100644 --- a/src/vs/workbench/parts/debug/browser/linkDetector.ts +++ b/src/vs/workbench/parts/debug/browser/linkDetector.ts @@ -24,6 +24,7 @@ export class LinkDetector { constructor( @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService ) { // noop diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 7683e3d99e3..f87ee2d6c80 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -304,7 +304,7 @@ export interface IModel extends ITreeElement { onDidChangeCallStack: Event; onDidChangeWatchExpressions: Event; onDidChangeReplElements: Event; -}; +} // Debug enums @@ -319,6 +319,7 @@ export enum State { export interface IDebugConfiguration { allowBreakpointsEverywhere: boolean; + openDebug: string; openExplorerOnEnd: boolean; inlineValues: boolean; hideActionBar: boolean; diff --git a/src/vs/workbench/parts/debug/common/debugViewModel.ts b/src/vs/workbench/parts/debug/common/debugViewModel.ts index d394b47018d..2da97bc70b5 100644 --- a/src/vs/workbench/parts/debug/common/debugViewModel.ts +++ b/src/vs/workbench/parts/debug/common/debugViewModel.ts @@ -17,14 +17,12 @@ export class ViewModel implements debug.IViewModel { private _onDidSelectExpression: Emitter; private _onDidSelectFunctionBreakpoint: Emitter; private multiProcessView: boolean; - public changedWorkbenchViewState: boolean; constructor() { this._onDidFocusProcess = new Emitter(); this._onDidFocusStackFrame = new Emitter<{ stackFrame: debug.IStackFrame, explicit: boolean }>(); this._onDidSelectExpression = new Emitter(); this._onDidSelectFunctionBreakpoint = new Emitter(); - this.changedWorkbenchViewState = false; this.multiProcessView = false; } diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index f4b58609845..5bc4348995b 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -188,6 +188,11 @@ configurationRegistry.registerConfiguration({ default: false }, 'debug.internalConsoleOptions': INTERNAL_CONSOLE_OPTIONS_SCHEMA, + 'debug.openDebug': { + enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'], + default: 'openOnFirstSessionStart', + description: nls.localize('openDebug', "Controls whether debug viewlet should be open on debugging session start.") + }, 'launch': { type: 'object', description: nls.localize({ comment: ['This is the description for a setting'], key: 'launch' }, "Global debug launch configuration. Should be used as an alternative to 'launch.json' that is shared across workspaces"), diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts index 3a1bc568bd4..568ece14e38 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts @@ -217,11 +217,14 @@ export class ConfigurationManager implements IConfigurationManager { constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService, + // @ts-ignore unused injected service @IFileService private fileService: IFileService, + // @ts-ignore unused injected service @ITelemetryService private telemetryService: ITelemetryService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IConfigurationService private configurationService: IConfigurationService, @IQuickOpenService private quickOpenService: IQuickOpenService, + // @ts-ignore unused injected service @IConfigurationResolverService private configurationResolverService: IConfigurationResolverService, @IInstantiationService private instantiationService: IInstantiationService, @ICommandService private commandService: ICommandService, diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 8c2ce64e770..6b5c01fec8e 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -60,11 +60,6 @@ const DEBUG_FUNCTION_BREAKPOINTS_KEY = 'debug.functionbreakpoint'; const DEBUG_EXCEPTION_BREAKPOINTS_KEY = 'debug.exceptionbreakpoint'; const DEBUG_WATCH_EXPRESSIONS_KEY = 'debug.watchexpressions'; -interface StartSessionResult { - status: 'ok' | 'initialConfiguration' | 'saveConfiguration'; - content?: string; -}; - export class DebugService implements debug.IDebugService { public _serviceBrand: any; @@ -84,6 +79,7 @@ export class DebugService implements debug.IDebugService { private debugState: IContextKey; private breakpointsToSendOnResourceSaved: Set; private launchJsonChanged: boolean; + private firstSessionStart: boolean; private previousState: debug.State; constructor( @@ -94,6 +90,7 @@ export class DebugService implements debug.IDebugService { @IPanelService private panelService: IPanelService, @IMessageService private messageService: IMessageService, @IPartService private partService: IPartService, + // @ts-ignore unused injected service @IWindowsService private windowsService: IWindowsService, @IWindowService private windowService: IWindowService, @IBroadcastService private broadcastService: IBroadcastService, @@ -107,6 +104,7 @@ export class DebugService implements debug.IDebugService { @ITaskService private taskService: ITaskService, @IFileService private fileService: IFileService, @IConfigurationService private configurationService: IConfigurationService, + // @ts-ignore unused injected service @ICommandService private commandService: ICommandService ) { this.toDispose = []; @@ -129,6 +127,7 @@ export class DebugService implements debug.IDebugService { this.loadExceptionBreakpoints(), this.loadWatchExpressions()); this.toDispose.push(this.model); this.viewModel = new ViewModel(); + this.firstSessionStart = true; this.registerListeners(lifecycleService); } @@ -411,7 +410,7 @@ export class DebugService implements debug.IDebugService { this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidExitAdapter(event => { // 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905 if (strings.equalsIgnoreCase(process.configuration.type, 'extensionhost') && this.sessionStates.get(session.getId()) === debug.State.Running && - process && this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && process.configuration.noDebug) { + process && process.session.root && process.configuration.noDebug) { this.broadcastService.broadcast({ channel: EXTENSION_CLOSE_EXTHOST_BROADCAST_CHANNEL, payload: [process.session.root.uri.fsPath] @@ -868,15 +867,16 @@ export class DebugService implements debug.IDebugService { this.focusStackFrameAndEvaluate(null, process); const internalConsoleOptions = configuration.internalConsoleOptions || this.configurationService.getConfiguration('debug').internalConsoleOptions; - if (internalConsoleOptions === 'openOnSessionStart' || (!this.viewModel.changedWorkbenchViewState && internalConsoleOptions === 'openOnFirstSessionStart')) { + if (internalConsoleOptions === 'openOnSessionStart' || (this.firstSessionStart && internalConsoleOptions === 'openOnFirstSessionStart')) { this.panelService.openPanel(debug.REPL_ID, false).done(undefined, errors.onUnexpectedError); } - if (!this.viewModel.changedWorkbenchViewState && (this.partService.isVisible(Parts.SIDEBAR_PART) || this.contextService.getWorkbenchState() === WorkbenchState.EMPTY)) { - // We only want to change the workbench view state on the first debug session #5738 and if the side bar is not hidden - this.viewModel.changedWorkbenchViewState = true; + const openDebugOptions = this.configurationService.getConfiguration('debug').openDebug; + // Open debug viewlet based on the visibility of the side bar and openDebug setting + if (openDebugOptions === 'openOnSessionStart' || (openDebugOptions === 'openOnFirstSessionStart' && this.firstSessionStart)) { this.viewletService.openViewlet(debug.VIEWLET_ID); } + this.firstSessionStart = false; this.debugType.set(configuration.type); if (this.model.getProcesses().length > 1) { @@ -902,7 +902,7 @@ export class DebugService implements debug.IDebugService { watchExpressionsCount: this.model.getWatchExpressions().length, extensionName: `${adapter.extensionDescription.publisher}.${adapter.extensionDescription.name}`, isBuiltin: adapter.extensionDescription.isBuiltin, - launchJsonExists: this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && !!this.configurationService.getConfiguration('launch', { resource: root.uri }) + launchJsonExists: root && !!this.configurationService.getConfiguration('launch', { resource: root.uri }) }); }).then(() => process, (error: any) => { if (error instanceof Error && error.message === 'Canceled') { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugViewer.ts b/src/vs/workbench/parts/debug/electron-browser/debugViewer.ts index 88994468dc2..57811167418 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugViewer.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugViewer.ts @@ -53,7 +53,7 @@ export interface IRenderValueOptions { } function replaceWhitespace(value: string): string { - const map = { '\n': '\\n', '\r': '\\r', '\t': '\\t' }; + const map: { [x: string]: string } = { '\n': '\\n', '\r': '\\r', '\t': '\\t' }; return value.replace(/[\n\r\t]/g, char => map[char]); } @@ -310,6 +310,7 @@ export class CallStackController extends BaseDebugController { export class CallStackActionProvider implements IActionProvider { + // @ts-ignore unused injected service constructor( @IInstantiationService private instantiationService: IInstantiationService, @debug.IDebugService private debugService: debug.IDebugService) { // noop } @@ -885,10 +886,12 @@ export class WatchExpressionsRenderer implements IRenderer { private static WATCH_EXPRESSION_TEMPLATE_ID = 'watchExpression'; private static VARIABLE_TEMPLATE_ID = 'variables'; private toDispose: lifecycle.IDisposable[]; + // @ts-ignore unused property private actionProvider: WatchExpressionsActionProvider; constructor( actionProvider: IActionProvider, + // @ts-ignore unused property private actionRunner: IActionRunner, @debug.IDebugService private debugService: debug.IDebugService, @IContextViewService private contextViewService: IContextViewService, @@ -1132,7 +1135,9 @@ export class BreakpointsRenderer implements IRenderer { private static BREAKPOINT_TEMPLATE_ID = 'breakpoint'; constructor( + // @ts-ignore unused property private actionProvider: BreakpointsActionProvider, + // @ts-ignore unused property private actionRunner: IActionRunner, @IWorkspaceContextService private contextService: IWorkspaceContextService, @debug.IDebugService private debugService: debug.IDebugService, diff --git a/src/vs/workbench/parts/debug/electron-browser/debugViews.ts b/src/vs/workbench/parts/debug/electron-browser/debugViews.ts index e5c982d17cd..62f77354324 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugViews.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugViews.ts @@ -50,8 +50,10 @@ export class VariablesView extends ViewsViewletPanel { private expandedElements: any[]; constructor( + // @ts-ignore unused property private options: IViewletViewOptions, @IContextMenuService contextMenuService: IContextMenuService, + // @ts-ignore unused injected service @ITelemetryService private telemetryService: ITelemetryService, @IDebugService private debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService, @@ -162,6 +164,7 @@ export class WatchExpressionsView extends ViewsViewletPanel { private settings: any; constructor( + // @ts-ignore unused property private options: IViewletViewOptions, @IContextMenuService contextMenuService: IContextMenuService, @IDebugService private debugService: IDebugService, @@ -256,6 +259,7 @@ export class CallStackView extends ViewsViewletPanel { constructor( private options: IViewletViewOptions, @IContextMenuService contextMenuService: IContextMenuService, + // @ts-ignore unused injected service @ITelemetryService private telemetryService: ITelemetryService, @IDebugService private debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService, @@ -390,6 +394,7 @@ export class BreakpointsView extends ViewsViewletPanel { private settings: any; constructor( + // @ts-ignore unused property private options: IViewletViewOptions, @IContextMenuService contextMenuService: IContextMenuService, @IDebugService private debugService: IDebugService, diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index a1a9c8250a5..189ce191a23 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -313,6 +313,7 @@ export class Repl extends Panel implements IPrivateReplService { } @editorAction +// @ts-ignore @editorAction uses the class class ReplHistoryPreviousAction extends EditorAction { constructor() { @@ -338,6 +339,7 @@ class ReplHistoryPreviousAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class ReplHistoryNextAction extends EditorAction { constructor() { @@ -363,6 +365,7 @@ class ReplHistoryNextAction extends EditorAction { } @editorAction +// @ts-ignore @editorAction uses the class class AcceptReplInputAction extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts b/src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts index 3456d7b4f41..df6f2affc77 100644 --- a/src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts +++ b/src/vs/workbench/parts/debug/electron-browser/terminalSupport.ts @@ -11,7 +11,7 @@ import { ITerminalService, ITerminalInstance, ITerminalConfiguration } from 'vs/ import { ITerminalService as IExternalTerminalService } from 'vs/workbench/parts/execution/common/execution'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -const enum ShellType { cmd, powershell, bash }; +const enum ShellType { cmd, powershell, bash } export class TerminalSupport { diff --git a/src/vs/workbench/parts/debug/node/debugAdapter.ts b/src/vs/workbench/parts/debug/node/debugAdapter.ts index 0bfdffe4fa2..24272e989cf 100644 --- a/src/vs/workbench/parts/debug/node/debugAdapter.ts +++ b/src/vs/workbench/parts/debug/node/debugAdapter.ts @@ -22,6 +22,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; export class Adapter { constructor(private rawAdapter: IRawAdapter, public extensionDescription: IExtensionDescription, + // @ts-ignore unused injected service @IConfigurationResolverService private configurationResolverService: IConfigurationResolverService, @IConfigurationService private configurationService: IConfigurationService, @ICommandService private commandService: ICommandService @@ -35,7 +36,7 @@ export class Adapter { public getAdapterExecutable(root: IWorkspaceFolder, verifyAgainstFS = true): TPromise { - if (this.rawAdapter.adapterExecutableCommand) { + if (this.rawAdapter.adapterExecutableCommand && root) { return this.commandService.executeCommand(this.rawAdapter.adapterExecutableCommand, root.uri.toString()).then(ad => { return this.verifyAdapterDetails(ad, verifyAgainstFS); }); @@ -165,7 +166,7 @@ export class Adapter { } return TPromise.as(content); - }; + } public getSchemaAttributes(): IJSONSchema[] { if (!this.rawAdapter.configurationAttributes) { diff --git a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts index c5414c58f34..cd85afc69dd 100644 --- a/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts +++ b/src/vs/workbench/parts/debug/test/common/debugViewModel.test.ts @@ -42,7 +42,6 @@ suite('Debug - View Model', () => { }); test('multi process view and changed workbench state', () => { - assert.equal(model.changedWorkbenchViewState, false); assert.equal(model.isMultiProcessView(), false); model.setMultiProcessView(true); assert.equal(model.isMultiProcessView(), true); diff --git a/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts b/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts index a11c3333fe8..289ca1d5e5b 100644 --- a/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts +++ b/src/vs/workbench/parts/emmet/browser/actions/showEmmetCommands.ts @@ -16,6 +16,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; const EMMET_COMMANDS_PREFIX = '>Emmet: '; @editorAction +// @ts-ignore @editorAction uses the class class ShowEmmetCommandsAction extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts b/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts index fc9136fce72..02540f66630 100644 --- a/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts +++ b/src/vs/workbench/parts/emmet/electron-browser/actions/expandAbbreviation.ts @@ -12,6 +12,7 @@ import { KeyCode } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; @editorAction +// @ts-ignore @editorAction uses the class class ExpandAbbreviationAction extends EmmetEditorAction { constructor() { diff --git a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts index e26b830c9dd..9eb9e7b123e 100644 --- a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts +++ b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts @@ -10,9 +10,9 @@ import { WinTerminalService, LinuxTerminalService, MacTerminalService } from 'vs import { DEFAULT_TERMINAL_WINDOWS, DEFAULT_TERMINAL_LINUX_READY, DEFAULT_TERMINAL_OSX } from 'vs/workbench/parts/execution/electron-browser/terminal'; suite('Execution - TerminalService', () => { - let mockOnExit; - let mockOnError; - let mockConfig; + let mockOnExit: Function; + let mockOnError: Function; + let mockConfig: any; setup(() => { mockConfig = { @@ -25,22 +25,22 @@ suite('Execution - TerminalService', () => { } } }; - mockOnExit = s => s; - mockOnError = e => e; + mockOnExit = (s: any) => s; + mockOnError = (e: any) => e; }); test(`WinTerminalService - uses terminal from configuration`, done => { let testShell = 'cmd'; let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(command, testShell, 'shell should equal expected'); equal(args[args.length - 1], mockConfig.terminal.external.windowsExec, 'terminal should equal expected'); equal(opts.cwd, testCwd, 'opts.cwd should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -59,12 +59,12 @@ suite('Execution - TerminalService', () => { let testShell = 'cmd'; let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(args[args.length - 1], DEFAULT_TERMINAL_WINDOWS, 'terminal should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -84,12 +84,12 @@ suite('Execution - TerminalService', () => { let testShell = 'cmd'; let testCwd = 'c:/foo'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(opts.cwd, 'C:/foo', 'cwd should be uppercase regardless of the case that\'s passed in'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -109,12 +109,12 @@ suite('Execution - TerminalService', () => { mockConfig.terminal.external.windowsExec = 'cmder'; let testCwd = 'c:/foo'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert deepEqual(args, ['C:/foo']); equal(opts, undefined); done(); - return { on: (evt) => evt }; + return { on: (evt: any) => evt }; } }; let testService = new WinTerminalService(mockConfig); @@ -131,12 +131,12 @@ suite('Execution - TerminalService', () => { test(`MacTerminalService - uses terminal from configuration`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(args[1], mockConfig.terminal.external.osxExec, 'terminal should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -153,12 +153,12 @@ suite('Execution - TerminalService', () => { test(`MacTerminalService - uses default terminal when configuration.terminal.external.osxExec is undefined`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(args[1], DEFAULT_TERMINAL_OSX, 'terminal should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -176,13 +176,13 @@ suite('Execution - TerminalService', () => { test(`LinuxTerminalService - uses terminal from configuration`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(command, mockConfig.terminal.external.linuxExec, 'terminal should equal expected'); equal(opts.cwd, testCwd, 'opts.cwd should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; @@ -200,12 +200,12 @@ suite('Execution - TerminalService', () => { DEFAULT_TERMINAL_LINUX_READY.then(defaultTerminalLinux => { let testCwd = 'path/to/workspace'; let mockSpawner = { - spawn: (command, args, opts) => { + spawn: (command: any, args: any, opts: any) => { // assert equal(command, defaultTerminalLinux, 'terminal should equal expected'); done(); return { - on: (evt) => evt + on: (evt: any) => evt }; } }; diff --git a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts index 9794f7ba135..c468fb8b995 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionEditor.ts @@ -17,7 +17,7 @@ import Cache from 'vs/base/common/cache'; import { Action } from 'vs/base/common/actions'; import { isPromiseCanceledError } from 'vs/base/common/errors'; import Severity from 'vs/base/common/severity'; -import { IDisposable, empty, dispose, toDisposable } from 'vs/base/common/lifecycle'; +import { IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle'; import { Builder } from 'vs/base/browser/builder'; import { domEvent } from 'vs/base/browser/event'; import { append, $, addClass, removeClass, finalHandler, join } from 'vs/base/browser/dom'; @@ -25,13 +25,11 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; -import { IExtensionGalleryService, IExtensionManifest, IKeyBinding, IView, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement'; +import { IExtensionManifest, IKeyBinding, IView, IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { ResolvedKeybinding, KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput'; import { IExtensionsWorkbenchService, IExtensionsViewlet, VIEWLET_ID, IExtension, IExtensionDependencies } from 'vs/workbench/parts/extensions/common/extensions'; import { Renderer, DataSource, Controller } from 'vs/workbench/parts/extensions/browser/dependenciesViewer'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { ITemplateData } from 'vs/workbench/parts/extensions/browser/extensionsList'; import { RatingsWidget, InstallWidget } from 'vs/workbench/parts/extensions/browser/extensionsWidgets'; import { EditorOptions } from 'vs/workbench/common/editor'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; @@ -165,8 +163,6 @@ export class ExtensionEditor extends BaseEditor { private content: HTMLElement; private recommendation: HTMLElement; private header: HTMLElement; - private _highlight: ITemplateData; - private highlightDisposable: IDisposable; private extensionReadme: Cache; private extensionChangelog: Cache; @@ -183,8 +179,6 @@ export class ExtensionEditor extends BaseEditor { constructor( @ITelemetryService telemetryService: ITelemetryService, - @IExtensionGalleryService private galleryService: IExtensionGalleryService, - @IConfigurationService private configurationService: IConfigurationService, @IInstantiationService private instantiationService: IInstantiationService, @IViewletService private viewletService: IViewletService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @@ -199,15 +193,13 @@ export class ExtensionEditor extends BaseEditor { @IExtensionTipsService private extensionTipsService: IExtensionTipsService ) { super(ExtensionEditor.ID, telemetryService, themeService); - this._highlight = null; - this.highlightDisposable = empty; this.disposables = []; this.extensionReadme = null; this.extensionChangelog = null; this.extensionManifest = null; this.extensionDependencies = null; - this.contextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS.bindTo(contextKeyService); - this.findInputFocusContextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED.bindTo(contextKeyService); + this.contextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS.bindTo(this.contextKeyService); + this.findInputFocusContextKey = KEYBINDING_CONTEXT_EXTENSIONEDITOR_FIND_WIDGET_INPUT_FOCUSED.bindTo(this.contextKeyService); } createEditor(parent: Builder): void { @@ -895,7 +887,6 @@ export class ExtensionEditor extends BaseEditor { } dispose(): void { - this._highlight = null; this.transientDisposables = dispose(this.transientDisposables); this.disposables = dispose(this.disposables); super.dispose(); @@ -927,22 +918,6 @@ const showCommand = new ShowExtensionEditorFindCommand({ }); KeybindingsRegistry.registerCommandAndKeybindingRule(showCommand.toCommandAndKeybindingRule(KeybindingsRegistry.WEIGHT.editorContrib())); -class HideExtensionEditorFindCommand extends Command { - public runCommand(accessor: ServicesAccessor, args: any): void { - const extensionEditor = this.getExtensionEditor(accessor); - if (extensionEditor) { - extensionEditor.hideFind(); - } - } - - private getExtensionEditor(accessor: ServicesAccessor): ExtensionEditor { - const activeEditor = accessor.get(IWorkbenchEditorService).getActiveEditor() as ExtensionEditor; - if (activeEditor instanceof ExtensionEditor) { - return activeEditor; - } - return null; - } -} const hideCommand = new ShowExtensionEditorFindCommand({ id: 'editor.action.extensioneditor.hidefind', precondition: KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS, diff --git a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts index 5092c0cac43..b4a731de182 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts @@ -110,9 +110,7 @@ export class UninstallAction extends Action { set extension(extension: IExtension) { this._extension = extension; this.update(); } constructor( - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IMessageService private messageService: IMessageService, - @IInstantiationService private instantiationService: IInstantiationService + @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService ) { super('extensions.uninstall', UninstallAction.UninstallLabel, UninstallAction.UninstallClass, false); @@ -363,9 +361,7 @@ export class ManageExtensionAction extends Action { set extension(extension: IExtension) { this._extension = extension; this._actionItem.extension = extension; this.update(); } constructor( - @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService, @IInstantiationService private instantiationService: IInstantiationService ) { super(ManageExtensionAction.ID); @@ -426,8 +422,7 @@ export class EnableForWorkspaceAction extends Action implements IExtensionAction constructor(label: string, @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService, - @IInstantiationService private instantiationService: IInstantiationService + @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService ) { super(EnableForWorkspaceAction.ID, label); @@ -466,8 +461,7 @@ export class EnableGloballyAction extends Action implements IExtensionAction { constructor(label: string, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService, - @IInstantiationService private instantiationService: IInstantiationService + @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService ) { super(EnableGloballyAction.ID, label); @@ -563,8 +557,7 @@ export class DisableForWorkspaceAction extends Action implements IExtensionActio constructor(label: string, @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IInstantiationService private instantiationService: IInstantiationService + @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService ) { super(DisableForWorkspaceAction.ID, label); @@ -602,8 +595,7 @@ export class DisableGloballyAction extends Action implements IExtensionAction { set extension(extension: IExtension) { this._extension = extension; this.update(); } constructor(label: string, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IInstantiationService private instantiationService: IInstantiationService + @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService ) { super(DisableGloballyAction.ID, label); @@ -802,7 +794,6 @@ export class ReloadAction extends Action { constructor( @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IMessageService private messageService: IMessageService, @IWindowService private windowService: IWindowService, @IExtensionService private extensionService: IExtensionService ) { @@ -910,8 +901,7 @@ export class ShowEnabledExtensionsAction extends Action { constructor( id: string, label: string, - @IViewletService private viewletService: IViewletService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService + @IViewletService private viewletService: IViewletService ) { super(id, label, 'clear-extensions', true); } @@ -934,8 +924,7 @@ export class ShowInstalledExtensionsAction extends Action { constructor( id: string, label: string, - @IViewletService private viewletService: IViewletService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService + @IViewletService private viewletService: IViewletService ) { super(id, label, 'clear-extensions', true); } @@ -958,8 +947,7 @@ export class ShowDisabledExtensionsAction extends Action { constructor( id: string, label: string, - @IViewletService private viewletService: IViewletService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService + @IViewletService private viewletService: IViewletService ) { super(id, label, 'null', true); } @@ -985,8 +973,7 @@ export class ClearExtensionsInputAction extends Action { id: string, label: string, onSearchChange: Event, - @IViewletService private viewletService: IViewletService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService + @IViewletService private viewletService: IViewletService ) { super(id, label, 'clear-extensions', true); this.enabled = false; @@ -1552,8 +1539,7 @@ export class DisableAllAction extends Action { constructor( id: string = DisableAllAction.ID, label: string = DisableAllAction.LABEL, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService + @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService ) { super(id, label); this.update(); @@ -1584,8 +1570,7 @@ export class DisableAllWorkpsaceAction extends Action { constructor( id: string = DisableAllWorkpsaceAction.ID, label: string = DisableAllWorkpsaceAction.LABEL, @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, - @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService + @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService ) { super(id, label); this.update(); diff --git a/src/vs/workbench/parts/extensions/browser/extensionsList.ts b/src/vs/workbench/parts/extensions/browser/extensionsList.ts index 29e8d84b673..24eacaef0a0 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionsList.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionsList.ts @@ -20,7 +20,6 @@ import { InstallAction, UpdateAction, BuiltinStatusLabelAction, ManageExtensionA import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { Label, RatingsWidget, InstallWidget } from 'vs/workbench/parts/extensions/browser/extensionsWidgets'; import { EventType } from 'vs/base/common/events'; -import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IExtensionService } from 'vs/platform/extensions/common/extensions'; import { IExtensionTipsService } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IThemeService } from 'vs/platform/theme/common/themeService'; @@ -50,7 +49,6 @@ export class Renderer implements IPagedRenderer { constructor( @IInstantiationService private instantiationService: IInstantiationService, - @IContextMenuService private contextMenuService: IContextMenuService, @IMessageService private messageService: IMessageService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @IExtensionService private extensionService: IExtensionService, diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts index 7387483260a..361ecfb1c9d 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts @@ -85,7 +85,6 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens @IInstantiationService instantiationService: IInstantiationService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IEditorGroupService private editorInputService: IEditorGroupService, - @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @IExtensionManagementService private extensionManagementService: IExtensionManagementService, @IMessageService private messageService: IMessageService, @IViewletService private viewletService: IViewletService, @@ -106,7 +105,7 @@ export class ExtensionsViewlet extends PersistentViewsViewlet implements IExtens this.searchInstalledExtensionsContextKey = SearchInstalledExtensionsContext.bindTo(contextKeyService); this.recommendedExtensionsContextKey = RecommendedExtensionsContext.bindTo(contextKeyService); - this.disposables.push(viewletService.onDidViewletOpen(this.onViewletOpen, this, this.disposables)); + this.disposables.push(this.viewletService.onDidViewletOpen(this.onViewletOpen, this, this.disposables)); this.configurationService.onDidChangeConfiguration(e => { if (e.affectsConfiguration(AutoUpdateConfigurationKey)) { diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts index eaad5c72393..4f44869ebc0 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts @@ -18,8 +18,6 @@ import { SortBy, SortOrder, IQueryOptions, LocalExtensionType, IExtensionTipsSer import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; -import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { ICommandService } from 'vs/platform/commands/common/commands'; import { append, $, toggleClass } from 'vs/base/browser/dom'; import { PagedList } from 'vs/base/browser/ui/list/listPaging'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -36,7 +34,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModeService } from 'vs/editor/common/services/modeService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IProgressService } from 'vs/platform/progress/common/progress'; import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { EventType } from 'vs/base/common/events'; @@ -58,16 +55,13 @@ export class ExtensionsListView extends ViewsViewletPanel { @IInstantiationService protected instantiationService: IInstantiationService, @IListService private listService: IListService, @IThemeService private themeService: IThemeService, - @IContextKeyService private contextKeyService: IContextKeyService, @IExtensionService private extensionService: IExtensionService, - @ICommandService private commandService: ICommandService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IEditorGroupService private editorInputService: IEditorGroupService, @IExtensionTipsService private tipsService: IExtensionTipsService, @IModeService private modeService: IModeService, - @ITelemetryService private telemetryService: ITelemetryService, - @IProgressService private progressService: IProgressService + @ITelemetryService private telemetryService: ITelemetryService ) { super({ ...(options as IViewOptions), ariaHeaderLabel: options.name }, keybindingService, contextMenuService); } diff --git a/src/vs/workbench/parts/extensions/node/extensionsWorkbenchService.ts b/src/vs/workbench/parts/extensions/node/extensionsWorkbenchService.ts index 47dd74d76a5..3c57bee6e70 100644 --- a/src/vs/workbench/parts/extensions/node/extensionsWorkbenchService.ts +++ b/src/vs/workbench/parts/extensions/node/extensionsWorkbenchService.ts @@ -20,7 +20,7 @@ import { IPager, mapPager, singlePagePager } from 'vs/base/common/paging'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions, IExtensionManifest, - InstallExtensionEvent, DidInstallExtensionEvent, LocalExtensionType, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionTipsService, IExtensionIdentifier + InstallExtensionEvent, DidInstallExtensionEvent, LocalExtensionType, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement'; import { getGalleryExtensionIdFromLocal, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -332,7 +332,6 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService { @IChoiceService private choiceService: IChoiceService, @IURLService urlService: IURLService, @IExtensionEnablementService private extensionEnablementService: IExtensionEnablementService, - @IExtensionTipsService private tipsService: IExtensionTipsService, @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, @IWindowService private windowService: IWindowService ) { diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index b60b3bce030..3fb83c894cd 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -29,7 +29,6 @@ import { CancelAction } from 'vs/platform/message/common/message'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { ScrollType } from 'vs/editor/common/editorCommon'; /** @@ -50,10 +49,9 @@ export class TextFileEditor extends BaseTextEditor { @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IThemeService themeService: IThemeService, @IEditorGroupService editorGroupService: IEditorGroupService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService, ) { - super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, modeService, textFileService, editorGroupService); + super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); // Clear view state for deleted files this.toUnbind.push(this.fileService.onFileChanges(e => this.onFilesChanged(e))); @@ -192,8 +190,8 @@ export class TextFileEditor extends BaseTextEditor { // Best we can do is to reveal the folder in the explorer if (this.contextService.isInsideWorkspace(input.getResource())) { - this.viewletService.openViewlet(VIEWLET_ID, true).done((viewlet: ExplorerViewlet) => { - return viewlet.getExplorerView().select(input.getResource(), true); + this.viewletService.openViewlet(VIEWLET_ID, true).done(viewlet => { + return (viewlet as ExplorerViewlet).getExplorerView().select(input.getResource(), true); }, errors.onUnexpectedError); } }, errors.onUnexpectedError); diff --git a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts index 69f877671f9..2dddb2c5105 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts @@ -14,7 +14,6 @@ import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTI import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { FileStat, Model } from 'vs/workbench/parts/files/common/explorerModel'; import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; @@ -23,16 +22,13 @@ import { copyFocusedFilesExplorerViewItem, revealInOSFocusedFilesExplorerItem, o import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { explorerItemToFileResource, ExplorerFocusCondition, FilesExplorerFocusCondition } from 'vs/workbench/parts/files/common/files'; class FilesViewerActionContributor extends ActionBarContributor { constructor( @IInstantiationService private instantiationService: IInstantiationService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, - @IKeybindingService private keybindingService: IKeybindingService, - @IEnvironmentService private environmentService: IEnvironmentService + @IKeybindingService private keybindingService: IKeybindingService ) { super(); } diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index 9ef7fff70e5..ccc0d2ba899 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -1878,9 +1878,7 @@ export class GlobalRevealInOSAction extends Action { constructor( id: string, label: string, - @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IInstantiationService private instantiationService: IInstantiationService, - @IMessageService private messageService: IMessageService + @IInstantiationService private instantiationService: IInstantiationService ) { super(id, label); } @@ -1920,9 +1918,6 @@ export class GlobalCopyPathAction extends Action { constructor( id: string, label: string, - @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IEditorGroupService private editorGroupService: IEditorGroupService, - @IMessageService private messageService: IMessageService, @IInstantiationService private instantiationService: IInstantiationService ) { super(id, label); diff --git a/src/vs/workbench/parts/files/browser/fileCommands.ts b/src/vs/workbench/parts/files/browser/fileCommands.ts index 35926676f8a..8a0a4629dc2 100644 --- a/src/vs/workbench/parts/files/browser/fileCommands.ts +++ b/src/vs/workbench/parts/files/browser/fileCommands.ts @@ -140,7 +140,7 @@ function withVisibleExplorer(accessor: ServicesAccessor): TPromise; -}; +} export function withFocusedFilesExplorerViewItem(accessor: ServicesAccessor): TPromise<{ explorer: ExplorerViewlet, tree: ITree, item: FileStat }> { return withFocusedFilesExplorer(accessor).then(res => { @@ -155,7 +155,7 @@ export function withFocusedFilesExplorerViewItem(accessor: ServicesAccessor): TP return { explorer, tree, item: tree.getFocus() }; }); -}; +} export function withFocusedFilesExplorer(accessor: ServicesAccessor): TPromise<{ explorer: ExplorerViewlet, tree: ITree }> { return withVisibleExplorer(accessor).then(explorer => { @@ -172,7 +172,7 @@ export function withFocusedFilesExplorer(accessor: ServicesAccessor): TPromise<{ return { explorer, tree }; }); -}; +} function withFocusedOpenEditorsViewItem(accessor: ServicesAccessor): TPromise<{ explorer: ExplorerViewlet, tree: ITree, item: OpenEditor }> { return withVisibleExplorer(accessor).then(explorer => { @@ -190,7 +190,7 @@ function withFocusedOpenEditorsViewItem(accessor: ServicesAccessor): TPromise<{ return { explorer, tree, item: focus }; }); -}; +} function withFocusedExplorerItem(accessor: ServicesAccessor): TPromise { return withFocusedFilesExplorerViewItem(accessor).then(res => { @@ -206,7 +206,7 @@ function withFocusedExplorerItem(accessor: ServicesAccessor): TPromise { runActionOnFocusedFilesExplorerViewItem(accessor, 'renameFile'); diff --git a/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts b/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts index 7151d614f6f..9174477d966 100644 --- a/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts +++ b/src/vs/workbench/parts/files/browser/fileResultsNavigation.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { Disposable } from 'vs/base/common/lifecycle'; -import { Throttler } from 'vs/base/common/async'; import Event, { Emitter } from 'vs/base/common/event'; import { IEditorOptions } from 'vs/platform/editor/common/editor'; import { ITree } from 'vs/base/parts/tree/browser/tree'; @@ -21,11 +20,8 @@ export default class FileResultsNavigation extends Disposable { private _openFile: Emitter = new Emitter(); public readonly openFile: Event = this._openFile.event; - private throttler: Throttler; - constructor(private tree: ITree) { super(); - this.throttler = new Throttler(); this._register(this.tree.addListener('focus', e => this.onFocus(e))); this._register(this.tree.addListener('selection', e => this.onSelection(e))); } diff --git a/src/vs/workbench/parts/files/browser/files.contribution.ts b/src/vs/workbench/parts/files/browser/files.contribution.ts index 685f955c969..15b4a09a9fa 100644 --- a/src/vs/workbench/parts/files/browser/files.contribution.ts +++ b/src/vs/workbench/parts/files/browser/files.contribution.ts @@ -29,7 +29,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { KeyMod, KeyCode } from 'vs/base/common/keyCodes'; import * as platform from 'vs/base/common/platform'; import { DirtyFilesTracker } from 'vs/workbench/parts/files/common/dirtyFilesTracker'; -import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { ExplorerViewlet } from 'vs/workbench/parts/files/browser/explorerViewlet'; import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor'; @@ -110,10 +109,7 @@ interface ISerializedFileInput { // Register Editor Input Factory class FileEditorInputFactory implements IEditorInputFactory { - constructor( - @ITextResourceConfigurationService private configurationService: ITextResourceConfigurationService - ) { - } + constructor() { } public serialize(editorInput: EditorInput): string { const fileEditorInput = editorInput; diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 169f4134dd0..0969df39c49 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -44,7 +44,6 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c import { ResourceContextKey, ResourceGlobMatcher } from 'vs/workbench/common/resources'; import { IWorkbenchThemeService, IFileIconTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { isLinux } from 'vs/base/common/platform'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations'; @@ -57,7 +56,6 @@ export class ExplorerView extends ViewsViewletPanel { public static ID: string = 'workbench.explorer.fileView'; private static EXPLORER_FILE_CHANGES_REACT_DELAY = 500; // delay in ms to react to file changes to give our internal events a chance to react first private static EXPLORER_FILE_CHANGES_REFRESH_DELAY = 100; // delay in ms to refresh the explorer from disk file changes - private static EXPLORER_IMPORT_REFRESH_DELAY = 300; // delay in ms to refresh the explorer from imports private static MEMENTO_LAST_ACTIVE_FILE_RESOURCE = 'explorer.memento.lastActiveFileResource'; private static MEMENTO_EXPANDED_FOLDER_RESOURCES = 'explorer.memento.expandedFolderResources'; @@ -69,7 +67,6 @@ export class ExplorerView extends ViewsViewletPanel { private viewletState: FileViewletState; private explorerRefreshDelayer: ThrottledDelayer; - private explorerImportDelayer: ThrottledDelayer; private resourceContext: ResourceContextKey; private folderContext: IContextKey; @@ -100,7 +97,6 @@ export class ExplorerView extends ViewsViewletPanel { @IContextKeyService contextKeyService: IContextKeyService, @IConfigurationService private configurationService: IConfigurationService, @IWorkbenchThemeService private themeService: IWorkbenchThemeService, - @IEnvironmentService private environmentService: IEnvironmentService, @IDecorationsService decorationService: IDecorationsService ) { super({ ...(options as IViewOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService); @@ -110,7 +106,6 @@ export class ExplorerView extends ViewsViewletPanel { this.autoReveal = true; this.explorerRefreshDelayer = new ThrottledDelayer(ExplorerView.EXPLORER_FILE_CHANGES_REFRESH_DELAY); - this.explorerImportDelayer = new ThrottledDelayer(ExplorerView.EXPLORER_IMPORT_REFRESH_DELAY); this.resourceContext = instantiationService.createInstance(ResourceContextKey); this.folderContext = ExplorerFolderContext.bindTo(contextKeyService); diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index a11f8564498..6b80e582f28 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -53,7 +53,6 @@ import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; -import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { getPathLabel } from 'vs/base/common/labels'; import { extractResources } from 'vs/workbench/browser/editor'; @@ -62,8 +61,7 @@ export class FileDataSource implements IDataSource { @IProgressService private progressService: IProgressService, @IMessageService private messageService: IMessageService, @IFileService private fileService: IFileService, - @IPartService private partService: IPartService, - @IWorkspaceContextService private contextService: IWorkspaceContextService + @IPartService private partService: IPartService ) { } public getId(tree: ITree, stat: FileStat | Model): string { @@ -352,8 +350,7 @@ export class FileRenderer implements IRenderer { // Input field for name const inputBox = new InputBox(label.element, this.contextViewService, { validationOptions: { - validation: editableData.validator, - showMessage: true + validation: editableData.validator }, ariaLabel: nls.localize('fileInputAriaLabel', "Type file name. Press Enter to confirm or Escape to cancel.") }); @@ -425,9 +422,7 @@ export class FileController extends DefaultController { constructor(state: FileViewletState, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IContextMenuService private contextMenuService: IContextMenuService, - @IInstantiationService private instantiationService: IInstantiationService, @ITelemetryService private telemetryService: ITelemetryService, - @IWorkspaceContextService private contextService: IWorkspaceContextService, @IMenuService menuService: IMenuService, @IContextKeyService contextKeyService: IContextKeyService ) { @@ -751,8 +746,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { @ITextFileService private textFileService: ITextFileService, @IBackupFileService private backupFileService: IBackupFileService, @IWindowService private windowService: IWindowService, - @IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService, - @IEnvironmentService private environmentService: IEnvironmentService + @IWorkspaceEditingService private workspaceEditingService: IWorkspaceEditingService ) { super(stat => this.statToResource(stat)); @@ -1031,14 +1025,11 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { // 3.) run the move operation .then(() => { const targetResource = target.resource.with({ path: paths.join(target.resource.path, source.name) }); - let didHandleConflict = false; return this.fileService.moveFile(source.resource, targetResource).then(null, error => { // Conflict if ((error).fileOperationResult === FileOperationResult.FILE_MOVE_CONFLICT) { - didHandleConflict = true; - const confirm: IConfirmation = { message: nls.localize('confirmOverwriteMessage', "'{0}' already exists in the destination folder. Do you want to replace it?", source.name), detail: nls.localize('irreversible', "This action is irreversible!"), diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts index 3209fbc2a2e..771cde62269 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts @@ -10,7 +10,7 @@ import errors = require('vs/base/common/errors'); import URI from 'vs/base/common/uri'; import paths = require('vs/base/common/paths'); import { IEditorViewState, isCommonCodeEditor } from 'vs/editor/common/editorCommon'; -import { toResource, IEditorStacksModel, SideBySideEditorInput, IEditorGroup, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; +import { toResource, SideBySideEditorInput, IEditorGroup, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/parts/files/common/files'; import { ITextFileService, ITextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles'; import { FileOperationEvent, FileOperation, IFileService, FileChangeType, FileChangesEvent, indexOf } from 'vs/platform/files/common/files'; @@ -31,9 +31,8 @@ export class FileEditorTracker implements IWorkbenchContribution { protected closeOnFileDelete: boolean; - private stacks: IEditorStacksModel; private toUnbind: IDisposable[]; - private modelLoadQueue: ResourceQueue; + private modelLoadQueue: ResourceQueue; private activeOutOfWorkspaceWatchers: ResourceMap; constructor( @@ -47,8 +46,7 @@ export class FileEditorTracker implements IWorkbenchContribution { @IWorkspaceContextService private contextService: IWorkspaceContextService, ) { this.toUnbind = []; - this.stacks = editorGroupService.getStacksModel(); - this.modelLoadQueue = new ResourceQueue(); + this.modelLoadQueue = new ResourceQueue(); this.activeOutOfWorkspaceWatchers = new ResourceMap(); this.onConfigurationUpdated(configurationService.getConfiguration()); diff --git a/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts b/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts index 4f19a7f53e8..494443216a4 100644 --- a/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts +++ b/src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts @@ -19,8 +19,8 @@ import { Verbosity } from 'vs/platform/editor/common/editor'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IModelService } from 'vs/editor/common/services/modelService'; -function toResource(path) { - return URI.file(join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path)); +function toResource(self, path) { + return URI.file(join('C:\\', new Buffer(self.test.fullTitle()).toString('base64'), path)); } class ServiceAccessor { @@ -44,9 +44,9 @@ suite('Files - FileEditorInput', () => { }); test('Basics', function (done) { - let input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/file.js'), void 0); - const otherInput = instantiationService.createInstance(FileEditorInput, toResource.call(this, 'foo/bar/otherfile.js'), void 0); - const otherInputSame = instantiationService.createInstance(FileEditorInput, toResource.call(this, 'foo/bar/file.js'), void 0); + let input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/file.js'), void 0); + const otherInput = instantiationService.createInstance(FileEditorInput, toResource(this, 'foo/bar/otherfile.js'), void 0); + const otherInputSame = instantiationService.createInstance(FileEditorInput, toResource(this, 'foo/bar/file.js'), void 0); assert(input.matches(input)); assert(input.matches(otherInputSame)); @@ -58,13 +58,13 @@ suite('Files - FileEditorInput', () => { assert.strictEqual('file.js', input.getName()); - assert.strictEqual(toResource.call(this, '/foo/bar/file.js').fsPath, input.getResource().fsPath); + assert.strictEqual(toResource(this, '/foo/bar/file.js').fsPath, input.getResource().fsPath); assert(input.getResource() instanceof URI); - input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar.html'), void 0); + input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar.html'), void 0); - const inputToResolve: FileEditorInput = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/file.js'), void 0); - const sameOtherInput: FileEditorInput = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/file.js'), void 0); + const inputToResolve: FileEditorInput = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/file.js'), void 0); + const sameOtherInput: FileEditorInput = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/file.js'), void 0); return inputToResolve.resolve(true).then(resolved => { assert.ok(inputToResolve.isResolved()); @@ -86,16 +86,16 @@ suite('Files - FileEditorInput', () => { resolvedModelA.dispose(); - return inputToResolve.resolve(true).then((resolved: TextFileEditorModel) => { + return inputToResolve.resolve(true).then(resolved => { assert(resolvedModelA !== resolved); // Different instance, because input got disposed - let stat = resolved.getStat(); - return inputToResolve.resolve(true).then((resolved: TextFileEditorModel) => { - assert(stat !== resolved.getStat()); // Different stat, because resolve always goes to the server for refresh + let stat = (resolved as TextFileEditorModel).getStat(); + return inputToResolve.resolve(true).then(resolved => { + assert(stat !== (resolved as TextFileEditorModel).getStat()); // Different stat, because resolve always goes to the server for refresh - stat = resolved.getStat(); - return inputToResolve.resolve(false).then((resolved: TextFileEditorModel) => { - assert(stat === resolved.getStat()); // Same stat, because not refreshed + stat = (resolved as TextFileEditorModel).getStat(); + return inputToResolve.resolve(false).then(resolved => { + assert(stat === (resolved as TextFileEditorModel).getStat()); // Same stat, because not refreshed done(); }); @@ -108,10 +108,10 @@ suite('Files - FileEditorInput', () => { }); test('matches', function () { - const input1 = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); - const input2 = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); - const input3 = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/other.js'), void 0); - const input2Upper = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/UPDATEFILE.js'), void 0); + const input1 = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); + const input2 = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); + const input3 = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/other.js'), void 0); + const input2Upper = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/UPDATEFILE.js'), void 0); assert.strictEqual(input1.matches(null), false); assert.strictEqual(input1.matches(input1), true); @@ -122,7 +122,7 @@ suite('Files - FileEditorInput', () => { }); test('getEncoding/setEncoding', function (done) { - const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); + const input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); input.setEncoding('utf16', EncodingMode.Encode); assert.equal(input.getEncoding(), 'utf16'); @@ -137,7 +137,7 @@ suite('Files - FileEditorInput', () => { }); test('save', function (done) { - const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); + const input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); return input.resolve(true).then((resolved: TextFileEditorModel) => { resolved.textEditorModel.setValue('changed'); @@ -154,7 +154,7 @@ suite('Files - FileEditorInput', () => { }); test('revert', function (done) { - const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); + const input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); return input.resolve(true).then((resolved: TextFileEditorModel) => { resolved.textEditorModel.setValue('changed'); @@ -171,7 +171,7 @@ suite('Files - FileEditorInput', () => { }); test('resolve handles binary files', function (done) { - const input = instantiationService.createInstance(FileEditorInput, toResource.call(this, '/foo/bar/updatefile.js'), void 0); + const input = instantiationService.createInstance(FileEditorInput, toResource(this, '/foo/bar/updatefile.js'), void 0); accessor.textFileService.setResolveTextContentErrorOnce(new FileOperationError('error', FileOperationResult.FILE_IS_BINARY)); @@ -185,7 +185,7 @@ suite('Files - FileEditorInput', () => { }); test('disposes model when not open anymore', function (done) { - const resource = toResource.call(this, '/path/index.txt'); + const resource = toResource(this, '/path/index.txt'); const input = createFileInput(instantiationService, resource); diff --git a/src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts b/src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts index 93b1c4d0ae9..dab717dcf66 100644 --- a/src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts +++ b/src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts @@ -27,8 +27,8 @@ class TestFileEditorTracker extends FileEditorTracker { } } -function toResource(path) { - return URI.file(join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path)); +function toResource(self: any, path: string) { + return URI.file(join('C:\\', new Buffer(self.test.fullTitle()).toString('base64'), path)); } class ServiceAccessor { @@ -58,8 +58,8 @@ suite('Files - FileEditorTracker', () => { const tracker = instantiationService.createInstance(FileEditorTracker); assert.ok(tracker); - const parent = toResource.call(this, '/foo/bar'); - const resource = toResource.call(this, '/foo/bar/updatefile.js'); + const parent = toResource(this, '/foo/bar'); + const resource = toResource(this, '/foo/bar/updatefile.js'); let input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); @@ -72,7 +72,7 @@ suite('Files - FileEditorTracker', () => { input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); - const other = toResource.call(this, '/foo/barfoo'); + const other = toResource(this, '/foo/barfoo'); accessor.fileService.fireAfterOperation(new FileOperationEvent(other, FileOperation.DELETE)); assert.ok(!input.isDisposed()); @@ -81,7 +81,7 @@ suite('Files - FileEditorTracker', () => { assert.ok(input.isDisposed()); // Move - const to = toResource.call(this, '/foo/barfoo/change.js'); + const to: any = toResource(this, '/foo/barfoo/change.js'); accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, to)); assert.ok(input.isDisposed()); @@ -96,8 +96,8 @@ suite('Files - FileEditorTracker', () => { tracker.setCloseOnFileDelete(false); assert.ok(tracker); - const parent = toResource.call(this, '/foo/bar'); - const resource = toResource.call(this, '/foo/bar/updatefile.js'); + const parent = toResource(this, '/foo/bar'); + const resource = toResource(this, '/foo/bar/updatefile.js'); let input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); @@ -110,7 +110,7 @@ suite('Files - FileEditorTracker', () => { input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); - const other = toResource.call(this, '/foo/barfoo'); + const other = toResource(this, '/foo/barfoo'); accessor.fileService.fireAfterOperation(new FileOperationEvent(other, FileOperation.DELETE)); assert.ok(!input.isDisposed()); @@ -119,7 +119,7 @@ suite('Files - FileEditorTracker', () => { assert.ok(input.isDisposed()); // Move - const to = toResource.call(this, '/foo/barfoo/change.js'); + const to: any = toResource(this, '/foo/barfoo/change.js'); accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, to)); assert.ok(input.isDisposed()); @@ -133,8 +133,8 @@ suite('Files - FileEditorTracker', () => { const tracker = instantiationService.createInstance(FileEditorTracker); assert.ok(tracker); - const parent = toResource.call(this, '/foo/bar'); - const resource = toResource.call(this, '/foo/bar/updatefile.js'); + const parent = toResource(this, '/foo/bar'); + const resource = toResource(this, '/foo/bar/updatefile.js'); let input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); @@ -149,7 +149,7 @@ suite('Files - FileEditorTracker', () => { input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); - const other = toResource.call(this, '/foo/barfoo'); + const other = toResource(this, '/foo/barfoo'); accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource: other, type: FileChangeType.DELETED }])); assert.ok(!input.isDisposed()); @@ -173,7 +173,7 @@ suite('Files - FileEditorTracker', () => { tracker.setCloseOnFileDelete(false); assert.ok(tracker); - const resource = toResource.call(this, '/foo/bar/updatefile.js'); + const resource = toResource(this, '/foo/bar/updatefile.js'); let input = instantiationService.createInstance(FileEditorInput, resource, void 0); group.openEditor(input); @@ -187,7 +187,7 @@ suite('Files - FileEditorTracker', () => { test('file change event updates model', function (done) { const tracker = instantiationService.createInstance(FileEditorTracker); - const resource = toResource.call(this, '/path/index.txt'); + const resource = toResource(this, '/path/index.txt'); accessor.textFileService.models.loadOrCreate(resource).then((model: TextFileEditorModel) => { model.textEditorModel.setValue('Super Good'); diff --git a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts index fe9ecaa3fef..3f35b6d15b6 100644 --- a/src/vs/workbench/parts/html/browser/webviewFindWidget.ts +++ b/src/vs/workbench/parts/html/browser/webviewFindWidget.ts @@ -25,7 +25,7 @@ export class WebviewFindWidget extends SimpleFindWidget { if (this.webview !== null && val) { this.webview.find(val, { findNext: true, forward: !previous }); } - }; + } public hide() { super.hide(); diff --git a/src/vs/workbench/parts/markers/browser/markersPanel.ts b/src/vs/workbench/parts/markers/browser/markersPanel.ts index 5c811c3b975..86daa95eeb3 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanel.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanel.ts @@ -69,6 +69,7 @@ export class MarkersPanel extends Panel { @IEditorGroupService private editorGroupService: IEditorGroupService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IConfigurationService private configurationService: IConfigurationService, + // @ts-ignore unused injected service @IContextKeyService private contextKeyService: IContextKeyService, @ITelemetryService telemetryService: ITelemetryService, @IListService private listService: IListService, diff --git a/src/vs/workbench/parts/markers/browser/markersPanelActions.ts b/src/vs/workbench/parts/markers/browser/markersPanelActions.ts index ddb0a8b77be..a2c0a03bfff 100644 --- a/src/vs/workbench/parts/markers/browser/markersPanelActions.ts +++ b/src/vs/workbench/parts/markers/browser/markersPanelActions.ts @@ -117,6 +117,7 @@ export class FilterAction extends Action { public static ID: string = 'workbench.actions.problems.filter'; + // @ts-ignore unused property constructor(private markersPanel: MarkersPanel) { super(FilterAction.ID, Messages.MARKERS_PANEL_ACTION_TOOLTIP_FILTER, 'markers-panel-action-filter', true); } diff --git a/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts b/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts index a01620d3e42..9e9e050f737 100644 --- a/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/parts/markers/browser/markersTreeViewer.ts @@ -81,8 +81,11 @@ export class Renderer implements IRenderer { private static FILE_RESOURCE_TEMPLATE_ID = 'file-resource-template'; private static MARKER_TEMPLATE_ID = 'marker-template'; + // @ts-ignore unused property constructor(private actionRunner: IActionRunner, + // @ts-ignore unused property private actionProvider: IActionProvider, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @IInstantiationService private instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService diff --git a/src/vs/workbench/parts/output/browser/outputPanel.ts b/src/vs/workbench/parts/output/browser/outputPanel.ts index 811e8d69a05..73c2d9a89be 100644 --- a/src/vs/workbench/parts/output/browser/outputPanel.ts +++ b/src/vs/workbench/parts/output/browser/outputPanel.ts @@ -22,7 +22,6 @@ import { OutputEditors, OUTPUT_PANEL_ID, IOutputService, CONTEXT_IN_OUTPUT } fro import { SwitchOutputAction, SwitchOutputActionItem, ClearOutputAction, ToggleOutputScrollLockAction } from 'vs/workbench/parts/output/browser/outputActions'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; export class OutputPanel extends TextResourceEditor { @@ -38,10 +37,9 @@ export class OutputPanel extends TextResourceEditor { @IOutputService private outputService: IOutputService, @IContextKeyService private contextKeyService: IContextKeyService, @IEditorGroupService editorGroupService: IEditorGroupService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService ) { - super(telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, modeService, textFileService); + super(telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, textFileService); this.scopedInstantiationService = instantiationService; } diff --git a/src/vs/workbench/parts/output/browser/outputServices.ts b/src/vs/workbench/parts/output/browser/outputServices.ts index 6f7f7326885..37aa71b666d 100644 --- a/src/vs/workbench/parts/output/browser/outputServices.ts +++ b/src/vs/workbench/parts/output/browser/outputServices.ts @@ -91,7 +91,6 @@ export class OutputService implements IOutputService { private _onOutputChannel: Emitter; private _onActiveOutputChannel: Emitter; - private _outputLinkDetector: OutputLinkProvider; private _outputContentProvider: OutputContentProvider; private _outputPanel: OutputPanel; @@ -110,7 +109,7 @@ export class OutputService implements IOutputService { const channels = this.getChannels(); this.activeChannelId = this.storageService.get(OUTPUT_ACTIVE_CHANNEL_KEY, StorageScope.WORKSPACE, channels && channels.length > 0 ? channels[0].id : null); - this._outputLinkDetector = instantiationService.createInstance(OutputLinkProvider); + instantiationService.createInstance(OutputLinkProvider); this._outputContentProvider = instantiationService.createInstance(OutputContentProvider, this); diff --git a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts index fffca3a3e5e..d860eb770b9 100644 --- a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts +++ b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts @@ -17,7 +17,6 @@ import { ReportPerformanceIssueAction } from 'vs/workbench/electron-browser/acti import { TPromise } from 'vs/base/common/winjs.base'; import { join } from 'path'; import { localize } from 'vs/nls'; -import { toPromise, filterEvent } from 'vs/base/common/event'; import { readdir } from 'vs/base/node/pfs'; import { stopProfiling } from 'vs/base/node/profiler'; @@ -33,8 +32,8 @@ class StartupProfiler implements IWorkbenchContribution { ) { // wait for everything to be ready TPromise.join([ + lifecycleService.when(LifecyclePhase.Running), extensionService.onReady(), - toPromise(filterEvent(lifecycleService.onDidChangePhase, phase => phase === LifecyclePhase.Running)), ]).then(() => { this._stopProfiling(); }); diff --git a/src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts b/src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts index 2bf9edfc5c2..e8afc26ae6b 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts @@ -152,6 +152,7 @@ export class DefineKeybindingWidget extends Widget { constructor( parent: HTMLElement, + // @ts-ignore unused injected service @IKeybindingService private keybindingService: IKeybindingService, @IInstantiationService private instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService diff --git a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts index 386b2013334..b594c4cfff0 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts @@ -49,6 +49,7 @@ export class KeybindingsEditorInput extends EditorInput { public static ID: string = 'workbench.input.keybindings'; public readonly keybindingsModel: KeybindingsEditorModel; + // @ts-ignore unused injected service constructor( @IInstantiationService private instantiationService: IInstantiationService) { super(); this.keybindingsModel = instantiationService.createInstance(KeybindingsEditorModel, OS); @@ -106,6 +107,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor @IKeybindingEditingService private keybindingEditingService: IKeybindingEditingService, @IListService private listService: IListService, @IContextKeyService private contextKeyService: IContextKeyService, + // @ts-ignore unused injected service @IChoiceService private choiceService: IChoiceService, @IMessageService private messageService: IMessageService, @IClipboardService private clipboardService: IClipboardService, diff --git a/src/vs/workbench/parts/preferences/browser/preferencesActions.ts b/src/vs/workbench/parts/preferences/browser/preferencesActions.ts index 1bdd9b31166..8a31da0bdfc 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesActions.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesActions.ts @@ -114,6 +114,7 @@ export class OpenFolderSettingsAction extends Action { constructor( id: string, label: string, + // @ts-ignore unused injected service @IPreferencesService private preferencesService: IPreferencesService, @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, @ICommandService private commandService: ICommandService diff --git a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts index 82220081583..1acd6036909 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesEditor.ts @@ -36,7 +36,6 @@ import { Command } from 'vs/editor/common/editorCommonExtensions'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { IModeService } from 'vs/editor/common/services/modeService'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -120,6 +119,7 @@ export class PreferencesEditor extends BaseEditor { constructor( @IPreferencesService private preferencesService: IPreferencesService, + // @ts-ignore unused injected service @IEnvironmentService private environmentService: IEnvironmentService, @ITelemetryService telemetryService: ITelemetryService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @@ -698,18 +698,19 @@ export class EditableSettingsEditor extends BaseTextEditor { constructor( @ITelemetryService telemetryService: ITelemetryService, + // @ts-ignore unused injected service @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IInstantiationService instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService, @IThemeService themeService: IThemeService, @IPreferencesService private preferencesService: IPreferencesService, + // @ts-ignore unused injected service @IModelService private modelService: IModelService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService, @IEditorGroupService editorGroupService: IEditorGroupService ) { - super(EditableSettingsEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, modeService, textFileService, editorGroupService); + super(EditableSettingsEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); this._register({ dispose: () => dispose(this.modelDisposables) }); this.saveDelayer = new Delayer(1000); } @@ -769,18 +770,20 @@ export class DefaultPreferencesEditor extends BaseTextEditor { constructor( @ITelemetryService telemetryService: ITelemetryService, + // @ts-ignore unused injected service @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IInstantiationService instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService, @IThemeService themeService: IThemeService, + // @ts-ignore unused injected service @IPreferencesService private preferencesService: IPreferencesService, + // @ts-ignore unused injected service @IModelService private modelService: IModelService, - @IModeService modeService: IModeService, @ITextFileService textFileService: ITextFileService, @IEditorGroupService editorGroupService: IEditorGroupService ) { - super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, modeService, textFileService, editorGroupService); + super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService); } public createEditorControl(parent: Builder, configuration: IEditorOptions): editorCommon.IEditor { diff --git a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts index 07c1b5285be..9e7aebc3f21 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts @@ -6,6 +6,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import * as nls from 'vs/nls'; import { Delayer } from 'vs/base/common/async'; +import * as strings from 'vs/base/common/strings'; import { tail } from 'vs/base/common/arrays'; import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IAction } from 'vs/base/common/actions'; @@ -16,7 +17,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import { Range, IRange } from 'vs/editor/common/core/range'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, IConfigurationPropertySchema } from 'vs/platform/configuration/common/configurationRegistry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IPreferencesService, ISettingsGroup, ISetting, IPreferencesEditorModel, IFilterResult, ISettingsEditorModel, IScoredResults } from 'vs/workbench/parts/preferences/common/preferences'; +import { IPreferencesService, ISettingsGroup, ISetting, IPreferencesEditorModel, IFilterResult, ISettingsEditorModel, IScoredResults, IWorkbenchSettingsConfiguration } from 'vs/workbench/parts/preferences/common/preferences'; import { SettingsEditorModel, DefaultSettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/parts/preferences/common/preferencesModels'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser'; import { IContextMenuService, ContextSubMenu } from 'vs/platform/contextview/browser/contextView'; @@ -73,6 +74,7 @@ export class UserSettingsRenderer extends Disposable implements IPreferencesRend constructor(protected editor: ICodeEditor, public readonly preferencesModel: SettingsEditorModel, @IPreferencesService protected preferencesService: IPreferencesService, @ITelemetryService private telemetryService: ITelemetryService, + // @ts-ignore unused injected service @ITextFileService private textFileService: ITextFileService, @IConfigurationService private configurationService: IConfigurationService, @IInstantiationService protected instantiationService: IInstantiationService @@ -251,6 +253,7 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR constructor(protected editor: ICodeEditor, public readonly preferencesModel: DefaultSettingsEditorModel, @IPreferencesService protected preferencesService: IPreferencesService, + // @ts-ignore unused injected service @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IInstantiationService protected instantiationService: IInstantiationService ) { @@ -415,6 +418,7 @@ class DefaultSettingsHeaderRenderer extends Disposable { private settingsHeaderWidget: DefaultSettingsHeaderWidget; public onClick: Event; + // @ts-ignore unused property constructor(private editor: ICodeEditor, scope: ConfigurationScope) { super(); const title = scope === ConfigurationScope.RESOURCE ? nls.localize('defaultFolderSettingsTitle', "Default Folder Settings") : nls.localize('defaultSettingsTitle', "Default Settings"); @@ -432,7 +436,7 @@ class DefaultSettingsHeaderRenderer extends Disposable { export class SettingsGroupTitleRenderer extends Disposable implements HiddenAreasProvider { private _onHiddenAreasChanged: Emitter = new Emitter(); - get onHiddenAreasChanged(): Event { return this._onHiddenAreasChanged.event; }; + get onHiddenAreasChanged(): Event { return this._onHiddenAreasChanged.event; } private settingsGroups: ISettingsGroup[]; private hiddenGroups: ISettingsGroup[] = []; @@ -531,6 +535,7 @@ export class SettingsGroupTitleRenderer extends Disposable implements HiddenArea export class HiddenAreasRenderer extends Disposable { constructor(private editor: ICodeEditor, private hiddenAreasProviders: HiddenAreasProvider[], + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService ) { super(); @@ -551,8 +556,13 @@ export class HiddenAreasRenderer extends Disposable { } export class FeedbackWidgetRenderer extends Disposable { - private static DEFAULT_COMMENT_TEXT = 'Modify the below results to match your expectations. Assign scores to indicate their relevance. Replace this comment with any text feedback.'; + private static DEFAULT_COMMENT_TEXT = 'Replace this comment with any text feedback.'; private static DEFAULT_ALTS = ['alt 1', 'alt 2']; + private static INSTRUCTION_TEXT = [ + '// Modify the "resultScores" section to contain only your expected results. Assign scores to indicate their relevance.', + '// Results present in "resultScores" will be automatically "boosted" for this query, if they are not already at the top of the result set.', + '// Add phrase pairs to the "alts" section to have them considered to be synonyms in queries.' + ].join('\n'); private _feedbackWidget: FloatingClickWidget; private _currentResult: IFilterResult; @@ -562,7 +572,8 @@ export class FeedbackWidgetRenderer extends Disposable { @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @ITelemetryService private telemetryService: ITelemetryService, @IMessageService private messageService: IMessageService, - @IEnvironmentService private environmentService: IEnvironmentService + @IEnvironmentService private environmentService: IEnvironmentService, + @IConfigurationService private configurationService: IConfigurationService ) { super(); } @@ -585,7 +596,7 @@ export class FeedbackWidgetRenderer extends Disposable { } private getFeedback(): void { - if (!this.telemetryService.isOptedIn) { + if (!this.telemetryService.isOptedIn && this.environmentService.appQuality) { this.messageService.show(Severity.Error, 'Can\'t send feedback, user is opted out of telemetry'); return; } @@ -602,7 +613,7 @@ export class FeedbackWidgetRenderer extends Disposable { }); feedbackQuery['alts'] = [FeedbackWidgetRenderer.DEFAULT_ALTS]; - const contents = JSON.stringify(feedbackQuery, undefined, ' '); + const contents = FeedbackWidgetRenderer.INSTRUCTION_TEXT + '\n' + JSON.stringify(feedbackQuery, undefined, ' '); this.editorService.openEditor({ contents, language: 'json' }, /*sideBySide=*/true).then(feedbackEditor => { const sendFeedbackWidget = this._register(this.instantiationService.createInstance(FloatingClickWidget, feedbackEditor.getControl(), 'Send feedback', null)); sendFeedbackWidget.render(); @@ -620,7 +631,9 @@ export class FeedbackWidgetRenderer extends Disposable { private sendFeedback(feedbackEditor: ICodeEditor, result: IFilterResult, actualResults: IScoredResults): TPromise { const model = feedbackEditor.getModel(); - const expectedQueryLines = model.getLinesContent(); + const expectedQueryLines = model.getLinesContent() + .filter(line => !strings.startsWith(line, '//')); + let expectedQuery: any; try { expectedQuery = JSON.parse(expectedQueryLines.join('\n')); @@ -638,6 +651,8 @@ export class FeedbackWidgetRenderer extends Disposable { const altsAdded = expectedQuery.alts && expectedQuery.alts[0] && (expectedQuery.alts[0][0] !== FeedbackWidgetRenderer.DEFAULT_ALTS[0] || expectedQuery.alts[0][1] !== FeedbackWidgetRenderer.DEFAULT_ALTS[1]); const alts = altsAdded ? expectedQuery.alts : undefined; + const workbenchSettings = this.configurationService.getConfiguration().workbench.settings; + const autoIngest = workbenchSettings.experimentalFuzzySearchAutoIngestFeedback; /* __GDPR__ "settingsSearchResultFeedback" : { @@ -658,8 +673,9 @@ export class FeedbackWidgetRenderer extends Disposable { url: result.metadata.remoteUrl, duration: result.metadata.duration, timestamp: result.metadata.timestamp, - buildNumber: this.environmentService.debugSearch, - alts + buildNumber: this.environmentService.settingsSearchBuildId, + alts, + autoIngest }); } @@ -703,6 +719,7 @@ export class FilteredMatchesRenderer extends Disposable implements HiddenAreasPr public hiddenAreas: IRange[] = []; constructor(private editor: ICodeEditor, + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService ) { super(); @@ -807,6 +824,7 @@ export class HighlightMatchesRenderer extends Disposable { private decorationIds: string[] = []; constructor(private editor: ICodeEditor, + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService ) { super(); @@ -860,6 +878,7 @@ class EditSettingRenderer extends Disposable { constructor(private editor: ICodeEditor, private masterSettingsModel: ISettingsEditorModel, private settingHighlighter: SettingHighlighter, + // @ts-ignore unused injected service @IPreferencesService private preferencesService: IPreferencesService, @IInstantiationService private instantiationService: IInstantiationService, @IContextMenuService private contextMenuService: IContextMenuService @@ -1131,6 +1150,7 @@ class UnsupportedSettingsRenderer extends Disposable { constructor( private editor: editorCommon.ICommonCodeEditor, private settingsEditorModel: SettingsEditorModel, + // @ts-ignore unused injected service @IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService, @IMarkerService private markerService: IMarkerService, @IEnvironmentService private environmentService: IEnvironmentService diff --git a/src/vs/workbench/parts/preferences/browser/preferencesSearch.ts b/src/vs/workbench/parts/preferences/browser/preferencesSearch.ts index bf9d27cd179..eda9991fce8 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesSearch.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesSearch.ts @@ -52,7 +52,7 @@ export class PreferencesSearchProvider { } startSearch(filter: string, remote: boolean): PreferencesSearchModel { - return new PreferencesSearchModel(this, filter, remote); + return new PreferencesSearchModel(this, filter, remote, this.environmentService); } } @@ -60,11 +60,11 @@ export class PreferencesSearchModel { private _localProvider: LocalSearchProvider; private _remoteProvider: RemoteSearchProvider; - constructor(private provider: PreferencesSearchProvider, private filter: string, remote: boolean) { + constructor(private provider: PreferencesSearchProvider, private filter: string, remote: boolean, environmentService: IEnvironmentService) { this._localProvider = new LocalSearchProvider(filter); if (remote && filter) { - this._remoteProvider = new RemoteSearchProvider(filter, this.provider.endpoint); + this._remoteProvider = new RemoteSearchProvider(filter, this.provider.endpoint, environmentService); } } @@ -109,9 +109,9 @@ class RemoteSearchProvider { private _filter: string; private _remoteSearchP: TPromise; - constructor(filter: string, endpoint: IEndpointDetails) { + constructor(filter: string, endpoint: IEndpointDetails, private environmentService: IEnvironmentService) { this._filter = filter; - this._remoteSearchP = filter ? getSettingsFromBing(filter, endpoint) : TPromise.wrap(null); + this._remoteSearchP = filter ? this.getSettingsFromBing(filter, endpoint) : TPromise.wrap(null); } filterPreferences(preferencesModel: ISettingsEditorModel): TPromise { @@ -139,47 +139,47 @@ class RemoteSearchProvider { } }); } -} -function getSettingsFromBing(filter: string, endpoint: IEndpointDetails): TPromise { - const url = prepareUrl(filter, endpoint); - console.log('fetching: ' + url); - const start = Date.now(); - const p = fetch(url, { - headers: new Headers({ - 'User-Agent': 'request', - 'Content-Type': 'application/json; charset=utf-8', - 'api-key': endpoint.key + private getSettingsFromBing(filter: string, endpoint: IEndpointDetails): TPromise { + const url = prepareUrl(filter, endpoint, this.environmentService.settingsSearchBuildId); + console.log('fetching: ' + url); + const start = Date.now(); + const p = fetch(url, { + headers: new Headers({ + 'User-Agent': 'request', + 'Content-Type': 'application/json; charset=utf-8', + 'api-key': endpoint.key + }) }) - }) - .then(r => r.json()) - .then(result => { - const timestamp = Date.now(); - const duration = timestamp - start; - console.log('time: ' + duration / 1000); - const suggestions = (result.value || []) - .map(r => ({ - name: r.setting || r.Setting, - score: r['@search.score'] - })); + .then(r => r.json()) + .then(result => { + const timestamp = Date.now(); + const duration = timestamp - start; + console.log('time: ' + duration / 1000); + const suggestions = (result.value || []) + .map(r => ({ + name: r.setting || r.Setting, + score: r['@search.score'] + })); - const scoredResults = Object.create(null); - suggestions.forEach(s => { - const name = s.name - .replace(/^"/, '') - .replace(/"$/, ''); - scoredResults[name] = s.score; + const scoredResults = Object.create(null); + suggestions.forEach(s => { + const name = s.name + .replace(/^"/, '') + .replace(/"$/, ''); + scoredResults[name] = s.score; + }); + + return { + remoteUrl: url, + duration, + timestamp, + scoredResults + }; }); - return { - remoteUrl: url, - duration, - timestamp, - scoredResults - }; - }); - - return TPromise.as(p as any); + return TPromise.as(p as any); + } } const API_VERSION = 'api-version=2016-09-01-Preview'; @@ -193,7 +193,7 @@ function escapeSpecialChars(query: string): string { .trim(); } -function prepareUrl(query: string, endpoint: IEndpointDetails): string { +function prepareUrl(query: string, endpoint: IEndpointDetails, buildNumber: number): string { query = escapeSpecialChars(query); const boost = endpoint.boost || 1; const userQuery = `(${query})^${boost}`; @@ -201,7 +201,12 @@ function prepareUrl(query: string, endpoint: IEndpointDetails): string { // Appending Fuzzy after each word. query = query.replace(/\ +/g, '~ ') + '~'; - return `${endpoint.urlBase}?${API_VERSION}&search=${encodeURIComponent(userQuery + ' || ' + query)}&${QUERY_TYPE}&${SCORING_PROFILE}`; + let url = `${endpoint.urlBase}?${API_VERSION}&search=${encodeURIComponent(userQuery + ' || ' + query)}&${QUERY_TYPE}&${SCORING_PROFILE}`; + if (buildNumber) { + url += `&$filter startbuildno le ${buildNumber} and endbuildno ge ${buildNumber}`; + } + + return url; } class SettingMatches { diff --git a/src/vs/workbench/parts/preferences/browser/preferencesService.ts b/src/vs/workbench/parts/preferences/browser/preferencesService.ts index 41ada932bde..c9f691030ed 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesService.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesService.ts @@ -63,9 +63,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic @IFileService private fileService: IFileService, @IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService, @IMessageService private messageService: IMessageService, + // @ts-ignore unused injected service @IChoiceService private choiceService: IChoiceService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @IInstantiationService private instantiationService: IInstantiationService, + // @ts-ignore unused injected service @IStorageService private storageService: IStorageService, @IEnvironmentService private environmentService: IEnvironmentService, @ITelemetryService private telemetryService: ITelemetryService, diff --git a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts index cf03fd27d6f..0057f2d43d2 100644 --- a/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/parts/preferences/browser/preferencesWidgets.ts @@ -444,6 +444,7 @@ export class SearchWidget extends Widget { constructor(parent: HTMLElement, protected options: SearchOptions, @IContextViewService private contextViewService: IContextViewService, + // @ts-ignore unused injected service @IContextMenuService private contextMenuService: IContextMenuService, @IInstantiationService protected instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService @@ -593,6 +594,7 @@ export class FloatingClickWidget extends Widget implements IOverlayWidget { constructor( private editor: ICodeEditor, private label: string, + // @ts-ignore unused property private keyBindingAction: string, @IKeybindingService keybindingService: IKeybindingService, @IThemeService private themeService: IThemeService diff --git a/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts b/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts index 8549fbdd25a..65e93c3b212 100644 --- a/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts +++ b/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts @@ -77,6 +77,7 @@ export class KeybindingsEditorModel extends EditorModel { private modifierLabels: ModifierLabels; constructor( + // @ts-ignore unused property private os: OperatingSystem, @IKeybindingService private keybindingsService: IKeybindingService, @IExtensionService private extensionService: IExtensionService @@ -244,6 +245,7 @@ class KeybindingItemMatches { public readonly whenMatches: IMatch[] = null; public readonly keybindingMatches: KeybindingMatches = null; + // @ts-ignore unused property constructor(private modifierLabels: ModifierLabels, keybindingItem: IKeybindingItem, private searchValue: string, private words: string[], private keybindingWords: string[], private completeMatch: boolean) { this.commandIdMatches = this.matches(searchValue, keybindingItem.command, or(matchesWords, matchesCamelCase), words); this.commandLabelMatches = keybindingItem.commandLabel ? this.matches(searchValue, keybindingItem.commandLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandLabel, true), words) : null; diff --git a/src/vs/workbench/parts/preferences/common/preferences.ts b/src/vs/workbench/parts/preferences/common/preferences.ts index 9e102bf5051..1490704ca4a 100644 --- a/src/vs/workbench/parts/preferences/common/preferences.ts +++ b/src/vs/workbench/parts/preferences/common/preferences.ts @@ -23,6 +23,7 @@ export interface IWorkbenchSettingsConfiguration { experimentalFuzzySearchEndpoint: string; experimentalFuzzySearchKey: string; experimentalFuzzySearchBoost: number; + experimentalFuzzySearchAutoIngestFeedback: boolean; } }; } diff --git a/src/vs/workbench/parts/preferences/common/preferencesModels.ts b/src/vs/workbench/parts/preferences/common/preferencesModels.ts index e75d3ec9f63..f68e560cf0f 100644 --- a/src/vs/workbench/parts/preferences/common/preferencesModels.ts +++ b/src/vs/workbench/parts/preferences/common/preferencesModels.ts @@ -372,6 +372,7 @@ export class WorkspaceConfigModel extends SettingsEditorModel implements ISettin _configurationTarget: ConfigurationTarget, onDispose: Event, @IFileService private fileService: IFileService, + // @ts-ignore unused injected service @ITextModelService private textModelResolverService: ITextModelService, @ITextFileService textFileService: ITextFileService ) { @@ -810,6 +811,7 @@ class SettingsContentBuilder { return this._contentByLines[this._contentByLines.length - 1] || ''; } + // @ts-ignore unused property constructor(private _rangeOffset = 0, private _maxLines = Infinity) { this._contentByLines = []; } diff --git a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts index 27ed3dfa3ff..2148ec88e17 100644 --- a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts @@ -14,7 +14,7 @@ import { Action } from 'vs/base/common/actions'; import { toErrorMessage } from 'vs/base/common/errorMessage'; import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen'; import { QuickOpenEntryGroup, IHighlight, QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel'; -import { SyncActionDescriptor, IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; +import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { QuickOpenHandler, IWorkbenchQuickOpenConfiguration } from 'vs/workbench/browser/quickopen'; import { IEditorAction, IEditor, ICommonCodeEditor } from 'vs/editor/common/editorCommon'; @@ -157,7 +157,6 @@ export class ClearCommandHistoryAction extends Action { constructor( id: string, label: string, - @IStorageService private storageService: IStorageService, @IConfigurationService private configurationService: IConfigurationService ) { super(id, label); @@ -175,6 +174,7 @@ export class ClearCommandHistoryAction extends Action { } @editorAction +// @ts-ignore @editorAction uses the class class CommandPaletteEditorAction extends EditorAction { constructor() { @@ -322,28 +322,6 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup { } } -class CommandEntry extends BaseCommandEntry { - - constructor( - commandId: string, - keybinding: ResolvedKeybinding, - label: string, - meta: string, - highlights: { label: IHighlight[], alias: IHighlight[] }, - private actionDescriptor: SyncActionDescriptor, - onBeforeRun: (commandId: string) => void, - @IInstantiationService private instantiationService: IInstantiationService, - @IMessageService messageService: IMessageService, - @ITelemetryService telemetryService: ITelemetryService - ) { - super(commandId, keybinding, label, meta, highlights, onBeforeRun, messageService, telemetryService); - } - - protected getAction(): Action | IEditorAction { - return this.instantiationService.createInstance(this.actionDescriptor.syncDescriptor); - } -} - class EditorActionCommandEntry extends BaseCommandEntry { constructor( @@ -402,7 +380,6 @@ export class CommandsHandler extends QuickOpenHandler { @IInstantiationService private instantiationService: IInstantiationService, @IKeybindingService private keybindingService: IKeybindingService, @IMenuService private menuService: IMenuService, - @IContextKeyService private contextKeyService: IContextKeyService, @IConfigurationService private configurationService: IConfigurationService ) { super(); diff --git a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts index b467e7526c4..9f0570fbc06 100644 --- a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts +++ b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts @@ -9,7 +9,6 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { Registry } from 'vs/platform/registry/common/platform'; import { IMessageService } from 'vs/platform/message/common/message'; -import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences'; import { IWindowsService, IWindowService, IWindowsConfiguration } from 'vs/platform/windows/common/windows'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { localize } from 'vs/nls'; @@ -44,7 +43,6 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution { @IWindowsService private windowsService: IWindowsService, @IWindowService private windowService: IWindowService, @IConfigurationService private configurationService: IConfigurationService, - @IPreferencesService private preferencesService: IPreferencesService, @IEnvironmentService private envService: IEnvironmentService, @IMessageService private messageService: IMessageService, @IWorkspaceContextService private contextService: IWorkspaceContextService, diff --git a/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts b/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts index 22d8ab03a1f..5275bc6cdd4 100644 --- a/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts +++ b/src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts @@ -194,6 +194,7 @@ class DirtyDiffWidget extends PeekViewWidget { private model: DirtyDiffModel, @IThemeService private themeService: IThemeService, @IInstantiationService private instantiationService: IInstantiationService, + // @ts-ignore unused injected service @IMenuService private menuService: IMenuService, @IKeybindingService private keybindingService: IKeybindingService, @IMessageService private messageService: IMessageService, @@ -467,6 +468,7 @@ export class DirtyDiffController implements IEditorContribution { private model: DirtyDiffModel | null = null; private widget: DirtyDiffWidget | null = null; + // @ts-ignore unused property private currentLineNumber: number = -1; private currentIndex: number = -1; private readonly isDirtyDiffVisible: IContextKey; @@ -478,6 +480,7 @@ export class DirtyDiffController implements IEditorContribution { constructor( private editor: ICodeEditor, @IContextKeyService contextKeyService: IContextKeyService, + // @ts-ignore unused injected service @IThemeService private themeService: IThemeService, @IInstantiationService private instantiationService: IInstantiationService ) { @@ -872,9 +875,12 @@ export class DirtyDiffModel { constructor( private _editorModel: IModel, @ISCMService private scmService: ISCMService, + // @ts-ignore unused injected service @IModelService private modelService: IModelService, @IEditorWorkerService private editorWorkerService: IEditorWorkerService, + // @ts-ignore unused injected service @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @ITextModelService private textModelResolverService: ITextModelService ) { @@ -1018,9 +1024,11 @@ export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution, private disposables: IDisposable[] = []; constructor( + // @ts-ignore unused injected service @IMessageService private messageService: IMessageService, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @IInstantiationService private instantiationService: IInstantiationService ) { diff --git a/src/vs/workbench/parts/scm/electron-browser/scmMenus.ts b/src/vs/workbench/parts/scm/electron-browser/scmMenus.ts index 89e93eccac8..fe15f294473 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scmMenus.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scmMenus.ts @@ -28,6 +28,7 @@ export class SCMMenus implements IDisposable { private disposables: IDisposable[] = []; constructor( + // @ts-ignore unused property private provider: ISCMProvider | undefined, @IContextKeyService contextKeyService: IContextKeyService, @IMenuService private menuService: IMenuService diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 7238c2a7060..0c72fa5787d 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -123,7 +123,6 @@ export class OpenFileHandler extends QuickOpenHandler { @IWorkbenchThemeService private themeService: IWorkbenchThemeService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @ISearchService private searchService: ISearchService, - @IConfigurationService private configurationService: IConfigurationService, @IEnvironmentService private environmentService: IEnvironmentService ) { super(); diff --git a/src/vs/workbench/parts/search/browser/patternInputWidget.ts b/src/vs/workbench/parts/search/browser/patternInputWidget.ts index e282dfcb600..d3101e9b681 100644 --- a/src/vs/workbench/parts/search/browser/patternInputWidget.ts +++ b/src/vs/workbench/parts/search/browser/patternInputWidget.ts @@ -37,6 +37,7 @@ export class PatternInputWidget extends Widget { private ariaLabel: string; private domNode: HTMLElement; + // @ts-ignore unused property private inputNode: HTMLInputElement; protected inputBox: InputBox; @@ -167,8 +168,7 @@ export class PatternInputWidget extends Widget { placeholder: this.placeholder || '', ariaLabel: this.ariaLabel || '', validationOptions: { - validation: null, - showMessage: true + validation: null } }); this._register(attachInputBoxStyler(this.inputBox, this.themeService)); diff --git a/src/vs/workbench/parts/search/browser/replaceService.ts b/src/vs/workbench/parts/search/browser/replaceService.ts index 2a302d947ea..90c0895a44d 100644 --- a/src/vs/workbench/parts/search/browser/replaceService.ts +++ b/src/vs/workbench/parts/search/browser/replaceService.ts @@ -99,15 +99,17 @@ export class ReplaceService implements IReplaceService { @ITelemetryService private telemetryService: ITelemetryService, @IFileService private fileService: IFileService, @IEditorService private editorService: IWorkbenchEditorService, + // @ts-ignore unused injected service @IInstantiationService private instantiationService: IInstantiationService, @ITextModelService private textModelResolverService: ITextModelService, + // @ts-ignore unused injected service @ISearchWorkbenchService private searchWorkbenchService: ISearchWorkbenchService ) { } - public replace(match: Match): TPromise - public replace(files: FileMatch[], progress?: IProgressRunner): TPromise - public replace(match: FileMatchOrMatch, progress?: IProgressRunner, resource?: URI): TPromise + public replace(match: Match): TPromise; + public replace(files: FileMatch[], progress?: IProgressRunner): TPromise; + public replace(match: FileMatchOrMatch, progress?: IProgressRunner, resource?: URI): TPromise; public replace(arg: any, progress: IProgressRunner = null, resource: URI = null): TPromise { let bulkEdit: BulkEdit = createBulkEdit(this.textModelResolverService, null, this.fileService); diff --git a/src/vs/workbench/parts/search/browser/search.contribution.ts b/src/vs/workbench/parts/search/browser/search.contribution.ts index af48f7bc74c..0431d6bea30 100644 --- a/src/vs/workbench/parts/search/browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/browser/search.contribution.ts @@ -172,6 +172,7 @@ CommandsRegistry.registerCommand(searchActions.FindInFolderAction.ID, searchActi class ExplorerViewerActionContributor extends ActionBarContributor { private _instantiationService: IInstantiationService; + // @ts-ignore unused injected service private _contextService: IWorkspaceContextService; constructor( @IInstantiationService instantiationService: IInstantiationService, @IWorkspaceContextService contextService: IWorkspaceContextService) { diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index 55e8c831da5..b9939f0339f 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -369,8 +369,8 @@ export class FindInWorkspaceAction extends Action { } public run(event?: any): TPromise { - return this.viewletService.openViewlet(Constants.VIEWLET_ID, true).then((viewlet: SearchViewlet) => { - viewlet.searchInFolder(null); + return this.viewletService.openViewlet(Constants.VIEWLET_ID, true).then(viewlet => { + (viewlet as SearchViewlet).searchInFolder(null); }); } } @@ -406,9 +406,9 @@ export const findInFolderCommand = (accessor: ServicesAccessor, resource?: URI) } } - viewletService.openViewlet(Constants.VIEWLET_ID, true).then((viewlet: SearchViewlet) => { + viewletService.openViewlet(Constants.VIEWLET_ID, true).then(viewlet => { if (resource) { - viewlet.searchInFolder(resource); + (viewlet as SearchViewlet).searchInFolder(resource); } }).done(null, errors.onUnexpectedError); }; @@ -480,8 +480,8 @@ export class FocusNextSearchResultAction extends Action { } public run(): TPromise { - return this.viewletService.openViewlet(Constants.VIEWLET_ID).then((searchViewlet: SearchViewlet) => { - searchViewlet.selectNextMatch(); + return this.viewletService.openViewlet(Constants.VIEWLET_ID).then(searchViewlet => { + (searchViewlet as SearchViewlet).selectNextMatch(); }); } } @@ -495,8 +495,8 @@ export class FocusPreviousSearchResultAction extends Action { } public run(): TPromise { - return this.viewletService.openViewlet(Constants.VIEWLET_ID).then((searchViewlet: SearchViewlet) => { - searchViewlet.selectPreviousMatch(); + return this.viewletService.openViewlet(Constants.VIEWLET_ID).then(searchViewlet => { + (searchViewlet as SearchViewlet).selectPreviousMatch(); }); } } @@ -518,10 +518,10 @@ export abstract class AbstractSearchAndReplaceAction extends Action { let navigator: INavigator = this.getNavigatorAt(element, viewer); if (element instanceof FolderMatch) { // If file match is removed then next element is the next file match - while (!!navigator.next() && !(navigator.current() instanceof FolderMatch)) { }; + while (!!navigator.next() && !(navigator.current() instanceof FolderMatch)) { } } else if (element instanceof FileMatch) { // If file match is removed then next element is the next file match - while (!!navigator.next() && !(navigator.current() instanceof FileMatch)) { }; + while (!!navigator.next() && !(navigator.current() instanceof FileMatch)) { } } else { navigator.next(); } @@ -583,6 +583,7 @@ export class RemoveAction extends AbstractSearchAndReplaceAction { export class ReplaceAllAction extends AbstractSearchAndReplaceAction { constructor(private viewer: ITree, private fileMatch: FileMatch, private viewlet: SearchViewlet, + // @ts-ignore unused injected service @IReplaceService private replaceService: IReplaceService, @IKeybindingService keyBindingService: IKeybindingService, @ITelemetryService private telemetryService: ITelemetryService) { diff --git a/src/vs/workbench/parts/search/browser/searchResultsView.ts b/src/vs/workbench/parts/search/browser/searchResultsView.ts index 522ae4e54ef..d9eebd8932c 100644 --- a/src/vs/workbench/parts/search/browser/searchResultsView.ts +++ b/src/vs/workbench/parts/search/browser/searchResultsView.ts @@ -155,6 +155,7 @@ export class SearchRenderer extends Disposable implements IRenderer { constructor( actionRunner: IActionRunner, private viewlet: SearchViewlet, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @IInstantiationService private instantiationService: IInstantiationService, @IThemeService private themeService: IThemeService diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index 6cd49dd06a5..679dd2d65bd 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -71,9 +71,11 @@ export class SearchViewlet extends Viewlet { private isDisposed: boolean; + // @ts-ignore unused property private loading: boolean; private queryBuilder: QueryBuilder; private viewModel: SearchModel; + // @ts-ignore unused property private callOnModelChange: lifecycle.IDisposable[]; private viewletVisible: IContextKey; @@ -88,6 +90,7 @@ export class SearchViewlet extends Viewlet { private actionRegistry: { [key: string]: Action; }; private tree: ITree; private viewletSettings: any; + // @ts-ignore unused property private domNode: Builder; private messages: Builder; private searchWidgetsContainer: Builder; @@ -254,7 +257,7 @@ export class SearchViewlet extends Viewlet { this.createSearchResultsView(builder); - this.actionRegistry = {}; + this.actionRegistry = {}; let actions: Action[] = [new CollapseDeepestExpandedLevelAction(this), new RefreshAction(this), new ClearSearchResultsAction(this)]; actions.forEach((action) => { this.actionRegistry[action.id] = action; diff --git a/src/vs/workbench/parts/search/common/searchModel.ts b/src/vs/workbench/parts/search/common/searchModel.ts index 717213f614c..a3ada6ff325 100644 --- a/src/vs/workbench/parts/search/common/searchModel.ts +++ b/src/vs/workbench/parts/search/common/searchModel.ts @@ -348,6 +348,7 @@ export class FolderMatch extends Disposable { private _unDisposedFileMatches: ResourceMap; private _replacingAll: boolean = false; + // @ts-ignore unused injected service constructor(private _resource: URI, private _id: string, private _index: number, private _query: ISearchQuery, private _parent: SearchResult, private _searchModel: SearchModel, @IReplaceService private replaceService: IReplaceService, @ITelemetryService private telemetryService: ITelemetryService, @IInstantiationService private instantiationService: IInstantiationService) { super(); @@ -497,6 +498,7 @@ export class SearchResult extends Disposable { private _folderMatches: FolderMatch[] = []; private _folderMatchesMap: TernarySearchTree = TernarySearchTree.forPaths(); + // @ts-ignore unused property private _query: ISearchQuery = null; private _showHighlights: boolean; diff --git a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts index 4cf542b63a9..5f5fa458e07 100644 --- a/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts +++ b/src/vs/workbench/parts/search/test/common/queryBuilder.test.ts @@ -356,12 +356,12 @@ suite('QueryBuilder', () => { includePattern); } - function testIncludesDataItem([includePattern, expectedResult]): void { - testIncludes(includePattern, expectedResult); + function testIncludesDataItem([includePattern, expectedResult]: [string, ISearchPathsResult]): void { + testIncludes(includePattern, expectedResult); } test('absolute includes', () => { - [ + const cases: [string, ISearchPathsResult][] = [ [ fixPath('/foo/bar'), { @@ -425,11 +425,12 @@ suite('QueryBuilder', () => { }] } ] - ].forEach(testIncludesDataItem); + ]; + cases.forEach(testIncludesDataItem); }); test('relative includes w/single root folder', () => { - [ + const cases: [string, ISearchPathsResult][] = [ [ './a', { @@ -468,7 +469,8 @@ suite('QueryBuilder', () => { }] } ], - ].forEach(testIncludesDataItem); + ]; + cases.forEach(testIncludesDataItem); }); test('relative includes w/two root folders', () => { @@ -476,7 +478,7 @@ suite('QueryBuilder', () => { mockWorkspace.folders = toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }, { path: getUri(ROOT_2).fsPath }]); mockWorkspace.configuration = uri.file(fixPath('config')); - [ + const cases: [string, ISearchPathsResult][] = [ [ './root1', { @@ -507,7 +509,8 @@ suite('QueryBuilder', () => { }] } ] - ].forEach(testIncludesDataItem); + ]; + cases.forEach(testIncludesDataItem); }); test('relative includes w/multiple ambiguous root folders', () => { @@ -516,7 +519,7 @@ suite('QueryBuilder', () => { mockWorkspace.folders = toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }, { path: getUri(ROOT_2).fsPath }, { path: getUri(ROOT_3).fsPath }]); mockWorkspace.configuration = uri.file(fixPath('/config')); - [ + const cases: [string, ISearchPathsResult][] = [ [ '', { @@ -579,7 +582,8 @@ suite('QueryBuilder', () => { }] } ] - ].forEach(testIncludesDataItem); + ]; + cases.forEach(testIncludesDataItem); }); }); }); diff --git a/src/vs/workbench/parts/search/test/common/searchModel.test.ts b/src/vs/workbench/parts/search/test/common/searchModel.test.ts index c969aa57335..315d2b182fe 100644 --- a/src/vs/workbench/parts/search/test/common/searchModel.test.ts +++ b/src/vs/workbench/parts/search/test/common/searchModel.test.ts @@ -44,7 +44,7 @@ const nullEvent = new class { suite('SearchModel', () => { let instantiationService: TestInstantiationService; - let restoreStubs; + let restoreStubs: sinon.SinonStub[]; const testSearchStats: IUncachedSearchStats = { fromCache: false, @@ -306,7 +306,7 @@ suite('SearchModel', () => { return { preview, lineNumber, offsetAndLengths }; } - function stub(arg1, arg2, arg3): sinon.SinonStub { + function stub(arg1: any, arg2: any, arg3: any): sinon.SinonStub { const stub = sinon.stub(arg1, arg2, arg3); restoreStubs.push(stub); return stub; diff --git a/src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts b/src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts index 6ed72114838..37bd918e9d4 100644 --- a/src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts +++ b/src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts @@ -52,6 +52,7 @@ class Args { } @editorAction +// @ts-ignore @editorAction uses the class class InsertSnippetAction extends EditorAction { constructor() { diff --git a/src/vs/workbench/parts/snippets/electron-browser/snippets.contribution.ts b/src/vs/workbench/parts/snippets/electron-browser/snippets.contribution.ts index 1e83ba2ab3f..b262f72df95 100644 --- a/src/vs/workbench/parts/snippets/electron-browser/snippets.contribution.ts +++ b/src/vs/workbench/parts/snippets/electron-browser/snippets.contribution.ts @@ -133,8 +133,8 @@ export class Snippet { } } -namespace OpenSnippetsAction { +{ const id = 'workbench.action.openSnippets'; CommandsRegistry.registerCommand(id, accessor => { diff --git a/src/vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution.ts b/src/vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution.ts index 55567eec11f..3fa92e9391e 100644 --- a/src/vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution.ts +++ b/src/vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution.ts @@ -122,6 +122,7 @@ class LanguageSurvey { class LanguageSurveysContribution implements IWorkbenchContribution { + // @ts-ignore unused property private surveys: LanguageSurvey[]; constructor( diff --git a/src/vs/workbench/parts/tasks/browser/quickOpen.ts b/src/vs/workbench/parts/tasks/browser/quickOpen.ts index 3298cbc6126..d534e3707c7 100644 --- a/src/vs/workbench/parts/tasks/browser/quickOpen.ts +++ b/src/vs/workbench/parts/tasks/browser/quickOpen.ts @@ -200,6 +200,7 @@ export class QuickOpenActionContributor extends ActionBarContributor { private action: CustomizeTaskAction; + // @ts-ignore unused injected service constructor( @ITaskService private taskService: ITaskService, @IQuickOpenService private quickOpenService: IQuickOpenService) { super(); this.action = new CustomizeTaskAction(taskService, quickOpenService); diff --git a/src/vs/workbench/parts/tasks/common/problemCollectors.ts b/src/vs/workbench/parts/tasks/common/problemCollectors.ts index c40e58579b1..c6222b5902a 100644 --- a/src/vs/workbench/parts/tasks/common/problemCollectors.ts +++ b/src/vs/workbench/parts/tasks/common/problemCollectors.ts @@ -297,6 +297,7 @@ export enum ProblemHandlingStrategy { export class StartStopProblemCollector extends AbstractProblemCollector implements IProblemMatcher { private owners: string[]; + // @ts-ignore unused property private strategy: ProblemHandlingStrategy; private currentOwner: string; diff --git a/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts b/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts index ce52f2c6536..77406c82d73 100644 --- a/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts +++ b/src/vs/workbench/parts/tasks/common/taskDefinitionRegistry.ts @@ -101,7 +101,7 @@ class TaskDefinitionRegistryImpl implements ITaskDefinitionRegistry { this.taskTypes[type.taskType] = type; } } - }; + } } catch (error) { } resolve(undefined); diff --git a/src/vs/workbench/parts/tasks/electron-browser/media/task.contribution.css b/src/vs/workbench/parts/tasks/electron-browser/media/task.contribution.css index b0acde0d340..05c596a162b 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/media/task.contribution.css +++ b/src/vs/workbench/parts/tasks/electron-browser/media/task.contribution.css @@ -32,8 +32,7 @@ vertical-align: top; } -.task-statusbar-item-progress { - width: 6px; +.task-statusbar-item-building { height: 18px; padding: 0px 2px 0px 2px; display: inline-block; @@ -44,7 +43,6 @@ .task-statusbar-item-label { display: inline-block; cursor: pointer; - padding: 0 5px 0 0; } .task-statusbar-item-label > .task-statusbar-item-label-counter { diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index 7d1628523d9..4eb99abea9a 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -71,7 +71,7 @@ import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; -import { ITaskSystem, ITaskResolver, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, TaskSystemEvents, TaskTerminateResponse } from 'vs/workbench/parts/tasks/common/taskSystem'; +import { ITaskSystem, ITaskResolver, ITaskSummary, TaskExecuteKind, TaskError, TaskErrors, TaskSystemEvents, TaskTerminateResponse } from 'vs/workbench/parts/tasks/common/taskSystem'; import { Task, CustomTask, ConfiguringTask, ContributedTask, InMemoryTask, TaskSet, TaskGroup, GroupType, ExecutionEngine, JsonSchemaVersion, TaskSourceKind, TaskIdentifier, TaskSorter } from 'vs/workbench/parts/tasks/common/tasks'; import { ITaskService, TaskServiceEvents, ITaskProvider, TaskEvent, RunOptions, CustomizationProperties } from 'vs/workbench/parts/tasks/common/taskService'; import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates'; @@ -97,11 +97,6 @@ namespace ConfigureTaskAction { export const TEXT = nls.localize('ConfigureTaskRunnerAction.label', "Configure Task"); } -namespace ConfigureBuildTaskAction { - export const ID = 'workbench.action.tasks.configureBuildTask'; - export const TEXT = nls.localize('ConfigureBuildTaskAction.label', "Configure Build Task"); -} - class CloseMessageAction extends Action { public static ID = 'workbench.action.build.closeMessage'; @@ -120,30 +115,14 @@ class CloseMessageAction extends Action { } } -class ViewTerminalAction extends Action { - - public static ID = 'workbench.action.build.viewTerminal'; - public static TEXT = nls.localize('ShowTerminalAction.label', 'View Terminal'); - - constructor( @ITerminalService private terminalService: ITerminalService) { - super(ViewTerminalAction.ID, ViewTerminalAction.TEXT); - } - - public run(): TPromise { - this.terminalService.showPanel(); - return TPromise.as(undefined); - } -} - class BuildStatusBarItem extends Themable implements IStatusbarItem { - private intervalToken: any; private activeCount: number; - private static progressChars: string = '|/-\\'; private icons: HTMLElement[]; constructor( @IPanelService private panelService: IPanelService, @IMarkerService private markerService: IMarkerService, + // @ts-ignore unused injected service @IOutputService private outputService: IOutputService, @ITaskService private taskService: ITaskService, @IPartService private partService: IPartService, @@ -174,7 +153,6 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { let callOnDispose: IDisposable[] = []; const element = document.createElement('div'); - const progress = document.createElement('div'); const label = document.createElement('a'); const errorIcon = document.createElement('div'); const warningIcon = document.createElement('div'); @@ -182,14 +160,10 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { const error = document.createElement('div'); const warning = document.createElement('div'); const info = document.createElement('div'); + const building = document.createElement('div'); Dom.addClass(element, 'task-statusbar-item'); - Dom.addClass(progress, 'task-statusbar-item-progress'); - element.appendChild(progress); - progress.innerHTML = BuildStatusBarItem.progressChars[0]; - $(progress).hide(); - Dom.addClass(label, 'task-statusbar-item-label'); element.appendChild(label); element.title = nls.localize('problems', "Problems"); @@ -222,6 +196,12 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { label.appendChild(info); $(info).hide(); + Dom.addClass(building, 'task-statusbar-item-building'); + element.appendChild(building); + building.innerHTML = nls.localize('building', 'Building...'); + $(building).hide(); + + callOnDispose.push(Dom.addDisposableListener(label, 'click', (e: MouseEvent) => { const panel = this.panelService.getActivePanel(); if (panel && panel.getId() === Constants.MARKERS_PANEL_ID) { @@ -261,17 +241,7 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { } this.activeCount++; if (this.activeCount === 1) { - let index = 1; - let chars = BuildStatusBarItem.progressChars; - progress.innerHTML = chars[0]; - this.intervalToken = setInterval(() => { - progress.innerHTML = chars[index]; - index++; - if (index >= chars.length) { - index = 0; - } - }, 50); - $(progress).show(); + $(building).show(); } })); @@ -284,11 +254,7 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { if (this.activeCount > 0) { this.activeCount--; if (this.activeCount === 0) { - $(progress).hide(); - if (this.intervalToken) { - clearInterval(this.intervalToken); - this.intervalToken = null; - } + $(building).hide(); } } })); @@ -298,11 +264,7 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { return; } if (this.activeCount !== 0) { - $(progress).hide(); - if (this.intervalToken) { - clearInterval(this.intervalToken); - this.intervalToken = null; - } + $(building).hide(); this.activeCount = 0; } })); @@ -335,12 +297,17 @@ class BuildStatusBarItem extends Themable implements IStatusbarItem { class TaskStatusBarItem extends Themable implements IStatusbarItem { constructor( + // @ts-ignore unused injected service @IPanelService private panelService: IPanelService, + // @ts-ignore unused injected service @IMarkerService private markerService: IMarkerService, + // @ts-ignore unused injected service @IOutputService private outputService: IOutputService, @ITaskService private taskService: ITaskService, + // @ts-ignore unused injected service @IPartService private partService: IPartService, @IThemeService themeService: IThemeService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, ) { super(themeService); @@ -397,40 +364,6 @@ class TaskStatusBarItem extends Themable implements IStatusbarItem { } } -interface TaskServiceEventData { - error?: any; -} - -class NullTaskSystem extends EventEmitter implements ITaskSystem { - public run(task: Task): ITaskExecuteResult { - return { - kind: TaskExecuteKind.Started, - promise: TPromise.as({}) - }; - } - public revealTask(task: Task): boolean { - return false; - } - public isActive(): TPromise { - return TPromise.as(false); - } - public isActiveSync(): boolean { - return false; - } - public getActiveTasks(): Task[] { - return []; - } - public canAutoTerminate(): boolean { - return true; - } - public terminate(task: string | Task): TPromise { - return TPromise.as({ success: true, task: undefined }); - } - public terminateAll(): TPromise { - return TPromise.as([]); - } -} - class ProblemReporter implements TaskConfig.IProblemReporter { private _validationStatus: ValidationStatus; @@ -548,6 +481,7 @@ class TaskService extends EventEmitter implements ITaskService { public static OutputChannelId: string = 'tasks'; public static OutputChannelLabel: string = nls.localize('tasks', "Tasks"); + // @ts-ignore unused injected service private modeService: IModeService; private configurationService: IConfigurationService; private markerService: IMarkerService; @@ -588,6 +522,7 @@ class TaskService extends EventEmitter implements ITaskService { @ILifecycleService lifecycleService: ILifecycleService, @IModelService modelService: IModelService, @IExtensionService extensionService: IExtensionService, @IQuickOpenService quickOpenService: IQuickOpenService, + // @ts-ignore unused injected service @IEnvironmentService private environmentService: IEnvironmentService, @IConfigurationResolverService private configurationResolverService: IConfigurationResolverService, @ITerminalService private terminalService: ITerminalService, @@ -806,14 +741,14 @@ class TaskService extends EventEmitter implements ITaskService { if (Task.matches(task, alias)) { return task; } - }; + } return undefined; }); } public tasks(): TPromise { return this.getGroupedTasks().then(result => result.all()); - }; + } public createSorter(): TaskSorter { return new TaskSorter(this.contextService.getWorkspace() ? this.contextService.getWorkspace().folders : []); @@ -1124,7 +1059,7 @@ class TaskService extends EventEmitter implements ITaskService { } promise = this.writeConfiguration(workspaceFolder, 'tasks.tasks', fileConfig.tasks); } - }; + } if (!promise) { return TPromise.as(undefined); } @@ -2057,6 +1992,7 @@ class TaskService extends EventEmitter implements ITaskService { }; let promise = this.getTasksForGroup(TaskGroup.Build).then((tasks) => { if (tasks.length > 0) { + // @ts-ignore unused local let { none, defaults, users } = this.splitPerGroupType(tasks); if (defaults.length === 1) { this.run(defaults[0]); @@ -2101,6 +2037,7 @@ class TaskService extends EventEmitter implements ITaskService { }; let promise = this.getTasksForGroup(TaskGroup.Test).then((tasks) => { if (tasks.length > 0) { + // @ts-ignore unused local let { none, defaults, users } = this.splitPerGroupType(tasks); if (defaults.length === 1) { this.run(defaults[0]); diff --git a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts index 84731255e73..a5cec7639db 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts @@ -38,11 +38,6 @@ import { TelemetryEvent, Triggers, TaskSystemEvents, TaskEvent, TaskType, TaskTerminateResponse } from 'vs/workbench/parts/tasks/common/taskSystem'; -interface PrimaryTerminal { - terminal: ITerminalInstance; - busy: boolean; -} - interface TerminalData { terminal: ITerminalInstance; lastTask: string; @@ -68,6 +63,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { private markerService: IMarkerService, private modelService: IModelService, private configurationResolverService: IConfigurationResolverService, private telemetryService: ITelemetryService, + // @ts-ignore unused injected service private workbenchEditorService: IWorkbenchEditorService, private contextService: IWorkspaceContextService, outputChannelId: string) { @@ -152,7 +148,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { let activeTerminal = this.activeTasks[Task.getMapKey(task)]; if (!activeTerminal) { return TPromise.as({ success: false, task: undefined }); - }; + } return new TPromise((resolve, reject) => { let terminal = activeTerminal.terminal; const onExit = terminal.onExit(() => { @@ -397,7 +393,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { let waitOnExit: boolean | string = false; if (task.command.presentation.reveal !== RevealKind.Never || !task.isBackground) { waitOnExit = nls.localize('reuseTerminal', 'Terminal will be reused by tasks, press any key to close it.'); - }; + } let shellLaunchConfig: IShellLaunchConfig = undefined; let isShellCommand = task.command.runtime === RuntimeType.Shell; if (isShellCommand) { diff --git a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts index 3d57714c819..2f03ec2ff94 100644 --- a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts @@ -44,6 +44,7 @@ export class ProcessTaskSystem extends EventEmitter implements ITaskSystem { private outputService: IOutputService; private telemetryService: ITelemetryService; private configurationResolverService: IConfigurationResolverService; + // @ts-ignore unused injected service private contextService: IWorkspaceContextService; private outputChannel: IOutputChannel; diff --git a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts index a98744c2025..280c007955c 100644 --- a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts +++ b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts @@ -14,7 +14,7 @@ import * as Platform from 'vs/base/common/platform'; import * as Types from 'vs/base/common/types'; import * as UUID from 'vs/base/common/uuid'; -import { ValidationStatus, IProblemReporter as IProblemReporterBase, NullProblemReporter as NullProblemReporterBase } from 'vs/base/common/parsers'; +import { ValidationStatus, IProblemReporter as IProblemReporterBase } from 'vs/base/common/parsers'; import { NamedProblemMatcher, ProblemMatcher, ProblemMatcherParser, Config as ProblemMatcherConfig, isNamedProblemMatcher, ProblemMatcherRegistry @@ -1648,10 +1648,6 @@ export interface IProblemReporter extends IProblemReporterBase { clearOutput(): void; } -class NullProblemReporter extends NullProblemReporterBase implements IProblemReporter { - clearOutput(): void { }; -} - class UUIDMap { private last: IStringDictionary; diff --git a/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts b/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts index b8057237852..5ae1d3e6fb0 100644 --- a/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts +++ b/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts @@ -10,7 +10,6 @@ import { Mode, IEntryRunContext, IAutoFocus, IQuickNavigateConfiguration, IModel import { QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { QuickOpenHandler } from 'vs/workbench/browser/quickopen'; import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; -import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { ContributableActionProvider } from 'vs/workbench/browser/actions'; import { stripWildcards } from 'vs/base/common/strings'; import { matchesFuzzy } from 'vs/base/common/filters'; @@ -50,7 +49,6 @@ export class CreateTerminal extends QuickOpenEntry { constructor( private label: string, - private terminalService: ITerminalService, private commandService: ICommandService ) { super(); @@ -81,7 +79,6 @@ export class TerminalPickerHandler extends QuickOpenHandler { constructor( @ITerminalService private terminalService: ITerminalService, @ICommandService private commandService: ICommandService, - @IPanelService private panelService: IPanelService ) { super(); } @@ -91,7 +88,7 @@ export class TerminalPickerHandler extends QuickOpenHandler { const normalizedSearchValueLowercase = stripWildcards(searchValue).toLowerCase(); const terminalEntries: QuickOpenEntry[] = this.getTerminals(); - terminalEntries.push(new CreateTerminal(nls.localize("'workbench.action.terminal.newplus", "$(plus) Create New Integrated Terminal"), this.terminalService, this.commandService)); + terminalEntries.push(new CreateTerminal(nls.localize("'workbench.action.terminal.newplus", "$(plus) Create New Integrated Terminal"), this.commandService)); const entries = terminalEntries.filter(e => { if (!searchValue) { diff --git a/src/vs/workbench/parts/terminal/browser/terminalWidgetManager.ts b/src/vs/workbench/parts/terminal/browser/terminalWidgetManager.ts index f51e97e5dd7..4a1fb003d5e 100644 --- a/src/vs/workbench/parts/terminal/browser/terminalWidgetManager.ts +++ b/src/vs/workbench/parts/terminal/browser/terminalWidgetManager.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ITerminalConfigHelper } from 'vs/workbench/parts/terminal/common/terminal'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; export class TerminalWidgetManager { @@ -14,7 +13,6 @@ export class TerminalWidgetManager { private _messageListeners: IDisposable[] = []; constructor( - private _configHelper: ITerminalConfigHelper, terminalWrapper: HTMLElement ) { this._container = document.createElement('div'); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts index 1e4d71a8c2d..b73b020260e 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as cp from 'child_process'; import * as os from 'os'; import * as platform from 'vs/base/common/platform'; import * as processes from 'vs/base/node/processes'; @@ -26,10 +25,6 @@ const powerShellPath = `${process.env.windir}\\${is32ProcessOn64Windows ? 'Sysna export const TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : processes.getWindowsShell(); -export interface ITerminalProcessFactory { - create(env: { [key: string]: string }): cp.ChildProcess; -} - if (platform.isLinux) { const file = '/etc/os-release'; fileExists(file).then(exists => { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index ce3950c1dbb..3db89bc5d53 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -729,8 +729,6 @@ export class ShowPreviousFindTermTerminalFindWidgetAction extends Action { export class QuickOpenActionTermContributor extends ActionBarContributor { constructor( - @ITerminalService private terminalService: ITerminalService, - @IQuickOpenService private quickOpenService: IQuickOpenService, @IInstantiationService private instantiationService: IInstantiationService ) { super(); @@ -774,8 +772,7 @@ export class RenameTerminalQuickOpenAction extends RenameTerminalAction { id: string, label: string, private terminal: TerminalEntry, @IQuickOpenService quickOpenService: IQuickOpenService, - @ITerminalService terminalService: ITerminalService, - @IInstantiationService private instantiationService: IInstantiationService + @ITerminalService terminalService: ITerminalService ) { super(id, label, quickOpenService, terminalService); this.class = 'quick-open-terminal-configure'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index a2b24f21f08..3724726111a 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -42,7 +42,6 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { private _lastFontMeasurement: ITerminalFont; public constructor( - private _platform: platform.Platform, @IConfigurationService private _configurationService: IConfigurationService, @IWorkspaceConfigurationService private _workspaceConfigurationService: IWorkspaceConfigurationService, @IChoiceService private _choiceService: IChoiceService, diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts index 7ffa860ab6a..43202651a4d 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalFindWidget.ts @@ -30,7 +30,7 @@ export class TerminalFindWidget extends SimpleFindWidget { instance.findNext(val); } } - }; + } public hide() { super.hide(); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 110deb4b14b..46cc64e1c2f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -21,9 +21,6 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IStringDictionary } from 'vs/base/common/collections'; import { ITerminalInstance, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_PANEL_ID, IShellLaunchConfig } from 'vs/workbench/parts/terminal/common/terminal'; -import { ITerminalProcessFactory } from 'vs/workbench/parts/terminal/electron-browser/terminal'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { TabFocus } from 'vs/editor/common/config/commonEditorConfig'; @@ -47,15 +44,6 @@ XTermTerminal.loadAddon('search'); // Enable the winpty compatibility addon which will simulate wraparound mode XTermTerminal.loadAddon('winptyCompat'); -class StandardTerminalProcessFactory implements ITerminalProcessFactory { - public create(env: { [key: string]: string }): cp.ChildProcess { - return cp.fork('./terminalProcess', [], { - env, - cwd: Uri.parse(path.dirname(require.toUrl('./terminalProcess'))).fsPath - }); - } -} - enum ProcessState { // The process has not been initialized yet. UNINITIALIZED, @@ -78,7 +66,6 @@ enum ProcessState { export class TerminalInstance implements ITerminalInstance { private static readonly EOL_REGEX = /\r?\n/g; - private static _terminalProcessFactory: ITerminalProcessFactory = new StandardTerminalProcessFactory(); private static _lastKnownDimensions: Dimension = null; private static _idCounter = 1; @@ -133,8 +120,6 @@ export class TerminalInstance implements ITerminalInstance { @IKeybindingService private _keybindingService: IKeybindingService, @IMessageService private _messageService: IMessageService, @IPanelService private _panelService: IPanelService, - @IWorkspaceContextService private _contextService: IWorkspaceContextService, - @IWorkbenchEditorService private _editorService: IWorkbenchEditorService, @IInstantiationService private _instantiationService: IInstantiationService, @IClipboardService private _clipboardService: IClipboardService, @IHistoryService private _historyService: IHistoryService, @@ -170,7 +155,7 @@ export class TerminalInstance implements ITerminalInstance { if (platform.isWindows) { this._processReady.then(() => { if (!this._isDisposed) { - this._windowsShellHelper = new WindowsShellHelper(this._processId, this._shellLaunchConfig.executable, this, this._xterm); + this._windowsShellHelper = new WindowsShellHelper(this._processId, this, this._xterm); } }); } @@ -377,7 +362,7 @@ export class TerminalInstance implements ITerminalInstance { })); this._wrapperElement.appendChild(this._xtermElement); - this._widgetManager = new TerminalWidgetManager(this._configHelper, this._wrapperElement); + this._widgetManager = new TerminalWidgetManager(this._wrapperElement); this._linkHandler.setWidgetManager(this._widgetManager); this._container.appendChild(this._wrapperElement); @@ -1019,10 +1004,6 @@ export class TerminalInstance implements ITerminalInstance { }); } - public static setTerminalProcessFactory(factory: ITerminalProcessFactory): void { - this._terminalProcessFactory = factory; - } - public setTitle(title: string, eventFromProcess: boolean): void { if (!title) { return; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts index 8650646c7ad..22634f79026 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts @@ -9,7 +9,6 @@ import * as platform from 'vs/base/common/platform'; import * as pfs from 'vs/base/node/pfs'; import Uri from 'vs/base/common/uri'; import { dispose, IDisposable } from 'vs/base/common/lifecycle'; -import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -67,7 +66,6 @@ export class TerminalLinkHandler { private _platform: platform.Platform, private _initialCwd: string, @IOpenerService private _openerService: IOpenerService, - @IWorkbenchEditorService private _editorService: IWorkbenchEditorService, @IConfigurationService private _configurationService: IConfigurationService, @ITerminalService private _terminalService: ITerminalService ) { @@ -298,4 +296,4 @@ export class TerminalLinkHandler { export interface LineColumnInfo { lineNumber?: string; columnNumber?: string; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 4a0363f17b5..2dd16ba5775 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -12,10 +12,10 @@ import { Action, IAction } from 'vs/base/common/actions'; import { Builder, Dimension } from 'vs/base/browser/builder'; import { IActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; +import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { ITerminalService, ITerminalFont, TERMINAL_PANEL_ID } from 'vs/workbench/parts/terminal/common/terminal'; +import { ITerminalService, TERMINAL_PANEL_ID } from 'vs/workbench/parts/terminal/common/terminal'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { TerminalFindWidget } from './terminalFindWidget'; import { editorHoverBackground, editorHoverBorder, editorForeground } from 'vs/platform/theme/common/colorRegistry'; @@ -33,7 +33,6 @@ export class TerminalPanel extends Panel { private _copyContextMenuAction: IAction; private _contextMenuActions: IAction[]; private _cancelContextMenu: boolean = false; - private _font: ITerminalFont; private _fontStyleElement: HTMLElement; private _parentDomElement: HTMLElement; private _terminalContainer: HTMLElement; @@ -43,7 +42,6 @@ export class TerminalPanel extends Panel { constructor( @IConfigurationService private _configurationService: IConfigurationService, @IContextMenuService private _contextMenuService: IContextMenuService, - @IContextViewService private _contextViewService: IContextViewService, @IInstantiationService private _instantiationService: IInstantiationService, @ITerminalService private _terminalService: ITerminalService, @IThemeService protected themeService: IThemeService, @@ -308,7 +306,6 @@ export class TerminalPanel extends Panel { if (this._terminalService.terminalInstances.length === 0) { return; } - this._font = this._terminalService.configHelper.getFont(); // TODO: Can we support ligatures? // dom.toggleClass(this._parentDomElement, 'enable-ligatures', this._terminalService.configHelper.config.fontLigatures); this.layout(new Dimension(this._parentDomElement.offsetWidth, this._parentDomElement.offsetHeight)); diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts index 66d5340d584..d498d16a71f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalService.ts @@ -23,11 +23,10 @@ import Severity from 'vs/base/common/severity'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { TERMINAL_DEFAULT_SHELL_WINDOWS } from 'vs/workbench/parts/terminal/electron-browser/terminal'; import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel'; -import { IWindowService } from 'vs/platform/windows/common/windows'; export class TerminalService extends AbstractTerminalService implements ITerminalService { private _configHelper: TerminalConfigHelper; - public get configHelper(): ITerminalConfigHelper { return this._configHelper; }; + public get configHelper(): ITerminalConfigHelper { return this._configHelper; } constructor( @IContextKeyService _contextKeyService: IContextKeyService, @@ -36,7 +35,6 @@ export class TerminalService extends AbstractTerminalService implements ITermina @IPartService _partService: IPartService, @ILifecycleService _lifecycleService: ILifecycleService, @IInstantiationService private _instantiationService: IInstantiationService, - @IWindowService private _windowService: IWindowService, @IQuickOpenService private _quickOpenService: IQuickOpenService, @IChoiceService private _choiceService: IChoiceService, @IStorageService private _storageService: IStorageService, @@ -44,7 +42,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina ) { super(_contextKeyService, _configurationService, _panelService, _partService, _lifecycleService); - this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper, platform.platform); + this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper); } public createInstance(shell: IShellLaunchConfig = {}, wasNewTerminalAction?: boolean): ITerminalInstance { diff --git a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts index b4a2d55c42a..da9a2b515ea 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts @@ -14,7 +14,6 @@ const SHELL_EXECUTABLES = ['cmd.exe', 'powershell.exe', 'bash.exe']; let windowsProcessTree; export class WindowsShellHelper { - private _childProcessIdStack: number[]; private _onCheckShell: Emitter>; private _isDisposed: boolean; private _currentRequest: TPromise; @@ -22,7 +21,6 @@ export class WindowsShellHelper { public constructor( private _rootProcessId: number, - private _rootShellExecutable: string, private _terminalInstance: ITerminalInstance, private _xterm: XTermTerminal ) { @@ -34,7 +32,6 @@ export class WindowsShellHelper { windowsProcessTree = require.__$__nodeRequire('windows-process-tree'); } - this._childProcessIdStack = [this._rootProcessId]; this._isDisposed = false; this._onCheckShell = new Emitter>(); // The debounce is necessary to prevent multiple processes from spawning when diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalColorRegistry.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalColorRegistry.test.ts index 8a0820c4ac7..fa5448c879a 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalColorRegistry.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalColorRegistry.test.ts @@ -6,7 +6,7 @@ 'use strict'; import * as assert from 'assert'; -import { Extensions as ThemeingExtensions, IColorRegistry } from 'vs/platform/theme/common/colorRegistry'; +import { Extensions as ThemeingExtensions, IColorRegistry, ColorIdentifier } from 'vs/platform/theme/common/colorRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { ansiColorIdentifiers, registerColors } from 'vs/workbench/parts/terminal/electron-browser/terminalColorRegistry'; import { ITheme, ThemeType } from 'vs/platform/theme/common/themeService'; @@ -20,7 +20,7 @@ function getMockTheme(type: ThemeType): ITheme { selector: '', label: '', type: type, - getColor: (colorId) => themingRegistry.resolveDefaultColor(colorId, theme), + getColor: (colorId: ColorIdentifier): Color => themingRegistry.resolveDefaultColor(colorId, theme), defines: () => true }; return theme; diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts index be088071437..3dfbf80c376 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts @@ -7,7 +7,6 @@ import * as assert from 'assert'; import { IConfigurationService, getConfigurationValue, IConfigurationOverrides } from 'vs/platform/configuration/common/configuration'; -import { Platform } from 'vs/base/common/platform'; import { TPromise } from 'vs/base/common/winjs.base'; import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; @@ -18,13 +17,13 @@ class MockConfigurationService implements IConfigurationService { public serviceId = IConfigurationService; public constructor(private configuration: any = {}) { } public inspect(key: string, overrides?: IConfigurationOverrides): any { return { value: getConfigurationValue(this.getConfiguration(), key), default: getConfigurationValue(this.getConfiguration(), key), user: getConfigurationValue(this.getConfiguration(), key), workspace: void 0, workspaceFolder: void 0 }; } - public keys() { return { default: [], user: [], workspace: [], workspaceFolder: [] }; } + public keys() { return { default: [] as string[], user: [] as string[], workspace: [] as string[], workspaceFolder: [] as string[] }; } public getConfiguration(): any { return this.configuration; } public getValue(key: string, overrides?: IConfigurationOverrides): T { return getConfigurationValue(this.getConfiguration(), key); } - public updateValue(): TPromise { return null; } + public updateValue(): TPromise { return null; } public getConfigurationData(): any { return null; } public onDidChangeConfiguration() { return { dispose() { } }; } - public reloadConfiguration() { return null; } + public reloadConfiguration(): TPromise { return null; } } suite('Workbench - TerminalConfigHelper', () => { @@ -48,7 +47,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily'); @@ -62,7 +61,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; if (isFedora) { assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\'', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set'); @@ -87,7 +86,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize'); @@ -102,7 +101,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it'); @@ -117,7 +116,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set'); }); @@ -138,7 +137,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight'); @@ -154,7 +153,7 @@ suite('Workbench - TerminalConfigHelper', () => { } } }); - configHelper = new TerminalConfigHelper(Platform.Linux, configurationService, null, null, null); + configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; assert.equal(configHelper.getFont().lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set'); }); diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts index 2083ae505e9..608a9e5f8bc 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts @@ -45,9 +45,9 @@ suite('Workbench - TerminalInstance', () => { executable: '/bin/foosh', args: ['-bar', 'baz'] }; - const parentEnv1: IStringDictionary = { + const parentEnv1: IStringDictionary = { ok: true - }; + } as any; const env1 = TerminalInstance.createTerminalEnv(parentEnv1, shell1, '/foo', 'en-au'); assert.ok(env1['ok'], 'Parent environment is copied'); assert.deepStrictEqual(parentEnv1, { ok: true }, 'Parent environment is unchanged'); @@ -59,11 +59,11 @@ suite('Workbench - TerminalInstance', () => { assert.equal(env1['PTYCWD'], '/foo', 'PTYCWD is equal to requested cwd'); assert.equal(env1['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8'); - const shell2 = { + const shell2: IShellLaunchConfig = { executable: '/bin/foosh', args: [] }; - const parentEnv2: IStringDictionary = { + const parentEnv2: IStringDictionary = { LANG: 'en_US.UTF-8' }; const env2 = TerminalInstance.createTerminalEnv(parentEnv2, shell2, '/foo', 'en-au'); @@ -114,7 +114,7 @@ suite('Workbench - TerminalInstance', () => { a: 'b', c: 'd' }; - const other = { + const other: IStringDictionary = { a: null }; TerminalInstance.mergeEnvironments(parent, other); @@ -131,7 +131,7 @@ suite('Workbench - TerminalInstance', () => { a: 'b', c: 'd' }; - const other = { + const other: IStringDictionary = { A: null }; TerminalInstance.mergeEnvironments(parent, other); diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts index 491637a485c..a16322808aa 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalLinkHandler.test.ts @@ -35,7 +35,7 @@ interface LinkFormatInfo { suite('Workbench - TerminalLinkHandler', () => { suite('localLinkRegex', () => { test('Windows', () => { - const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null, null, null, null, null); + const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, null, null, null, null); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -105,7 +105,7 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('Linux', () => { - const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null, null); + const terminalLinkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null); function testLink(link: string, linkUrl: string, lineNo?: string, columnNo?: string) { assert.equal(terminalLinkHandler.extractLinkUrl(link), linkUrl); assert.equal(terminalLinkHandler.extractLinkUrl(`:${link}:`), linkUrl); @@ -169,9 +169,9 @@ suite('Workbench - TerminalLinkHandler', () => { suite('preprocessPath', () => { test('Windows', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, 'C:\\base', null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Windows, 'C:\\base', null, null, null); - let stub = sinon.stub(path, 'join', function (arg1, arg2) { + let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) { return arg1 + '\\' + arg2; }); assert.equal(linkHandler.preprocessPath('./src/file1'), 'C:\\base\\./src/file1'); @@ -182,9 +182,9 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('Linux', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, '/base', null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, '/base', null, null, null); - let stub = sinon.stub(path, 'join', function (arg1, arg2) { + let stub = sinon.stub(path, 'join', function (arg1: string, arg2: string) { return arg1 + '/' + arg2; }); @@ -195,7 +195,7 @@ suite('Workbench - TerminalLinkHandler', () => { }); test('No Workspace', () => { - const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null, null); + const linkHandler = new TestTerminalLinkHandler(new TestXterm(), Platform.Linux, null, null, null, null); assert.equal(linkHandler.preprocessPath('./src/file1'), null); assert.equal(linkHandler.preprocessPath('src/file2'), null); diff --git a/src/vs/workbench/parts/themes/electron-browser/themes.contribution.ts b/src/vs/workbench/parts/themes/electron-browser/themes.contribution.ts index d8f6bebd750..937068e685d 100644 --- a/src/vs/workbench/parts/themes/electron-browser/themes.contribution.ts +++ b/src/vs/workbench/parts/themes/electron-browser/themes.contribution.ts @@ -35,6 +35,7 @@ export class SelectColorThemeAction extends Action { id: string, label: string, @IQuickOpenService private quickOpenService: IQuickOpenService, + // @ts-ignore unused injected service @IMessageService private messageService: IMessageService, @IWorkbenchThemeService private themeService: IWorkbenchThemeService, @IExtensionGalleryService private extensionGalleryService: IExtensionGalleryService, diff --git a/src/vs/workbench/parts/update/electron-browser/update.ts b/src/vs/workbench/parts/update/electron-browser/update.ts index 9a42bcaf34b..096d930c697 100644 --- a/src/vs/workbench/parts/update/electron-browser/update.ts +++ b/src/vs/workbench/parts/update/electron-browser/update.ts @@ -128,6 +128,7 @@ export abstract class AbstractShowReleaseNotesAction extends Action { constructor( id: string, label: string, + // @ts-ignore unused property private returnValue: boolean, private version: string, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @@ -182,6 +183,7 @@ export class ShowCurrentReleaseNotesAction extends AbstractShowReleaseNotesActio export class DownloadAction extends Action { + // @ts-ignore unused property constructor(private url: string, @IUpdateService private updateService: IUpdateService) { super('update.download', nls.localize('downloadNow', "Download Now"), null, true); } @@ -301,6 +303,7 @@ class CommandAction extends Action { constructor( commandId: string, label: string, + // @ts-ignore unused injected service @ICommandService private commandService: ICommandService ) { super(`command-action:${commandId}`, label, undefined, true, () => commandService.executeCommand(commandId)); diff --git a/src/vs/workbench/parts/watermark/electron-browser/watermark.ts b/src/vs/workbench/parts/watermark/electron-browser/watermark.ts index 1031a79131b..e8aa038a47c 100644 --- a/src/vs/workbench/parts/watermark/electron-browser/watermark.ts +++ b/src/vs/workbench/parts/watermark/electron-browser/watermark.ts @@ -114,6 +114,7 @@ export class WatermarkContribution implements IWorkbenchContribution { @IPartService private partService: IPartService, @IKeybindingService private keybindingService: IKeybindingService, @IWorkspaceContextService private contextService: IWorkspaceContextService, + // @ts-ignore unused injected service @ITelemetryService private telemetryService: ITelemetryService, @IConfigurationService private configurationService: IConfigurationService ) { diff --git a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts index cdb9eb088b0..04541aa4295 100644 --- a/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts +++ b/src/vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.ts @@ -11,50 +11,6 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' import * as platform from 'vs/base/common/platform'; import product from 'vs/platform/node/product'; -abstract class AbstractGettingStarted implements IWorkbenchContribution { - protected static hideWelcomeSettingskey = 'workbench.hide.welcome'; - - protected welcomePageURL: string; - protected appName: string; - - constructor( - @IStorageService private storageService: IStorageService, - @IEnvironmentService environmentService: IEnvironmentService, - @ITelemetryService private telemetryService: ITelemetryService - ) { - this.appName = product.nameLong; - - if (product.welcomePage && !environmentService.isExtensionDevelopment /* do not open a browser when we run an extension */) { - this.welcomePageURL = product.welcomePage; - this.handleWelcome(); - } - } - - protected handleWelcome(): void { - let firstStartup = !this.storageService.get(AbstractGettingStarted.hideWelcomeSettingskey); - - if (firstStartup && this.welcomePageURL) { - this.telemetryService.getTelemetryInfo().then(info => { - let url = this.getUrl(info); - this.openExternal(url); - this.storageService.store(AbstractGettingStarted.hideWelcomeSettingskey, true); - }); - } - } - - private getUrl(telemetryInfo: ITelemetryInfo): string { - return `${this.welcomePageURL}&&from=${this.appName}&&id=${telemetryInfo.machineId}`; - } - - protected openExternal(url: string) { - throw new Error('implement me'); - } - - getId(): string { - return 'vs.gettingstarted'; - } -} - export class GettingStarted implements IWorkbenchContribution { private static hideWelcomeSettingskey = 'workbench.hide.welcome'; diff --git a/src/vs/workbench/parts/welcome/gettingStarted/test/common/gettingStarted.test.ts b/src/vs/workbench/parts/welcome/gettingStarted/test/common/gettingStarted.test.ts index 39c4c2697dd..7427ca510f2 100644 --- a/src/vs/workbench/parts/welcome/gettingStarted/test/common/gettingStarted.test.ts +++ b/src/vs/workbench/parts/welcome/gettingStarted/test/common/gettingStarted.test.ts @@ -18,7 +18,7 @@ suite('Workbench - GettingStarted', () => { suiteSetup(() => { instantiation = new TestInstantiationService(); - instantiation.stub(IWorkspaceContextService, { + instantiation.stub(IWorkspaceContextService, { getConfiguration: () => { return { env: { @@ -28,7 +28,7 @@ suite('Workbench - GettingStarted', () => { }; } }); - instantiation.stub(IStorageService, { + instantiation.stub(IStorageService, { get: () => hideWelcomeSettingsValue, store: (value) => hideWelcomeSettingsValue = value }); diff --git a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts index 7967cacab4e..8a53b671f5f 100644 --- a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts +++ b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts @@ -122,8 +122,8 @@ interface ExtensionSuggestion { const extensionPacks: ExtensionSuggestion[] = [ { name: localize('welcomePage.javaScript', "JavaScript"), id: 'dbaeumer.vscode-eslint' }, { name: localize('welcomePage.typeScript', "TypeScript"), id: 'eg2.tslint' }, - { name: localize('welcomePage.python', "Python"), id: 'donjayamanne.python' }, - // { name: localize('welcomePage.go', "Go"), id: 'lukehoban.go' }, + // { name: localize('welcomePage.python', "Python"), id: 'donjayamanne.python' }, + { name: localize('welcomePage.go', "Go"), id: 'lukehoban.go' }, { name: localize('welcomePage.php', "PHP"), id: 'felixfbecker.php-pack' }, { name: localize('welcomePage.azure', "Azure"), title: localize('welcomePage.showAzureExtensions', "Show Azure extensions"), id: 'workbench.extensions.action.showAzureExtensions', isCommand: true }, { name: localize('welcomePage.docker', "Docker"), id: 'PeterJausovec.vscode-docker' }, @@ -243,7 +243,9 @@ class WelcomePage { @IExtensionTipsService private tipsService: IExtensionTipsService, @IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService, @ILifecycleService lifecycleService: ILifecycleService, + // @ts-ignore unused injected service @IThemeService private themeService: IThemeService, + // @ts-ignore unused injected service @IExperimentService private experimentService: IExperimentService, @ITelemetryService private telemetryService: ITelemetryService ) { @@ -358,7 +360,7 @@ class WelcomePage { this.updateInstalledExtensions(container, installedExtensions); break; } - }; + } })); } diff --git a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts index 84757bd9881..2eb59c0b93d 100644 --- a/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts +++ b/src/vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart.ts @@ -19,8 +19,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { WalkThroughInput } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughInput'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { marked } from 'vs/base/common/marked/marked'; -import { IModeService } from 'vs/editor/common/services/modeService'; -import { IFileService } from 'vs/platform/files/common/files'; import { IModelService } from 'vs/editor/common/services/modelService'; import { CodeEditor } from 'vs/editor/browser/codeEditor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -34,7 +32,6 @@ import { once } from 'vs/base/common/event'; import { isObject } from 'vs/base/common/types'; import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands'; import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService'; -import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; @@ -99,15 +96,12 @@ export class WalkThroughPart extends BaseEditor { @IInstantiationService private instantiationService: IInstantiationService, @IThemeService protected themeService: IThemeService, @IOpenerService private openerService: IOpenerService, - @IFileService private fileService: IFileService, @IModelService protected modelService: IModelService, @IKeybindingService private keybindingService: IKeybindingService, @IStorageService private storageService: IStorageService, @IContextKeyService private contextKeyService: IContextKeyService, @IConfigurationService private configurationService: IConfigurationService, - @IModeService private modeService: IModeService, - @IMessageService private messageService: IMessageService, - @IPartService private partService: IPartService + @IMessageService private messageService: IMessageService ) { super(WalkThroughPart.ID, telemetryService, themeService); this.editorFocus = WALK_THROUGH_FOCUS.bindTo(this.contextKeyService); diff --git a/src/vs/workbench/services/backup/node/backupFileService.ts b/src/vs/workbench/services/backup/node/backupFileService.ts index d03f40a59dc..af5ca6bda2b 100644 --- a/src/vs/workbench/services/backup/node/backupFileService.ts +++ b/src/vs/workbench/services/backup/node/backupFileService.ts @@ -95,14 +95,14 @@ export class BackupFileService implements IBackupFileService { private isShuttingDown: boolean; private ready: TPromise; - private ioOperationQueues: ResourceQueue; // queue IO operations to ensure write order + private ioOperationQueues: ResourceQueue; // queue IO operations to ensure write order constructor( backupWorkspacePath: string, @IFileService private fileService: IFileService ) { this.isShuttingDown = false; - this.ioOperationQueues = new ResourceQueue(); + this.ioOperationQueues = new ResourceQueue(); this.initialize(backupWorkspacePath); } diff --git a/src/vs/workbench/services/backup/test/node/backupFileService.test.ts b/src/vs/workbench/services/backup/test/node/backupFileService.test.ts index 23420f77df0..28db9272fcf 100644 --- a/src/vs/workbench/services/backup/test/node/backupFileService.test.ts +++ b/src/vs/workbench/services/backup/test/node/backupFileService.test.ts @@ -16,24 +16,11 @@ import pfs = require('vs/base/node/pfs'); import Uri from 'vs/base/common/uri'; import { BackupFileService, BackupFilesModel } from 'vs/workbench/services/backup/node/backupFileService'; import { FileService } from 'vs/workbench/services/files/node/fileService'; -import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; -import { parseArgs } from 'vs/platform/environment/node/argv'; import { RawTextSource } from 'vs/editor/common/model/textSource'; import { TestContextService, TestTextResourceConfigurationService, getRandomTestPath } from 'vs/workbench/test/workbenchTestServices'; import { Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; -class TestEnvironmentService extends EnvironmentService { - - constructor(private _backupHome: string, private _backupWorkspacesPath: string) { - super(parseArgs(process.argv), process.execPath); - } - - get backupHome(): string { return this._backupHome; } - - get backupWorkspacesPath(): string { return this._backupWorkspacesPath; } -} - const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'backupfileservice'); const backupHome = path.join(parentDir, 'Backups'); const workspacesJsonPath = path.join(backupHome, 'workspaces.json'); diff --git a/src/vs/workbench/services/configuration/common/configuration.ts b/src/vs/workbench/services/configuration/common/configuration.ts index 3d4eb1394b2..d6f6475490b 100644 --- a/src/vs/workbench/services/configuration/common/configuration.ts +++ b/src/vs/workbench/services/configuration/common/configuration.ts @@ -27,6 +27,6 @@ export const folderSettingsSchemaId = 'vscode://schemas/settings/folder'; export const TASKS_CONFIGURATION_KEY = 'tasks'; export const LAUNCH_CONFIGURATION_KEY = 'launch'; -export const WORKSPACE_STANDALONE_CONFIGURATIONS = {}; +export const WORKSPACE_STANDALONE_CONFIGURATIONS = Object.create(null); WORKSPACE_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME}/tasks.json`; WORKSPACE_STANDALONE_CONFIGURATIONS[LAUNCH_CONFIGURATION_KEY] = `${WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME}/launch.json`; \ No newline at end of file diff --git a/src/vs/workbench/services/configuration/common/configurationExtensionPoint.ts b/src/vs/workbench/services/configuration/common/configurationExtensionPoint.ts index 2742eddbc95..5525cc06c01 100644 --- a/src/vs/workbench/services/configuration/common/configurationExtensionPoint.ts +++ b/src/vs/workbench/services/configuration/common/configurationExtensionPoint.ts @@ -78,7 +78,7 @@ configurationExtPoint.setHandler(extensions => { configuration.id = id; configurations.push(configuration); - }; + } for (let extension of extensions) { const value = extension.value; diff --git a/src/vs/workbench/services/configuration/node/configurationEditingService.ts b/src/vs/workbench/services/configuration/node/configurationEditingService.ts index 7bcb81beb7a..1deacb7b526 100644 --- a/src/vs/workbench/services/configuration/node/configurationEditingService.ts +++ b/src/vs/workbench/services/configuration/node/configurationEditingService.ts @@ -109,11 +109,6 @@ interface IConfigurationEditOperation extends IConfigurationValue { } -interface IValidationResult { - error?: ConfigurationEditingErrorCode; - exists?: boolean; -} - interface ConfigurationEditingOptions extends IConfigurationEditingOptions { force?: boolean; } @@ -308,7 +303,7 @@ export class ConfigurationEditingService { return nls.localize('errorInvalidConfigurationFolder', "Unable to write into folder settings. Please open **Folder Settings** file under **{0}** folder to correct errors/warnings in it and try again.", workspaceFolderName); } return ''; - }; + } case ConfigurationEditingErrorCode.ERROR_CONFIGURATION_FILE_DIRTY: { if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) { return nls.localize('errorTasksConfigurationFileDirty', "Unable to write into tasks file because the file is dirty. Please save the **Tasks Configuration** file and try again."); @@ -326,7 +321,7 @@ export class ConfigurationEditingService { return nls.localize('errorConfigurationFileDirtyFolder', "Unable to write into folder settings because the file is dirty. Please save the **Folder Settings** file under **{0}** folder and try again.", workspaceFolderName); } return ''; - }; + } } } diff --git a/src/vs/workbench/services/configuration/node/configurationService.ts b/src/vs/workbench/services/configuration/node/configurationService.ts index b105f745aab..11cd1329ab5 100644 --- a/src/vs/workbench/services/configuration/node/configurationService.ts +++ b/src/vs/workbench/services/configuration/node/configurationService.ts @@ -68,6 +68,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat private configurationEditingService: ConfigurationEditingService; private jsonEditingService: JSONEditingService; + // @ts-ignore unused injected service constructor(private environmentService: IEnvironmentService, private workspacesService: IWorkspacesService, private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME) { super(); @@ -222,10 +223,10 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat return this._configuration.toData(); } - getConfiguration(): T - getConfiguration(section: string): T - getConfiguration(overrides: IConfigurationOverrides): T - getConfiguration(section: string, overrides: IConfigurationOverrides): T + getConfiguration(): T; + getConfiguration(section: string): T; + getConfiguration(overrides: IConfigurationOverrides): T; + getConfiguration(section: string, overrides: IConfigurationOverrides): T; getConfiguration(arg1?: any, arg2?: any): any { const section = typeof arg1 === 'string' ? arg1 : void 0; const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : void 0; @@ -236,11 +237,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat return this._configuration.getValue(key, overrides); } - updateValue(key: string, value: any): TPromise - updateValue(key: string, value: any, overrides: IConfigurationOverrides): TPromise - updateValue(key: string, value: any, target: ConfigurationTarget): TPromise - updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): TPromise - updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError: boolean): TPromise + updateValue(key: string, value: any): TPromise; + updateValue(key: string, value: any, overrides: IConfigurationOverrides): TPromise; + updateValue(key: string, value: any, target: ConfigurationTarget): TPromise; + updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget): TPromise; + updateValue(key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError: boolean): TPromise; updateValue(key: string, value: any, arg3?: any, arg4?: any, donotNotifyError?: any): TPromise { assert.ok(this.configurationEditingService, 'Workbench is not initialized yet'); const overrides = isConfigurationOverrides(arg3) ? arg3 : void 0; diff --git a/src/vs/workbench/services/configuration/node/jsonEditingService.ts b/src/vs/workbench/services/configuration/node/jsonEditingService.ts index edd33ee7881..c2786248c14 100644 --- a/src/vs/workbench/services/configuration/node/jsonEditingService.ts +++ b/src/vs/workbench/services/configuration/node/jsonEditingService.ts @@ -126,10 +126,10 @@ export class JSONEditingService implements IJSONEditingService { // User issues case JSONEditingErrorCode.ERROR_INVALID_FILE: { return nls.localize('errorInvalidFile', "Unable to write into the file. Please open the file to correct errors/warnings in the file and try again."); - }; + } case JSONEditingErrorCode.ERROR_FILE_DIRTY: { return nls.localize('errorFileDirty', "Unable to write into the file because the file is dirty. Please save the file and try again."); - }; + } } } } \ No newline at end of file diff --git a/src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts b/src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts index 8bfb2c6fbe5..9966a0a9fa5 100644 --- a/src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts +++ b/src/vs/workbench/services/configuration/test/node/configurationEditingService.test.ts @@ -38,7 +38,7 @@ import { IWindowConfiguration } from 'vs/platform/windows/common/windows'; class SettingsTestEnvironmentService extends EnvironmentService { - constructor(args: ParsedArgs, _execPath: string, private customAppSettingsHome) { + constructor(args: ParsedArgs, _execPath: string, private customAppSettingsHome: string) { super(args, _execPath); } @@ -49,9 +49,9 @@ suite('ConfigurationEditingService', () => { let instantiationService: TestInstantiationService; let testObject: ConfigurationEditingService; - let parentDir; - let workspaceDir; - let globalSettingsFile; + let parentDir: string; + let workspaceDir: string; + let globalSettingsFile: string; let workspaceSettingsDir; suiteSetup(() => { diff --git a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts index d9df4dda92f..80a59f403e7 100644 --- a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts @@ -133,7 +133,7 @@ export class ConfigurationResolverService implements IConfigurationResolverServi } public resolveAny(root: IWorkspaceFolder, value: T): T; - public resolveAny(root: IWorkspaceFolder, value: any): any { + public resolveAny(root: IWorkspaceFolder, value: any): any { try { this._lastWorkspaceFolder = root; if (types.isString(value)) { @@ -205,7 +205,7 @@ export class ConfigurationResolverService implements IConfigurationResolverServi } private resolveAnyLiteral(root: IWorkspaceFolder, values: T): T; - private resolveAnyLiteral(root: IWorkspaceFolder, values: any): any { + private resolveAnyLiteral(root: IWorkspaceFolder, values: any): any { let result: IStringDictionary | string[]> = Object.create(null); Object.keys(values).forEach(key => { let value = values[key]; diff --git a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts index fce774139c1..a7ad4e84a3f 100644 --- a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts @@ -364,8 +364,7 @@ class MockCommandService implements ICommandService { public callCount = 0; onWillExecuteCommand = () => ({ dispose: () => { } }); - - public executeCommand(commandId: string, ...args: any[]): TPromise { + public executeCommand(commandId: string, ...args: any[]): TPromise { this.callCount++; return TPromise.as(commandId); } diff --git a/src/vs/workbench/services/editor/test/browser/editorService.test.ts b/src/vs/workbench/services/editor/test/browser/editorService.test.ts index dabe18285d6..0e71a596420 100644 --- a/src/vs/workbench/services/editor/test/browser/editorService.test.ts +++ b/src/vs/workbench/services/editor/test/browser/editorService.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import { Promise, TPromise } from 'vs/base/common/winjs.base'; import paths = require('vs/base/common/paths'); -import { Position, Direction, IEditor } from 'vs/platform/editor/common/editor'; +import { Position, Direction, IEditor, IEditorInput } from 'vs/platform/editor/common/editor'; import URI from 'vs/base/common/uri'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { EditorInput, EditorOptions, TextEditorOptions } from 'vs/workbench/common/editor'; @@ -19,26 +19,25 @@ import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorIn import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; -let activeEditor: BaseEditor = { +let activeEditor: BaseEditor = { getSelection: function () { return 'test.selection'; } -}; +} as any; -let openedEditorInput; -let openedEditorOptions; -let openedEditorPosition; +let openedEditorInput: EditorInput; +let openedEditorOptions: EditorOptions; -function toResource(path) { +function toResource(path: string) { return URI.from({ scheme: 'custom', path }); } -function toFileResource(path) { - return URI.file(paths.join('C:\\', new Buffer(this.test.fullTitle()).toString('base64'), path)); +function toFileResource(self: any, path: string) { + return URI.file(paths.join('C:\\', new Buffer(self.test.fullTitle()).toString('base64'), path)); } class TestEditorPart implements IEditorPart { - private activeInput; + private activeInput: EditorInput; public getId(): string { return null; @@ -69,7 +68,6 @@ class TestEditorPart implements IEditorPart { public openEditor(input?: EditorInput, options?: EditorOptions, arg?: any): TPromise { openedEditorInput = input; openedEditorOptions = options; - openedEditorPosition = arg; return TPromise.as(activeEditor); } @@ -96,7 +94,7 @@ suite('WorkbenchEditorService', () => { test('basics', function () { let instantiationService = workbenchInstantiationService(); - let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource.call(this, '/something.js'), void 0); + let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource(this, '/something.js'), void 0); let testEditorPart = new TestEditorPart(); testEditorPart.setActiveEditorInput(activeInput); @@ -123,12 +121,12 @@ suite('WorkbenchEditorService', () => { }); // Open Untyped Input (file) - service.openEditor({ resource: toFileResource.call(this, '/index.html'), options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { + service.openEditor({ resource: toFileResource(this, '/index.html'), options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { assert.strictEqual(editor, activeEditor); assert(openedEditorInput instanceof FileEditorInput); let contentInput = openedEditorInput; - assert.strictEqual(contentInput.getResource().fsPath, toFileResource.call(this, '/index.html').fsPath); + assert.strictEqual(contentInput.getResource().fsPath, toFileResource(this, '/index.html').fsPath); assert(openedEditorOptions instanceof TextEditorOptions); let textEditorOptions = openedEditorOptions; @@ -136,7 +134,7 @@ suite('WorkbenchEditorService', () => { }); // Open Untyped Input (file, encoding) - service.openEditor({ resource: toFileResource.call(this, '/index.html'), encoding: 'utf16le', options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { + service.openEditor({ resource: toFileResource(this, '/index.html'), encoding: 'utf16le', options: { selection: { startLineNumber: 1, startColumn: 1 } } }).then((editor) => { assert.strictEqual(editor, activeEditor); assert(openedEditorInput instanceof FileEditorInput); @@ -181,18 +179,18 @@ suite('WorkbenchEditorService', () => { test('caching', function () { let instantiationService = workbenchInstantiationService(); - let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource.call(this, '/something.js'), void 0); + let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource(this, '/something.js'), void 0); let testEditorPart = new TestEditorPart(); testEditorPart.setActiveEditorInput(activeInput); let service: WorkbenchEditorService = instantiationService.createInstance(WorkbenchEditorService, testEditorPart); // Cached Input (Files) - const fileResource1 = toFileResource.call(this, '/foo/bar/cache1.js'); + const fileResource1 = toFileResource(this, '/foo/bar/cache1.js'); const fileInput1 = service.createInput({ resource: fileResource1 }); assert.ok(fileInput1); - const fileResource2 = toFileResource.call(this, '/foo/bar/cache2.js'); + const fileResource2 = toFileResource(this, '/foo/bar/cache2.js'); const fileInput2 = service.createInput({ resource: fileResource2 }); assert.ok(fileInput2); @@ -234,7 +232,7 @@ suite('WorkbenchEditorService', () => { test('delegate', function (done) { let instantiationService = workbenchInstantiationService(); - let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource.call(this, '/something.js'), void 0); + let activeInput: EditorInput = instantiationService.createInstance(FileEditorInput, toFileResource(this, '/something.js'), void 0); let testEditorPart = new TestEditorPart(); testEditorPart.setActiveEditorInput(activeInput); @@ -262,7 +260,7 @@ suite('WorkbenchEditorService', () => { let inp = instantiationService.createInstance(ResourceEditorInput, 'name', 'description', URI.parse('my://resource')); let delegate = instantiationService.createInstance(DelegatingWorkbenchEditorService); - delegate.setEditorOpenHandler((input, options?) => { + delegate.setEditorOpenHandler((input: IEditorInput, options?: EditorOptions) => { assert.strictEqual(input, inp); return TPromise.as(ed); diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionPoints.ts b/src/vs/workbench/services/extensions/electron-browser/extensionPoints.ts index 7e08926c197..4204b5715a1 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionPoints.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionPoints.ts @@ -201,7 +201,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler { if (literal.hasOwnProperty(key)) { processEntry(literal, key); } - }; + } } } diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index afbd40e9494..8e19e2df434 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -33,7 +33,6 @@ import { IWindowService } from 'vs/platform/windows/common/windows'; import { Action } from 'vs/base/common/actions'; import { IDisposable } from 'vs/base/common/lifecycle'; import { mark, time } from 'vs/base/common/performance'; -import { toPromise, filterEvent } from 'vs/base/common/event'; import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; const SystemExtensionsRoot = path.normalize(path.join(URI.parse(require.toUrl('')).fsPath, '..', 'extensions')); @@ -100,7 +99,7 @@ export class ExtensionService implements IExtensionService { this._extensionHostProcessCustomers = []; this._extensionHostProcessProxy = null; - toPromise(filterEvent(lifecycleService.onDidChangePhase, phase => phase === LifecyclePhase.Running)).then(() => { + lifecycleService.when(LifecyclePhase.Restoring).then(() => { // delay extension host creation and extension scanning // until after the editors/panels are restored this._startExtensionHostProcess([]); diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index a942280b1c7..48910f60660 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -919,11 +919,11 @@ export class StatResolver { clb(null, null); // return - we might not have permissions to read the folder or stat the file }, - function stat(): void { + function stat(this: any): void { fs.stat(fileResource.fsPath, this); }, - function countChildren(fsstat: fs.Stats): void { + function countChildren(this: any, fsstat: fs.Stats): void { fileStat = fsstat; if (fileStat.isDirectory()) { diff --git a/src/vs/workbench/services/files/test/node/watcher.test.ts b/src/vs/workbench/services/files/test/node/watcher.test.ts index a8c6b9ee80b..705595868cf 100644 --- a/src/vs/workbench/services/files/test/node/watcher.test.ts +++ b/src/vs/workbench/services/files/test/node/watcher.test.ts @@ -44,7 +44,7 @@ enum Path { UNIX, WINDOWS, UNC -}; +} suite('Watcher', () => { diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index b00ba458b71..04c8610f378 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -30,7 +30,6 @@ import { IExpression } from 'vs/base/common/glob'; import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ResourceGlobMatcher } from 'vs/workbench/common/resources'; -import { IEditorRegistry, Extensions } from 'vs/workbench/browser/editor'; /** * Stores the selection & view state of an editor and allows to compare it to other selection states. @@ -189,7 +188,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic private history: (IEditorInput | IResourceInput)[]; private recentlyClosedFiles: IRecentlyClosedFile[]; private loaded: boolean; - private registry: IEditorRegistry; private resourceFilter: ResourceGlobMatcher; constructor( @@ -210,7 +208,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic this.stack = []; this.recentlyClosedFiles = []; this.loaded = false; - this.registry = Registry.as(Extensions.Editors); this.resourceFilter = instantiationService.createInstance( ResourceGlobMatcher, (root: URI) => this.getExcludes(root), diff --git a/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts b/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts index a3f9d2f1c0f..242aebeffca 100644 --- a/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts +++ b/src/vs/workbench/services/keybinding/test/node/keybindingEditing.test.ts @@ -56,7 +56,7 @@ suite('Keybindings Editing', () => { let instantiationService: TestInstantiationService; let testObject: KeybindingsEditingService; let testDir: string; - let keybindingsFile; + let keybindingsFile: string; setup(() => { return setUpWorkspace().then(() => { diff --git a/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts b/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts index 99e62bc0aa6..3c73d835251 100644 --- a/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts +++ b/src/vs/workbench/services/lifecycle/electron-browser/lifecycleService.ts @@ -13,6 +13,8 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag import { ipcRenderer as ipc } from 'electron'; import Event, { Emitter } from 'vs/base/common/event'; import { IWindowService } from 'vs/platform/windows/common/windows'; +import { mark } from 'vs/base/common/performance'; +import { Barrier } from 'vs/workbench/services/extensions/node/barrier'; export class LifecycleService implements ILifecycleService { @@ -20,12 +22,12 @@ export class LifecycleService implements ILifecycleService { public _serviceBrand: any; - private readonly _onDidChangePhase = new Emitter(); private readonly _onWillShutdown = new Emitter(); private readonly _onShutdown = new Emitter(); private readonly _startupKind: StartupKind; private _phase: LifecyclePhase = LifecyclePhase.Starting; + private _phaseWhen = new Map(); constructor( @IMessageService private _messageService: IMessageService, @@ -50,20 +52,38 @@ export class LifecycleService implements ILifecycleService { } public set phase(value: LifecyclePhase) { - if (this._phase !== value) { - this._phase = value; - this._onDidChangePhase.fire(value); + if (value < this.phase) { + throw new Error('Lifecycle cannot go backwards'); } + if (this._phase === value) { + return; + } + + this._phase = value; + mark(`LifecyclePhase/${LifecyclePhase[value]}`); + + if (this._phaseWhen.has(this._phase)) { + this._phaseWhen.get(this._phase).open(); + this._phaseWhen.delete(this._phase); + } + } + + public when(phase: LifecyclePhase): Thenable { + if (phase <= this._phase) { + return Promise.resolve(); + } + let barrier = this._phaseWhen.get(phase); + if (!barrier) { + barrier = new Barrier(); + this._phaseWhen.set(phase, barrier); + } + return barrier.wait(); } public get startupKind(): StartupKind { return this._startupKind; } - public get onDidChangePhase(): Event { - return this._onDidChangePhase.event; - } - public get onWillShutdown(): Event { return this._onWillShutdown.event; } diff --git a/src/vs/workbench/services/mode/common/workbenchModeService.ts b/src/vs/workbench/services/mode/common/workbenchModeService.ts index 62023d035bb..621e9a5f65e 100644 --- a/src/vs/workbench/services/mode/common/workbenchModeService.ts +++ b/src/vs/workbench/services/mode/common/workbenchModeService.ts @@ -16,6 +16,7 @@ import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry'; import { ILanguageExtensionPoint, IValidLanguageExtensionPoint } from 'vs/editor/common/services/modeService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl'; +import { IEnvironmentService } from 'vs/platform/environment/common/environment'; export const languagesExtPoint: IExtensionPoint = ExtensionsRegistry.registerExtensionPoint('languages', [], { description: nls.localize('vscode.extension.contributes.languages', 'Contributes language declarations.'), @@ -84,9 +85,10 @@ export class WorkbenchModeServiceImpl extends ModeServiceImpl { constructor( @IExtensionService extensionService: IExtensionService, - @IConfigurationService configurationService: IConfigurationService + @IConfigurationService configurationService: IConfigurationService, + @IEnvironmentService environmentService: IEnvironmentService ) { - super(); + super(environmentService.verbose || environmentService.isExtensionDevelopment || !environmentService.isBuilt); this._configurationService = configurationService; this._extensionService = extensionService; diff --git a/src/vs/workbench/services/progress/browser/progressService.ts b/src/vs/workbench/services/progress/browser/progressService.ts index aebb56b7a0c..9a94a0d8908 100644 --- a/src/vs/workbench/services/progress/browser/progressService.ts +++ b/src/vs/workbench/services/progress/browser/progressService.ts @@ -17,6 +17,8 @@ interface ProgressState { worked?: number; done?: boolean; whilePromise?: TPromise; + whileStart?: number; + whileDelay?: number; } export abstract class ScopedService { @@ -87,7 +89,15 @@ export class WorkbenchProgressService extends ScopedService implements IProgress // Replay Infinite Progress from Promise if (this.progressState.whilePromise) { - this.doShowWhile(); + let delay: number; + if (this.progressState.whileDelay > 0) { + const remainingDelay = this.progressState.whileDelay - (Date.now() - this.progressState.whileStart); + if (remainingDelay > 0) { + delay = remainingDelay; + } + } + + this.doShowWhile(delay); } // Replay Infinite Progress @@ -113,6 +123,8 @@ export class WorkbenchProgressService extends ScopedService implements IProgress this.progressState.worked = void 0; this.progressState.total = void 0; this.progressState.whilePromise = void 0; + this.progressState.whileStart = void 0; + this.progressState.whileDelay = void 0; } public show(infinite: boolean, delay?: number): IProgressRunner; @@ -218,6 +230,8 @@ export class WorkbenchProgressService extends ScopedService implements IProgress // Keep Promise in State this.progressState.whilePromise = promise; + this.progressState.whileDelay = delay || 0; + this.progressState.whileStart = Date.now(); let stop = () => { diff --git a/src/vs/workbench/services/progress/test/progressService.test.ts b/src/vs/workbench/services/progress/test/progressService.test.ts index 9a4a2dd281b..ef327a11f63 100644 --- a/src/vs/workbench/services/progress/test/progressService.test.ts +++ b/src/vs/workbench/services/progress/test/progressService.test.ts @@ -17,7 +17,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; import { IViewlet } from 'vs/workbench/common/viewlet'; import { Emitter } from 'vs/base/common/event'; -let activeViewlet: Viewlet = {}; +let activeViewlet: Viewlet = {} as any; class TestViewletService implements IViewletService { public _serviceBrand: any; diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 02e7c5e570c..372fab93bdf 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -493,7 +493,7 @@ export class FileWalker { if (self.isLimitHit) { break; } - }; + } } matchDirectory(rootEntries); } diff --git a/src/vs/workbench/services/search/node/searchService.ts b/src/vs/workbench/services/search/node/searchService.ts index 9fa0959b5c2..da0865c1e95 100644 --- a/src/vs/workbench/services/search/node/searchService.ts +++ b/src/vs/workbench/services/search/node/searchService.ts @@ -34,6 +34,7 @@ export class SearchService implements ISearchService { @IModelService private modelService: IModelService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, @IEnvironmentService environmentService: IEnvironmentService, + // @ts-ignore unused injected service @IWorkspaceContextService private contextService: IWorkspaceContextService, @ITelemetryService private telemetryService: ITelemetryService, @IConfigurationService private configurationService: IConfigurationService diff --git a/src/vs/workbench/services/telemetry/node/workspaceStats.ts b/src/vs/workbench/services/telemetry/node/workspaceStats.ts index e81862ca195..8c122d88bdb 100644 --- a/src/vs/workbench/services/telemetry/node/workspaceStats.ts +++ b/src/vs/workbench/services/telemetry/node/workspaceStats.ts @@ -412,5 +412,5 @@ export class WorkspaceStats { this.reportRemotes(uris); this.reportAzure(uris); } - }; + } } diff --git a/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts b/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts index 45f1ce8d60f..99275a3e567 100644 --- a/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts @@ -322,15 +322,15 @@ suite('Files - TextFileEditorModelManager', () => { const resource = toResource('/path/index_something.txt'); - manager.loadOrCreate(resource, { encoding: 'utf8' }).done((model: TextFileEditorModel) => { + manager.loadOrCreate(resource, { encoding: 'utf8' }).done(model => { model.textEditorModel.setValue('make dirty'); - manager.disposeModel(model); + manager.disposeModel(model as TextFileEditorModel); assert.ok(!model.isDisposed()); model.revert(true); - manager.disposeModel(model); + manager.disposeModel(model as TextFileEditorModel); assert.ok(model.isDisposed()); manager.dispose(); diff --git a/src/vs/workbench/services/textfile/test/textFileService.test.ts b/src/vs/workbench/services/textfile/test/textFileService.test.ts index 6416edee36b..3fe68e030d9 100644 --- a/src/vs/workbench/services/textfile/test/textFileService.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileService.test.ts @@ -371,7 +371,7 @@ suite('Files - TextFileService', () => { }); }); - function hotExitTest(setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean, done: () => void): void { + function hotExitTest(this: any, setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean, done: () => void): void { model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/file.txt'), 'utf8'); (accessor.textFileService.models).add(model.getResource(), model); diff --git a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts index 125ef301221..e81451b195a 100644 --- a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts +++ b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts @@ -102,7 +102,6 @@ export class TextModelResolverService implements ITextModelService { private resourceModelCollection: ResourceModelCollection; constructor( - @ITextFileService private textFileService: ITextFileService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, @IInstantiationService private instantiationService: IInstantiationService, @IModelService private modelService: IModelService diff --git a/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts b/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts index 9ae8a6fd4ba..968623410fd 100644 --- a/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts +++ b/src/vs/workbench/services/textmodelResolver/test/textModelResolverService.test.ts @@ -71,9 +71,9 @@ suite('Workbench - TextModelResolverService', () => { let resource = URI.from({ scheme: 'test', authority: null, path: 'thePath' }); let input: ResourceEditorInput = instantiationService.createInstance(ResourceEditorInput, 'The Name', 'The Description', resource); - input.resolve().then((model: ResourceEditorModel) => { + input.resolve().then(model => { assert.ok(model); - assert.equal(model.getValue(), 'Hello Test'); + assert.equal((model as ResourceEditorModel).getValue(), 'Hello Test'); let disposed = false; once(model.onDispose)(() => { diff --git a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts index 572299fd514..0adedb4a6a7 100644 --- a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts @@ -92,6 +92,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { constructor( container: HTMLElement, + // @ts-ignore unused injected service @IExtensionService private extensionService: IExtensionService, @IStorageService private storageService: IStorageService, @IBroadcastService private broadcastService: IBroadcastService, @@ -178,7 +179,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { }, err => { if (err && err.code === 'ENOENT') { return TPromise.as(null); // ignore, user config file doesn't exist yet - }; + } return TPromise.wrapError(err); }); } @@ -346,7 +347,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { this.storageService.store(PERSISTED_THEME_STORAGE_KEY, newTheme.toStorageData()); return this.writeColorThemeConfiguration(settingsTarget); - }; + } private writeColorThemeConfiguration(settingsTarget: ConfigurationTarget): TPromise { if (!types.isUndefinedOrNull(settingsTarget)) { @@ -476,7 +477,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { } } -function _applyIconTheme(data: FileIconThemeData, onApply: (theme: FileIconThemeData) => TPromise): TPromise { +function _applyIconTheme(this: any, data: FileIconThemeData, onApply: (theme: FileIconThemeData) => TPromise): TPromise { if (!data) { _applyRules('', iconThemeRulesClassName); return TPromise.as(onApply(data)); @@ -588,7 +589,7 @@ function tokenGroupSettings(description: string) { colorThemeSchema.tokenColorizationSettingSchema ] }; -}; +} configurationRegistry.registerConfiguration({ id: 'editor', diff --git a/src/vs/workbench/services/thread/common/threadService.ts b/src/vs/workbench/services/thread/common/threadService.ts index 9c0e152fd52..0fd6a9cd6af 100644 --- a/src/vs/workbench/services/thread/common/threadService.ts +++ b/src/vs/workbench/services/thread/common/threadService.ts @@ -21,6 +21,7 @@ export interface IThreadService { assertRegistered(identifiers: ProxyIdentifier[]): void; } +// @ts-ignore unused generic parameter export class ProxyIdentifier { _proxyIdentifierBrand: void; diff --git a/src/vs/workbench/services/viewlet/browser/viewletService.ts b/src/vs/workbench/services/viewlet/browser/viewletService.ts index 3af0a697b6f..39cc03bd556 100644 --- a/src/vs/workbench/services/viewlet/browser/viewletService.ts +++ b/src/vs/workbench/services/viewlet/browser/viewletService.ts @@ -25,8 +25,8 @@ export class ViewletService implements IViewletService { private extensionViewletsLoaded: TPromise; private extensionViewletsLoadedPromiseComplete: ValueCallback; - public get onDidViewletOpen(): Event { return this.sidebarPart.onDidViewletOpen; }; - public get onDidViewletClose(): Event { return this.sidebarPart.onDidViewletClose; }; + public get onDidViewletOpen(): Event { return this.sidebarPart.onDidViewletOpen; } + public get onDidViewletClose(): Event { return this.sidebarPart.onDidViewletClose; } constructor( sidebarPart: SidebarPart, diff --git a/src/vs/workbench/test/browser/actionRegistry.test.ts b/src/vs/workbench/test/browser/actionRegistry.test.ts index 97a62c5cc7f..2e9e472df7f 100644 --- a/src/vs/workbench/test/browser/actionRegistry.test.ts +++ b/src/vs/workbench/test/browser/actionRegistry.test.ts @@ -10,13 +10,6 @@ import { Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { prepareActions } from 'vs/workbench/browser/actions'; import { Action } from 'vs/base/common/actions'; - -class MyClass extends Action { - constructor(id: string, label: string) { - super(id, label); - } -} - suite('Workbench Action Registry', () => { test('Workbench Action Bar prepareActions()', function () { diff --git a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts index 1e7826a9ae6..25246bcaa3c 100644 --- a/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/baseEditor.test.ts @@ -75,7 +75,7 @@ class MyInputFactory implements IEditorInputFactory { } class MyInput extends EditorInput { - getPreferredEditorId(ids) { + getPreferredEditorId(ids: string[]) { return ids[1]; } diff --git a/src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts b/src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts index e0e73cd5df4..6308cacd798 100644 --- a/src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/editorStacksModel.test.ts @@ -17,11 +17,12 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { Registry } from 'vs/platform/registry/common/platform'; -import { Position, Direction } from 'vs/platform/editor/common/editor'; +import { Position, Direction, IEditorModel } from 'vs/platform/editor/common/editor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; +import { TPromise } from 'vs/base/common/winjs.base'; function create(): EditorStacksModel { let inst = new TestInstantiationService(); @@ -60,7 +61,7 @@ interface GroupEvents { } function modelListener(model: EditorStacksModel): ModelEvents { - const modelEvents = { + const modelEvents: ModelEvents = { opened: [], activated: [], closed: [], @@ -86,7 +87,7 @@ function modelListener(model: EditorStacksModel): ModelEvents { } function groupListener(group: EditorGroup): GroupEvents { - const groupEvents = { + const groupEvents: GroupEvents = { opened: [], closed: [], activated: [], @@ -111,7 +112,7 @@ class TestEditorInput extends EditorInput { super(); } public getTypeId() { return 'testEditorInput'; } - public resolve() { return null; } + public resolve(): TPromise { return null; } public matches(other: TestEditorInput): boolean { return other && this.id === other.id && other instanceof TestEditorInput; @@ -131,7 +132,7 @@ class NonSerializableTestEditorInput extends EditorInput { super(); } public getTypeId() { return 'testEditorInput-nonSerializable'; } - public resolve() { return null; } + public resolve(): TPromise { return null; } public matches(other: TestEditorInput): boolean { return other && this.id === other.id && other instanceof NonSerializableTestEditorInput; @@ -144,7 +145,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput { super(); } public getTypeId() { return 'testFileEditorInput'; } - public resolve() { return null; } + public resolve(): TPromise { return null; } public matches(other: TestEditorInput): boolean { return other && this.id === other.id && other instanceof TestFileEditorInput; @@ -364,6 +365,7 @@ suite('Editor Stacks Model', () => { model.moveGroup(group3, 1); assert.equal(events.moved.length, 2); + assert.ok(group2); }); test('Groups - Event Aggregation', function () { diff --git a/src/vs/workbench/test/common/editor/editorDiffModel.test.ts b/src/vs/workbench/test/common/editor/editorDiffModel.test.ts index 432571a2e27..505e26e4b22 100644 --- a/src/vs/workbench/test/common/editor/editorDiffModel.test.ts +++ b/src/vs/workbench/test/common/editor/editorDiffModel.test.ts @@ -6,8 +6,6 @@ 'use strict'; import * as assert from 'assert'; -import { EditorModel } from 'vs/workbench/common/editor'; -import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel'; import { TextDiffEditorModel } from 'vs/workbench/common/editor/textDiffEditorModel'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -21,9 +19,6 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IModel } from 'vs/editor/common/editorCommon'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -class MyEditorModel extends EditorModel { } -class MyTextEditorModel extends BaseTextEditorModel { } - class ServiceAccessor { constructor( @ITextModelService public textModelResolverService: ITextModelService, diff --git a/src/vs/workbench/test/common/editor/rangeDecorations.test.ts b/src/vs/workbench/test/common/editor/rangeDecorations.test.ts index e9677bbdb23..08b419544c3 100644 --- a/src/vs/workbench/test/common/editor/rangeDecorations.test.ts +++ b/src/vs/workbench/test/common/editor/rangeDecorations.test.ts @@ -28,8 +28,11 @@ import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands suite('Editor - Range decorations', () => { let instantiationService: TestInstantiationService; + // @ts-ignore unused injected service let editorService: WorkbenchEditorService.IWorkbenchEditorService; + // @ts-ignore unused injected service let modelService: IModelService; + // @ts-ignore unused injected service let modeService: IModeService; let codeEditor: editorCommon.ICommonCodeEditor; let model: Model; diff --git a/src/vs/workbench/test/common/memento.test.ts b/src/vs/workbench/test/common/memento.test.ts index 686250e7b1b..8a3eb9d9219 100644 --- a/src/vs/workbench/test/common/memento.test.ts +++ b/src/vs/workbench/test/common/memento.test.ts @@ -13,8 +13,8 @@ import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; suite('Workbench Memento', () => { - let context; - let storage; + let context: Scope = undefined; + let storage: StorageService; setup(() => { storage = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id); @@ -70,9 +70,9 @@ suite('Workbench Memento', () => { assert.deepEqual(memento, {}); // Assert the Mementos are also removed from storage - assert.strictEqual(storage.get('memento/memento.test', Scope.GLOBAL, null), null); + assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null), null); - assert.strictEqual(storage.get('memento/memento.test', Scope.WORKSPACE, null), null); + assert.strictEqual(storage.get('memento/memento.test', StorageScope.WORKSPACE, null), null); }); test('Save and Load', () => { diff --git a/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts b/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts index f2e905cbb73..812d8bd1ea1 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostApiCommands.test.ts @@ -131,6 +131,7 @@ suite('ExtHostLanguageFeatureCommands', function () { suiteTeardown(() => { setUnexpectedErrorHandler(originalErrorHandler); model.dispose(); + mainThread.dispose(); }); teardown(function (done) { diff --git a/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts b/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts index 5014719ddb2..bbe463f0080 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostConfiguration.test.ts @@ -25,7 +25,7 @@ suite('ExtHostConfiguration', function () { this.lastArgs = [target, key, value]; return TPromise.as(void 0); } - }; + } function createExtHostConfiguration(contents: any = Object.create(null), shape?: MainThreadConfigurationShape) { if (!shape) { diff --git a/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts index 76aa419a4b5..b0fee510b50 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDiagnostics.test.ts @@ -24,7 +24,7 @@ suite('ExtHostDiagnostics', () => { $clear(owner: string): TPromise { return TPromise.as(null); } - }; + } test('disposeCheck', function () { @@ -35,6 +35,7 @@ suite('ExtHostDiagnostics', () => { assert.throws(() => collection.name); assert.throws(() => collection.clear()); assert.throws(() => collection.delete(URI.parse('aa:bb'))); + // tslint:disable-next-line:semicolon assert.throws(() => collection.forEach(() => { ; })); assert.throws(() => collection.get(URI.parse('aa:bb'))); assert.throws(() => collection.has(URI.parse('aa:bb'))); diff --git a/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts b/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts index d4a3a7a422f..b89cbfe82dd 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts @@ -42,18 +42,18 @@ suite('ExtHostDocumentData', () => { }); test('readonly-ness', function () { - assert.throws(() => (data).document.uri = null); - assert.throws(() => (data).document.fileName = 'foofile'); - assert.throws(() => (data).document.isDirty = false); - assert.throws(() => (data).document.isUntitled = false); - assert.throws(() => (data).document.languageId = 'dddd'); - assert.throws(() => (data).document.lineCount = 9); + assert.throws((): void => (data as any).document.uri = null); + assert.throws(() => (data as any).document.fileName = 'foofile'); + assert.throws(() => (data as any).document.isDirty = false); + assert.throws(() => (data as any).document.isUntitled = false); + assert.throws(() => (data as any).document.languageId = 'dddd'); + assert.throws(() => (data as any).document.lineCount = 9); }); test('save, when disposed', function () { let saved: URI; let data = new ExtHostDocumentData(new class extends mock() { - $trySaveDocument(uri) { + $trySaveDocument(uri: URI) { assert.ok(!saved); saved = uri; return TPromise.as(true); diff --git a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts index 92c6cfed88e..eaed5845910 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts @@ -118,6 +118,7 @@ suite('ExtHostLanguageFeatures', function () { suiteTeardown(() => { setUnexpectedErrorHandler(originalErrorHandler); model.dispose(); + mainThread.dispose(); }); teardown(function () { diff --git a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts index 37c944c5ce9..ed06fa678dc 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostMessagerService.test.ts @@ -9,22 +9,23 @@ import * as assert from 'assert'; import { Action } from 'vs/base/common/actions'; import { MainThreadMessageService } from 'vs/workbench/api/electron-browser/mainThreadMessageService'; import { TPromise as Promise } from 'vs/base/common/winjs.base'; +import { IMessageService, IChoiceService } from 'vs/platform/message/common/message'; suite('ExtHostMessageService', function () { test('propagte handle on select', function () { - let service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + let service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { assert.equal(m.actions.length, 1); setImmediate(() => m.actions[0].run()); return () => { }; } - }, { - choose() { + } as IMessageService, { + choose(severity, message, options, modal) { throw new Error('not implemented'); } - }); + } as IChoiceService); return service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => { assert.equal(handle, 42); @@ -34,15 +35,15 @@ suite('ExtHostMessageService', function () { test('isCloseAffordance', function () { let actions: Action[]; - let service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + let service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { actions = m.actions; } - }, { - choose() { + } as IMessageService, { + choose(severity, message, options, modal) { throw new Error('not implemented'); } - }); + } as IChoiceService); // default close action service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: false, handle: 0 }]); @@ -62,19 +63,19 @@ suite('ExtHostMessageService', function () { let actions: Action[]; let c: number; - let service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + let service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { c = 0; actions = m.actions; return () => { c += 1; }; } - }, { - choose() { + } as IMessageService, { + choose(severity, message, options, modal) { throw new Error('not implemented'); } - }); + } as IChoiceService); service.$showMessage(1, '', {}, [{ title: 'a thing', isCloseAffordance: true, handle: 0 }]); assert.equal(actions.length, 1); @@ -85,11 +86,11 @@ suite('ExtHostMessageService', function () { suite('modal', () => { test('calls choice service', () => { - const service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + const service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { throw new Error('not implemented'); } - }, { + } as IMessageService, { choose(severity, message, options, modal) { assert.equal(severity, 1); assert.equal(message, 'h'); @@ -97,7 +98,7 @@ suite('ExtHostMessageService', function () { assert.equal(options[1], 'Cancel'); return Promise.as(0); } - }); + } as IChoiceService); return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => { assert.equal(handle, 42); @@ -105,15 +106,15 @@ suite('ExtHostMessageService', function () { }); test('returns undefined when cancelled', () => { - const service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + const service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { throw new Error('not implemented'); } - }, { + } as IMessageService, { choose(severity, message, options, modal) { return Promise.as(1); } - }); + } as IChoiceService); return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]).then(handle => { assert.equal(handle, undefined); @@ -121,16 +122,16 @@ suite('ExtHostMessageService', function () { }); test('hides Cancel button when not needed', () => { - const service = new MainThreadMessageService(null, null, { - show(sev: number, m: { message; actions: Action[] }) { + const service = new MainThreadMessageService(null, { + show(sev: number, m: { actions: Action[] }) { throw new Error('not implemented'); } - }, { + } as IMessageService, { choose(severity, message, options, modal) { assert.equal(options.length, 1); return Promise.as(0); } - }); + } as IChoiceService); return service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]).then(handle => { assert.equal(handle, 42); diff --git a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts index 1426bcdef75..f1824c5c95d 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTreeViews.test.ts @@ -31,7 +31,7 @@ suite('ExtHostConfiguration', function () { $refresh(viewId: string, itemHandles: number[]): void { this.onRefresh.fire(itemHandles); } - }; + } let testObject: ExtHostTreeViews; let target: RecordingShape; diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts index 7fd5cb0883e..f070654bb3a 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadDocumentsAndEditors.test.ts @@ -25,7 +25,6 @@ suite('MainThreadDocumentsAndEditors', () => { let codeEditorService: MockCodeEditorService; let textFileService: ITextFileService; let workbenchEditorService: IWorkbenchEditorService; - let documentAndEditor: MainThreadDocumentsAndEditors; let deltas: IDocumentsAndEditorsDelta[] = []; const hugeModelString = new Array(2 + (50 * 1024 * 1024)).join('-'); @@ -36,7 +35,7 @@ suite('MainThreadDocumentsAndEditors', () => { modelService = new ModelServiceImpl(null, configService); codeEditorService = new MockCodeEditorService(); textFileService = new class extends mock() { - isDirty() { return false; }; + isDirty() { return false; } models = { onModelSaved: Event.None, onModelReverted: Event.None, @@ -52,7 +51,7 @@ suite('MainThreadDocumentsAndEditors', () => { onEditorGroupMoved = Event.None; }; - documentAndEditor = new MainThreadDocumentsAndEditors( + new MainThreadDocumentsAndEditors( OneGetThreadService(new class extends mock() { $acceptDocumentsAndEditorsDelta(delta) { deltas.push(delta); } }), diff --git a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts index b470742526b..ab9454d1177 100644 --- a/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts +++ b/src/vs/workbench/test/electron-browser/api/mainThreadEditors.test.ts @@ -36,7 +36,7 @@ suite('MainThreadEditors', () => { modelService = new ModelServiceImpl(null, configService); const codeEditorService = new MockCodeEditorService(); const textFileService = new class extends mock() { - isDirty() { return false; }; + isDirty() { return false; } models = { onModelSaved: Event.None, onModelReverted: Event.None, diff --git a/src/vs/workbench/test/electron-browser/api/mock.ts b/src/vs/workbench/test/electron-browser/api/mock.ts index 622f52cade3..9e8c56e11bc 100644 --- a/src/vs/workbench/test/electron-browser/api/mock.ts +++ b/src/vs/workbench/test/electron-browser/api/mock.ts @@ -10,5 +10,5 @@ export interface Ctor { } export function mock(): Ctor { - return function () { }; + return function () { } as any; } diff --git a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts index f811c0727c3..e0fc023cb81 100644 --- a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts @@ -178,7 +178,7 @@ class TestTelemetryService implements ITelemetryService { machineId: 'someValue.machineId' }); } -}; +} class TestExperimentService implements IExperimentService { diff --git a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts index 0cc049bd232..056f00fdbd0 100644 --- a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts @@ -166,4 +166,4 @@ class TestTelemetryService implements ITelemetryService { machineId: 'someValue.machineId' }); } -}; +} diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 3d0c198bc98..9b42bc2bd74 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -60,6 +60,7 @@ import { ITextResourceConfigurationService } from 'vs/editor/common/services/res import { IPosition } from 'vs/editor/common/core/position'; import { ICommandAction } from 'vs/platform/actions/common/actions'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; +import { notImplemented } from 'vs/base/common/errors'; export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput { return instantiationService.createInstance(FileEditorInput, resource, void 0); @@ -71,7 +72,6 @@ export class TestContextService implements IWorkspaceContextService { public _serviceBrand: any; private workspace: IWorkbenchWorkspace; - private id: string; private options: any; private _onDidChangeWorkspaceName: Emitter; @@ -80,7 +80,6 @@ export class TestContextService implements IWorkspaceContextService { constructor(workspace: any = TestWorkspace, options: any = null) { this.workspace = workspace; - this.id = generateUuid(); this.options = options || Object.create(null); this._onDidChangeWorkspaceFolders = new Emitter(); this._onDidChangeWorkbenchState = new Emitter(); @@ -880,7 +879,7 @@ export class TestBackupFileService implements IBackupFileService { public discardAllWorkspaceBackups(): TPromise { return TPromise.as(void 0); } -}; +} export class TestWindowService implements IWindowService { @@ -1008,10 +1007,12 @@ export class TestLifecycleService implements ILifecycleService { public phase: LifecyclePhase; public startupKind: StartupKind; - private _onDidChangePhase = new Emitter(); private _onWillShutdown = new Emitter(); private _onShutdown = new Emitter(); + when(): Thenable { + throw notImplemented(); + } public fireShutdown(reason = ShutdownReason.QUIT): void { this._onShutdown.fire(reason); @@ -1021,10 +1022,6 @@ export class TestLifecycleService implements ILifecycleService { this._onWillShutdown.fire(event); } - public get onDidChangePhase(): Event { - return this._onDidChangePhase.event; - } - public get onWillShutdown(): Event { return this._onWillShutdown.event; } @@ -1250,4 +1247,4 @@ export class TestHashService implements IHashService { export function getRandomTestPath(tmpdir: string, ...segments: string[]): string { return paths.join(tmpdir, ...segments, generateUuid()); -} \ No newline at end of file +} diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index 4844c81d0aa..bfd4680bc86 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -28,6 +28,7 @@ import 'vs/workbench/browser/actions/toggleSidebarVisibility'; import 'vs/workbench/browser/actions/toggleSidebarPosition'; import 'vs/workbench/browser/actions/toggleEditorLayout'; import 'vs/workbench/browser/actions/toggleZenMode'; +import 'vs/workbench/browser/actions/toggleTabsVisibility'; import 'vs/workbench/parts/preferences/browser/preferences.contribution'; import 'vs/workbench/parts/preferences/browser/keybindingsEditorContribution'; diff --git a/test/smoke/src/areas/activitybar/activityBar.ts b/test/smoke/src/areas/activitybar/activityBar.ts index ada2cb9c5b6..894eef36f9f 100644 --- a/test/smoke/src/areas/activitybar/activityBar.ts +++ b/test/smoke/src/areas/activitybar/activityBar.ts @@ -9,7 +9,7 @@ import { SpectronApplication } from '../../spectron/application'; export enum ActivityBarPosition { LEFT = 0, RIGHT = 1 -}; +} export class ActivityBar { diff --git a/test/smoke/src/areas/preferences/settings.ts b/test/smoke/src/areas/preferences/settings.ts index 37352e30c8e..657d71357e9 100644 --- a/test/smoke/src/areas/preferences/settings.ts +++ b/test/smoke/src/areas/preferences/settings.ts @@ -10,7 +10,7 @@ import { SpectronApplication } from '../../spectron/application'; export enum ActivityBarPosition { LEFT = 0, RIGHT = 1 -}; +} const SEARCH_INPUT = '.settings-search-input input'; const EDITOR = '.editable-preferences-editor-container .monaco-editor textarea'; diff --git a/test/smoke/src/areas/problems/problems.ts b/test/smoke/src/areas/problems/problems.ts index ed1ea406c1a..f28697e5e81 100644 --- a/test/smoke/src/areas/problems/problems.ts +++ b/test/smoke/src/areas/problems/problems.ts @@ -8,7 +8,7 @@ import { SpectronApplication } from '../../spectron/application'; export enum ProblemSeverity { WARNING = 0, ERROR = 1 -}; +} export class Problems { diff --git a/test/smoke/src/spectron/application.ts b/test/smoke/src/spectron/application.ts index 18f5cfb5413..22c1c23010d 100644 --- a/test/smoke/src/spectron/application.ts +++ b/test/smoke/src/spectron/application.ts @@ -332,6 +332,6 @@ export class SpectronApplication { return 'Meta'; default: return key.length === 1 ? key : key.charAt(0).toUpperCase() + key.slice(1); - }; + } } } diff --git a/tslint.json b/tslint.json index a1d03a430f6..e5f6005ed78 100644 --- a/tslint.json +++ b/tslint.json @@ -6,7 +6,7 @@ "no-string-throw": true, "no-unused-expression": true, "no-duplicate-variable": true, - "no-unused-variable": true, + // "no-unused-variable": true, // requires type information in tslint > v4 "curly": true, "class-name": true, "semicolon": [ @@ -430,5 +430,6 @@ ], "duplicate-imports": true, "translation-remind": true - } -} + }, + "defaultSeverity": "warning" +} \ No newline at end of file