From 7747dfe54d5b5eb30ad738273f13e4983e15e735 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 8 Nov 2017 17:09:35 +0100 Subject: [PATCH] Remove @ts-ignore (#37212) --- src/vs/editor/common/commonCodeEditor.ts | 4 +- .../editor/common/controller/coreCommands.ts | 238 +++++++++--------- src/vs/editor/common/core/uint.ts | 13 +- .../modes/languageConfigurationRegistry.ts | 4 - .../editor/common/modes/supports/onEnter.ts | 7 +- .../services/editorWorkerServiceImpl.ts | 10 +- .../codelens/browser/codelensWidget.ts | 2 +- .../colorPicker/browser/colorPickerWidget.ts | 6 +- .../contrib/indentation/common/indentation.ts | 8 +- .../standalone/browser/standaloneServices.ts | 2 +- .../test/browser/controller/imeTester.ts | 3 - .../browser/controller/textAreaState.test.ts | 59 +---- .../viewModel/viewModelDecorations.test.ts | 36 ++- .../test/common/mockKeybindingService.ts | 7 +- .../services/thread/common/threadService.ts | 2 +- 15 files changed, 153 insertions(+), 248 deletions(-) diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index b59e5fa0c82bd..242fa9d90be5e 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -1036,8 +1036,6 @@ 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; private _editorTabMovesFocus: IContextKey; @@ -1053,7 +1051,7 @@ class EditorContextKeysManager extends Disposable { this._editor = editor; - this._editorId = contextKeyService.createKey('editorId', editor.getId()); + contextKeyService.createKey('editorId', editor.getId()); this._editorFocus = EditorContextKeys.focus.bindTo(contextKeyService); this._editorTextFocus = EditorContextKeys.textFocus.bindTo(contextKeyService); this._editorTabMovesFocus = EditorContextKeys.tabMovesFocus.bindTo(contextKeyService); diff --git a/src/vs/editor/common/controller/coreCommands.ts b/src/vs/editor/common/controller/coreCommands.ts index f3a8e446f638a..36f743bb0cc82 100644 --- a/src/vs/editor/common/controller/coreCommands.ts +++ b/src/vs/editor/common/controller/coreCommands.ts @@ -1650,148 +1650,144 @@ export namespace CoreEditingCommands { }); } -// @ts-ignore unused namespace -namespace Config { - function findFocusedEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor { - return accessor.get(ICodeEditorService).getFocusedCodeEditor(); - } +function findFocusedEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor { + return accessor.get(ICodeEditorService).getFocusedCodeEditor(); +} - function getWorkbenchActiveEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor { - const editorService = accessor.get(IEditorService); - let activeEditor = (editorService).getActiveEditor && (editorService).getActiveEditor(); - return getCodeEditor(activeEditor); - } +function getWorkbenchActiveEditor(accessor: ServicesAccessor): editorCommon.ICommonCodeEditor { + const editorService = accessor.get(IEditorService); + let activeEditor = (editorService).getActiveEditor && (editorService).getActiveEditor(); + return getCodeEditor(activeEditor); +} - function registerCommand(command: Command) { - KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(CORE_WEIGHT)); - } +function registerCommand(command: Command) { + KeybindingsRegistry.registerCommandAndKeybindingRule(command.toCommandAndKeybindingRule(CORE_WEIGHT)); +} - /** - * A command that will: - * 1. invoke a command on the focused editor. - * 2. otherwise, invoke a browser built-in command on the `activeElement`. - * 3. otherwise, invoke a command on the workbench active editor. - */ - class EditorOrNativeTextInputCommand extends Command { +/** + * A command that will: + * 1. invoke a command on the focused editor. + * 2. otherwise, invoke a browser built-in command on the `activeElement`. + * 3. otherwise, invoke a command on the workbench active editor. + */ +class EditorOrNativeTextInputCommand extends Command { + + private readonly _editorHandler: string | EditorCommand; + private readonly _inputHandler: string; + + constructor(opts: ICommandOptions & { editorHandler: string | EditorCommand; inputHandler: string; }) { + super(opts); + this._editorHandler = opts.editorHandler; + this._inputHandler = opts.inputHandler; + } - private readonly _editorHandler: string | EditorCommand; - private readonly _inputHandler: string; + public runCommand(accessor: ServicesAccessor, args: any): void { - constructor(opts: ICommandOptions & { editorHandler: string | EditorCommand; inputHandler: string; }) { - super(opts); - this._editorHandler = opts.editorHandler; - this._inputHandler = opts.inputHandler; + let focusedEditor = findFocusedEditor(accessor); + // Only if editor text focus (i.e. not if editor has widget focus). + if (focusedEditor && focusedEditor.isFocused()) { + return this._runEditorHandler(focusedEditor, args); } - public runCommand(accessor: ServicesAccessor, args: any): void { - - let focusedEditor = findFocusedEditor(accessor); - // Only if editor text focus (i.e. not if editor has widget focus). - if (focusedEditor && focusedEditor.isFocused()) { - return this._runEditorHandler(focusedEditor, args); - } - - // Ignore this action when user is focused on an element that allows for entering text - let activeElement = document.activeElement; - if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) { - document.execCommand(this._inputHandler); - return; - } - - // Redirecting to last active editor - let activeEditor = getWorkbenchActiveEditor(accessor); - if (activeEditor) { - activeEditor.focus(); - return this._runEditorHandler(activeEditor, args); - } + // Ignore this action when user is focused on an element that allows for entering text + let activeElement = document.activeElement; + if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) { + document.execCommand(this._inputHandler); + return; } - private _runEditorHandler(editor: editorCommon.ICommonCodeEditor, args: any): void { - let HANDLER = this._editorHandler; - if (typeof HANDLER === 'string') { - editor.trigger('keyboard', HANDLER, args); - } else { - args = args || {}; - args.source = 'keyboard'; - HANDLER.runEditorCommand(null, editor, args); - } + // Redirecting to last active editor + let activeEditor = getWorkbenchActiveEditor(accessor); + if (activeEditor) { + activeEditor.focus(); + return this._runEditorHandler(activeEditor, args); } } - registerCommand(new EditorOrNativeTextInputCommand({ - editorHandler: CoreNavigationCommands.SelectAll, - inputHandler: 'selectAll', - id: 'editor.action.selectAll', - precondition: null, - kbOpts: { - weight: CORE_WEIGHT, - kbExpr: null, - primary: KeyMod.CtrlCmd | KeyCode.KEY_A + private _runEditorHandler(editor: editorCommon.ICommonCodeEditor, args: any): void { + let HANDLER = this._editorHandler; + if (typeof HANDLER === 'string') { + editor.trigger('keyboard', HANDLER, args); + } else { + args = args || {}; + args.source = 'keyboard'; + HANDLER.runEditorCommand(null, editor, args); } - })); - - registerCommand(new EditorOrNativeTextInputCommand({ - editorHandler: H.Undo, - inputHandler: 'undo', - id: H.Undo, - precondition: EditorContextKeys.writable, - kbOpts: { - weight: CORE_WEIGHT, - kbExpr: EditorContextKeys.textFocus, - primary: KeyMod.CtrlCmd | KeyCode.KEY_Z - } - })); - - registerCommand(new EditorOrNativeTextInputCommand({ - editorHandler: H.Redo, - inputHandler: 'redo', - id: H.Redo, - precondition: EditorContextKeys.writable, - kbOpts: { - weight: CORE_WEIGHT, - kbExpr: EditorContextKeys.textFocus, - primary: KeyMod.CtrlCmd | KeyCode.KEY_Y, - secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z], - mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z } - } - })); + } +} - /** - * A command that will invoke a command on the focused editor. - */ - class EditorHandlerCommand extends Command { +registerCommand(new EditorOrNativeTextInputCommand({ + editorHandler: CoreNavigationCommands.SelectAll, + inputHandler: 'selectAll', + id: 'editor.action.selectAll', + precondition: null, + kbOpts: { + weight: CORE_WEIGHT, + kbExpr: null, + primary: KeyMod.CtrlCmd | KeyCode.KEY_A + } +})); + +registerCommand(new EditorOrNativeTextInputCommand({ + editorHandler: H.Undo, + inputHandler: 'undo', + id: H.Undo, + precondition: EditorContextKeys.writable, + kbOpts: { + weight: CORE_WEIGHT, + kbExpr: EditorContextKeys.textFocus, + primary: KeyMod.CtrlCmd | KeyCode.KEY_Z + } +})); + +registerCommand(new EditorOrNativeTextInputCommand({ + editorHandler: H.Redo, + inputHandler: 'redo', + id: H.Redo, + precondition: EditorContextKeys.writable, + kbOpts: { + weight: CORE_WEIGHT, + kbExpr: EditorContextKeys.textFocus, + primary: KeyMod.CtrlCmd | KeyCode.KEY_Y, + secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z], + mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_Z } + } +})); - private readonly _handlerId: string; +/** + * A command that will invoke a command on the focused editor. + */ +class EditorHandlerCommand extends Command { - constructor(id: string, handlerId: string) { - super({ - id: id, - precondition: null - }); - this._handlerId = handlerId; - } + private readonly _handlerId: string; - public runCommand(accessor: ServicesAccessor, args: any): void { - const editor = findFocusedEditor(accessor); - if (!editor) { - return; - } + constructor(id: string, handlerId: string) { + super({ + id: id, + precondition: null + }); + this._handlerId = handlerId; + } - editor.trigger('keyboard', this._handlerId, args); + public runCommand(accessor: ServicesAccessor, args: any): void { + const editor = findFocusedEditor(accessor); + if (!editor) { + return; } - } - function registerOverwritableCommand(handlerId: string): void { - registerCommand(new EditorHandlerCommand('default:' + handlerId, handlerId)); - registerCommand(new EditorHandlerCommand(handlerId, handlerId)); + editor.trigger('keyboard', this._handlerId, args); } +} - registerOverwritableCommand(H.Type); - registerOverwritableCommand(H.ReplacePreviousChar); - registerOverwritableCommand(H.CompositionStart); - registerOverwritableCommand(H.CompositionEnd); - registerOverwritableCommand(H.Paste); - registerOverwritableCommand(H.Cut); - +function registerOverwritableCommand(handlerId: string): void { + registerCommand(new EditorHandlerCommand('default:' + handlerId, handlerId)); + registerCommand(new EditorHandlerCommand(handlerId, handlerId)); } + +registerOverwritableCommand(H.Type); +registerOverwritableCommand(H.ReplacePreviousChar); +registerOverwritableCommand(H.CompositionStart); +registerOverwritableCommand(H.CompositionEnd); +registerOverwritableCommand(H.Paste); +registerOverwritableCommand(H.Cut); diff --git a/src/vs/editor/common/core/uint.ts b/src/vs/editor/common/core/uint.ts index 924b783a4a5ff..d368d7824fd01 100644 --- a/src/vs/editor/common/core/uint.ts +++ b/src/vs/editor/common/core/uint.ts @@ -7,9 +7,8 @@ export class Uint8Matrix { private _data: Uint8Array; - // @ts-ignore unused property - private _rows: number; - private _cols: number; + public readonly rows: number; + public readonly cols: number; constructor(rows: number, cols: number, defaultValue: number) { let data = new Uint8Array(rows * cols); @@ -18,16 +17,16 @@ export class Uint8Matrix { } this._data = data; - this._rows = rows; - this._cols = cols; + this.rows = rows; + this.cols = cols; } public get(row: number, col: number): number { - return this._data[row * this._cols + col]; + return this._data[row * this.cols + col]; } public set(row: number, col: number, value: number): void { - this._data[row * this._cols + col] = value; + this._data[row * this.cols + col] = value; } } diff --git a/src/vs/editor/common/modes/languageConfigurationRegistry.ts b/src/vs/editor/common/modes/languageConfigurationRegistry.ts index f069921add2e4..902f76c3f8ba0 100644 --- a/src/vs/editor/common/modes/languageConfigurationRegistry.ts +++ b/src/vs/editor/common/modes/languageConfigurationRegistry.ts @@ -110,10 +110,6 @@ export class RichEditSupport { empty = false; onEnter.brackets = conf.brackets; } - if (conf.indentationRules) { - empty = false; - onEnter.indentationRules = conf.indentationRules; - } if (conf.onEnterRules) { empty = false; onEnter.regExpRules = conf.onEnterRules; diff --git a/src/vs/editor/common/modes/supports/onEnter.ts b/src/vs/editor/common/modes/supports/onEnter.ts index be11c521278ad..bec5536307837 100644 --- a/src/vs/editor/common/modes/supports/onEnter.ts +++ b/src/vs/editor/common/modes/supports/onEnter.ts @@ -6,11 +6,10 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; -import { CharacterPair, IndentationRule, IndentAction, EnterAction, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration'; +import { CharacterPair, IndentAction, EnterAction, OnEnterRule } from 'vs/editor/common/modes/languageConfiguration'; export interface IOnEnterSupportOptions { brackets?: CharacterPair[]; - indentationRules?: IndentationRule; regExpRules?: OnEnterRule[]; } @@ -24,8 +23,6 @@ interface IProcessedBracketPair { export class OnEnterSupport { private readonly _brackets: IProcessedBracketPair[]; - // @ts-ignore unused property - private readonly _indentationRules: IndentationRule; private readonly _regExpRules: OnEnterRule[]; constructor(opts?: IOnEnterSupportOptions) { @@ -45,7 +42,6 @@ export class OnEnterSupport { }; }); this._regExpRules = opts.regExpRules || []; - this._indentationRules = opts.indentationRules; } public onEnter(oneLineAboveText: string, beforeEnterText: string, afterEnterText: string): EnterAction { @@ -114,4 +110,3 @@ export class OnEnterSupport { } } } - diff --git a/src/vs/editor/common/services/editorWorkerServiceImpl.ts b/src/vs/editor/common/services/editorWorkerServiceImpl.ts index ed44a216e56c8..42a9e0a9ce109 100644 --- a/src/vs/editor/common/services/editorWorkerServiceImpl.ts +++ b/src/vs/editor/common/services/editorWorkerServiceImpl.ts @@ -20,7 +20,6 @@ import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageCo import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IRange } from 'vs/editor/common/core/range'; -import { IModeService } from 'vs/editor/common/services/modeService'; /** * Stop syncing a model to the worker if it was not needed for 1 min. @@ -51,8 +50,7 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker constructor( @IModelService modelService: IModelService, - @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService, - @IModeService modeService: IModeService + @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService ) { super(); this._modelService = modelService; @@ -67,7 +65,7 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker return wireCancellationToken(token, this._workerManager.withWorker().then(client => client.computeLinks(model.uri))); } })); - this._register(modes.SuggestRegistry.register('*', new WordBasedCompletionItemProvider(this._workerManager, configurationService, modeService, this._modelService))); + this._register(modes.SuggestRegistry.register('*', new WordBasedCompletionItemProvider(this._workerManager, configurationService, this._modelService))); } public dispose(): void { @@ -114,19 +112,15 @@ 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; constructor( workerManager: WorkerManager, configurationService: ITextResourceConfigurationService, - modeService: IModeService, modelService: IModelService ) { this._workerManager = workerManager; this._configurationService = configurationService; - this._modeService = modeService; this._modelService = modelService; } diff --git a/src/vs/editor/contrib/codelens/browser/codelensWidget.ts b/src/vs/editor/contrib/codelens/browser/codelensWidget.ts index b98a31d4fa797..8fb0da68a491d 100644 --- a/src/vs/editor/contrib/codelens/browser/codelensWidget.ts +++ b/src/vs/editor/contrib/codelens/browser/codelensWidget.ts @@ -65,7 +65,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget { private readonly _disposables: IDisposable[] = []; private readonly _editor: editorBrowser.ICodeEditor; - // @ts-ignore unused property + // @ts-ignore TODO@Joh 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 1b461696a6856..12e81fd7206b7 100644 --- a/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts +++ b/src/vs/editor/contrib/colorPicker/browser/colorPickerWidget.ts @@ -66,8 +66,8 @@ 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) { + + constructor(container: HTMLElement, private model: ColorPickerModel, private pixelRatio: number) { super(); this.domNode = $('.colorpicker-body'); @@ -354,4 +354,4 @@ export class ColorPickerWidget extends Widget { layout(): void { this.body.layout(); } -} \ No newline at end of file +} diff --git a/src/vs/editor/contrib/indentation/common/indentation.ts b/src/vs/editor/contrib/indentation/common/indentation.ts index 991a7f2e4cb80..d64060feec0f4 100644 --- a/src/vs/editor/contrib/indentation/common/indentation.ts +++ b/src/vs/editor/contrib/indentation/common/indentation.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; import * as strings from 'vs/base/common/strings'; -import { ICommonCodeEditor, IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel, EndOfLineSequence } from 'vs/editor/common/editorCommon'; +import { ICommonCodeEditor, IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, registerCommonEditorContribution } from 'vs/editor/common/editorCommonExtensions'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; @@ -327,8 +327,6 @@ export class ReindentLinesAction extends EditorAction { export class AutoIndentOnPasteCommand implements ICommand { private _edits: TextEdit[]; - // @ts-ignore unused property - private _newEol: EndOfLineSequence; private _initialSelection: Selection; private _selectionId: string; @@ -336,12 +334,8 @@ export class AutoIndentOnPasteCommand implements ICommand { constructor(edits: TextEdit[], initialSelection: Selection) { this._initialSelection = initialSelection; this._edits = []; - this._newEol = undefined; for (let edit of edits) { - if (typeof edit.eol === 'number') { - this._newEol = edit.eol; - } if (edit.range && typeof edit.text === 'string') { this._edits.push(edit); } diff --git a/src/vs/editor/standalone/browser/standaloneServices.ts b/src/vs/editor/standalone/browser/standaloneServices.ts index 7fac82dc12b0d..c219b2f8e22ad 100644 --- a/src/vs/editor/standalone/browser/standaloneServices.ts +++ b/src/vs/editor/standalone/browser/standaloneServices.ts @@ -132,7 +132,7 @@ export module StaticServices { export const modelService = define(IModelService, (o) => new ModelServiceImpl(markerService.get(o), configurationService.get(o))); - export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o), modeService.get(o))); + export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o))); export const standaloneThemeService = define(IStandaloneThemeService, () => new StandaloneThemeServiceImpl()); diff --git a/src/vs/editor/test/browser/controller/imeTester.ts b/src/vs/editor/test/browser/controller/imeTester.ts index 6d80c9f7d5fbc..08b0b84882ddb 100644 --- a/src/vs/editor/test/browser/controller/imeTester.ts +++ b/src/vs/editor/test/browser/controller/imeTester.ts @@ -17,12 +17,9 @@ 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) { this._line = line; - this._eol = '\n'; } _setText(text: string) { diff --git a/src/vs/editor/test/browser/controller/textAreaState.test.ts b/src/vs/editor/test/browser/controller/textAreaState.test.ts index f63f52aadc30b..e9103196061e2 100644 --- a/src/vs/editor/test/browser/controller/textAreaState.test.ts +++ b/src/vs/editor/test/browser/controller/textAreaState.test.ts @@ -5,10 +5,8 @@ 'use strict'; import * as assert from 'assert'; -import { ISimpleModel, TextAreaState, ITextAreaWrapper, PagedScreenReaderStrategy } from 'vs/editor/browser/controller/textAreaState'; -import { Range } from 'vs/editor/common/core/range'; +import { TextAreaState, ITextAreaWrapper, PagedScreenReaderStrategy } from 'vs/editor/browser/controller/textAreaState'; import { Position } from 'vs/editor/common/core/position'; -import { EndOfLinePreference } from 'vs/editor/common/editorCommon'; import { Disposable } from 'vs/base/common/lifecycle'; import { Model } from 'vs/editor/common/model/model'; import { Selection } from 'vs/editor/common/core/selection'; @@ -587,58 +585,3 @@ suite('TextAreaState', () => { }); }); - -// @ts-ignore unused class -class SimpleModel implements ISimpleModel { - - private _lines: string[]; - private _eol: string; - - constructor(lines: string[], eol: string) { - this._lines = lines; - this._eol = eol; - } - - public getLineMaxColumn(lineNumber: number): number { - return this._lines[lineNumber - 1].length + 1; - } - - private _getEndOfLine(eol: EndOfLinePreference): string { - switch (eol) { - case EndOfLinePreference.LF: - return '\n'; - case EndOfLinePreference.CRLF: - return '\r\n'; - case EndOfLinePreference.TextDefined: - return this._eol; - } - throw new Error('Unknown EOL preference'); - } - - public getValueInRange(range: Range, eol: EndOfLinePreference): string { - if (Range.isEmpty(range)) { - return ''; - } - - if (range.startLineNumber === range.endLineNumber) { - return this._lines[range.startLineNumber - 1].substring(range.startColumn - 1, range.endColumn - 1); - } - - var lineEnding = this._getEndOfLine(eol), - startLineIndex = range.startLineNumber - 1, - endLineIndex = range.endLineNumber - 1, - resultLines: string[] = []; - - resultLines.push(this._lines[startLineIndex].substring(range.startColumn - 1)); - for (var i = startLineIndex + 1; i < endLineIndex; i++) { - resultLines.push(this._lines[i]); - } - resultLines.push(this._lines[endLineIndex].substring(0, range.endColumn - 1)); - - return resultLines.join(lineEnding); - } - - public getLineCount(): number { - return this._lines.length; - } -} diff --git a/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts b/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts index 290e750f64532..0674c3b181dc4 100644 --- a/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts +++ b/src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts @@ -25,8 +25,6 @@ suite('ViewModelDecorations', () => { assert.equal(viewModel.getLineContent(4), 'will be '); assert.equal(viewModel.getLineContent(5), 'wrapped'); - //@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 { @@ -40,39 +38,39 @@ suite('ViewModelDecorations', () => { // VIEWPORT will be (1,14) -> (1,36) // completely before viewport - dec1 = accessor.addDecoration(new Range(1, 2, 1, 3), createOpts('dec1')); + accessor.addDecoration(new Range(1, 2, 1, 3), createOpts('dec1')); // starts before viewport, ends at viewport start - dec2 = accessor.addDecoration(new Range(1, 2, 1, 14), createOpts('dec2')); + accessor.addDecoration(new Range(1, 2, 1, 14), createOpts('dec2')); // starts before viewport, ends inside viewport - dec3 = accessor.addDecoration(new Range(1, 2, 1, 15), createOpts('dec3')); + accessor.addDecoration(new Range(1, 2, 1, 15), createOpts('dec3')); // starts before viewport, ends at viewport end - dec4 = accessor.addDecoration(new Range(1, 2, 1, 36), createOpts('dec4')); + accessor.addDecoration(new Range(1, 2, 1, 36), createOpts('dec4')); // starts before viewport, ends after viewport - dec5 = accessor.addDecoration(new Range(1, 2, 1, 51), createOpts('dec5')); + accessor.addDecoration(new Range(1, 2, 1, 51), createOpts('dec5')); // starts at viewport start, ends at viewport start - dec6 = accessor.addDecoration(new Range(1, 14, 1, 14), createOpts('dec6')); + accessor.addDecoration(new Range(1, 14, 1, 14), createOpts('dec6')); // starts at viewport start, ends inside viewport - dec7 = accessor.addDecoration(new Range(1, 14, 1, 16), createOpts('dec7')); + accessor.addDecoration(new Range(1, 14, 1, 16), createOpts('dec7')); // starts at viewport start, ends at viewport end - dec8 = accessor.addDecoration(new Range(1, 14, 1, 36), createOpts('dec8')); + accessor.addDecoration(new Range(1, 14, 1, 36), createOpts('dec8')); // starts at viewport start, ends after viewport - dec9 = accessor.addDecoration(new Range(1, 14, 1, 51), createOpts('dec9')); + accessor.addDecoration(new Range(1, 14, 1, 51), createOpts('dec9')); // starts inside viewport, ends inside viewport - dec10 = accessor.addDecoration(new Range(1, 16, 1, 18), createOpts('dec10')); + accessor.addDecoration(new Range(1, 16, 1, 18), createOpts('dec10')); // starts inside viewport, ends at viewport end - dec11 = accessor.addDecoration(new Range(1, 16, 1, 36), createOpts('dec11')); + accessor.addDecoration(new Range(1, 16, 1, 36), createOpts('dec11')); // starts inside viewport, ends after viewport - dec12 = accessor.addDecoration(new Range(1, 16, 1, 51), createOpts('dec12')); + accessor.addDecoration(new Range(1, 16, 1, 51), createOpts('dec12')); // starts at viewport end, ends at viewport end - dec13 = accessor.addDecoration(new Range(1, 36, 1, 36), createOpts('dec13')); + accessor.addDecoration(new Range(1, 36, 1, 36), createOpts('dec13')); // starts at viewport end, ends after viewport - dec14 = accessor.addDecoration(new Range(1, 36, 1, 51), createOpts('dec14')); + accessor.addDecoration(new Range(1, 36, 1, 51), createOpts('dec14')); // starts after viewport, ends after viewport - dec15 = accessor.addDecoration(new Range(1, 40, 1, 51), createOpts('dec15')); + accessor.addDecoration(new Range(1, 40, 1, 51), createOpts('dec15')); }); let actualDecorations = viewModel.getDecorationsInViewport( @@ -267,10 +265,8 @@ 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( + accessor.addDecoration( new Range(1, 50, 1, 51), { beforeContentClassName: 'dec1' diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index 4fa6c2fabdbb9..56a36c0770255 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -14,13 +14,10 @@ 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; - constructor(key: string, defaultValue: T) { - this._key = key; + constructor(defaultValue: T) { this._defaultValue = defaultValue; this._value = this._defaultValue; } @@ -47,7 +44,7 @@ export class MockContextKeyService implements IContextKeyService { // } public createKey(key: string, defaultValue: T): IContextKey { - let ret = new MockKeybindingContextKey(key, defaultValue); + let ret = new MockKeybindingContextKey(defaultValue); this._keys.set(key, ret); return ret; } diff --git a/src/vs/workbench/services/thread/common/threadService.ts b/src/vs/workbench/services/thread/common/threadService.ts index 0fd6a9cd6afa8..a6530eee39f3c 100644 --- a/src/vs/workbench/services/thread/common/threadService.ts +++ b/src/vs/workbench/services/thread/common/threadService.ts @@ -21,9 +21,9 @@ export interface IThreadService { assertRegistered(identifiers: ProxyIdentifier[]): void; } -// @ts-ignore unused generic parameter export class ProxyIdentifier { _proxyIdentifierBrand: void; + _suppressCompilerUnusedWarning: T; isMain: boolean; id: string;