diff --git a/build/monaco/monaco.d.ts.recipe b/build/monaco/monaco.d.ts.recipe index 205256d7d49..25d329fec87 100644 --- a/build/monaco/monaco.d.ts.recipe +++ b/build/monaco/monaco.d.ts.recipe @@ -62,12 +62,15 @@ export interface ICommandHandler { #include(vs/editor/standalone/browser/colorizer): IColorizerOptions, IColorizerElementOptions #include(vs/base/common/scrollable): ScrollbarVisibility #include(vs/platform/theme/common/themeService): ThemeColor -#includeAll(vs/editor/common/editorCommon;IMode=>languages.IMode;LanguageIdentifier=>languages.LanguageIdentifier;editorOptions.=>): ISelection, IScrollEvent +#includeAll(vs/editor/common/editorCommon;IMode=>languages.IMode;LanguageIdentifier=>languages.LanguageIdentifier;editorOptions.=>): IScrollEvent #includeAll(vs/editor/common/model/textModelEvents): #includeAll(vs/editor/common/controller/cursorEvents): #includeAll(vs/editor/common/config/editorOptions): #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>): #include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo + +//compatibility: +export type IReadOnlyModel = IModel; } declare module monaco.languages { diff --git a/src/vs/editor/common/commands/replaceCommand.ts b/src/vs/editor/common/commands/replaceCommand.ts index 1083964b0ff..53bc90e834f 100644 --- a/src/vs/editor/common/commands/replaceCommand.ts +++ b/src/vs/editor/common/commands/replaceCommand.ts @@ -20,11 +20,11 @@ export class ReplaceCommand implements editorCommon.ICommand { this.insertsAutoWhitespace = insertsAutoWhitespace; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { builder.addTrackedEditOperation(this._range, this._text); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { let inverseEditOperations = helper.getInverseEditOperations(); let srcRange = inverseEditOperations[0].range; return new Selection( @@ -48,11 +48,11 @@ export class ReplaceCommandWithoutChangingPosition implements editorCommon.IComm this.insertsAutoWhitespace = insertsAutoWhitespace; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { builder.addTrackedEditOperation(this._range, this._text); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { let inverseEditOperations = helper.getInverseEditOperations(); let srcRange = inverseEditOperations[0].range; return new Selection( @@ -80,11 +80,11 @@ export class ReplaceCommandWithOffsetCursorState implements editorCommon.IComman this.insertsAutoWhitespace = insertsAutoWhitespace; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { builder.addTrackedEditOperation(this._range, this._text); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { let inverseEditOperations = helper.getInverseEditOperations(); let srcRange = inverseEditOperations[0].range; return new Selection( @@ -109,12 +109,12 @@ export class ReplaceCommandThatPreservesSelection implements editorCommon.IComma this._initialSelection = initialSelection; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { builder.addEditOperation(this._range, this._text); this._selectionId = builder.trackSelection(this._initialSelection); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return helper.getTrackedSelection(this._selectionId); } } diff --git a/src/vs/editor/common/commands/shiftCommand.ts b/src/vs/editor/common/commands/shiftCommand.ts index e4074200469..8ced20c3f9c 100644 --- a/src/vs/editor/common/commands/shiftCommand.ts +++ b/src/vs/editor/common/commands/shiftCommand.ts @@ -8,7 +8,7 @@ import * as strings from 'vs/base/common/strings'; import { CursorColumns } from 'vs/editor/common/controller/cursorCommon'; import { Range } from 'vs/editor/common/core/range'; import { Selection, SelectionDirection } from 'vs/editor/common/core/selection'; -import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry'; import { CharCode } from 'vs/base/common/charCode'; @@ -62,7 +62,7 @@ export class ShiftCommand implements ICommand { } } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { const startLine = this._selection.startLineNumber; let endLine = this._selection.endLineNumber; @@ -216,7 +216,7 @@ export class ShiftCommand implements ICommand { this._selectionId = builder.trackSelection(this._selection); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { if (this._useLastEditRangeForCursorEndPosition) { let lastOp = helper.getInverseEditOperations()[0]; return new Selection(lastOp.range.endLineNumber, lastOp.range.endColumn, lastOp.range.endLineNumber, lastOp.range.endColumn); diff --git a/src/vs/editor/common/commands/surroundSelectionCommand.ts b/src/vs/editor/common/commands/surroundSelectionCommand.ts index 2a83cefac1b..1b76631bb49 100644 --- a/src/vs/editor/common/commands/surroundSelectionCommand.ts +++ b/src/vs/editor/common/commands/surroundSelectionCommand.ts @@ -6,7 +6,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; -import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; export class SurroundSelectionCommand implements ICommand { private _range: Selection; @@ -19,7 +19,7 @@ export class SurroundSelectionCommand implements ICommand { this._charAfterSelection = charAfterSelection; } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { builder.addTrackedEditOperation(new Range( this._range.startLineNumber, this._range.startColumn, @@ -35,7 +35,7 @@ export class SurroundSelectionCommand implements ICommand { ), this._charAfterSelection); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { let inverseEditOperations = helper.getInverseEditOperations(); let firstOperationRange = inverseEditOperations[0].range; let secondOperationRange = inverseEditOperations[1].range; diff --git a/src/vs/editor/common/commands/trimTrailingWhitespaceCommand.ts b/src/vs/editor/common/commands/trimTrailingWhitespaceCommand.ts index 20fbcbea5ac..d122f9e5a16 100644 --- a/src/vs/editor/common/commands/trimTrailingWhitespaceCommand.ts +++ b/src/vs/editor/common/commands/trimTrailingWhitespaceCommand.ts @@ -22,7 +22,7 @@ export class TrimTrailingWhitespaceCommand implements editorCommon.ICommand { this.cursors = cursors; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { let ops = trimTrailingWhitespace(model, this.cursors); for (let i = 0, len = ops.length; i < len; i++) { let op = ops[i]; @@ -33,7 +33,7 @@ export class TrimTrailingWhitespaceCommand implements editorCommon.ICommand { this.selectionId = builder.trackSelection(this.selection); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return helper.getTrackedSelection(this.selectionId); } } @@ -41,7 +41,7 @@ export class TrimTrailingWhitespaceCommand implements editorCommon.ICommand { /** * Generate commands for trimming trailing whitespace on a model and ignore lines on which cursors are sitting. */ -export function trimTrailingWhitespace(model: editorCommon.ITextModel, cursors: Position[]): editorCommon.IIdentifiedSingleEditOperation[] { +export function trimTrailingWhitespace(model: editorCommon.IModel, cursors: Position[]): editorCommon.IIdentifiedSingleEditOperation[] { // Sort cursors ascending cursors.sort((a, b) => { if (a.lineNumber === b.lineNumber) { diff --git a/src/vs/editor/common/controller/cursorTypeOperations.ts b/src/vs/editor/common/controller/cursorTypeOperations.ts index dd726110ed9..90f33e271c3 100644 --- a/src/vs/editor/common/controller/cursorTypeOperations.ts +++ b/src/vs/editor/common/controller/cursorTypeOperations.ts @@ -8,7 +8,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { ReplaceCommand, ReplaceCommandWithoutChangingPosition, ReplaceCommandWithOffsetCursorState } from 'vs/editor/common/commands/replaceCommand'; import { CursorColumns, CursorConfiguration, ICursorSimpleModel, EditOperationResult, EditOperationType } from 'vs/editor/common/controller/cursorCommon'; import { Range } from 'vs/editor/common/core/range'; -import { ICommand, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, IModel } from 'vs/editor/common/editorCommon'; import * as strings from 'vs/base/common/strings'; import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand'; import { Selection } from 'vs/editor/common/core/selection'; @@ -136,7 +136,7 @@ export class TypeOperations { } } - private static _goodIndentForLine(config: CursorConfiguration, model: ITokenizedModel, lineNumber: number): string { + private static _goodIndentForLine(config: CursorConfiguration, model: IModel, lineNumber: number): string { let action: IndentAction | EnterAction; let indentation: string; @@ -207,7 +207,7 @@ export class TypeOperations { return new ReplaceCommand(selection, typeText, insertsAutoWhitespace); } - public static tab(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { + public static tab(config: CursorConfiguration, model: IModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -248,7 +248,7 @@ export class TypeOperations { return commands; } - public static replacePreviousChar(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], txt: string, replaceCharCnt: number): EditOperationResult { + public static replacePreviousChar(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], txt: string, replaceCharCnt: number): EditOperationResult { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -278,7 +278,7 @@ export class TypeOperations { } } - private static _enter(config: CursorConfiguration, model: ITokenizedModel, keepPosition: boolean, range: Range): ICommand { + private static _enter(config: CursorConfiguration, model: IModel, keepPosition: boolean, range: Range): ICommand { if (!model.isCheapToTokenize(range.getStartPosition().lineNumber)) { let lineText = model.getLineContent(range.startLineNumber); let indentation = strings.getLeadingWhitespace(lineText).substring(0, range.startColumn - 1); @@ -375,7 +375,7 @@ export class TypeOperations { } } - private static _isAutoIndentType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): boolean { + private static _isAutoIndentType(config: CursorConfiguration, model: IModel, selections: Selection[]): boolean { if (!config.autoIndent) { return false; } @@ -389,7 +389,7 @@ export class TypeOperations { return true; } - private static _runAutoIndentType(config: CursorConfiguration, model: ITokenizedModel, range: Range, ch: string): ICommand { + private static _runAutoIndentType(config: CursorConfiguration, model: IModel, range: Range, ch: string): ICommand { let currentIndentation = LanguageConfigurationRegistry.getIndentationAtPosition(model, range.startLineNumber, range.startColumn); let actualIndentation = LanguageConfigurationRegistry.getIndentActionForType(model, range, ch, { shiftIndent: (indentation) => { @@ -425,7 +425,7 @@ export class TypeOperations { return null; } - private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { + private static _isAutoClosingCloseCharType(config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.autoClosingPairsClose.hasOwnProperty(ch)) { return false; } @@ -468,7 +468,7 @@ export class TypeOperations { return cnt; } - private static _runAutoClosingCloseCharType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { + private static _runAutoClosingCloseCharType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -482,7 +482,7 @@ export class TypeOperations { }); } - private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { + private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.autoClosingPairsOpen.hasOwnProperty(ch)) { return false; } @@ -550,7 +550,7 @@ export class TypeOperations { return true; } - private static _runAutoClosingOpenCharType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { + private static _runAutoClosingOpenCharType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -563,7 +563,7 @@ export class TypeOperations { }); } - private static _isSurroundSelectionType(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): boolean { + private static _isSurroundSelectionType(config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): boolean { if (!config.autoClosingBrackets || !config.surroundingPairs.hasOwnProperty(ch)) { return false; } @@ -597,7 +597,7 @@ export class TypeOperations { return true; } - private static _runSurroundSelectionType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { + private static _runSurroundSelectionType(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): EditOperationResult { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const selection = selections[i]; @@ -610,14 +610,14 @@ export class TypeOperations { }); } - private static _isTypeInterceptorElectricChar(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]) { + private static _isTypeInterceptorElectricChar(config: CursorConfiguration, model: IModel, selections: Selection[]) { if (selections.length === 1 && model.isCheapToTokenize(selections[0].getEndPosition().lineNumber)) { return true; } return false; } - private static _typeInterceptorElectricChar(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selection: Selection, ch: string): EditOperationResult { + private static _typeInterceptorElectricChar(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selection: Selection, ch: string): EditOperationResult { if (!config.electricChars.hasOwnProperty(ch) || !selection.isEmpty()) { return null; } @@ -680,7 +680,7 @@ export class TypeOperations { return null; } - public static typeWithInterceptors(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], ch: string): EditOperationResult { + public static typeWithInterceptors(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], ch: string): EditOperationResult { if (ch === '\n') { let commands: ICommand[] = []; @@ -747,7 +747,7 @@ export class TypeOperations { }); } - public static typeWithoutInterceptors(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: ITokenizedModel, selections: Selection[], str: string): EditOperationResult { + public static typeWithoutInterceptors(prevEditOperationType: EditOperationType, config: CursorConfiguration, model: IModel, selections: Selection[], str: string): EditOperationResult { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { commands[i] = new ReplaceCommand(selections[i], str); @@ -758,7 +758,7 @@ export class TypeOperations { }); } - public static lineInsertBefore(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { + public static lineInsertBefore(config: CursorConfiguration, model: IModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { let lineNumber = selections[i].positionLineNumber; @@ -775,7 +775,7 @@ export class TypeOperations { return commands; } - public static lineInsertAfter(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { + public static lineInsertAfter(config: CursorConfiguration, model: IModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { const lineNumber = selections[i].positionLineNumber; @@ -785,7 +785,7 @@ export class TypeOperations { return commands; } - public static lineBreakInsert(config: CursorConfiguration, model: ITokenizedModel, selections: Selection[]): ICommand[] { + public static lineBreakInsert(config: CursorConfiguration, model: IModel, selections: Selection[]): ICommand[] { let commands: ICommand[] = []; for (let i = 0, len = selections.length; i < len; i++) { commands[i] = this._enter(config, model, true, selections[i]); diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 2a2da3bdc4a..f187bae9e29 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -336,7 +336,7 @@ export interface ICommand { * @param model The model the command will execute on. * @param builder A helper to collect the needed edit operations and to track selections. */ - getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void; + getEditOperations(model: IModel, builder: IEditOperationBuilder): void; /** * Compute the cursor state after the edit operations were applied. @@ -344,7 +344,7 @@ export interface ICommand { * @param helper A helper to get inverse edit operations and to get previously tracked selections. * @return The cursor state after the command executed. */ - computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection; + computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection; } /** @@ -474,10 +474,46 @@ export interface ITextModelUpdateOptions { trimAutoWhitespace?: boolean; } +export class FindMatch { + _findMatchBrand: void; + + public readonly range: Range; + public readonly matches: string[]; + + /** + * @internal + */ + constructor(range: Range, matches: string[]) { + this.range = range; + this.matches = matches; + } +} + /** - * A textual read-only model. + * @internal */ -export interface ITextModel { +export interface IFoundBracket { + range: Range; + open: string; + close: string; + isOpen: boolean; +} + +/** + * Describes the behavior of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` + */ +export enum TrackedRangeStickiness { + AlwaysGrowsWhenTypingAtEdges = 0, + NeverGrowsWhenTypingAtEdges = 1, + GrowsOnlyWhenTypingBefore = 2, + GrowsOnlyWhenTypingAfter = 3, +} + +/** + * A model. + */ +export interface IModel { /** * If true, the text model might contain RTL. @@ -724,24 +760,7 @@ export interface ITextModel { * @return The range where the previous match is. It is null if no previous match has been found. */ findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; -} -export class FindMatch { - _findMatchBrand: void; - - public readonly range: Range; - public readonly matches: string[]; - - /** - * @internal - */ - constructor(range: Range, matches: string[]) { - this.range = range; - this.matches = matches; - } -} - -export interface IReadOnlyModel extends ITextModel { /** * Gets the resource associated with this editor model. */ @@ -773,22 +792,6 @@ export interface IReadOnlyModel extends ITextModel { * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; -} - -/** - * @internal - */ -export interface IFoundBracket { - range: Range; - open: string; - close: string; - isOpen: boolean; -} - -/** - * A model that is tokenized. - */ -export interface ITokenizedModel extends ITextModel { /** * Force tokenization information for `lineNumber` to be accurate. @@ -894,23 +897,7 @@ export interface ITokenizedModel extends ITextModel { * @internal */ getLinesIndentGuides(startLineNumber: number, endLineNumber: number): number[]; -} -/** - * Describes the behavior of decorations when typing/editing near their edges. - * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` - */ -export enum TrackedRangeStickiness { - AlwaysGrowsWhenTypingAtEdges = 0, - NeverGrowsWhenTypingAtEdges = 1, - GrowsOnlyWhenTypingBefore = 2, - GrowsOnlyWhenTypingAfter = 3, -} - -/** - * A model that can have decorations. - */ -export interface ITextModelWithDecorations { /** * Change the decorations. The callback will be called with a change accessor * that becomes invalid as soon as the callback finishes executing. @@ -1006,12 +993,6 @@ export interface ITextModelWithDecorations { * @internal */ _setTrackedRange(id: string, newRange: Range, newStickiness: TrackedRangeStickiness): string; -} - -/** - * An editable text model. - */ -export interface IEditableTextModel extends ITextModel { /** * Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs). @@ -1071,12 +1052,7 @@ export interface IEditableTextModel extends ITextModel { * @internal */ redo(): Selection[]; -} -/** - * A model. - */ -export interface IModel extends IReadOnlyModel, IEditableTextModel, ITokenizedModel, ITextModelWithDecorations { /** * @deprecated Please use `onDidChangeContent` instead. * An event emitted when the contents of the model have changed. diff --git a/src/vs/editor/common/model/editStack.ts b/src/vs/editor/common/model/editStack.ts index 32aa084f24c..9fdad75cdef 100644 --- a/src/vs/editor/common/model/editStack.ts +++ b/src/vs/editor/common/model/editStack.ts @@ -5,8 +5,9 @@ 'use strict'; import { onUnexpectedError } from 'vs/base/common/errors'; -import { ICursorStateComputer, IEditableTextModel, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon'; +import { ICursorStateComputer, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon'; import { Selection } from 'vs/editor/common/core/selection'; +import { TextModel } from 'vs/editor/common/model/textModel'; interface IEditOperation { operations: IIdentifiedSingleEditOperation[]; @@ -29,12 +30,12 @@ export interface IUndoRedoResult { export class EditStack { - private model: IEditableTextModel; + private model: TextModel; private currentOpenStackElement: IStackElement; private past: IStackElement[]; private future: IStackElement[]; - constructor(model: IEditableTextModel) { + constructor(model: TextModel) { this.model = model; this.currentOpenStackElement = null; this.past = []; diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index e013984d0da..28b3c1fff46 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -59,7 +59,7 @@ export interface ITextModelCreationData { readonly options: editorCommon.TextModelResolvedOptions; } -export class TextModel extends Disposable implements editorCommon.IModel, editorCommon.IEditableTextModel, editorCommon.ITextModelWithDecorations, editorCommon.ITokenizedModel, editorCommon.ITextModel { +export class TextModel extends Disposable implements editorCommon.IModel { private static readonly MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB private static readonly MODEL_TOKENIZATION_LIMIT = 20 * 1024 * 1024; // 20 MB diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 2fc0420eef8..cd984984286 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -181,7 +181,7 @@ export interface HoverProvider { * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ - provideHover(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Hover | Thenable; + provideHover(model: editorCommon.IModel, position: Position, token: CancellationToken): Hover | Thenable; } /** @@ -292,7 +292,7 @@ export interface CodeActionProvider { /** * Provide commands for the given document and range. */ - provideCodeActions(model: editorCommon.IReadOnlyModel, range: Range, token: CancellationToken): CodeAction[] | Thenable; + provideCodeActions(model: editorCommon.IModel, range: Range, token: CancellationToken): CodeAction[] | Thenable; } /** @@ -362,7 +362,7 @@ export interface SignatureHelpProvider { /** * Provide help for the signature at the given position and document. */ - provideSignatureHelp(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editorCommon.IModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; } /** @@ -406,7 +406,7 @@ export interface DocumentHighlightProvider { * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ - provideDocumentHighlights(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editorCommon.IModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; } /** @@ -427,7 +427,7 @@ export interface ReferenceProvider { /** * Provide a set of project-wide references for the given position and document. */ - provideReferences(model: editorCommon.IReadOnlyModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model: editorCommon.IModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; } /** @@ -460,7 +460,7 @@ export interface DefinitionProvider { /** * Provide the definition of the symbol at the given position and document. */ - provideDefinition(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideDefinition(model: editorCommon.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -471,7 +471,7 @@ export interface ImplementationProvider { /** * Provide the implementation of the symbol at the given position and document. */ - provideImplementation(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideImplementation(model: editorCommon.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -482,7 +482,7 @@ export interface TypeDefinitionProvider { /** * Provide the type definition of the symbol at the given position and document. */ - provideTypeDefinition(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideTypeDefinition(model: editorCommon.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -592,7 +592,7 @@ export interface DocumentSymbolProvider { /** * Provide symbol information for the given document. */ - provideDocumentSymbols(model: editorCommon.IReadOnlyModel, token: CancellationToken): SymbolInformation[] | Thenable; + provideDocumentSymbols(model: editorCommon.IModel, token: CancellationToken): SymbolInformation[] | Thenable; } export interface TextEdit { @@ -622,7 +622,7 @@ export interface DocumentFormattingEditProvider { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editorCommon.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentFormattingEdits(model: editorCommon.IModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** * The document formatting provider interface defines the contract between extensions and @@ -636,7 +636,7 @@ export interface DocumentRangeFormattingEditProvider { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editorCommon.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentRangeFormattingEdits(model: editorCommon.IModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** * The document formatting provider interface defines the contract between extensions and @@ -651,7 +651,7 @@ export interface OnTypeFormattingEditProvider { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editorCommon.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideOnTypeFormattingEdits(model: editorCommon.IModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -673,7 +673,7 @@ export interface ILink { * A provider of links. */ export interface LinkProvider { - provideLinks(model: editorCommon.IReadOnlyModel, token: CancellationToken): ILink[] | Thenable; + provideLinks(model: editorCommon.IModel, token: CancellationToken): ILink[] | Thenable; resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable; } @@ -748,11 +748,11 @@ export interface DocumentColorProvider { /** * Provides the color ranges for a specific model. */ - provideDocumentColors(model: editorCommon.IReadOnlyModel, token: CancellationToken): IColorInformation[] | Thenable; + provideDocumentColors(model: editorCommon.IModel, token: CancellationToken): IColorInformation[] | Thenable; /** * Provide the string representations for a color. */ - provideColorPresentations(model: editorCommon.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editorCommon.IModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; } export interface IResourceEdit { @@ -765,7 +765,7 @@ export interface WorkspaceEdit { rejectReason?: string; } export interface RenameProvider { - provideRenameEdits(model: editorCommon.IReadOnlyModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; + provideRenameEdits(model: editorCommon.IModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; } @@ -782,8 +782,8 @@ export interface ICodeLensSymbol { } export interface CodeLensProvider { onDidChange?: Event; - provideCodeLenses(model: editorCommon.IReadOnlyModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; - resolveCodeLens?(model: editorCommon.IReadOnlyModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; + provideCodeLenses(model: editorCommon.IModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; + resolveCodeLens?(model: editorCommon.IModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; } // --- feature registries ------ diff --git a/src/vs/editor/common/modes/languageConfigurationRegistry.ts b/src/vs/editor/common/modes/languageConfigurationRegistry.ts index 4d15e0f504b..accad47c04e 100644 --- a/src/vs/editor/common/modes/languageConfigurationRegistry.ts +++ b/src/vs/editor/common/modes/languageConfigurationRegistry.ts @@ -10,7 +10,7 @@ import { IOnEnterSupportOptions, OnEnterSupport } from 'vs/editor/common/modes/s import { IndentRulesSupport, IndentConsts } from 'vs/editor/common/modes/supports/indentRules'; import { RichEditBrackets } from 'vs/editor/common/modes/supports/richEditBrackets'; import Event, { Emitter } from 'vs/base/common/event'; -import { ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { onUnexpectedError } from 'vs/base/common/errors'; import * as strings from 'vs/base/common/strings'; import { IDisposable } from 'vs/base/common/lifecycle'; @@ -544,7 +544,7 @@ export class LanguageConfigurationRegistryImpl { return null; } - public getIndentForEnter(model: ITokenizedModel, range: Range, indentConverter: IIndentConverter, autoIndent: boolean): { beforeEnter: string, afterEnter: string } { + public getIndentForEnter(model: IModel, range: Range, indentConverter: IIndentConverter, autoIndent: boolean): { beforeEnter: string, afterEnter: string } { model.forceTokenization(range.startLineNumber); let lineTokens = model.getLineTokens(range.startLineNumber); @@ -642,7 +642,7 @@ export class LanguageConfigurationRegistryImpl { * We should always allow intentional indentation. It means, if users change the indentation of `lineNumber` and the content of * this line doesn't match decreaseIndentPattern, we should not adjust the indentation. */ - public getIndentActionForType(model: ITokenizedModel, range: Range, ch: string, indentConverter: IIndentConverter): string { + public getIndentActionForType(model: IModel, range: Range, ch: string, indentConverter: IIndentConverter): string { let scopedLineTokens = this.getScopedLineTokens(model, range.startLineNumber, range.startColumn); let indentRulesSupport = this.getIndentRulesSupport(scopedLineTokens.languageId); if (!indentRulesSupport) { @@ -683,7 +683,7 @@ export class LanguageConfigurationRegistryImpl { return null; } - public getIndentMetadata(model: ITokenizedModel, lineNumber: number): number { + public getIndentMetadata(model: IModel, lineNumber: number): number { let indentRulesSupport = this.getIndentRulesSupport(model.getLanguageIdentifier().id); if (!indentRulesSupport) { return null; @@ -708,13 +708,13 @@ export class LanguageConfigurationRegistryImpl { return value.onEnter || null; } - public getRawEnterActionAtPosition(model: ITokenizedModel, lineNumber: number, column: number): EnterAction { + public getRawEnterActionAtPosition(model: IModel, lineNumber: number, column: number): EnterAction { let r = this.getEnterAction(model, new Range(lineNumber, column, lineNumber, column)); return r ? r.enterAction : null; } - public getEnterAction(model: ITokenizedModel, range: Range): { enterAction: EnterAction; indentation: string; } { + public getEnterAction(model: IModel, range: Range): { enterAction: EnterAction; indentation: string; } { let indentation = this.getIndentationAtPosition(model, range.startLineNumber, range.startColumn); let scopedLineTokens = this.getScopedLineTokens(model, range.startLineNumber, range.startColumn); @@ -780,7 +780,7 @@ export class LanguageConfigurationRegistryImpl { }; } - public getIndentationAtPosition(model: ITokenizedModel, lineNumber: number, column: number): string { + public getIndentationAtPosition(model: IModel, lineNumber: number, column: number): string { let lineText = model.getLineContent(lineNumber); let indentation = strings.getLeadingWhitespace(lineText); if (indentation.length > column - 1) { @@ -790,7 +790,7 @@ export class LanguageConfigurationRegistryImpl { return indentation; } - private getScopedLineTokens(model: ITokenizedModel, lineNumber: number, columnNumber?: number) { + private getScopedLineTokens(model: IModel, lineNumber: number, columnNumber?: number) { model.forceTokenization(lineNumber); let lineTokens = model.getLineTokens(lineNumber); let column = isNaN(columnNumber) ? model.getLineMaxColumn(lineNumber) - 1 : columnNumber - 1; diff --git a/src/vs/editor/common/modes/languageFeatureRegistry.ts b/src/vs/editor/common/modes/languageFeatureRegistry.ts index 9ebaeca2fec..539f89b5965 100644 --- a/src/vs/editor/common/modes/languageFeatureRegistry.ts +++ b/src/vs/editor/common/modes/languageFeatureRegistry.ts @@ -7,7 +7,7 @@ import Event, { Emitter } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { LanguageSelector, score } from 'vs/editor/common/modes/languageSelector'; interface Entry { @@ -58,11 +58,11 @@ export default class LanguageFeatureRegistry { }; } - has(model: IReadOnlyModel): boolean { + has(model: IModel): boolean { return this.all(model).length > 0; } - all(model: IReadOnlyModel): T[] { + all(model: IModel): T[] { if (!model || model.isTooLargeForHavingARichMode()) { return []; } @@ -80,13 +80,13 @@ export default class LanguageFeatureRegistry { return result; } - ordered(model: IReadOnlyModel): T[] { + ordered(model: IModel): T[] { const result: T[] = []; this._orderedForEach(model, entry => result.push(entry.provider)); return result; } - orderedGroups(model: IReadOnlyModel): T[][] { + orderedGroups(model: IModel): T[][] { const result: T[][] = []; let lastBucket: T[]; let lastBucketScore: number; @@ -104,7 +104,7 @@ export default class LanguageFeatureRegistry { return result; } - private _orderedForEach(model: IReadOnlyModel, callback: (provider: Entry) => any): void { + private _orderedForEach(model: IModel, callback: (provider: Entry) => any): void { if (!model || model.isTooLargeForHavingARichMode()) { return; @@ -122,7 +122,7 @@ export default class LanguageFeatureRegistry { private _lastCandidate: { uri: string; language: string; }; - private _updateScores(model: IReadOnlyModel): void { + private _updateScores(model: IModel): void { let candidate = { uri: model.uri.toString(), diff --git a/src/vs/editor/contrib/caretOperations/moveCaretCommand.ts b/src/vs/editor/contrib/caretOperations/moveCaretCommand.ts index a908879a866..c52ae487cfc 100644 --- a/src/vs/editor/contrib/caretOperations/moveCaretCommand.ts +++ b/src/vs/editor/contrib/caretOperations/moveCaretCommand.ts @@ -6,7 +6,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; -import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; export class MoveCaretCommand implements ICommand { @@ -24,7 +24,7 @@ export class MoveCaretCommand implements ICommand { this._isMovingLeft = isMovingLeft; } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { var s = this._selection; this._selectionId = builder.trackSelection(s); if (s.startLineNumber !== s.endLineNumber) { @@ -63,7 +63,7 @@ export class MoveCaretCommand implements ICommand { this._moved = true; } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { var result = helper.getTrackedSelection(this._selectionId); if (this._moved) { result = result.setStartPosition(result.startLineNumber, this._cutStartIndex); diff --git a/src/vs/editor/contrib/colorPicker/color.ts b/src/vs/editor/contrib/colorPicker/color.ts index 14309923337..6755405ce8b 100644 --- a/src/vs/editor/contrib/colorPicker/color.ts +++ b/src/vs/editor/contrib/colorPicker/color.ts @@ -6,14 +6,14 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { ColorProviderRegistry, DocumentColorProvider, IColorInformation, IColorPresentation } from 'vs/editor/common/modes'; import { asWinJsPromise } from 'vs/base/common/async'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; export interface IColorData { colorInfo: IColorInformation; provider: DocumentColorProvider; } -export function getColors(model: IReadOnlyModel): TPromise { +export function getColors(model: IModel): TPromise { const colors: IColorData[] = []; const providers = ColorProviderRegistry.ordered(model).reverse(); const promises = providers.map(provider => asWinJsPromise(token => provider.provideDocumentColors(model, token)).then(result => { @@ -27,6 +27,6 @@ export function getColors(model: IReadOnlyModel): TPromise { return TPromise.join(promises).then(() => colors); } -export function getColorPresentations(model: IReadOnlyModel, colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise { +export function getColorPresentations(model: IModel, colorInfo: IColorInformation, provider: DocumentColorProvider): TPromise { return asWinJsPromise(token => provider.provideColorPresentations(model, colorInfo, token)); } diff --git a/src/vs/editor/contrib/comment/blockCommentCommand.ts b/src/vs/editor/contrib/comment/blockCommentCommand.ts index 933dff3f46b..91f24c30a06 100644 --- a/src/vs/editor/contrib/comment/blockCommentCommand.ts +++ b/src/vs/editor/contrib/comment/blockCommentCommand.ts @@ -39,7 +39,7 @@ export class BlockCommentCommand implements editorCommon.ICommand { return true; } - private _createOperationsForBlockComment(selection: Range, config: ICommentsConfiguration, model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + private _createOperationsForBlockComment(selection: Range, config: ICommentsConfiguration, model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { const startLineNumber = selection.startLineNumber; const startColumn = selection.startColumn; const endLineNumber = selection.endLineNumber; @@ -153,7 +153,7 @@ export class BlockCommentCommand implements editorCommon.ICommand { return res; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { const startLineNumber = this._selection.startLineNumber; const startColumn = this._selection.startColumn; @@ -170,7 +170,7 @@ export class BlockCommentCommand implements editorCommon.ICommand { ); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { const inverseEditOperations = helper.getInverseEditOperations(); if (inverseEditOperations.length === 2) { const startTokenEditOperation = inverseEditOperations[0]; diff --git a/src/vs/editor/contrib/comment/lineCommentCommand.ts b/src/vs/editor/contrib/comment/lineCommentCommand.ts index e1d5bec1202..4d22a0079e3 100644 --- a/src/vs/editor/contrib/comment/lineCommentCommand.ts +++ b/src/vs/editor/contrib/comment/lineCommentCommand.ts @@ -62,7 +62,7 @@ export class LineCommentCommand implements editorCommon.ICommand { * Do an initial pass over the lines and gather info about the line comment string. * Returns null if any of the lines doesn't support a line comment string. */ - public static _gatherPreflightCommentStrings(model: editorCommon.ITokenizedModel, startLineNumber: number, endLineNumber: number): ILinePreflightData[] { + public static _gatherPreflightCommentStrings(model: editorCommon.IModel, startLineNumber: number, endLineNumber: number): ILinePreflightData[] { model.tokenizeIfCheap(startLineNumber); const languageId = model.getLanguageIdAtPosition(startLineNumber, 1); @@ -173,7 +173,7 @@ export class LineCommentCommand implements editorCommon.ICommand { /** * Analyze all lines and decide exactly what to do => not supported | insert line comments | remove line comments */ - public static _gatherPreflightData(type: Type, model: editorCommon.ITokenizedModel, startLineNumber: number, endLineNumber: number): IPreflightData { + public static _gatherPreflightData(type: Type, model: editorCommon.IModel, startLineNumber: number, endLineNumber: number): IPreflightData { var lines = LineCommentCommand._gatherPreflightCommentStrings(model, startLineNumber, endLineNumber); if (lines === null) { return { @@ -215,7 +215,7 @@ export class LineCommentCommand implements editorCommon.ICommand { this._selectionId = builder.trackSelection(s); } - private _attemptRemoveBlockComment(model: editorCommon.ITokenizedModel, s: Selection, startToken: string, endToken: string): editorCommon.IIdentifiedSingleEditOperation[] { + private _attemptRemoveBlockComment(model: editorCommon.IModel, s: Selection, startToken: string, endToken: string): editorCommon.IIdentifiedSingleEditOperation[] { let startLineNumber = s.startLineNumber; let endLineNumber = s.endLineNumber; @@ -268,7 +268,7 @@ export class LineCommentCommand implements editorCommon.ICommand { /** * Given an unsuccessful analysis, delegate to the block comment command */ - private _executeBlockComment(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder, s: Selection): void { + private _executeBlockComment(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder, s: Selection): void { model.tokenizeIfCheap(s.startLineNumber); let languageId = model.getLanguageIdAtPosition(s.startLineNumber, 1); let config = LanguageConfigurationRegistry.getComments(languageId); @@ -309,7 +309,7 @@ export class LineCommentCommand implements editorCommon.ICommand { } } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { var s = this._selection; this._moveEndPositionDown = false; @@ -327,7 +327,7 @@ export class LineCommentCommand implements editorCommon.ICommand { return this._executeBlockComment(model, builder, s); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { var result = helper.getTrackedSelection(this._selectionId); if (this._moveEndPositionDown) { diff --git a/src/vs/editor/contrib/dnd/dragAndDropCommand.ts b/src/vs/editor/contrib/dnd/dragAndDropCommand.ts index b77a1785480..4e10b3cea70 100644 --- a/src/vs/editor/contrib/dnd/dragAndDropCommand.ts +++ b/src/vs/editor/contrib/dnd/dragAndDropCommand.ts @@ -23,7 +23,7 @@ export class DragAndDropCommand implements editorCommon.ICommand { this.copy = copy; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { let text = model.getValueInRange(this.selection); if (!this.copy) { builder.addEditOperation(this.selection, null); @@ -101,7 +101,7 @@ export class DragAndDropCommand implements editorCommon.ICommand { } } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return this.targetSelection; } -} \ No newline at end of file +} diff --git a/src/vs/editor/contrib/find/replaceAllCommand.ts b/src/vs/editor/contrib/find/replaceAllCommand.ts index 5e6d6dfa230..8e4650b81c5 100644 --- a/src/vs/editor/contrib/find/replaceAllCommand.ts +++ b/src/vs/editor/contrib/find/replaceAllCommand.ts @@ -26,7 +26,7 @@ export class ReplaceAllCommand implements editorCommon.ICommand { this._replaceStrings = replaceStrings; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { if (this._ranges.length > 0) { // Collect all edit operations var ops: IEditOperation[] = []; @@ -65,7 +65,7 @@ export class ReplaceAllCommand implements editorCommon.ICommand { this._trackedEditorSelectionId = builder.trackSelection(this._editorSelection); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return helper.getTrackedSelection(this._trackedEditorSelectionId); } } diff --git a/src/vs/editor/contrib/folding/indentRangeProvider.ts b/src/vs/editor/contrib/folding/indentRangeProvider.ts index 6be8d6cd170..8c5b02404e1 100644 --- a/src/vs/editor/contrib/folding/indentRangeProvider.ts +++ b/src/vs/editor/contrib/folding/indentRangeProvider.ts @@ -5,7 +5,7 @@ 'use strict'; -import { ITextModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { FoldingMarkers } from 'vs/editor/common/modes/languageConfiguration'; import { computeIndentLevel } from 'vs/editor/common/model/modelLine'; import { FoldingRanges, MAX_LINE_NUMBER } from 'vs/editor/contrib/folding/foldingRanges'; @@ -41,7 +41,7 @@ export class RangesCollector { } } - public toIndentRanges(model: ITextModel) { + public toIndentRanges(model: IModel) { if (this._length <= this._FoldingRangesLimit) { // reverse and create arrays of the exact length let startIndexes = new Uint32Array(this._length); @@ -87,7 +87,7 @@ export class RangesCollector { interface PreviousRegion { indent: number; line: number; marker: boolean; } -export function computeRanges(model: ITextModel, offSide: boolean, markers?: FoldingMarkers, FoldingRangesLimit = MAX_FOLDING_REGIONS_FOR_INDENT_LIMIT): FoldingRanges { +export function computeRanges(model: IModel, offSide: boolean, markers?: FoldingMarkers, FoldingRangesLimit = MAX_FOLDING_REGIONS_FOR_INDENT_LIMIT): FoldingRanges { const tabSize = model.getOptions().tabSize; let result = new RangesCollector(FoldingRangesLimit); diff --git a/src/vs/editor/contrib/format/format.ts b/src/vs/editor/contrib/format/format.ts index 7806e0c8f1f..864d6eb5ed7 100644 --- a/src/vs/editor/contrib/format/format.ts +++ b/src/vs/editor/contrib/format/format.ts @@ -10,7 +10,7 @@ import URI from 'vs/base/common/uri'; import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { TPromise } from 'vs/base/common/winjs.base'; import { Range } from 'vs/editor/common/core/range'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { registerDefaultLanguageCommand, registerLanguageCommand } from 'vs/editor/browser/editorExtensions'; import { DocumentFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry, OnTypeFormattingEditProviderRegistry, FormattingOptions, TextEdit } from 'vs/editor/common/modes'; import { IModelService } from 'vs/editor/common/services/modelService'; @@ -28,7 +28,7 @@ export class NoProviderError extends Error { } } -export function getDocumentRangeFormattingEdits(model: IReadOnlyModel, range: Range, options: FormattingOptions): TPromise { +export function getDocumentRangeFormattingEdits(model: IModel, range: Range, options: FormattingOptions): TPromise { const providers = DocumentRangeFormattingEditProviderRegistry.ordered(model); @@ -49,7 +49,7 @@ export function getDocumentRangeFormattingEdits(model: IReadOnlyModel, range: Ra })).then(() => result); } -export function getDocumentFormattingEdits(model: IReadOnlyModel, options: FormattingOptions): TPromise { +export function getDocumentFormattingEdits(model: IModel, options: FormattingOptions): TPromise { const providers = DocumentFormattingEditProviderRegistry.ordered(model); // try range formatters when no document formatter is registered @@ -70,7 +70,7 @@ export function getDocumentFormattingEdits(model: IReadOnlyModel, options: Forma })).then(() => result); } -export function getOnTypeFormattingEdits(model: IReadOnlyModel, position: Position, ch: string, options: FormattingOptions): TPromise { +export function getOnTypeFormattingEdits(model: IModel, position: Position, ch: string, options: FormattingOptions): TPromise { const [support] = OnTypeFormattingEditProviderRegistry.ordered(model); if (!support) { return TPromise.as(undefined); diff --git a/src/vs/editor/contrib/format/formatCommand.ts b/src/vs/editor/contrib/format/formatCommand.ts index 132922c9218..44425bffe53 100644 --- a/src/vs/editor/contrib/format/formatCommand.ts +++ b/src/vs/editor/contrib/format/formatCommand.ts @@ -44,7 +44,7 @@ export class EditOperationsCommand implements editorCommon.ICommand { } } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { for (let edit of this._edits) { // We know that this edit.range comes from the mirror model, so it should only contain \n and no \r's @@ -72,11 +72,11 @@ export class EditOperationsCommand implements editorCommon.ICommand { } } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return helper.getTrackedSelection(this._selectionId); } - static fixLineTerminators(edit: editorCommon.ISingleEditOperation, model: editorCommon.ITokenizedModel): void { + static fixLineTerminators(edit: editorCommon.ISingleEditOperation, model: editorCommon.IModel): void { edit.text = edit.text.replace(/\r\n|\r|\n/g, model.getEOL()); } @@ -88,14 +88,14 @@ export class EditOperationsCommand implements editorCommon.ICommand { * bug #15108. There the cursor was jumping since the tracked selection was in the middle of the range edit * and was lost. */ - static trimEdit(edit: editorCommon.ISingleEditOperation, model: editorCommon.ITokenizedModel): editorCommon.ISingleEditOperation { + static trimEdit(edit: editorCommon.ISingleEditOperation, model: editorCommon.IModel): editorCommon.ISingleEditOperation { this.fixLineTerminators(edit, model); return this._trimEdit(model.validateRange(edit.range), edit.text, edit.forceMoveMarkers, model); } - static _trimEdit(editRange: Range, editText: string, editForceMoveMarkers: boolean, model: editorCommon.ITokenizedModel): editorCommon.ISingleEditOperation { + static _trimEdit(editRange: Range, editText: string, editForceMoveMarkers: boolean, model: editorCommon.IModel): editorCommon.ISingleEditOperation { let currentText = model.getValueInRange(editRange); diff --git a/src/vs/editor/contrib/goToDeclaration/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/goToDeclaration.ts index c7e89776f36..ef3224fac8e 100644 --- a/src/vs/editor/contrib/goToDeclaration/goToDeclaration.ts +++ b/src/vs/editor/contrib/goToDeclaration/goToDeclaration.ts @@ -7,7 +7,7 @@ import { onUnexpectedExternalError } from 'vs/base/common/errors'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegistry'; import { DefinitionProviderRegistry, ImplementationProviderRegistry, TypeDefinitionProviderRegistry, Location } from 'vs/editor/common/modes'; @@ -30,10 +30,10 @@ function outputResults(promises: TPromise[]) { } function getDefinitions( - model: IReadOnlyModel, + model: IModel, position: Position, registry: LanguageFeatureRegistry, - provide: (provider: T, model: IReadOnlyModel, position: Position, token: CancellationToken) => Location | Location[] | Thenable + provide: (provider: T, model: IModel, position: Position, token: CancellationToken) => Location | Location[] | Thenable ): TPromise { const provider = registry.ordered(model); @@ -50,19 +50,19 @@ function getDefinitions( } -export function getDefinitionsAtPosition(model: IReadOnlyModel, position: Position): TPromise { +export function getDefinitionsAtPosition(model: IModel, position: Position): TPromise { return getDefinitions(model, position, DefinitionProviderRegistry, (provider, model, position, token) => { return provider.provideDefinition(model, position, token); }); } -export function getImplementationsAtPosition(model: IReadOnlyModel, position: Position): TPromise { +export function getImplementationsAtPosition(model: IModel, position: Position): TPromise { return getDefinitions(model, position, ImplementationProviderRegistry, (provider, model, position, token) => { return provider.provideImplementation(model, position, token); }); } -export function getTypeDefinitionsAtPosition(model: IReadOnlyModel, position: Position): TPromise { +export function getTypeDefinitionsAtPosition(model: IModel, position: Position): TPromise { return getDefinitions(model, position, TypeDefinitionProviderRegistry, (provider, model, position, token) => { return provider.provideTypeDefinition(model, position, token); }); diff --git a/src/vs/editor/contrib/hover/getHover.ts b/src/vs/editor/contrib/hover/getHover.ts index e7aa38b4c8e..358d543282d 100644 --- a/src/vs/editor/contrib/hover/getHover.ts +++ b/src/vs/editor/contrib/hover/getHover.ts @@ -8,13 +8,13 @@ import { coalesce } from 'vs/base/common/arrays'; import { onUnexpectedExternalError } from 'vs/base/common/errors'; import { TPromise } from 'vs/base/common/winjs.base'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; import { Hover, HoverProviderRegistry } from 'vs/editor/common/modes'; import { asWinJsPromise } from 'vs/base/common/async'; import { Position } from 'vs/editor/common/core/position'; -export function getHover(model: IReadOnlyModel, position: Position): TPromise { +export function getHover(model: IModel, position: Position): TPromise { const supports = HoverProviderRegistry.ordered(model); const values: Hover[] = []; diff --git a/src/vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand.ts b/src/vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand.ts index 94ffad7d218..2144c93c720 100644 --- a/src/vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand.ts +++ b/src/vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand.ts @@ -20,11 +20,11 @@ export class InPlaceReplaceCommand implements editorCommon.ICommand { this._text = text; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { builder.addTrackedEditOperation(this._editRange, this._text); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { var inverseEditOperations = helper.getInverseEditOperations(); var srcRange = inverseEditOperations[0].range; diff --git a/src/vs/editor/contrib/indentation/indentation.ts b/src/vs/editor/contrib/indentation/indentation.ts index 8b400af8d29..66d0386f854 100644 --- a/src/vs/editor/contrib/indentation/indentation.ts +++ b/src/vs/editor/contrib/indentation/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 { IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { IEditorContribution, IIdentifiedSingleEditOperation, ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; @@ -45,7 +45,7 @@ export function unshiftIndent(tabSize: number, indentation: string, count?: numb return newIndentation; } -export function getReindentEditOperations(model: ITokenizedModel, startLineNumber: number, endLineNumber: number, inheritedIndent?: string): IIdentifiedSingleEditOperation[] { +export function getReindentEditOperations(model: IModel, startLineNumber: number, endLineNumber: number, inheritedIndent?: string): IIdentifiedSingleEditOperation[] { if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) { // Model is empty return undefined; @@ -344,7 +344,7 @@ export class AutoIndentOnPasteCommand implements ICommand { } } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { for (let edit of this._edits) { builder.addEditOperation(Range.lift(edit.range), edit.text); } @@ -367,7 +367,7 @@ export class AutoIndentOnPasteCommand implements ICommand { } } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { return helper.getTrackedSelection(this._selectionId); } } @@ -547,7 +547,7 @@ export class AutoIndentOnPaste implements IEditorContribution { this.editor.pushUndoStop(); } - private shouldIgnoreLine(model: ITokenizedModel, lineNumber: number): boolean { + private shouldIgnoreLine(model: IModel, lineNumber: number): boolean { model.forceTokenization(lineNumber); let nonWhiteSpaceColumn = model.getLineFirstNonWhitespaceColumn(lineNumber); if (nonWhiteSpaceColumn === 0) { @@ -574,7 +574,7 @@ export class AutoIndentOnPaste implements IEditorContribution { } } -function getIndentationEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder, tabSize: number, tabsToSpaces: boolean): void { +function getIndentationEditOperations(model: IModel, builder: IEditOperationBuilder, tabSize: number, tabsToSpaces: boolean): void { if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) { // Model is empty return; @@ -606,12 +606,12 @@ export class IndentationToSpacesCommand implements ICommand { constructor(private selection: Selection, private tabSize: number) { } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { this.selectionId = builder.trackSelection(this.selection); getIndentationEditOperations(model, builder, this.tabSize, true); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { return helper.getTrackedSelection(this.selectionId); } } @@ -622,12 +622,12 @@ export class IndentationToTabsCommand implements ICommand { constructor(private selection: Selection, private tabSize: number) { } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { this.selectionId = builder.trackSelection(this.selection); getIndentationEditOperations(model, builder, this.tabSize, false); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { return helper.getTrackedSelection(this.selectionId); } } diff --git a/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts b/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts index ea216684f68..e054a97f14a 100644 --- a/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/copyLinesCommand.ts @@ -23,7 +23,7 @@ export class CopyLinesCommand implements editorCommon.ICommand { this._isCopyingDown = isCopyingDown; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { var s = this._selection; this._startLineNumberDelta = 0; @@ -57,7 +57,7 @@ export class CopyLinesCommand implements editorCommon.ICommand { this._selectionDirection = this._selection.getDirection(); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { var result = helper.getTrackedSelection(this._selectionId); if (this._startLineNumberDelta !== 0 || this._endLineNumberDelta !== 0) { diff --git a/src/vs/editor/contrib/linesOperations/deleteLinesCommand.ts b/src/vs/editor/contrib/linesOperations/deleteLinesCommand.ts index 7a71822740f..6702063aad2 100644 --- a/src/vs/editor/contrib/linesOperations/deleteLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/deleteLinesCommand.ts @@ -6,7 +6,7 @@ import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; -import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; export class DeleteLinesCommand implements ICommand { @@ -20,7 +20,7 @@ export class DeleteLinesCommand implements ICommand { this.restoreCursorToColumn = restoreCursorToColumn; } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) { // Model is empty return; @@ -42,7 +42,7 @@ export class DeleteLinesCommand implements ICommand { builder.addTrackedEditOperation(new Range(startLineNumber, startColumn, endLineNumber, endColumn), null); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { var inverseEditOperations = helper.getInverseEditOperations(); var srcRange = inverseEditOperations[0].range; return new Selection( diff --git a/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts b/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts index 8597c715724..7df2d0ce6ea 100644 --- a/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/moveLinesCommand.ts @@ -7,7 +7,7 @@ import * as strings from 'vs/base/common/strings'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; -import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon'; +import { ICommand, ICursorStateComputerData, IEditOperationBuilder, IModel } from 'vs/editor/common/editorCommon'; import { LanguageConfigurationRegistry, IIndentConverter } from 'vs/editor/common/modes/languageConfigurationRegistry'; import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand'; import * as IndentUtil from 'vs/editor/contrib/indentation/indentUtils'; @@ -31,7 +31,7 @@ export class MoveLinesCommand implements ICommand { this._moveEndLineSelectionShrink = false; } - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { var modelLineCount = model.getLineCount(); @@ -238,7 +238,7 @@ export class MoveLinesCommand implements ICommand { }; } - private matchEnterRule(model: ITokenizedModel, indentConverter: IIndentConverter, tabSize: number, line: number, oneLineAbove: number, oneLineAboveText?: string) { + private matchEnterRule(model: IModel, indentConverter: IIndentConverter, tabSize: number, line: number, oneLineAbove: number, oneLineAboveText?: string) { let validPrecedingLine = oneLineAbove; while (validPrecedingLine >= 1) { // ship empty lines as empty lines just inherit indentation @@ -297,7 +297,7 @@ export class MoveLinesCommand implements ICommand { return str.replace(/^\s+/, ''); } - private shouldAutoIndent(model: ITokenizedModel, selection: Selection) { + private shouldAutoIndent(model: IModel, selection: Selection) { if (!this._autoIndent) { return false; } @@ -319,7 +319,7 @@ export class MoveLinesCommand implements ICommand { return true; } - private getIndentEditsOfMovingBlock(model: ITokenizedModel, builder: IEditOperationBuilder, s: Selection, tabSize: number, insertSpaces: boolean, offset: number) { + private getIndentEditsOfMovingBlock(model: IModel, builder: IEditOperationBuilder, s: Selection, tabSize: number, insertSpaces: boolean, offset: number) { for (let i = s.startLineNumber; i <= s.endLineNumber; i++) { let lineContent = model.getLineContent(i); let originalIndent = strings.getLeadingWhitespace(lineContent); @@ -340,7 +340,7 @@ export class MoveLinesCommand implements ICommand { } } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { var result = helper.getTrackedSelection(this._selectionId); if (this._moveEndPositionDown) { diff --git a/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts b/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts index 2b07f06e838..ae7f1ae32c5 100644 --- a/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/sortLinesCommand.ts @@ -20,7 +20,7 @@ export class SortLinesCommand implements editorCommon.ICommand { this.descending = descending; } - public getEditOperations(model: editorCommon.ITokenizedModel, builder: editorCommon.IEditOperationBuilder): void { + public getEditOperations(model: editorCommon.IModel, builder: editorCommon.IEditOperationBuilder): void { let op = sortLines(model, this.selection, this.descending); if (op) { builder.addEditOperation(op.range, op.text); @@ -29,11 +29,11 @@ export class SortLinesCommand implements editorCommon.ICommand { this.selectionId = builder.trackSelection(this.selection); } - public computeCursorState(model: editorCommon.ITokenizedModel, helper: editorCommon.ICursorStateComputerData): Selection { + public computeCursorState(model: editorCommon.IModel, helper: editorCommon.ICursorStateComputerData): Selection { return helper.getTrackedSelection(this.selectionId); } - public static canRun(model: editorCommon.ITextModel, selection: Selection, descending: boolean): boolean { + public static canRun(model: editorCommon.IModel, selection: Selection, descending: boolean): boolean { let data = getSortData(model, selection, descending); if (!data) { @@ -50,7 +50,7 @@ export class SortLinesCommand implements editorCommon.ICommand { } } -function getSortData(model: editorCommon.ITextModel, selection: Selection, descending: boolean) { +function getSortData(model: editorCommon.IModel, selection: Selection, descending: boolean) { let startLineNumber = selection.startLineNumber; let endLineNumber = selection.endLineNumber; @@ -91,7 +91,7 @@ function getSortData(model: editorCommon.ITextModel, selection: Selection, desce /** * Generate commands for sorting lines on a model. */ -function sortLines(model: editorCommon.ITextModel, selection: Selection, descending: boolean): editorCommon.IIdentifiedSingleEditOperation { +function sortLines(model: editorCommon.IModel, selection: Selection, descending: boolean): editorCommon.IIdentifiedSingleEditOperation { let data = getSortData(model, selection, descending); if (!data) { diff --git a/src/vs/editor/contrib/links/getLinks.ts b/src/vs/editor/contrib/links/getLinks.ts index 86f3513e88b..ec2d15c89b3 100644 --- a/src/vs/editor/contrib/links/getLinks.ts +++ b/src/vs/editor/contrib/links/getLinks.ts @@ -9,7 +9,7 @@ import { onUnexpectedExternalError } from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { Range, IRange } from 'vs/editor/common/core/range'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { ILink, LinkProvider, LinkProviderRegistry } from 'vs/editor/common/modes'; import { asWinJsPromise } from 'vs/base/common/async'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; @@ -65,7 +65,7 @@ export class Link implements ILink { } } -export function getLinks(model: IReadOnlyModel): TPromise { +export function getLinks(model: IModel): TPromise { let links: Link[] = []; diff --git a/src/vs/editor/contrib/parameterHints/provideSignatureHelp.ts b/src/vs/editor/contrib/parameterHints/provideSignatureHelp.ts index a284ab7656f..78d7956032f 100644 --- a/src/vs/editor/contrib/parameterHints/provideSignatureHelp.ts +++ b/src/vs/editor/contrib/parameterHints/provideSignatureHelp.ts @@ -7,7 +7,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { onUnexpectedExternalError } from 'vs/base/common/errors'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; import { SignatureHelp, SignatureHelpProviderRegistry } from 'vs/editor/common/modes'; import { asWinJsPromise, sequence } from 'vs/base/common/async'; @@ -19,7 +19,7 @@ export const Context = { MultipleSignatures: new RawContextKey('parameterHintsMultipleSignatures', false), }; -export function provideSignatureHelp(model: IReadOnlyModel, position: Position): TPromise { +export function provideSignatureHelp(model: IModel, position: Position): TPromise { const supports = SignatureHelpProviderRegistry.ordered(model); let result: SignatureHelp; diff --git a/src/vs/editor/contrib/quickFix/quickFix.ts b/src/vs/editor/contrib/quickFix/quickFix.ts index 6c9de668262..af5cbf16508 100644 --- a/src/vs/editor/contrib/quickFix/quickFix.ts +++ b/src/vs/editor/contrib/quickFix/quickFix.ts @@ -5,7 +5,7 @@ 'use strict'; import URI from 'vs/base/common/uri'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { Range } from 'vs/editor/common/core/range'; import { CodeActionProviderRegistry, CodeAction } from 'vs/editor/common/modes'; import { asWinJsPromise } from 'vs/base/common/async'; @@ -15,7 +15,7 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { registerLanguageCommand } from 'vs/editor/browser/editorExtensions'; import { isFalsyOrEmpty } from 'vs/base/common/arrays'; -export function getCodeActions(model: IReadOnlyModel, range: Range): TPromise { +export function getCodeActions(model: IModel, range: Range): TPromise { const allResults: CodeAction[] = []; const promises = CodeActionProviderRegistry.all(model).map(support => { diff --git a/src/vs/editor/contrib/referenceSearch/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/referenceSearch.ts index b0aafa03a89..76f4c2955d9 100644 --- a/src/vs/editor/contrib/referenceSearch/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/referenceSearch.ts @@ -197,7 +197,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ }); -export function provideReferences(model: editorCommon.IReadOnlyModel, position: Position): TPromise { +export function provideReferences(model: editorCommon.IModel, position: Position): TPromise { // collect references from all providers const promises = ReferenceProviderRegistry.ordered(model).map(provider => { diff --git a/src/vs/editor/contrib/rename/rename.ts b/src/vs/editor/contrib/rename/rename.ts index a4b7c5c4409..328ca6923cf 100644 --- a/src/vs/editor/contrib/rename/rename.ts +++ b/src/vs/editor/contrib/rename/rename.ts @@ -15,7 +15,7 @@ import { RawContextKey, IContextKey, IContextKeyService, ContextKeyExpr } from ' import { IMessageService } from 'vs/platform/message/common/message'; import { IProgressService } from 'vs/platform/progress/common/progress'; import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction, EditorCommand, registerEditorCommand, registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions'; -import { IEditorContribution, IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IEditorContribution, IModel } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { createBulkEdit } from 'vs/editor/browser/services/bulkEdit'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; @@ -33,7 +33,7 @@ import { EditorState, CodeEditorStateFlag } from 'vs/editor/browser/core/editorS import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; -export function rename(model: IReadOnlyModel, position: Position, newName: string): TPromise { +export function rename(model: IModel, position: Position, newName: string): TPromise { const supports = RenameProviderRegistry.ordered(model); const rejects: string[] = []; diff --git a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts index 58be914c787..88229fa4596 100644 --- a/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts @@ -34,7 +34,7 @@ export const overviewRulerWordHighlightStrongForeground = registerColor('editorO export const ctxHasWordHighlights = new RawContextKey('hasWordHighlights', false); -export function getOccurrencesAtPosition(model: editorCommon.IReadOnlyModel, position: Position): TPromise { +export function getOccurrencesAtPosition(model: editorCommon.IModel, position: Position): TPromise { const orderedByScore = DocumentHighlightProviderRegistry.ordered(model); let foundResult = false; diff --git a/src/vs/editor/standalone/browser/standaloneLanguages.ts b/src/vs/editor/standalone/browser/standaloneLanguages.ts index be135034703..cd2bde17c7e 100644 --- a/src/vs/editor/standalone/browser/standaloneLanguages.ts +++ b/src/vs/editor/standalone/browser/standaloneLanguages.ts @@ -263,7 +263,7 @@ export function registerSignatureHelpProvider(languageId: string, provider: mode */ export function registerHoverProvider(languageId: string, provider: modes.HoverProvider): IDisposable { return modes.HoverProviderRegistry.register(languageId, { - provideHover: (model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Thenable => { + provideHover: (model: editorCommon.IModel, position: Position, token: CancellationToken): Thenable => { let word = model.getWordAtPosition(position); return toThenable(provider.provideHover(model, position, token)).then((value) => { @@ -329,7 +329,7 @@ export function registerCodeLensProvider(languageId: string, provider: modes.Cod */ export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider): IDisposable { return modes.CodeActionProviderRegistry.register(languageId, { - provideCodeActions: (model: editorCommon.IReadOnlyModel, range: Range, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]> => { + provideCodeActions: (model: editorCommon.IModel, range: Range, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]> => { let markers = StaticServices.markerService.get().read({ resource: model.uri }).filter(m => { return Range.areIntersectingOrTouching(m, range); }); @@ -373,10 +373,10 @@ export function registerCompletionItemProvider(languageId: string, provider: Com let adapter = new SuggestAdapter(provider); return modes.SuggestRegistry.register(languageId, { triggerCharacters: provider.triggerCharacters, - provideCompletionItems: (model: editorCommon.IReadOnlyModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable => { + provideCompletionItems: (model: editorCommon.IModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable => { return adapter.provideCompletionItems(model, position, context, token); }, - resolveCompletionItem: (model: editorCommon.IReadOnlyModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable => { + resolveCompletionItem: (model: editorCommon.IModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable => { return adapter.resolveCompletionItem(model, position, suggestion, token); } }); @@ -411,7 +411,7 @@ export interface CodeActionProvider { /** * Provide commands for the given document and range. */ - provideCodeActions(model: editorCommon.IReadOnlyModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]>; + provideCodeActions(model: editorCommon.IModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]>; } /** @@ -576,7 +576,7 @@ export interface CompletionItemProvider { /** * Provide completion items for the given position and document. */ - provideCompletionItems(document: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; + provideCompletionItems(document: editorCommon.IModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) @@ -665,7 +665,7 @@ class SuggestAdapter { return suggestion; } - provideCompletionItems(model: editorCommon.IReadOnlyModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable { + provideCompletionItems(model: editorCommon.IModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable { const result = this._provider.provideCompletionItems(model, position, token, context); return toThenable(result).then(value => { const result: modes.ISuggestResult = { @@ -708,7 +708,7 @@ class SuggestAdapter { }); } - resolveCompletionItem(model: editorCommon.IReadOnlyModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable { + resolveCompletionItem(model: editorCommon.IModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable { if (typeof this._provider.resolveCompletionItem !== 'function') { return TPromise.as(suggestion); } diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 385c17d7501..a720485d292 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -13,7 +13,7 @@ import { Selection } from 'vs/editor/common/core/selection'; import { EndOfLinePreference, Handler, DefaultEndOfLine, ITextModelCreationOptions, ICommand, - ITokenizedModel, IEditOperationBuilder, ICursorStateComputerData, EndOfLineSequence + IModel, IEditOperationBuilder, ICursorStateComputerData, EndOfLineSequence } from 'vs/editor/common/editorCommon'; import { TextModel } from 'vs/editor/common/model/textModel'; import { IndentAction, IndentationRule } from 'vs/editor/common/modes/languageConfiguration'; @@ -2087,12 +2087,12 @@ suite('Editor Controller - Cursor Configuration', () => { private _selectionId: string = null; - public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void { + public getEditOperations(model: IModel, builder: IEditOperationBuilder): void { builder.addEditOperation(new Range(1, 13, 1, 14), ''); this._selectionId = builder.trackSelection(cursor.getSelection()); } - public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection { + public computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection { return helper.getTrackedSelection(this._selectionId); } diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index ef21f827a94..0380e9138d3 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1371,14 +1371,14 @@ declare module monaco.editor { * @param model The model the command will execute on. * @param builder A helper to collect the needed edit operations and to track selections. */ - getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void; + getEditOperations(model: IModel, builder: IEditOperationBuilder): void; /** * Compute the cursor state after the edit operations were applied. * @param model The model the commad has executed on. * @param helper A helper to get inverse edit operations and to get previously tracked selections. * @return The cursor state after the command executed. */ - computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection; + computeCursorState(model: IModel, helper: ICursorStateComputerData): Selection; } /** @@ -1453,10 +1453,27 @@ declare module monaco.editor { trimAutoWhitespace?: boolean; } + export class FindMatch { + _findMatchBrand: void; + readonly range: Range; + readonly matches: string[]; + } + /** - * A textual read-only model. + * Describes the behavior of decorations when typing/editing near their edges. + * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` */ - export interface ITextModel { + export enum TrackedRangeStickiness { + AlwaysGrowsWhenTypingAtEdges = 0, + NeverGrowsWhenTypingAtEdges = 1, + GrowsOnlyWhenTypingBefore = 2, + GrowsOnlyWhenTypingAfter = 3, + } + + /** + * A model. + */ + export interface IModel { /** * Get the resolved options for this model. */ @@ -1629,15 +1646,6 @@ declare module monaco.editor { * @return The range where the previous match is. It is null if no previous match has been found. */ findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean): FindMatch; - } - - export class FindMatch { - _findMatchBrand: void; - readonly range: Range; - readonly matches: string[]; - } - - export interface IReadOnlyModel extends ITextModel { /** * Gets the resource associated with this editor model. */ @@ -1660,12 +1668,6 @@ declare module monaco.editor { * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; - } - - /** - * A model that is tokenized. - */ - export interface ITokenizedModel extends ITextModel { /** * Get the language associated with this model. */ @@ -1684,23 +1686,6 @@ declare module monaco.editor { * @return The word under or besides `position`. Will never be null. */ getWordUntilPosition(position: IPosition): IWordAtPosition; - } - - /** - * Describes the behavior of decorations when typing/editing near their edges. - * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior` - */ - export enum TrackedRangeStickiness { - AlwaysGrowsWhenTypingAtEdges = 0, - NeverGrowsWhenTypingAtEdges = 1, - GrowsOnlyWhenTypingBefore = 2, - GrowsOnlyWhenTypingAfter = 3, - } - - /** - * A model that can have decorations. - */ - export interface ITextModelWithDecorations { /** * Perform a minimum ammount of operations, in order to transform the decorations * identified by `oldDecorations` to the decorations described by `newDecorations` @@ -1762,12 +1747,6 @@ declare module monaco.editor { * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors). */ getOverviewRulerDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]; - } - - /** - * An editable text model. - */ - export interface IEditableTextModel extends ITextModel { /** * Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs). */ @@ -1806,12 +1785,6 @@ declare module monaco.editor { * @return The inverse edit operations, that, when applied, will bring the model back to the previous state. */ applyEdits(operations: IIdentifiedSingleEditOperation[]): IIdentifiedSingleEditOperation[]; - } - - /** - * A model. - */ - export interface IModel extends IReadOnlyModel, IEditableTextModel, ITokenizedModel, ITextModelWithDecorations { /** * An event emitted when the contents of the model have changed. * @event @@ -3901,6 +3874,9 @@ declare module monaco.editor { readonly lineHeight: number; readonly letterSpacing: number; } + + //compatibility: + export type IReadOnlyModel = IModel; } declare module monaco.languages { @@ -4080,7 +4056,7 @@ declare module monaco.languages { /** * Provide commands for the given document and range. */ - provideCodeActions(model: editor.IReadOnlyModel, range: Range, context: CodeActionContext, token: CancellationToken): (Command | CodeAction)[] | Thenable<(Command | CodeAction)[]>; + provideCodeActions(model: editor.IModel, range: Range, context: CodeActionContext, token: CancellationToken): (Command | CodeAction)[] | Thenable<(Command | CodeAction)[]>; } /** @@ -4244,7 +4220,7 @@ declare module monaco.languages { /** * Provide completion items for the given position and document. */ - provideCompletionItems(document: editor.IReadOnlyModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; + provideCompletionItems(document: editor.IModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) * or [details](#CompletionItem.detail). @@ -4505,7 +4481,7 @@ declare module monaco.languages { * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ - provideHover(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Hover | Thenable; + provideHover(model: editor.IModel, position: Position, token: CancellationToken): Hover | Thenable; } /** @@ -4591,7 +4567,7 @@ declare module monaco.languages { /** * Provide help for the signature at the given position and document. */ - provideSignatureHelp(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editor.IModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; } /** @@ -4637,7 +4613,7 @@ declare module monaco.languages { * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ - provideDocumentHighlights(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editor.IModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; } /** @@ -4659,7 +4635,7 @@ declare module monaco.languages { /** * Provide a set of project-wide references for the given position and document. */ - provideReferences(model: editor.IReadOnlyModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model: editor.IModel, position: Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; } /** @@ -4693,7 +4669,7 @@ declare module monaco.languages { /** * Provide the definition of the symbol at the given position and document. */ - provideDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideDefinition(model: editor.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -4704,7 +4680,7 @@ declare module monaco.languages { /** * Provide the implementation of the symbol at the given position and document. */ - provideImplementation(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideImplementation(model: editor.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -4715,7 +4691,7 @@ declare module monaco.languages { /** * Provide the type definition of the symbol at the given position and document. */ - provideTypeDefinition(model: editor.IReadOnlyModel, position: Position, token: CancellationToken): Definition | Thenable; + provideTypeDefinition(model: editor.IModel, position: Position, token: CancellationToken): Definition | Thenable; } /** @@ -4781,7 +4757,7 @@ declare module monaco.languages { /** * Provide symbol information for the given document. */ - provideDocumentSymbols(model: editor.IReadOnlyModel, token: CancellationToken): SymbolInformation[] | Thenable; + provideDocumentSymbols(model: editor.IModel, token: CancellationToken): SymbolInformation[] | Thenable; } export interface TextEdit { @@ -4812,7 +4788,7 @@ declare module monaco.languages { /** * Provide formatting edits for a whole document. */ - provideDocumentFormattingEdits(model: editor.IReadOnlyModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentFormattingEdits(model: editor.IModel, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4827,7 +4803,7 @@ declare module monaco.languages { * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ - provideDocumentRangeFormattingEdits(model: editor.IReadOnlyModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideDocumentRangeFormattingEdits(model: editor.IModel, range: Range, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4843,7 +4819,7 @@ declare module monaco.languages { * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ - provideOnTypeFormattingEdits(model: editor.IReadOnlyModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; + provideOnTypeFormattingEdits(model: editor.IModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): TextEdit[] | Thenable; } /** @@ -4858,7 +4834,7 @@ declare module monaco.languages { * A provider of links. */ export interface LinkProvider { - provideLinks(model: editor.IReadOnlyModel, token: CancellationToken): ILink[] | Thenable; + provideLinks(model: editor.IModel, token: CancellationToken): ILink[] | Thenable; resolveLink?: (link: ILink, token: CancellationToken) => ILink | Thenable; } @@ -4927,11 +4903,11 @@ declare module monaco.languages { /** * Provides the color ranges for a specific model. */ - provideDocumentColors(model: editor.IReadOnlyModel, token: CancellationToken): IColorInformation[] | Thenable; + provideDocumentColors(model: editor.IModel, token: CancellationToken): IColorInformation[] | Thenable; /** * Provide the string representations for a color. */ - provideColorPresentations(model: editor.IReadOnlyModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; + provideColorPresentations(model: editor.IModel, colorInfo: IColorInformation, token: CancellationToken): IColorPresentation[] | Thenable; } export interface IResourceEdit { @@ -4946,7 +4922,7 @@ declare module monaco.languages { } export interface RenameProvider { - provideRenameEdits(model: editor.IReadOnlyModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; + provideRenameEdits(model: editor.IModel, position: Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; } export interface Command { @@ -4964,8 +4940,8 @@ declare module monaco.languages { export interface CodeLensProvider { onDidChange?: IEvent; - provideCodeLenses(model: editor.IReadOnlyModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; - resolveCodeLens?(model: editor.IReadOnlyModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; + provideCodeLenses(model: editor.IModel, token: CancellationToken): ICodeLensSymbol[] | Thenable; + resolveCodeLens?(model: editor.IModel, codeLens: ICodeLensSymbol, token: CancellationToken): ICodeLensSymbol | Thenable; } export interface ILanguageExtensionPoint { diff --git a/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts b/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts index e1bc5da5f5b..b2bc78f9b78 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts @@ -8,7 +8,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IDisposable } from 'vs/base/common/lifecycle'; import { Emitter } from 'vs/base/common/event'; import * as vscode from 'vscode'; -import { IReadOnlyModel, ISingleEditOperation } from 'vs/editor/common/editorCommon'; +import { IModel, ISingleEditOperation } from 'vs/editor/common/editorCommon'; import * as modes from 'vs/editor/common/modes'; import { WorkspaceSymbolProviderRegistry, IWorkspaceSymbolProvider } from 'vs/workbench/parts/search/common/search'; import { wireCancellationToken } from 'vs/base/common/async'; @@ -111,7 +111,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerOutlineSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.DocumentSymbolProviderRegistry.register(toLanguageSelector(selector), { - provideDocumentSymbols: (model: IReadOnlyModel, token: CancellationToken): Thenable => { + provideDocumentSymbols: (model: IModel, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideDocumentSymbols(handle, model.uri)).then(MainThreadLanguageFeatures._reviveSymbolInformationDto); } }); @@ -122,10 +122,10 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerCodeLensSupport(handle: number, selector: vscode.DocumentSelector, eventHandle: number): void { const provider = { - provideCodeLenses: (model: IReadOnlyModel, token: CancellationToken): modes.ICodeLensSymbol[] | Thenable => { + provideCodeLenses: (model: IModel, token: CancellationToken): modes.ICodeLensSymbol[] | Thenable => { return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$provideCodeLenses(handle, model.uri))); }, - resolveCodeLens: (model: IReadOnlyModel, codeLens: modes.ICodeLensSymbol, token: CancellationToken): modes.ICodeLensSymbol | Thenable => { + resolveCodeLens: (model: IModel, codeLens: modes.ICodeLensSymbol, token: CancellationToken): modes.ICodeLensSymbol | Thenable => { return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$resolveCodeLens(handle, model.uri, codeLens))); } }; @@ -176,7 +176,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerHoverProvider(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.HoverProviderRegistry.register(toLanguageSelector(selector), { - provideHover: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable => { + provideHover: (model: IModel, position: EditorPosition, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideHover(handle, model.uri, position)); } }); @@ -186,7 +186,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerDocumentHighlightProvider(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(toLanguageSelector(selector), { - provideDocumentHighlights: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable => { + provideDocumentHighlights: (model: IModel, position: EditorPosition, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideDocumentHighlights(handle, model.uri, position)); } }); @@ -196,7 +196,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerReferenceSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.ReferenceProviderRegistry.register(toLanguageSelector(selector), { - provideReferences: (model: IReadOnlyModel, position: EditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable => { + provideReferences: (model: IModel, position: EditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideReferences(handle, model.uri, position, context)).then(MainThreadLanguageFeatures._reviveLocationDto); } }); @@ -206,7 +206,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerQuickFixSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.CodeActionProviderRegistry.register(toLanguageSelector(selector), { - provideCodeActions: (model: IReadOnlyModel, range: EditorRange, token: CancellationToken): Thenable => { + provideCodeActions: (model: IModel, range: EditorRange, token: CancellationToken): Thenable => { return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$provideCodeActions(handle, model.uri, range))).then(MainThreadLanguageFeatures._reviveCodeActionDto); } }); @@ -216,7 +216,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerDocumentFormattingSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.DocumentFormattingEditProviderRegistry.register(toLanguageSelector(selector), { - provideDocumentFormattingEdits: (model: IReadOnlyModel, options: modes.FormattingOptions, token: CancellationToken): Thenable => { + provideDocumentFormattingEdits: (model: IModel, options: modes.FormattingOptions, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideDocumentFormattingEdits(handle, model.uri, options)); } }); @@ -224,7 +224,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerRangeFormattingSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.DocumentRangeFormattingEditProviderRegistry.register(toLanguageSelector(selector), { - provideDocumentRangeFormattingEdits: (model: IReadOnlyModel, range: EditorRange, options: modes.FormattingOptions, token: CancellationToken): Thenable => { + provideDocumentRangeFormattingEdits: (model: IModel, range: EditorRange, options: modes.FormattingOptions, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options)); } }); @@ -235,7 +235,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha autoFormatTriggerCharacters, - provideOnTypeFormattingEdits: (model: IReadOnlyModel, position: EditorPosition, ch: string, options: modes.FormattingOptions, token: CancellationToken): Thenable => { + provideOnTypeFormattingEdits: (model: IModel, position: EditorPosition, ch: string, options: modes.FormattingOptions, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideOnTypeFormattingEdits(handle, model.uri, position, ch, options)); } }); @@ -265,7 +265,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerRenameSupport(handle: number, selector: vscode.DocumentSelector): void { this._registrations[handle] = modes.RenameProviderRegistry.register(toLanguageSelector(selector), { - provideRenameEdits: (model: IReadOnlyModel, position: EditorPosition, newName: string, token: CancellationToken): Thenable => { + provideRenameEdits: (model: IModel, position: EditorPosition, newName: string, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideRenameEdits(handle, model.uri, position, newName)).then(MainThreadLanguageFeatures._reviveWorkspaceEditDto); } }); @@ -276,7 +276,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha $registerSuggestSupport(handle: number, selector: vscode.DocumentSelector, triggerCharacters: string[], supportsResolveDetails: boolean): void { this._registrations[handle] = modes.SuggestRegistry.register(toLanguageSelector(selector), { triggerCharacters, - provideCompletionItems: (model: IReadOnlyModel, position: EditorPosition, context: modes.SuggestContext, token: CancellationToken): Thenable => { + provideCompletionItems: (model: IModel, position: EditorPosition, context: modes.SuggestContext, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideCompletionItems(handle, model.uri, position, context)).then(result => { if (!result) { return result; @@ -301,7 +301,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha signatureHelpTriggerCharacters: triggerCharacter, - provideSignatureHelp: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable => { + provideSignatureHelp: (model: IModel, position: EditorPosition, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideSignatureHelp(handle, model.uri, position)); } diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts index 86bd470365c..e555da511fd 100644 --- a/src/vs/workbench/parts/debug/electron-browser/repl.ts +++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts @@ -18,7 +18,7 @@ import { KeyCode } from 'vs/base/common/keyCodes'; import { ITree, ITreeOptions } from 'vs/base/parts/tree/browser/tree'; import { Context as SuggestContext } from 'vs/editor/contrib/suggest/suggest'; import { SuggestController } from 'vs/editor/contrib/suggest/suggestController'; -import { IReadOnlyModel } from 'vs/editor/common/editorCommon'; +import { IModel } from 'vs/editor/common/editorCommon'; import { EditorContextKeys } from 'vs/editor/common/editorContextKeys'; import { Position } from 'vs/editor/common/core/position'; import * as modes from 'vs/editor/common/modes'; @@ -170,7 +170,7 @@ export class Repl extends Panel implements IPrivateReplService { modes.SuggestRegistry.register({ scheme: debug.DEBUG_SCHEME }, { triggerCharacters: ['.'], - provideCompletionItems: (model: IReadOnlyModel, position: Position, _context: modes.SuggestContext, token: CancellationToken): Thenable => { + provideCompletionItems: (model: IModel, position: Position, _context: modes.SuggestContext, token: CancellationToken): Thenable => { const word = this.replInput.getModel().getWordAtPosition(position); const overwriteBefore = word ? word.word.length : 0; const text = this.replInput.getModel().getLineContent(position.lineNumber); diff --git a/src/vs/workbench/parts/preferences/common/smartSnippetInserter.ts b/src/vs/workbench/parts/preferences/common/smartSnippetInserter.ts index 7c0228ca05e..6e08f69cf43 100644 --- a/src/vs/workbench/parts/preferences/common/smartSnippetInserter.ts +++ b/src/vs/workbench/parts/preferences/common/smartSnippetInserter.ts @@ -31,7 +31,7 @@ export class SmartSnippetInserter { return false; } - private static offsetToPosition(model: editorCommon.ITextModel, offset: number): Position { + private static offsetToPosition(model: editorCommon.IModel, offset: number): Position { let offsetBeforeLine = 0; let eolLength = model.getEOL().length; let lineCount = model.getLineCount(); @@ -53,7 +53,7 @@ export class SmartSnippetInserter { ); } - public static insertSnippet(model: editorCommon.ITextModel, _position: Position): InsertSnippetResult { + public static insertSnippet(model: editorCommon.IModel, _position: Position): InsertSnippetResult { let desiredPosition = model.getValueLengthInRange(new Range(1, 1, _position.lineNumber, _position.column)); diff --git a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts index 1187e04bc01..3fd7a7e2d9a 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts @@ -11,7 +11,7 @@ import errors = require('vs/base/common/errors'); import { IEntryRunContext, Mode, IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen'; import { QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { QuickOpenHandler, EditorQuickOpenEntry, QuickOpenAction } from 'vs/workbench/browser/quickopen'; -import { IEditor, IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, IEditorViewState, ITextModel, IDiffEditorModel, ScrollType } from 'vs/editor/common/editorCommon'; +import { IEditor, IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, IEditorViewState, IModel, IDiffEditorModel, ScrollType } from 'vs/editor/common/editorCommon'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { Position, IEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; @@ -115,7 +115,7 @@ class GotoLineEntry extends EditorQuickOpenEntry { model = (model).modified; // Support for diff editor models } - return model && types.isFunction((model).getLineCount) ? (model).getLineCount() : -1; + return model && types.isFunction((model).getLineCount) ? (model).getLineCount() : -1; } public run(mode: Mode, context: IEntryRunContext): boolean { diff --git a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts index e83194a9110..13f2745a803 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts @@ -15,7 +15,7 @@ import { IEntryRunContext, Mode, IAutoFocus } from 'vs/base/parts/quickopen/comm import { QuickOpenModel, IHighlight } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { QuickOpenHandler, EditorQuickOpenEntryGroup, QuickOpenAction } from 'vs/workbench/browser/quickopen'; import filters = require('vs/base/common/filters'); -import { IEditor, IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, IModel, ITokenizedModel, IDiffEditorModel, IEditorViewState, ScrollType } from 'vs/editor/common/editorCommon'; +import { IEditor, IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDeltaDecoration, IModel, IDiffEditorModel, IEditorViewState, ScrollType } from 'vs/editor/common/editorCommon'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { Position, IEditorInput, ITextEditorOptions } from 'vs/platform/editor/common/editor'; @@ -426,7 +426,7 @@ export class GotoSymbolHandler extends QuickOpenHandler { model = (model).modified; // Support for diff editor models } - if (model && types.isFunction((model).getLanguageIdentifier)) { + if (model && types.isFunction((model).getLanguageIdentifier)) { canRun = DocumentSymbolProviderRegistry.has(model); } } @@ -485,7 +485,7 @@ export class GotoSymbolHandler extends QuickOpenHandler { model = (model).modified; // Support for diff editor models } - if (model && types.isFunction((model).getLanguageIdentifier)) { + if (model && types.isFunction((model).getLanguageIdentifier)) { // Ask cache first const modelId = (model).id;