diff --git a/build/lib/monaco-editor.d.ts b/build/lib/monaco-editor.d.ts index 58ef1c4f44b..5edf9032250 100644 --- a/build/lib/monaco-editor.d.ts +++ b/build/lib/monaco-editor.d.ts @@ -185,7 +185,11 @@ declare module monaco { static revive(data: any): Uri; } - export interface IEmitterEvent { + + export class EmitterEvent { + private _type; + private _data; + constructor(eventType?: string, data?: any); getType(): string; getData(): any; } @@ -194,24 +198,15 @@ declare module monaco { (value: any): void; } - export interface IBulkListenerCallback { - (value: IEmitterEvent[]): void; - } - - export interface ListenerUnbind { - (): void; + export interface BulkListenerCallback { + (value: EmitterEvent[]): void; } export interface IEventEmitter extends IDisposable { - addListener(eventType: string, listener: ListenerCallback): ListenerUnbind; addListener2(eventType: string, listener: ListenerCallback): IDisposable; - addOneTimeListener(eventType: string, listener: ListenerCallback): ListenerUnbind; - addBulkListener(listener: IBulkListenerCallback): ListenerUnbind; - addBulkListener2(listener: IBulkListenerCallback): IDisposable; - addEmitter(eventEmitter: IEventEmitter, emitterType?: string): ListenerUnbind; - addEmitter2(eventEmitter: IEventEmitter, emitterType?: string): IDisposable; - addEmitterTypeListener(eventType: string, emitterType: string, listener: ListenerCallback): ListenerUnbind; - emit(eventType: string, data?: any): void; + addOneTimeDisposableListener(eventType: string, listener: ListenerCallback): IDisposable; + addBulkListener2(listener: BulkListenerCallback): IDisposable; + addEmitter2(eventEmitter: IEventEmitter): IDisposable; } @@ -477,6 +472,242 @@ declare module monaco { export interface IConstructorSignature2 { new (context: IPlatformServices, first: A1, second: A2): T; } + + + /** + * A position in the editor. This interface is suitable for serialization. + */ + export interface IPosition { + /** + * line number (starts at 1) + */ + lineNumber: number; + /** + * column (the first character in a line is between column 1 and column 2) + */ + column: number; + } + + /** + * A range in the editor. This interface is suitable for serialization. + */ + export interface IRange { + /** + * Line number on which the range starts (starts at 1). + */ + startLineNumber: number; + /** + * Column on which the range starts in line `startLineNumber` (starts at 1). + */ + startColumn: number; + /** + * Line number on which the range ends. + */ + endLineNumber: number; + /** + * Column on which the range ends in line `endLineNumber`. + */ + endColumn: number; + } + + /** + * A range in the editor. + */ + export interface IEditorRange extends IRange { + /** + * Test if this range is empty. + */ + isEmpty(): boolean; + collapseToStart(): IEditorRange; + /** + * Test if position is in this range. If the position is at the edges, will return true. + */ + containsPosition(position: IPosition): boolean; + /** + * Test if range is in this range. If the range is equal to this range, will return true. + */ + containsRange(range: IRange): boolean; + /** + * A reunion of the two ranges. The smallest position will be used as the start point, and the largest one as the end point. + */ + plusRange(range: IRange): IEditorRange; + /** + * A intersection of the two ranges. + */ + intersectRanges(range: IRange): IEditorRange; + /** + * Test if this range equals other. + */ + equalsRange(other: IRange): boolean; + /** + * Return the end position (which will be after or equal to the start position) + */ + getEndPosition(): Position; + /** + * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position. + */ + setEndPosition(endLineNumber: number, endColumn: number): IEditorRange; + /** + * Return the start position (which will be before or equal to the end position) + */ + getStartPosition(): Position; + /** + * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position. + */ + setStartPosition(startLineNumber: number, startColumn: number): IEditorRange; + /** + * Clone this range. + */ + cloneRange(): IEditorRange; + /** + * Transform to a user presentable string representation. + */ + toString(): string; + } + + /** + * The direction of a selection. + */ + export enum SelectionDirection { + /** + * The selection starts above where it ends. + */ + LTR = 0, + /** + * The selection starts below where it ends. + */ + RTL = 1, + } + + /** + * A selection in the editor. + * The selection is a range that has an orientation. + */ + export interface ISelection { + /** + * The line number on which the selection has started. + */ + selectionStartLineNumber: number; + /** + * The column on `selectionStartLineNumber` where the selection has started. + */ + selectionStartColumn: number; + /** + * The line number on which the selection has ended. + */ + positionLineNumber: number; + /** + * The column on `positionLineNumber` where the selection has ended. + */ + positionColumn: number; + } + + /** + * A selection in the editor. + */ + export interface IEditorSelection extends ISelection, IEditorRange { + /** + * Test if equals other selection. + */ + equalsSelection(other: ISelection): boolean; + /** + * Clone this selection. + */ + clone(): IEditorSelection; + /** + * Get directions (LTR or RTL). + */ + getDirection(): SelectionDirection; + /** + * Create a new selection with a different `positionLineNumber` and `positionColumn`. + */ + setEndPosition(endLineNumber: number, endColumn: number): IEditorSelection; + /** + * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`. + */ + setStartPosition(startLineNumber: number, startColumn: number): IEditorSelection; + } + + export class Position { + lineNumber: number; + column: number; + constructor(lineNumber: number, column: number); + equals(other: IPosition): boolean; + static equals(a: IPosition, b: IPosition): boolean; + isBefore(other: IPosition): boolean; + static isBefore(a: IPosition, b: IPosition): boolean; + isBeforeOrEqual(other: IPosition): boolean; + static isBeforeOrEqual(a: IPosition, b: IPosition): boolean; + clone(): Position; + toString(): string; + static lift(pos: IPosition): Position; + static isIPosition(obj: any): obj is IPosition; + static asEmptyRange(position: IPosition): IRange; + static startPosition(range: IRange): IPosition; + static endPosition(range: IRange): IPosition; + } + + export class Range implements IEditorRange { + startLineNumber: number; + startColumn: number; + endLineNumber: number; + endColumn: number; + constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number); + isEmpty(): boolean; + containsPosition(position: IPosition): boolean; + containsRange(range: IRange): boolean; + plusRange(range: IRange): Range; + intersectRanges(range: IRange): Range; + equalsRange(other: IRange): boolean; + getEndPosition(): Position; + getStartPosition(): Position; + cloneRange(): Range; + toString(): string; + setEndPosition(endLineNumber: number, endColumn: number): IEditorRange; + setStartPosition(startLineNumber: number, startColumn: number): IEditorRange; + collapseToStart(): Range; + static lift(range: IRange): IEditorRange; + static isIRange(obj: any): obj is IRange; + static isEmpty(range: IRange): boolean; + static containsPosition(range: IRange, position: IPosition): boolean; + static containsRange(range: IRange, otherRange: IRange): boolean; + static areIntersectingOrTouching(a: IRange, b: IRange): boolean; + static intersectRanges(a: IRange, b: IRange): Range; + static plusRange(a: IRange, b: IRange): Range; + static equalsRange(a: IRange, b: IRange): boolean; + /** + * A function that compares ranges, useful for sorting ranges + * It will first compare ranges on the startPosition and then on the endPosition + */ + static compareRangesUsingStarts(a: IRange, b: IRange): number; + /** + * A function that compares ranges, useful for sorting ranges + * It will first compare ranges on the endPosition and then on the startPosition + */ + static compareRangesUsingEnds(a: IRange, b: IRange): number; + static spansMultipleLines(range: IRange): boolean; + static collapseToStart(range: IRange): IRange; + } + + export class Selection extends Range implements IEditorSelection { + selectionStartLineNumber: number; + selectionStartColumn: number; + positionLineNumber: number; + positionColumn: number; + constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number); + clone(): IEditorSelection; + toString(): string; + equalsSelection(other: ISelection): boolean; + getDirection(): SelectionDirection; + setEndPosition(endLineNumber: number, endColumn: number): IEditorSelection; + setStartPosition(startLineNumber: number, startColumn: number): IEditorSelection; + static createSelection(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number): IEditorSelection; + static liftSelection(sel: ISelection): IEditorSelection; + static selectionsEqual(a: ISelection, b: ISelection): boolean; + static selectionsArrEqual(a: ISelection[], b: ISelection[]): boolean; + static isISelection(obj: any): boolean; + static createWithDirection(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, direction: SelectionDirection): IEditorSelection; + } } @@ -621,180 +852,8 @@ declare module monaco.editor { } - /** - * A position in the editor. This interface is suitable for serialization. - */ - export interface IPosition { - /** - * line number (starts at 1) - */ - lineNumber: number; - /** - * column (the first character in a line is between column 1 and column 2) - */ - column: number; - } - - /** - * A position in the editor. - */ - export interface IEditorPosition extends IPosition { - /** - * Test if this position equals other position - */ - equals(other: IPosition): boolean; - /** - * Test if this position is before other position. If the two positions are equal, the result will be false. - */ - isBefore(other: IPosition): boolean; - /** - * Test if this position is before other position. If the two positions are equal, the result will be true. - */ - isBeforeOrEqual(other: IPosition): boolean; - /** - * Clone this position. - */ - clone(): IEditorPosition; - } - - /** - * A range in the editor. This interface is suitable for serialization. - */ - export interface IRange { - /** - * Line number on which the range starts (starts at 1). - */ - startLineNumber: number; - /** - * Column on which the range starts in line `startLineNumber` (starts at 1). - */ - startColumn: number; - /** - * Line number on which the range ends. - */ - endLineNumber: number; - /** - * Column on which the range ends in line `endLineNumber`. - */ - endColumn: number; - } - - /** - * A range in the editor. - */ - export interface IEditorRange extends IRange { - /** - * Test if this range is empty. - */ - isEmpty(): boolean; - collapseToStart(): IEditorRange; - /** - * Test if position is in this range. If the position is at the edges, will return true. - */ - containsPosition(position: IPosition): boolean; - /** - * Test if range is in this range. If the range is equal to this range, will return true. - */ - containsRange(range: IRange): boolean; - /** - * A reunion of the two ranges. The smallest position will be used as the start point, and the largest one as the end point. - */ - plusRange(range: IRange): IEditorRange; - /** - * A intersection of the two ranges. - */ - intersectRanges(range: IRange): IEditorRange; - /** - * Test if this range equals other. - */ - equalsRange(other: IRange): boolean; - /** - * Return the end position (which will be after or equal to the start position) - */ - getEndPosition(): IEditorPosition; - /** - * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position. - */ - setEndPosition(endLineNumber: number, endColumn: number): IEditorRange; - /** - * Return the start position (which will be before or equal to the end position) - */ - getStartPosition(): IEditorPosition; - /** - * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position. - */ - setStartPosition(startLineNumber: number, startColumn: number): IEditorRange; - /** - * Clone this range. - */ - cloneRange(): IEditorRange; - /** - * Transform to a user presentable string representation. - */ - toString(): string; - } - - /** - * A selection in the editor. - * The selection is a range that has an orientation. - */ - export interface ISelection { - /** - * The line number on which the selection has started. - */ - selectionStartLineNumber: number; - /** - * The column on `selectionStartLineNumber` where the selection has started. - */ - selectionStartColumn: number; - /** - * The line number on which the selection has ended. - */ - positionLineNumber: number; - /** - * The column on `positionLineNumber` where the selection has ended. - */ - positionColumn: number; - } - - /** - * The direction of a selection. - */ - export enum SelectionDirection { - /** - * The selection starts above where it ends. - */ - LTR = 0, - /** - * The selection starts below where it ends. - */ - RTL = 1, - } - - /** - * A selection in the editor. - */ - export interface IEditorSelection extends ISelection, IEditorRange { - /** - * Test if equals other selection. - */ - equalsSelection(other: ISelection): boolean; - /** - * Clone this selection. - */ - clone(): IEditorSelection; - /** - * Get directions (LTR or RTL). - */ - getDirection(): SelectionDirection; - /** - * Create a new selection with a different `positionLineNumber` and `positionColumn`. - */ - setEndPosition(endLineNumber: number, endColumn: number): IEditorSelection; - /** - * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`. - */ - setStartPosition(startLineNumber: number, startColumn: number): IEditorSelection; + export interface IEvent { + (listener: (e: T) => any, thisArg?: any): IDisposable; } /** @@ -1827,6 +1886,10 @@ declare module monaco.editor { * Replace the entire text buffer value contained in this model. */ setValue(newValue: string): void; + /** + * Replace the entire text buffer value contained in this model. + */ + setValueFromRawText(newValue: IRawText): void; /** * Get the text stored in this model. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`. @@ -1896,7 +1959,7 @@ declare module monaco.editor { /** * Create a valid position, */ - validatePosition(position: IPosition): IEditorPosition; + validatePosition(position: IPosition): Position; /** * Advances the given position by the given offest (negative offsets are also accepted) * and returns it as a new valid position. @@ -1907,7 +1970,7 @@ declare module monaco.editor { * If the ofsset is such that the new position would be in the middle of a multi-byte * line terminator, throws an exception. */ - modifyPosition(position: IPosition, offset: number): IEditorPosition; + modifyPosition(position: IPosition, offset: number): Position; /** * Create a valid range. */ @@ -1962,13 +2025,6 @@ declare module monaco.editor { reversedRegex: RegExp; } - export interface IFoundBracket { - range: IEditorRange; - open: string; - close: string; - isOpen: boolean; - } - /** * A model that is tokenized. */ @@ -1984,16 +2040,6 @@ declare module monaco.editor { */ getLineContext(lineNumber: number): ILineContext; _getLineModeTransitions(lineNumber: number): IModeTransition[]; - /** - * Replace the entire text buffer value contained in this model. - * Optionally, the language mode of the model can be changed. - * This call clears all of the undo / redo stack, - * removes all decorations or tracked ranges, emits a - * ModelContentChanged(ModelContentChangedFlush) event and - * unbinds the mirror model from the previous mode to the new - * one if the mode has changed. - */ - setValue(newValue: string, newMode?: IMode): void; /** * Get the current language mode associated with the model. */ @@ -2001,8 +2047,7 @@ declare module monaco.editor { /** * Set the current language mode associated with the model. */ - setMode(newMode: IMode): void; - setMode(newModePromise: TPromise): void; + setMode(newMode: IMode | TPromise): void; /** * A mode can be currently pending loading if a promise is used when constructing a model or calling setMode(). * @@ -2057,7 +2102,7 @@ declare module monaco.editor { _addMarker(lineNumber: number, column: number, stickToPreviousCharacter: boolean): string; _changeMarker(id: string, newLineNumber: number, newColumn: number): void; _changeMarkerStickiness(id: string, newStickToPreviousCharacter: boolean): void; - _getMarker(id: string): IEditorPosition; + _getMarker(id: string): Position; _removeMarker(id: string): void; _getLineMarkers(lineNumber: number): IReadOnlyLineMarker[]; } @@ -2301,19 +2346,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, wholeWord: boolean): IEditorRange; - /** - * Replace the entire text buffer value contained in this model. - * Optionally, the language mode of the model can be changed. - * This call clears all of the undo / redo stack, - * removes all decorations or tracked ranges, emits a - * ModelContentChanged(ModelContentChangedFlush) event and - * unbinds the mirror model from the previous mode to the new - * one if the mode has changed. - */ - setValue(newValue: string, newMode?: IMode): void; - setValue(newValue: string, newModePromise: TPromise): void; - setValueFromRawText(newValue: IRawText, newMode?: IMode): void; - setValueFromRawText(newValue: IRawText, newModePromise: TPromise): void; onBeforeAttached(): void; onBeforeDetached(): void; /** @@ -2545,19 +2577,19 @@ declare module monaco.editor { /** * Primary cursor's position. */ - position: IEditorPosition; + position: Position; /** * Primary cursor's view position */ - viewPosition: IEditorPosition; + viewPosition: Position; /** * Secondary cursors' position. */ - secondaryPositions: IEditorPosition[]; + secondaryPositions: Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions: IEditorPosition[]; + secondaryViewPositions: Position[]; /** * Reason. */ @@ -3115,11 +3147,11 @@ declare module monaco.editor { /** * Primary cursor's position. */ - position: IEditorPosition; + position: Position; /** * Secondary cursors' position. */ - secondaryPositions: IEditorPosition[]; + secondaryPositions: Position[]; /** * Is the primary cursor in the editable range? */ @@ -3235,7 +3267,15 @@ declare module monaco.editor { /** * An editor. */ - export interface IEditor extends IEventEmitter { + export interface IEditor { + onDidModelContentChange(listener: (e: IModelContentChangedEvent) => void): IDisposable; + onDidModelModeChange(listener: (e: IModelModeChangedEvent) => void): IDisposable; + onDidModelOptionsChange(listener: (e: IModelOptionsChangedEvent) => void): IDisposable; + onDidConfigurationChange(listener: (e: IConfigurationChangedEvent) => void): IDisposable; + onDidCursorPositionChange(listener: (e: ICursorPositionChangedEvent) => void): IDisposable; + onDidCursorSelectionChange(listener: (e: ICursorSelectionChangedEvent) => void): IDisposable; + onDidDispose(listener: () => void): IDisposable; + dispose(): void; getId(): string; /** * Get the editor type. Current supported types: @@ -3296,7 +3336,7 @@ declare module monaco.editor { /** * Returns the primary position of the cursor. */ - getPosition(): IEditorPosition; + getPosition(): Position; /** * Set the primary position of the cursor. This will remove any secondary cursors. * @param position New primary cursor's position @@ -3464,6 +3504,13 @@ declare module monaco.editor { } export interface ICommonCodeEditor extends IEditor { + onDidModelChange(listener: (e: IModelChangedEvent) => void): IDisposable; + onDidModelModeSupportChange(listener: (e: IModeSupportChangedEvent) => void): IDisposable; + onDidModelDecorationsChange(listener: (e: IModelDecorationsChangedEvent) => void): IDisposable; + onDidEditorTextFocus(listener: () => void): IDisposable; + onDidEditorTextBlur(listener: () => void): IDisposable; + onDidEditorFocus(listener: () => void): IDisposable; + onDidEditorBlur(listener: () => void): IDisposable; /** * Returns true if this editor or one of its widgets has keyboard focus. */ @@ -3583,10 +3630,11 @@ declare module monaco.editor { * @param character Character to listen to. * @param callback Function to call when `character` is typed. */ - addTypingListener(character: string, callback: () => void): ListenerUnbind; + addTypingListener(character: string, callback: () => void): IDisposable; } export interface ICommonDiffEditor extends IEditor { + onDidUpdateDiff(listener: () => void): IDisposable; /** * Type the getModel() of IEditor. */ @@ -3769,6 +3817,7 @@ declare module monaco.editor { export function cursorStyleToString(cursorStyle: TextEditorCursorStyle): string; + export interface IContentWidgetData { widget: IContentWidget; position: IContentWidgetPosition; @@ -3815,14 +3864,14 @@ declare module monaco.editor { export interface IViewZoneData { viewZoneId: number; - positionBefore: IEditorPosition; - positionAfter: IEditorPosition; - position: IEditorPosition; + positionBefore: Position; + positionAfter: Position; + position: Position; afterLineNumber: number; } export interface IMouseDispatchData { - position: IEditorPosition; + position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -3838,7 +3887,7 @@ declare module monaco.editor { export interface IViewController { dispatchMouse(data: IMouseDispatchData): any; - moveTo(source: string, position: IEditorPosition): void; + moveTo(source: string, position: Position): void; paste(source: string, text: string, pasteOnNewLine: boolean): void; type(source: string, text: string): void; replacePreviousChar(source: string, text: string, replaceCharCnt: number): void; @@ -4066,7 +4115,7 @@ declare module monaco.editor { /** * The 'approximate' editor position */ - position: IEditorPosition; + position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -4144,6 +4193,15 @@ declare module monaco.editor { * A rich code editor. */ export interface ICodeEditor extends ICommonCodeEditor { + onMouseUp(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseDown(listener: (e: IEditorMouseEvent) => void): IDisposable; + onContextMenu(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseMove(listener: (e: IEditorMouseEvent) => void): IDisposable; + onMouseLeave(listener: (e: IEditorMouseEvent) => void): IDisposable; + onKeyUp(listener: (e: IKeyboardEvent) => void): IDisposable; + onKeyDown(listener: (e: IKeyboardEvent) => void): IDisposable; + onDidLayoutChange(listener: (e: EditorLayoutInfo) => void): IDisposable; + onDidScrollChange(listener: (e: IScrollEvent) => void): IDisposable; /** * Returns the editor's dom node */ diff --git a/build/lib/monaco-editor.d.ts.recipe b/build/lib/monaco-editor.d.ts.recipe index 533a5423985..daa920b8462 100644 --- a/build/lib/monaco-editor.d.ts.recipe +++ b/build/lib/monaco-editor.d.ts.recipe @@ -66,7 +66,7 @@ declare module monaco { #include(vs/base/common/uri): URI - #include(vs/base/common/eventEmitter): IEmitterEvent, ListenerCallback, IBulkListenerCallback, ListenerUnbind, IEventEmitter + #include(vs/base/common/eventEmitter): EmitterEvent, ListenerCallback, BulkListenerCallback, IEventEmitter #include(vs/base/common/keyCodes): KeyCode, KeyMod @@ -91,6 +91,11 @@ declare module monaco { export interface IConstructorSignature2 { new (context: IPlatformServices, first: A1, second: A2): T; } + + #include(vs/editor/common/editorCommon): IPosition, IRange, IEditorRange, SelectionDirection, ISelection, IEditorSelection + #include(vs/editor/common/core/position): Position + #include(vs/editor/common/core/range): Range + #include(vs/editor/common/core/selection): Selection } @@ -110,7 +115,7 @@ declare module monaco.editor { #include(vs/editor/common/core/viewLineToken): ViewLineToken - #includeAll(vs/editor/common/editorCommon): KeyCode, KeyMod + #includeAll(vs/editor/common/editorCommon): IPosition, IRange, IEditorRange, SelectionDirection, ISelection, IEditorSelection, IFoundBracket #includeAll(vs/editor/browser/editorBrowser): diff --git a/build/lib/monaco.js b/build/lib/monaco.js index c967c62414c..0d31a263110 100644 --- a/build/lib/monaco.js +++ b/build/lib/monaco.js @@ -171,6 +171,13 @@ lines.forEach(function (line) { typesToExclude_1[typeName] = true; }); getAllTopLevelDeclarations(sourceFile_2).forEach(function (declaration) { + if (isDeclaration(declaration)) { + if (typesToExclude_1[declaration.name.text]) { + return; + } + } + else { + } result.push(getMassagedTopLevelDeclarationText(sourceFile_2, declaration)); }); return; diff --git a/build/lib/monaco.ts b/build/lib/monaco.ts index 10f23df86c6..38eef06be24 100644 --- a/build/lib/monaco.ts +++ b/build/lib/monaco.ts @@ -214,6 +214,15 @@ lines.forEach(line => { }); getAllTopLevelDeclarations(sourceFile).forEach((declaration) => { + if (isDeclaration(declaration)) { + if (typesToExclude[declaration.name.text]) { + return; + } + } else { + // todo + // node is ts.VariableStatement + // return (getNodeText(sourceFile, declaration).indexOf(typeName) >= 0); + } result.push(getMassagedTopLevelDeclarationText(sourceFile, declaration)); }); return; diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index ad6558a40a2..efa3cd98f2d 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts +++ b/src/vs/editor/browser/controller/mouseHandler.ts @@ -77,10 +77,10 @@ class EventGateKeeper extends Disposable { } class MousePosition { - public position: editorCommon.IEditorPosition; + public position: Position; public mouseColumn: number; - constructor(position:editorCommon.IEditorPosition, mouseColumn:number) { + constructor(position:Position, mouseColumn:number) { this.position = position; this.mouseColumn = mouseColumn; } @@ -523,7 +523,7 @@ class MouseDownState { private _startedOnLineNumbers: boolean; public get startedOnLineNumbers(): boolean { return this._startedOnLineNumbers; } - private _lastMouseDownPosition: editorCommon.IEditorPosition; + private _lastMouseDownPosition: Position; private _lastMouseDownPositionEqualCount: number; private _lastMouseDownCount: number; private _lastSetMouseDownCountTime: number; @@ -555,7 +555,7 @@ class MouseDownState { this._startedOnLineNumbers = startedOnLineNumbers; } - public trySetCount(setMouseDownCount:number, newMouseDownPosition:editorCommon.IEditorPosition): void { + public trySetCount(setMouseDownCount:number, newMouseDownPosition:Position): void { // a. Invalidate multiple clicking if too much time has passed (will be hit by IE because the detail field of mouse events contains garbage in IE10) let currentTime = (new Date()).getTime(); if (currentTime - this._lastSetMouseDownCountTime > MouseDownState.CLEAR_MOUSE_DOWN_COUNT_TIME) { diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index d6d8615c3f9..9f1b6943bf5 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -6,7 +6,7 @@ import {Position} from 'vs/editor/common/core/position'; import {Range as EditorRange} from 'vs/editor/common/core/range'; -import {EditorLayoutInfo, IEditorPosition, IEditorRange, IPosition, MouseTargetType} from 'vs/editor/common/editorCommon'; +import {EditorLayoutInfo, IEditorRange, IPosition, MouseTargetType} from 'vs/editor/common/editorCommon'; import {ClassNames, IMouseTarget, IViewZoneData} from 'vs/editor/browser/editorBrowser'; import {IDomNodePosition} from 'vs/base/browser/dom'; import {ViewContext} from 'vs/editor/common/view/viewContext'; @@ -28,11 +28,11 @@ class MouseTarget implements IMouseTarget { public element: Element; public type: MouseTargetType; public mouseColumn: number; - public position: IEditorPosition; + public position: Position; public range: IEditorRange; public detail: any; - constructor(element: Element, type: MouseTargetType, mouseColumn:number = 0, position:IEditorPosition = null, range: IEditorRange = null, detail: any = null) { + constructor(element: Element, type: MouseTargetType, mouseColumn:number = 0, position:Position = null, range: IEditorRange = null, detail: any = null) { this.element = element; this.type = type; this.mouseColumn = mouseColumn; @@ -541,9 +541,9 @@ export class MouseTargetFactory { if (viewZoneWhitespace) { var viewZoneMiddle = viewZoneWhitespace.verticalOffset + viewZoneWhitespace.height / 2, lineCount = this._context.model.getLineCount(), - positionBefore: IEditorPosition = null, - position: IEditorPosition, - positionAfter: IEditorPosition = null; + positionBefore: Position = null, + position: Position, + positionAfter: Position = null; if (viewZoneWhitespace.afterLineNumber !== lineCount) { // There are more lines after this view zone diff --git a/src/vs/editor/browser/editorBrowser.ts b/src/vs/editor/browser/editorBrowser.ts index 969382def45..8b1e6ae7e70 100644 --- a/src/vs/editor/browser/editorBrowser.ts +++ b/src/vs/editor/browser/editorBrowser.ts @@ -10,6 +10,7 @@ import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {IMouseEvent} from 'vs/base/browser/mouseEvent'; import {IInstantiationService, IConstructorSignature1} from 'vs/platform/instantiation/common/instantiation'; import * as editorCommon from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export interface IContentWidgetData { widget: IContentWidget; @@ -69,14 +70,14 @@ export interface IView extends IDisposable { export interface IViewZoneData { viewZoneId: number; - positionBefore:editorCommon.IEditorPosition; - positionAfter:editorCommon.IEditorPosition; - position: editorCommon.IEditorPosition; + positionBefore:Position; + positionAfter:Position; + position: Position; afterLineNumber: number; } export interface IMouseDispatchData { - position: editorCommon.IEditorPosition; + position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ @@ -94,7 +95,7 @@ export interface IMouseDispatchData { export interface IViewController { dispatchMouse(data:IMouseDispatchData); - moveTo(source:string, position:editorCommon.IEditorPosition): void; + moveTo(source:string, position:Position): void; paste(source:string, text:string, pasteOnNewLine:boolean): void; type(source: string, text: string): void; @@ -323,7 +324,7 @@ export interface IMouseTarget { /** * The 'approximate' editor position */ - position: editorCommon.IEditorPosition; + position: Position; /** * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line). */ diff --git a/src/vs/editor/browser/view/viewController.ts b/src/vs/editor/browser/view/viewController.ts index 55fbe1efe52..da1ccd30d10 100644 --- a/src/vs/editor/browser/view/viewController.ts +++ b/src/vs/editor/browser/view/viewController.ts @@ -59,7 +59,7 @@ export class ViewController implements IViewController { this.keybindingService.executeCommand(editorCommon.Handler.Cut, {}); } - private _validateViewColumn(viewPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition { + private _validateViewColumn(viewPosition:Position): Position { var minColumn = this.viewModel.getLineMinColumn(viewPosition.lineNumber); if (viewPosition.column < minColumn) { return new Position(viewPosition.lineNumber, minColumn); @@ -133,7 +133,7 @@ export class ViewController implements IViewController { } } - public moveTo(source:string, viewPosition:editorCommon.IEditorPosition): void { + public moveTo(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.MoveTo, { position: this.convertViewToModelPosition(viewPosition), @@ -141,7 +141,7 @@ export class ViewController implements IViewController { }); } - private moveToSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private moveToSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.MoveToSelect, { position: this.convertViewToModelPosition(viewPosition), @@ -149,7 +149,7 @@ export class ViewController implements IViewController { }); } - private columnSelect(source:string, viewPosition:editorCommon.IEditorPosition, mouseColumn:number): void { + private columnSelect(source:string, viewPosition:Position, mouseColumn:number): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.ColumnSelect, { position: this.convertViewToModelPosition(viewPosition), @@ -158,7 +158,7 @@ export class ViewController implements IViewController { }); } - private createCursor(source:string, viewPosition:editorCommon.IEditorPosition, wholeLine:boolean): void { + private createCursor(source:string, viewPosition:Position, wholeLine:boolean): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.CreateCursor, { position: this.convertViewToModelPosition(viewPosition), @@ -167,7 +167,7 @@ export class ViewController implements IViewController { }); } - private lastCursorMoveToSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lastCursorMoveToSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LastCursorMoveToSelect, { position: this.convertViewToModelPosition(viewPosition), @@ -175,28 +175,28 @@ export class ViewController implements IViewController { }); } - private wordSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private wordSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.WordSelect, { position: this.convertViewToModelPosition(viewPosition) }); } - private wordSelectDrag(source:string, viewPosition:editorCommon.IEditorPosition): void { + private wordSelectDrag(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.WordSelectDrag, { position: this.convertViewToModelPosition(viewPosition) }); } - private lastCursorWordSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lastCursorWordSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LastCursorWordSelect, { position: this.convertViewToModelPosition(viewPosition) }); } - private lineSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lineSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LineSelect, { position: this.convertViewToModelPosition(viewPosition), @@ -204,7 +204,7 @@ export class ViewController implements IViewController { }); } - private lineSelectDrag(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lineSelectDrag(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LineSelectDrag, { position: this.convertViewToModelPosition(viewPosition), @@ -212,7 +212,7 @@ export class ViewController implements IViewController { }); } - private lastCursorLineSelect(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lastCursorLineSelect(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LastCursorLineSelect, { position: this.convertViewToModelPosition(viewPosition), @@ -220,7 +220,7 @@ export class ViewController implements IViewController { }); } - private lastCursorLineSelectDrag(source:string, viewPosition:editorCommon.IEditorPosition): void { + private lastCursorLineSelectDrag(source:string, viewPosition:Position): void { viewPosition = this._validateViewColumn(viewPosition); this.triggerCursorHandler(source, editorCommon.Handler.LastCursorLineSelectDrag, { position: this.convertViewToModelPosition(viewPosition), @@ -234,7 +234,7 @@ export class ViewController implements IViewController { // ---------------------- - private convertViewToModelPosition(viewPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition { + private convertViewToModelPosition(viewPosition:Position): Position { return this.viewModel.convertViewPositionToModelPosition(viewPosition.lineNumber, viewPosition.column); } diff --git a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts index d11d9a98327..c2d2380c6f0 100644 --- a/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts +++ b/src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts @@ -13,6 +13,7 @@ import {ClassNames, ContentWidgetPositionPreference, IContentWidget} from 'vs/ed import {ViewPart} from 'vs/editor/browser/view/viewPart'; import {ViewContext} from 'vs/editor/common/view/viewContext'; import {IRenderingContext, IRestrictedRenderingContext} from 'vs/editor/common/view/renderingContext'; +import {Position} from 'vs/editor/common/core/position'; interface IWidgetData { allowEditorOverflow: boolean; @@ -184,7 +185,7 @@ export class ViewContentWidgets extends ViewPart { } } - private _layoutBoxInViewport(position:editorCommon.IEditorPosition, domNode:HTMLElement, ctx:IRenderingContext): IBoxLayoutResult { + private _layoutBoxInViewport(position:Position, domNode:HTMLElement, ctx:IRenderingContext): IBoxLayoutResult { let visibleRange = ctx.visibleRangeForPosition(position); @@ -228,7 +229,7 @@ export class ViewContentWidgets extends ViewPart { }; } - private _layoutBoxInPage(position: editorCommon.IEditorPosition, domNode: HTMLElement, ctx: IRenderingContext): IBoxLayoutResult { + private _layoutBoxInPage(position: Position, domNode: HTMLElement, ctx: IRenderingContext): IBoxLayoutResult { let visibleRange = ctx.visibleRangeForPosition(position); if (!visibleRange) { @@ -282,7 +283,7 @@ export class ViewContentWidgets extends ViewPart { }; } - private _prepareRenderWidgetAtExactPosition(position:editorCommon.IEditorPosition, ctx:IRenderingContext): IMyWidgetRenderData { + private _prepareRenderWidgetAtExactPosition(position:Position, ctx:IRenderingContext): IMyWidgetRenderData { let visibleRange = ctx.visibleRangeForPosition(position); if (!visibleRange) { diff --git a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts index 463224e6047..ba6c401e155 100644 --- a/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts +++ b/src/vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler.ts @@ -11,6 +11,7 @@ import {ViewPart} from 'vs/editor/browser/view/viewPart'; import {OverviewRulerImpl} from 'vs/editor/browser/viewParts/overviewRuler/overviewRulerImpl'; import {ViewContext} from 'vs/editor/common/view/viewContext'; import {IRenderingContext, IRestrictedRenderingContext} from 'vs/editor/common/view/renderingContext'; +import {Position} from 'vs/editor/common/core/position'; export class DecorationsOverviewRuler extends ViewPart { @@ -25,7 +26,7 @@ export class DecorationsOverviewRuler extends ViewPart { private _shouldUpdateCursorPosition:boolean; private _hideCursor:boolean; - private _cursorPositions: editorCommon.IEditorPosition[]; + private _cursorPositions: Position[]; private _zonesFromDecorations: OverviewRulerZone[]; private _zonesFromCursors: OverviewRulerZone[]; diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index aa574139b76..2bb7f68ca8c 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -25,6 +25,7 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import {CodeEditorWidget} from 'vs/editor/browser/widget/codeEditorWidget'; import {ViewLineToken, ViewLineTokens} from 'vs/editor/common/core/viewLineToken'; import {Configuration} from 'vs/editor/browser/config/configuration'; +import {Position} from 'vs/editor/common/core/position'; interface IEditorDiffDecorations { decorations:editorCommon.IModelDeltaDecoration[]; @@ -503,7 +504,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif return this.modifiedEditor.getVisibleColumnFromPosition(position); } - public getPosition(): editorCommon.IEditorPosition { + public getPosition(): Position { return this.modifiedEditor.getPosition(); } diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index 8db13b98387..fc773bbeb20 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -300,7 +300,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr return CursorMoveHelper.visibleColumnFromColumn(this.model, position.lineNumber, position.column, tabSize) + 1; } - public getPosition(): editorCommon.IEditorPosition { + public getPosition(): Position { if (!this.cursor) { return null; } @@ -757,7 +757,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr convertViewSelectionToModelSelection: (viewSelection:editorCommon.ISelection) => { return this.viewModel.convertViewSelectionToModelSelection(viewSelection); }, - validateViewPosition: (viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition) => { + validateViewPosition: (viewLineNumber:number, viewColumn:number, modelPosition:Position) => { return this.viewModel.validateViewPosition(viewLineNumber, viewColumn, modelPosition); }, validateViewRange: (viewStartLineNumber:number, viewStartColumn:number, viewEndLineNumber:number, viewEndColumn:number, modelRange:editorCommon.IEditorRange) => { diff --git a/src/vs/editor/common/controller/cursor.ts b/src/vs/editor/common/controller/cursor.ts index 6c6d1f22228..ebbe939f92e 100644 --- a/src/vs/editor/common/controller/cursor.ts +++ b/src/vs/editor/common/controller/cursor.ts @@ -116,7 +116,7 @@ export class Cursor extends EventEmitter { convertViewSelectionToModelSelection: (viewSelection:editorCommon.IEditorSelection) => { return viewSelection; }, - validateViewPosition: (viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition) => { + validateViewPosition: (viewLineNumber:number, viewColumn:number, modelPosition:Position) => { return modelPosition; }, validateViewRange: (viewStartLineNumber:number, viewStartColumn:number, viewEndLineNumber:number, viewEndColumn:number, modelRange:editorCommon.IEditorRange) => { @@ -289,7 +289,7 @@ export class Cursor extends EventEmitter { return this.cursors.getSelections(); } - public getPosition(): editorCommon.IEditorPosition { + public getPosition(): Position { return this.cursors.getPosition(0); } diff --git a/src/vs/editor/common/controller/cursorCollection.ts b/src/vs/editor/common/controller/cursorCollection.ts index af87c138ebf..67c1b5b093a 100644 --- a/src/vs/editor/common/controller/cursorCollection.ts +++ b/src/vs/editor/common/controller/cursorCollection.ts @@ -7,8 +7,9 @@ import {onUnexpectedError} from 'vs/base/common/errors'; import {IModeConfiguration, IOneCursorState, IViewModelHelper, OneCursor} from 'vs/editor/common/controller/oneCursor'; import {Selection} from 'vs/editor/common/core/selection'; -import {IConfiguration, IEditorPosition, IEditorSelection, IModel, ISelection} from 'vs/editor/common/editorCommon'; +import {IConfiguration, IEditorSelection, IModel, ISelection} from 'vs/editor/common/editorCommon'; import {IAutoClosingPair} from 'vs/editor/common/modes'; +import {Position} from 'vs/editor/common/core/position'; export interface ICursorCollectionState { primary: IOneCursorState; @@ -78,7 +79,7 @@ export class CursorCollection { return result; } - public getPosition(index: number): IEditorPosition { + public getPosition(index: number): Position { if (index === 0) { return this.primaryCursor.getPosition(); } else { @@ -86,7 +87,7 @@ export class CursorCollection { } } - public getViewPosition(index: number): IEditorPosition { + public getViewPosition(index: number): Position { if (index === 0) { return this.primaryCursor.getViewPosition(); } else { @@ -94,8 +95,8 @@ export class CursorCollection { } } - public getPositions(): IEditorPosition[] { - var result: IEditorPosition[] = []; + public getPositions(): Position[] { + var result: Position[] = []; result.push(this.primaryCursor.getPosition()); for (var i = 0, len = this.secondaryCursors.length; i < len; i++) { result.push(this.secondaryCursors[i].getPosition()); @@ -103,8 +104,8 @@ export class CursorCollection { return result; } - public getViewPositions(): IEditorPosition[] { - var result: IEditorPosition[] = []; + public getViewPositions(): Position[] { + var result: Position[] = []; result.push(this.primaryCursor.getViewPosition()); for (var i = 0, len = this.secondaryCursors.length; i < len; i++) { result.push(this.secondaryCursors[i].getViewPosition()); diff --git a/src/vs/editor/common/controller/oneCursor.ts b/src/vs/editor/common/controller/oneCursor.ts index 7751d1f5901..bd27ac3e71b 100644 --- a/src/vs/editor/common/controller/oneCursor.ts +++ b/src/vs/editor/common/controller/oneCursor.ts @@ -57,21 +57,21 @@ export interface IViewModelHelper { viewModel:ICursorMoveHelperModel; - convertModelPositionToViewPosition(lineNumber:number, column:number): editorCommon.IEditorPosition; + convertModelPositionToViewPosition(lineNumber:number, column:number): Position; convertModelRangeToViewRange(modelRange:editorCommon.IEditorRange): editorCommon.IEditorRange; - convertViewToModelPosition(lineNumber:number, column:number): editorCommon.IEditorPosition; + convertViewToModelPosition(lineNumber:number, column:number): Position; convertViewSelectionToModelSelection(viewSelection:editorCommon.IEditorSelection): editorCommon.IEditorSelection; - validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition; + validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:Position): Position; validateViewRange(viewStartLineNumber:number, viewStartColumn:number, viewEndLineNumber:number, viewEndColumn:number, modelRange:editorCommon.IEditorRange): editorCommon.IEditorRange; } export interface IOneCursorState { selectionStart: editorCommon.IEditorRange; viewSelectionStart: editorCommon.IEditorRange; - position: editorCommon.IEditorPosition; - viewPosition: editorCommon.IEditorPosition; + position: Position; + viewPosition: Position; leftoverVisibleColumns: number; selectionStartLeftoverVisibleColumns: number; } @@ -132,8 +132,8 @@ export class OneCursor { private selectionStartLeftoverVisibleColumns: number; // --- position - private position: editorCommon.IEditorPosition; - private viewPosition: editorCommon.IEditorPosition; + private position: Position; + private viewPosition: Position; private leftoverVisibleColumns: number; // --- bracket match decorations @@ -171,8 +171,8 @@ export class OneCursor { private _set( selectionStart: editorCommon.IEditorRange, selectionStartLeftoverVisibleColumns: number, - position: editorCommon.IEditorPosition, leftoverVisibleColumns:number, - viewSelectionStart: editorCommon.IEditorRange, viewPosition: editorCommon.IEditorPosition + position: Position, leftoverVisibleColumns:number, + viewSelectionStart: editorCommon.IEditorRange, viewPosition: Position ): void { this.selectionStart = selectionStart; this.selectionStartLeftoverVisibleColumns = selectionStartLeftoverVisibleColumns; @@ -276,7 +276,7 @@ export class OneCursor { this.bracketDecorations = this.model.deltaDecorations(this.bracketDecorations, newDecorations, this.editorId); } - private static computeSelection(selectionStart:editorCommon.IEditorRange, position:editorCommon.IEditorPosition): Selection { + private static computeSelection(selectionStart:editorCommon.IEditorRange, position:Position): Selection { let startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number; if (selectionStart.isEmpty()) { startLineNumber = selectionStart.startLineNumber; @@ -458,20 +458,20 @@ export class OneCursor { public getSelectionStart(): editorCommon.IEditorRange { return this.selectionStart; } - public getPosition(): editorCommon.IEditorPosition { + public getPosition(): Position { return this.position; } public getSelection(): editorCommon.IEditorSelection { return this._cachedSelection; } - public getViewPosition(): editorCommon.IEditorPosition { + public getViewPosition(): Position { return this.viewPosition; } public getViewSelection(): editorCommon.IEditorSelection { return this._cachedViewSelection; } - public getValidViewPosition(): editorCommon.IEditorPosition { + public getValidViewPosition(): Position { return this.viewModelHelper.validateViewPosition(this.viewPosition.lineNumber, this.viewPosition.column, this.position); } @@ -492,10 +492,10 @@ export class OneCursor { } // -- utils - public validatePosition(position:editorCommon.IPosition): editorCommon.IEditorPosition { + public validatePosition(position:editorCommon.IPosition): Position { return this.model.validatePosition(position); } - public validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition { + public validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:Position): Position { return this.viewModelHelper.validateViewPosition(viewLineNumber, viewColumn, modelPosition); } public convertViewToModelPosition(lineNumber:number, column:number): editorCommon.IPosition { @@ -512,10 +512,10 @@ export class OneCursor { public getLineContent(lineNumber:number): string { return this.model.getLineContent(lineNumber); } - public findPreviousWordOnLine(position:editorCommon.IEditorPosition): IFindWordResult { + public findPreviousWordOnLine(position:Position): IFindWordResult { return this.helper.findPreviousWordOnLine(position); } - public findNextWordOnLine(position:editorCommon.IEditorPosition): IFindWordResult { + public findNextWordOnLine(position:Position): IFindWordResult { return this.helper.findNextWordOnLine(position); } public getLeftOfPosition(lineNumber:number, column:number): editorCommon.IPosition { @@ -1187,7 +1187,7 @@ export class OneCursorOp { return this._enter(cursor, true, ctx); } - private static _enter(cursor:OneCursor, keepPosition: boolean, ctx: IOneCursorOperationContext, position?: editorCommon.IEditorPosition, range?: editorCommon.IEditorRange): boolean { + private static _enter(cursor:OneCursor, keepPosition: boolean, ctx: IOneCursorOperationContext, position?: Position, range?: editorCommon.IEditorRange): boolean { if (typeof position === 'undefined') { position = cursor.getPosition(); } @@ -2020,7 +2020,7 @@ class CursorHelper { return { start: start, end: end, wordType: wordType }; } - public findPreviousWordOnLine(_position:editorCommon.IEditorPosition): IFindWordResult { + public findPreviousWordOnLine(_position:Position): IFindWordResult { let position = this.model.validatePosition(_position); let wordSeparators = getMapForWordSeparators(this.configuration.editor.wordSeparators); let lineContent = this.model.getLineContent(position.lineNumber); @@ -2072,7 +2072,7 @@ class CursorHelper { return len; } - public findNextWordOnLine(_position:editorCommon.IEditorPosition): IFindWordResult { + public findNextWordOnLine(_position:Position): IFindWordResult { let position = this.model.validatePosition(_position); let wordSeparators = getMapForWordSeparators(this.configuration.editor.wordSeparators); let lineContent = this.model.getLineContent(position.lineNumber); diff --git a/src/vs/editor/common/controller/textAreaHandler.ts b/src/vs/editor/common/controller/textAreaHandler.ts index fb4ca1d637a..6be3696120a 100644 --- a/src/vs/editor/common/controller/textAreaHandler.ts +++ b/src/vs/editor/common/controller/textAreaHandler.ts @@ -11,7 +11,7 @@ import {Disposable} from 'vs/base/common/lifecycle'; import {IClipboardEvent, ICompositionEvent, IKeyboardEventWrapper, ISimpleModel, ITextAreaWrapper, ITypeData, TextAreaState, TextAreaStrategy, createTextAreaState} from 'vs/editor/common/controller/textAreaState'; import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; -import {EndOfLinePreference, IEditorPosition, IEditorRange} from 'vs/editor/common/editorCommon'; +import {EndOfLinePreference, IEditorRange} from 'vs/editor/common/editorCommon'; enum ReadFromTextArea { Type, @@ -74,7 +74,7 @@ export class TextAreaHandler extends Disposable { private asyncTriggerCut: RunOnceScheduler; private lastCompositionEndTime:number; - private cursorPosition:IEditorPosition; + private cursorPosition:Position; private textAreaState:TextAreaState; private textareaIsShownAtCursor: boolean; @@ -249,7 +249,7 @@ export class TextAreaHandler extends Disposable { this._writePlaceholderAndSelectTextArea('selection changed'); } - public setCursorPosition(primary: IEditorPosition): void { + public setCursorPosition(primary: Position): void { this.cursorPosition = primary; } diff --git a/src/vs/editor/common/controller/textAreaState.ts b/src/vs/editor/common/controller/textAreaState.ts index bd0aea3acbf..314b1f21234 100644 --- a/src/vs/editor/common/controller/textAreaState.ts +++ b/src/vs/editor/common/controller/textAreaState.ts @@ -7,7 +7,8 @@ import Event from 'vs/base/common/event'; import {commonPrefixLength, commonSuffixLength} from 'vs/base/common/strings'; import {Range} from 'vs/editor/common/core/range'; -import {EndOfLinePreference, IEditorPosition, IEditorRange, IRange} from 'vs/editor/common/editorCommon'; +import {EndOfLinePreference, IEditorRange, IRange} from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export interface IClipboardEvent { canUseTextData(): boolean; @@ -54,7 +55,7 @@ export interface ISimpleModel { getValueInRange(range:IRange, eol:EndOfLinePreference): string; getModelLineContent(lineNumber:number): string; getLineCount(): number; - convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): IEditorPosition; + convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): Position; } export interface ITypeData { diff --git a/src/vs/editor/common/core/editOperation.ts b/src/vs/editor/common/core/editOperation.ts index 47222ed50e8..5bb42be97ad 100644 --- a/src/vs/editor/common/core/editOperation.ts +++ b/src/vs/editor/common/core/editOperation.ts @@ -5,11 +5,12 @@ 'use strict'; import {Range} from 'vs/editor/common/core/range'; -import {IEditorPosition, IEditorRange, IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon'; +import {IEditorRange, IIdentifiedSingleEditOperation} from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export class EditOperation { - public static insert(position:IEditorPosition, text:string): IIdentifiedSingleEditOperation { + public static insert(position:Position, text:string): IIdentifiedSingleEditOperation { return { identifier: null, range: new Range(position.lineNumber, position.column, position.lineNumber, position.column), diff --git a/src/vs/editor/common/core/editorState.ts b/src/vs/editor/common/core/editorState.ts index f8a6f42fa82..35df62c325b 100644 --- a/src/vs/editor/common/core/editorState.ts +++ b/src/vs/editor/common/core/editorState.ts @@ -5,13 +5,14 @@ 'use strict'; import * as strings from 'vs/base/common/strings'; -import {CodeEditorStateFlag, ICodeEditorState, ICommonCodeEditor, IEditorPosition, IEditorRange} from 'vs/editor/common/editorCommon'; +import {CodeEditorStateFlag, ICodeEditorState, ICommonCodeEditor, IEditorRange} from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export class EditorState implements ICodeEditorState { private flags:CodeEditorStateFlag[]; - private position:IEditorPosition; + private position:Position; private selection:IEditorRange; private modelVersionId:string; private scrollLeft:number; diff --git a/src/vs/editor/common/core/position.ts b/src/vs/editor/common/core/position.ts index 8094514361d..45418aa70a0 100644 --- a/src/vs/editor/common/core/position.ts +++ b/src/vs/editor/common/core/position.ts @@ -4,9 +4,9 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import {IEditorPosition, IPosition, IRange} from 'vs/editor/common/editorCommon'; +import {IPosition, IRange} from 'vs/editor/common/editorCommon'; -export class Position implements IEditorPosition { +export class Position { public lineNumber: number; public column: number; @@ -67,7 +67,7 @@ export class Position implements IEditorPosition { // --- - public static lift(pos:IPosition): IEditorPosition { + public static lift(pos:IPosition): Position { return new Position(pos.lineNumber, pos.column); } diff --git a/src/vs/editor/common/core/range.ts b/src/vs/editor/common/core/range.ts index ffd19f11276..16e760a7892 100644 --- a/src/vs/editor/common/core/range.ts +++ b/src/vs/editor/common/core/range.ts @@ -6,7 +6,7 @@ 'use strict'; import {Position} from 'vs/editor/common/core/position'; -import {IEditorPosition, IEditorRange, IPosition, IRange} from 'vs/editor/common/editorCommon'; +import {IEditorRange, IPosition, IRange} from 'vs/editor/common/editorCommon'; export class Range implements IEditorRange { @@ -53,11 +53,11 @@ export class Range implements IEditorRange { return Range.equalsRange(this, other); } - public getEndPosition(): IEditorPosition { + public getEndPosition(): Position { return new Position(this.endLineNumber, this.endColumn); } - public getStartPosition(): IEditorPosition { + public getStartPosition(): Position { return new Position(this.startLineNumber, this.startColumn); } diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index cb9854ca003..edc84b2d606 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -14,6 +14,7 @@ import {ILineContext, IMode, IModeTransition, IToken} from 'vs/editor/common/mod import {ViewLineToken} from 'vs/editor/common/core/viewLineToken'; import {ScrollbarVisibility} from 'vs/base/browser/ui/scrollbar/scrollableElementOptions'; import {IDisposable} from 'vs/base/common/lifecycle'; +import {Position} from 'vs/editor/common/core/position'; export interface Event { (listener: (e: T) => any, thisArg?: any): IDisposable; @@ -35,28 +36,6 @@ export interface IPosition { column:number; } -/** - * A position in the editor. - */ -export interface IEditorPosition extends IPosition { - /** - * Test if this position equals other position - */ - equals(other:IPosition): boolean; - /** - * Test if this position is before other position. If the two positions are equal, the result will be false. - */ - isBefore(other:IPosition): boolean; - /** - * Test if this position is before other position. If the two positions are equal, the result will be true. - */ - isBeforeOrEqual(other:IPosition): boolean; - /** - * Clone this position. - */ - clone(): IEditorPosition; -} - /** * A range in the editor. This interface is suitable for serialization. */ @@ -111,7 +90,7 @@ export interface IEditorRange extends IRange { /** * Return the end position (which will be after or equal to the start position) */ - getEndPosition(): IEditorPosition; + getEndPosition(): Position; /** * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position. */ @@ -119,7 +98,7 @@ export interface IEditorRange extends IRange { /** * Return the start position (which will be before or equal to the end position) */ - getStartPosition(): IEditorPosition; + getStartPosition(): Position; /** * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position. */ @@ -1480,6 +1459,11 @@ export interface ITextModel { */ setValue(newValue:string): void; + /** + * Replace the entire text buffer value contained in this model. + */ + setValueFromRawText(newValue:IRawText): void; + /** * Get the text stored in this model. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`. @@ -1565,7 +1549,7 @@ export interface ITextModel { /** * Create a valid position, */ - validatePosition(position:IPosition): IEditorPosition; + validatePosition(position:IPosition): Position; /** * Advances the given position by the given offest (negative offsets are also accepted) @@ -1577,7 +1561,7 @@ export interface ITextModel { * If the ofsset is such that the new position would be in the middle of a multi-byte * line terminator, throws an exception. */ - modifyPosition(position: IPosition, offset: number): IEditorPosition; + modifyPosition(position: IPosition, offset: number): Position; /** * Create a valid range. @@ -1666,17 +1650,6 @@ export interface ITokenizedModel extends ITextModel { /*package*/_getLineModeTransitions(lineNumber:number): IModeTransition[]; - /** - * Replace the entire text buffer value contained in this model. - * Optionally, the language mode of the model can be changed. - * This call clears all of the undo / redo stack, - * removes all decorations or tracked ranges, emits a - * ModelContentChanged(ModelContentChangedFlush) event and - * unbinds the mirror model from the previous mode to the new - * one if the mode has changed. - */ - setValue(newValue:string, newMode?:IMode): void; - /** * Get the current language mode associated with the model. */ @@ -1685,8 +1658,8 @@ export interface ITokenizedModel extends ITextModel { /** * Set the current language mode associated with the model. */ - setMode(newMode:IMode): void; - setMode(newModePromise:TPromise): void; + setMode(newMode:IMode|TPromise): void; + /** * A mode can be currently pending loading if a promise is used when constructing a model or calling setMode(). * @@ -1761,7 +1734,7 @@ export interface ITextModelWithMarkers extends ITextModel { /*package*/_addMarker(lineNumber:number, column:number, stickToPreviousCharacter:boolean): string; /*package*/_changeMarker(id:string, newLineNumber:number, newColumn:number): void; /*package*/_changeMarkerStickiness(id:string, newStickToPreviousCharacter:boolean): void; - /*package*/_getMarker(id:string): IEditorPosition; + /*package*/_getMarker(id:string): Position; /*package*/_removeMarker(id:string): void; /*package*/_getLineMarkers(lineNumber: number): IReadOnlyLineMarker[]; } @@ -2033,21 +2006,6 @@ export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWi */ findPreviousMatch(searchString:string, searchStart:IPosition, isRegex:boolean, matchCase:boolean, wholeWord:boolean): IEditorRange; - /** - * Replace the entire text buffer value contained in this model. - * Optionally, the language mode of the model can be changed. - * This call clears all of the undo / redo stack, - * removes all decorations or tracked ranges, emits a - * ModelContentChanged(ModelContentChangedFlush) event and - * unbinds the mirror model from the previous mode to the new - * one if the mode has changed. - */ - setValue(newValue:string, newMode?:IMode): void; - setValue(newValue:string, newModePromise:TPromise): void; - - setValueFromRawText(newValue:IRawText, newMode?:IMode): void; - setValueFromRawText(newValue:IRawText, newModePromise:TPromise): void; - onBeforeAttached(): void; onBeforeDetached(): void; @@ -2267,19 +2225,19 @@ export interface ICursorPositionChangedEvent { /** * Primary cursor's position. */ - position:IEditorPosition; + position:Position; /** * Primary cursor's view position */ - viewPosition:IEditorPosition; + viewPosition:Position; /** * Secondary cursors' position. */ - secondaryPositions:IEditorPosition[]; + secondaryPositions:Position[]; /** * Secondary cursors' view position. */ - secondaryViewPositions:IEditorPosition[]; + secondaryViewPositions:Position[]; /** * Reason. */ @@ -2921,11 +2879,11 @@ export interface IViewCursorPositionChangedEvent { /** * Primary cursor's position. */ - position: IEditorPosition; + position: Position; /** * Secondary cursors' position. */ - secondaryPositions: IEditorPosition[]; + secondaryPositions: Position[]; /** * Is the primary cursor in the editable range? */ @@ -3135,7 +3093,7 @@ export interface IEditor { /** * Returns the primary position of the cursor. */ - getPosition(): IEditorPosition; + getPosition(): Position; /** * Set the primary position of the cursor. This will remove any secondary cursors. diff --git a/src/vs/editor/common/editorCommonExtensions.ts b/src/vs/editor/common/editorCommonExtensions.ts index df24d32b930..936286c53ed 100644 --- a/src/vs/editor/common/editorCommonExtensions.ts +++ b/src/vs/editor/common/editorCommonExtensions.ts @@ -102,7 +102,7 @@ export module CommonEditorRegistry { }); } - export function registerDefaultLanguageCommand(id: string, handler: (model: editorCommon.IModel, position: editorCommon.IEditorPosition, args: { [n: string]: any }) => any) { + export function registerDefaultLanguageCommand(id: string, handler: (model: editorCommon.IModel, position: Position, args: { [n: string]: any }) => any) { registerLanguageCommand(id, function(accessor, args) { const {resource, position} = args; diff --git a/src/vs/editor/common/model/mirrorModel.ts b/src/vs/editor/common/model/mirrorModel.ts index f6f9bd159bf..ab948ce29b2 100644 --- a/src/vs/editor/common/model/mirrorModel.ts +++ b/src/vs/editor/common/model/mirrorModel.ts @@ -289,9 +289,7 @@ export class MirrorModel extends AbstractMirrorModel implements editorCommon.IMi this._embeddedModels = {}; } - public setMode(newMode:IMode): void; - public setMode(newModePromise:TPromise): void; - public setMode(newModeOrPromise:any): void { + public setMode(newModeOrPromise:IMode|TPromise): void { super.setMode(newModeOrPromise); this._updateEmbeddedModels(); } diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index bd00f644e6a..2a8f3b76371 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -265,16 +265,18 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo } public setValue(value:string): void { - let rawText: editorCommon.IRawText = null; - if (value !== null) { - rawText = TextModel.toRawText(value, { - tabSize: this._options.tabSize, - insertSpaces: this._options.insertSpaces, - trimAutoWhitespace: this._options.trimAutoWhitespace, - detectIndentation: false, - defaultEOL: this._options.defaultEOL - }); + if (value === null) { + // There's nothing to do + return; } + let rawText: editorCommon.IRawText = null; + rawText = TextModel.toRawText(value, { + tabSize: this._options.tabSize, + insertSpaces: this._options.insertSpaces, + trimAutoWhitespace: this._options.trimAutoWhitespace, + detectIndentation: false, + defaultEOL: this._options.defaultEOL + }); this.setValueFromRawText(rawText); } @@ -512,7 +514,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo return lineNumber; } - public validatePosition(position:editorCommon.IPosition): editorCommon.IEditorPosition { + public validatePosition(position:editorCommon.IPosition): Position { var lineNumber = position.lineNumber ? position.lineNumber : 1; var column = position.column ? position.column : 1; @@ -543,7 +545,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo return new Range(start.lineNumber, start.column, end.lineNumber, end.column); } - public modifyPosition(rawPosition: editorCommon.IPosition, offset: number) : editorCommon.IEditorPosition { + public modifyPosition(rawPosition: editorCommon.IPosition, offset: number) : Position { var position = this.validatePosition(rawPosition); // Handle positive offsets, one line at a time diff --git a/src/vs/editor/common/model/textModelWithMarkers.ts b/src/vs/editor/common/model/textModelWithMarkers.ts index 66b61109bc8..e0986e15ddb 100644 --- a/src/vs/editor/common/model/textModelWithMarkers.ts +++ b/src/vs/editor/common/model/textModelWithMarkers.ts @@ -7,7 +7,7 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {IdGenerator} from 'vs/base/common/idGenerator'; import {Position} from 'vs/editor/common/core/position'; -import {IEditorPosition, IModelContentChangedFlushEvent, IRawText, IReadOnlyLineMarker, ITextModelWithMarkers} from 'vs/editor/common/editorCommon'; +import {IModelContentChangedFlushEvent, IRawText, IReadOnlyLineMarker, ITextModelWithMarkers} from 'vs/editor/common/editorCommon'; import {ILineMarker, ModelLine} from 'vs/editor/common/model/modelLine'; import {TextModelWithTokens} from 'vs/editor/common/model/textModelWithTokens'; import {IMode} from 'vs/editor/common/modes'; @@ -135,7 +135,7 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo } } - _getMarker(id:string): IEditorPosition { + _getMarker(id:string): Position { if (this._markerIdToMarker.hasOwnProperty(id)) { var marker = this._markerIdToMarker[id]; return new Position(marker.line.lineNumber, marker.column); diff --git a/src/vs/editor/common/model/textModelWithTokens.ts b/src/vs/editor/common/model/textModelWithTokens.ts index e48340564b8..cfd671dc15d 100644 --- a/src/vs/editor/common/model/textModelWithTokens.ts +++ b/src/vs/editor/common/model/textModelWithTokens.ts @@ -24,6 +24,7 @@ import {BracketsUtils} from 'vs/editor/common/modes/supports/richEditBrackets'; import {ModeTransition} from 'vs/editor/common/core/modeTransition'; import {LineToken} from 'vs/editor/common/model/lineToken'; import {TokensInflatorMap} from 'vs/editor/common/model/tokensBinaryEncoding'; +import {Position} from 'vs/editor/common/core/position'; class ModeToModelBinder implements IDisposable { @@ -411,62 +412,32 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke return this._lines[lineNumber - 1].getTokens(); } - public setValue(value:string, newMode?:IMode): void; - public setValue(value:string, newModePromise?:TPromise): void; - public setValue(value:string, newModeOrPromise:any=null): void { - let rawText: editorCommon.IRawText = null; - if (value !== null) { - rawText = TextModel.toRawText(value, { - tabSize: this._options.tabSize, - insertSpaces: this._options.insertSpaces, - detectIndentation: false, - defaultEOL: this._options.defaultEOL, - trimAutoWhitespace: this._options.trimAutoWhitespace - }); - } - this.setValueFromRawText(rawText, newModeOrPromise); - } - - public setValueFromRawText(value:editorCommon.IRawText, newMode?:IMode): void; - public setValueFromRawText(value:editorCommon.IRawText, newModePromise?:TPromise): void; - public setValueFromRawText(value:editorCommon.IRawText, newModeOrPromise:any=null): void { - if (value !== null) { - super.setValueFromRawText(value); - } - - if (newModeOrPromise) { - if (this._modeToModelBinder) { - this._modeToModelBinder.dispose(); - this._modeToModelBinder = null; - } - if (TPromise.is(newModeOrPromise)) { - this._modeToModelBinder = new ModeToModelBinder(>newModeOrPromise, this); - } else { - var actualNewMode = this._massageMode(newModeOrPromise); - if (this._mode !== actualNewMode) { - var e2:editorCommon.IModelModeChangedEvent = { - oldMode: this._mode, - newMode: actualNewMode - }; - this._resetMode(e2, actualNewMode); - this._emitModelModeChangedEvent(e2); - } - } - } - } - public getMode(): IMode { return this._mode; } - public setMode(newMode:IMode): void; - public setMode(newModePromise:TPromise): void; - public setMode(newModeOrPromise:any): void { + public setMode(newModeOrPromise:IMode|TPromise): void { if (!newModeOrPromise) { // There's nothing to do return; } - this.setValueFromRawText(null, newModeOrPromise); + if (this._modeToModelBinder) { + this._modeToModelBinder.dispose(); + this._modeToModelBinder = null; + } + if (TPromise.is(newModeOrPromise)) { + this._modeToModelBinder = new ModeToModelBinder(>newModeOrPromise, this); + } else { + var actualNewMode = this._massageMode(newModeOrPromise); + if (this._mode !== actualNewMode) { + var e2:editorCommon.IModelModeChangedEvent = { + oldMode: this._mode, + newMode: actualNewMode + }; + this._resetMode(e2, actualNewMode); + this._emitModelModeChangedEvent(e2); + } + } } public getModeAtPosition(_lineNumber:number, _column:number): IMode { @@ -809,7 +780,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke return this._matchBracket(this.validatePosition(position)); } - private _matchBracket(position:editorCommon.IEditorPosition): [editorCommon.IEditorRange,editorCommon.IEditorRange] { + private _matchBracket(position:Position): [editorCommon.IEditorRange,editorCommon.IEditorRange] { let lineNumber = position.lineNumber; let lineText = this._lines[lineNumber - 1].text; @@ -913,7 +884,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke return null; } - private _findMatchingBracketUp(bracket:editorCommon.IRichEditBracket, position:editorCommon.IEditorPosition): Range { + private _findMatchingBracketUp(bracket:editorCommon.IRichEditBracket, position:Position): Range { // console.log('_findMatchingBracketUp: ', 'bracket: ', JSON.stringify(bracket), 'startPosition: ', String(position)); let modeId = bracket.modeId; @@ -980,7 +951,7 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke return null; } - private _findMatchingBracketDown(bracket:editorCommon.IRichEditBracket, position:editorCommon.IEditorPosition): Range { + private _findMatchingBracketDown(bracket:editorCommon.IRichEditBracket, position:Position): Range { // console.log('_findMatchingBracketDown: ', 'bracket: ', JSON.stringify(bracket), 'startPosition: ', String(position)); let modeId = bracket.modeId; diff --git a/src/vs/editor/common/model/textModelWithTrackedRanges.ts b/src/vs/editor/common/model/textModelWithTrackedRanges.ts index 21ccd3b9154..0a6d8026349 100644 --- a/src/vs/editor/common/model/textModelWithTrackedRanges.ts +++ b/src/vs/editor/common/model/textModelWithTrackedRanges.ts @@ -12,6 +12,7 @@ import {ILineMarker} from 'vs/editor/common/model/modelLine'; import {INewMarker, TextModelWithMarkers} from 'vs/editor/common/model/textModelWithMarkers'; import {FullModelRetokenizer, IRetokenizeRequest} from 'vs/editor/common/model/textModelWithTokens'; import {IMode} from 'vs/editor/common/modes'; +import {Position} from 'vs/editor/common/core/position'; interface ITrackedRange { id:string; @@ -256,7 +257,7 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements } } - private _newEditorRange(startPosition: editorCommon.IEditorPosition, endPosition: editorCommon.IEditorPosition): editorCommon.IEditorRange { + private _newEditorRange(startPosition: Position, endPosition: Position): editorCommon.IEditorRange { if (endPosition.isBefore(startPosition)) { // This tracked range has turned in on itself (end marker before start marker) // This can happen in extreme editing conditions where lots of text is removed and lots is added @@ -314,8 +315,8 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements i: number, len: number, lineNumber: number, - startMarker: editorCommon.IEditorPosition, - endMarker: editorCommon.IEditorPosition; + startMarker: Position, + endMarker: Position; for (i = 0, len = result.length; i < len; i++) { resultMap[result[i].id] = true; diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index d4ed5b57554..690c7d494c1 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -13,6 +13,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import {ModeTransition} from 'vs/editor/common/core/modeTransition'; import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegistry'; import {CancellationToken} from 'vs/base/common/cancellation'; +import {Position} from 'vs/editor/common/core/position'; export interface ITokenizationResult { type?:string; @@ -291,7 +292,7 @@ export interface Hover { } export interface HoverProvider { - provideHover(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): Hover | Thenable; + provideHover(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): Hover | Thenable; } export type SuggestionType = 'method' @@ -341,9 +342,9 @@ export interface ISuggestSupport { filter?: IFilter; - provideCompletionItems(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): ISuggestResult[] | Thenable; + provideCompletionItems(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): ISuggestResult[] | Thenable; - resolveCompletionItem?(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, item: ISuggestion, token: CancellationToken): ISuggestion | Thenable; + resolveCompletionItem?(model:editorCommon.IReadOnlyModel, position:Position, item: ISuggestion, token: CancellationToken): ISuggestion | Thenable; } /** @@ -376,7 +377,7 @@ export interface SignatureHelpProvider { signatureHelpTriggerCharacters: string[]; - provideSignatureHelp(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, token: CancellationToken): SignatureHelp | Thenable; + provideSignatureHelp(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): SignatureHelp | Thenable; } @@ -390,7 +391,7 @@ export interface DocumentHighlight { kind: DocumentHighlightKind; } export interface DocumentHighlightProvider { - provideDocumentHighlights(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, token: CancellationToken): DocumentHighlight[] | Thenable; + provideDocumentHighlights(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): DocumentHighlight[] | Thenable; } @@ -398,7 +399,7 @@ export interface ReferenceContext { includeDeclaration: boolean; } export interface ReferenceProvider { - provideReferences(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; + provideReferences(model:editorCommon.IReadOnlyModel, position:Position, context: ReferenceContext, token: CancellationToken): Location[] | Thenable; } @@ -408,7 +409,7 @@ export class Location { } export type Definition = Location | Location[]; export interface DefinitionProvider { - provideDefinition(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): Definition | Thenable; + provideDefinition(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): Definition | Thenable; } export enum SymbolKind { @@ -551,7 +552,7 @@ export interface DocumentRangeFormattingEditProvider { } export interface OnTypeFormattingEditProvider { autoFormatTriggerCharacters: string[]; - provideOnTypeFormattingEdits(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, ch: string, options: IFormattingOptions, token: CancellationToken): editorCommon.ISingleEditOperation[] | Thenable; + provideOnTypeFormattingEdits(model: editorCommon.IReadOnlyModel, position: Position, ch: string, options: IFormattingOptions, token: CancellationToken): editorCommon.ISingleEditOperation[] | Thenable; } @@ -607,7 +608,7 @@ export interface WorkspaceEdit { rejectReason?: string; } export interface RenameProvider { - provideRenameEdits(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; + provideRenameEdits(model:editorCommon.IReadOnlyModel, position:Position, newName: string, token: CancellationToken): WorkspaceEdit | Thenable; } diff --git a/src/vs/editor/common/modes/supports/suggestSupport.ts b/src/vs/editor/common/modes/supports/suggestSupport.ts index e5426a82151..9bf09c0a2cd 100644 --- a/src/vs/editor/common/modes/supports/suggestSupport.ts +++ b/src/vs/editor/common/modes/supports/suggestSupport.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {ISuggestResult, ISuggestSupport} from 'vs/editor/common/modes'; import {IFilter, matchesStrictPrefix, fuzzyContiguousFilter} from 'vs/base/common/filters'; import {IEditorWorkerService} from 'vs/editor/common/services/editorWorkerService'; @@ -14,6 +14,7 @@ import {Registry} from 'vs/platform/platform'; import {localize} from 'vs/nls'; import {CancellationToken} from 'vs/base/common/cancellation'; import {wireCancellationToken} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; export class TextualSuggestSupport implements ISuggestSupport { @@ -52,7 +53,7 @@ export class TextualSuggestSupport implements ISuggestSupport { this._configurationService = configurationService; } - public provideCompletionItems(model:IReadOnlyModel, position:IEditorPosition, token:CancellationToken): ISuggestResult[] | Thenable { + public provideCompletionItems(model:IReadOnlyModel, position:Position, token:CancellationToken): ISuggestResult[] | Thenable { let config = this._configurationService.getConfiguration<{ wordBasedSuggestions: boolean }>('editor'); if (!config || config.wordBasedSuggestions) { return wireCancellationToken(token, this._editorWorkerService.textualSuggest(model.uri, position)); diff --git a/src/vs/editor/common/viewModel/splitLinesCollection.ts b/src/vs/editor/common/viewModel/splitLinesCollection.ts index 6630b0c2ac3..a8afece8c14 100644 --- a/src/vs/editor/common/viewModel/splitLinesCollection.ts +++ b/src/vs/editor/common/viewModel/splitLinesCollection.ts @@ -50,7 +50,7 @@ export interface ISplitLine { getOutputLineMaxColumn(model: IModel, myLineNumber: number, outputLineIndex: number): number; getOutputLineTokens(model: IModel, myLineNumber: number, outputLineIndex: number): ViewLineTokens; getInputColumnOfOutputPosition(outputLineIndex: number, outputColumn: number): number; - getOutputPositionOfInputPosition(deltaLineNumber: number, inputColumn: number): editorCommon.IEditorPosition; + getOutputPositionOfInputPosition(deltaLineNumber: number, inputColumn: number): Position; } class IdentitySplitLine implements ISplitLine { @@ -111,7 +111,7 @@ class IdentitySplitLine implements ISplitLine { return outputColumn; } - public getOutputPositionOfInputPosition(deltaLineNumber:number, inputColumn:number): editorCommon.IEditorPosition { + public getOutputPositionOfInputPosition(deltaLineNumber:number, inputColumn:number): Position { if (!this._isVisible) { throw new Error('Not supported'); } @@ -223,7 +223,7 @@ export class SplitLine implements ISplitLine { return this.positionMapper.getInputOffsetOfOutputPosition(outputLineIndex, adjustedColumn) + 1; } - public getOutputPositionOfInputPosition(deltaLineNumber:number, inputColumn:number): editorCommon.IEditorPosition { + public getOutputPositionOfInputPosition(deltaLineNumber:number, inputColumn:number): Position { if (!this._isVisible) { throw new Error('Not supported'); } @@ -663,7 +663,7 @@ export class SplitLinesCollection implements ILinesCollection { return this.lines[lineIndex].getOutputLineTokens(this.model, lineIndex + 1, remainder); } - public convertOutputPositionToInputPosition(viewLineNumber: number, viewColumn: number): editorCommon.IEditorPosition { + public convertOutputPositionToInputPosition(viewLineNumber: number, viewColumn: number): Position { this._ensureValidState(); viewLineNumber = this._toValidOutputLineNumber(viewLineNumber); @@ -676,7 +676,7 @@ export class SplitLinesCollection implements ILinesCollection { return this.model.validatePosition(new Position(lineIndex+1, inputColumn)); } - public convertInputPositionToOutputPosition(_inputLineNumber: number, _inputColumn: number): editorCommon.IEditorPosition { + public convertInputPositionToOutputPosition(_inputLineNumber: number, _inputColumn: number): Position { this._ensureValidState(); let validPosition = this.model.validatePosition(new Position(_inputLineNumber, _inputColumn)); @@ -695,7 +695,7 @@ export class SplitLinesCollection implements ILinesCollection { } let deltaLineNumber = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1)); - let r:editorCommon.IEditorPosition; + let r:Position; if (lineIndexChanged) { r = this.lines[lineIndex].getOutputPositionOfInputPosition(deltaLineNumber, this.model.getLineMaxColumn(lineIndex + 1)); } else { diff --git a/src/vs/editor/common/viewModel/viewModel.ts b/src/vs/editor/common/viewModel/viewModel.ts index 1ce3f1b4f52..96da8bf6245 100644 --- a/src/vs/editor/common/viewModel/viewModel.ts +++ b/src/vs/editor/common/viewModel/viewModel.ts @@ -5,8 +5,9 @@ 'use strict'; import {IEventEmitter} from 'vs/base/common/eventEmitter'; -import {IModelDecoration, IRange, IEditorRange, EndOfLinePreference, IEditorSelection, IPosition, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IModelDecoration, IRange, IEditorRange, EndOfLinePreference, IEditorSelection, IPosition} from 'vs/editor/common/editorCommon'; import {ViewLineTokens} from 'vs/editor/common/core/viewLineToken'; +import {Position} from 'vs/editor/common/core/position'; export interface IDecorationsViewportData { decorations: IModelDecoration[]; @@ -32,13 +33,13 @@ export interface IViewModel extends IEventEmitter { getSelections(): IEditorSelection[]; - convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): IEditorPosition; + convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): Position; convertViewRangeToModelRange(viewRange:IRange): IEditorRange; getModelLineContent(lineNumber:number): string; getModelLineMaxColumn(modelLineNumber:number): number; - validateModelPosition(position:IPosition): IEditorPosition; - convertModelPositionToViewPosition(modelLineNumber:number, modelColumn:number): IEditorPosition; + validateModelPosition(position:IPosition): Position; + convertModelPositionToViewPosition(modelLineNumber:number, modelColumn:number): Position; convertModelSelectionToViewSelection(modelSelection:IEditorSelection): IEditorSelection; modelPositionIsVisible(position:IPosition): boolean; } diff --git a/src/vs/editor/common/viewModel/viewModelCursors.ts b/src/vs/editor/common/viewModel/viewModelCursors.ts index c618a666827..8475bb24250 100644 --- a/src/vs/editor/common/viewModel/viewModelCursors.ts +++ b/src/vs/editor/common/viewModel/viewModelCursors.ts @@ -7,9 +7,10 @@ import {Range} from 'vs/editor/common/core/range'; import {Selection} from 'vs/editor/common/core/selection'; import * as editorCommon from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export interface IConverter { - validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition; + validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:Position): Position; validateViewSelection(viewSelection:editorCommon.IEditorSelection, modelSelection:editorCommon.IEditorSelection): editorCommon.IEditorSelection; convertModelSelectionToViewSelection(modelSelection:editorCommon.IEditorSelection): editorCommon.IEditorSelection; convertModelRangeToViewRange(modelRange:editorCommon.IRange): editorCommon.IEditorRange; @@ -54,7 +55,7 @@ export class ViewModelCursors { position = position.clone(); position.column = stopRenderingLineAfter; } - var secondaryPositions: editorCommon.IEditorPosition[] = []; + var secondaryPositions: Position[] = []; for (var i = 0, len = e.secondaryPositions.length; i < len; i++) { secondaryPositions[i] = this.converter.validateViewPosition(e.secondaryViewPositions[i].lineNumber, e.secondaryViewPositions[i].column, e.secondaryPositions[i]); // Limit position to be somewhere where it can actually be rendered diff --git a/src/vs/editor/common/viewModel/viewModelImpl.ts b/src/vs/editor/common/viewModel/viewModelImpl.ts index 30d6b1baf48..cbab7a9a5df 100644 --- a/src/vs/editor/common/viewModel/viewModelImpl.ts +++ b/src/vs/editor/common/viewModel/viewModelImpl.ts @@ -30,8 +30,8 @@ export interface ILinesCollection { getOutputLineMinColumn(outputLineNumber:number): number; getOutputLineMaxColumn(outputLineNumber:number): number; getOutputLineTokens(outputLineNumber:number): ViewLineTokens; - convertOutputPositionToInputPosition(viewLineNumber:number, viewColumn:number): editorCommon.IEditorPosition; - convertInputPositionToOutputPosition(inputLineNumber:number, inputColumn:number): editorCommon.IEditorPosition; + convertOutputPositionToInputPosition(viewLineNumber:number, viewColumn:number): Position; + convertInputPositionToOutputPosition(inputLineNumber:number, inputColumn:number): Position; setHiddenAreas(ranges:editorCommon.IRange[], emit:(evenType:string, payload:any)=>void): void; inputPositionIsVisible(inputLineNumber:number, inputColumn:number): boolean; dispose(): void; @@ -322,7 +322,7 @@ export class ViewModel extends EventEmitter implements IViewModel { return new Range(validViewStart.lineNumber, validViewStart.column, validViewEnd.lineNumber, validViewEnd.column); } - public validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:editorCommon.IEditorPosition): editorCommon.IEditorPosition { + public validateViewPosition(viewLineNumber:number, viewColumn:number, modelPosition:Position): Position { if (viewLineNumber < 1) { viewLineNumber = 1; } @@ -446,7 +446,7 @@ export class ViewModel extends EventEmitter implements IViewModel { // View -> Model conversion and related methods - public convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): editorCommon.IEditorPosition { + public convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): Position { return this.lines.convertOutputPositionToInputPosition(viewLineNumber, viewColumn); } @@ -472,11 +472,11 @@ export class ViewModel extends EventEmitter implements IViewModel { return this.model.getLineMaxColumn(modelLineNumber); } - public validateModelPosition(position:editorCommon.IPosition): editorCommon.IEditorPosition { + public validateModelPosition(position:editorCommon.IPosition): Position { return this.model.validatePosition(position); } - public convertModelPositionToViewPosition(modelLineNumber:number, modelColumn:number): editorCommon.IEditorPosition { + public convertModelPositionToViewPosition(modelLineNumber:number, modelColumn:number): Position { return this.lines.convertInputPositionToOutputPosition(modelLineNumber, modelColumn); } diff --git a/src/vs/editor/contrib/find/common/findDecorations.ts b/src/vs/editor/contrib/find/common/findDecorations.ts index 9a238950833..050a15ad297 100644 --- a/src/vs/editor/contrib/find/common/findDecorations.ts +++ b/src/vs/editor/contrib/find/common/findDecorations.ts @@ -6,6 +6,7 @@ import {IDisposable} from 'vs/base/common/lifecycle'; import * as editorCommon from 'vs/editor/common/editorCommon'; +import {Position} from 'vs/editor/common/core/position'; export class FindDecorations implements IDisposable { @@ -13,7 +14,7 @@ export class FindDecorations implements IDisposable { private _decorations:string[]; private _findScopeDecorationId:string; private _highlightedDecorationId:string; - private _startPosition:editorCommon.IEditorPosition; + private _startPosition:Position; constructor(editor:editorCommon.ICommonCodeEditor) { this._editor = editor; @@ -50,11 +51,11 @@ export class FindDecorations implements IDisposable { return null; } - public getStartPosition(): editorCommon.IEditorPosition { + public getStartPosition(): Position { return this._startPosition; } - public setStartPosition(newStartPosition:editorCommon.IEditorPosition): void { + public setStartPosition(newStartPosition:Position): void { this._startPosition = newStartPosition; this.setCurrentFindMatch(null); } diff --git a/src/vs/editor/contrib/find/common/findModel.ts b/src/vs/editor/contrib/find/common/findModel.ts index 316981d22ea..1f0f14a8018 100644 --- a/src/vs/editor/contrib/find/common/findModel.ts +++ b/src/vs/editor/contrib/find/common/findModel.ts @@ -153,7 +153,7 @@ export class FindModelBoundToEditorModel { return false; } - private _moveToPrevMatch(before:editorCommon.IEditorPosition, isRecursed:boolean = false): void { + private _moveToPrevMatch(before:Position, isRecursed:boolean = false): void { if (this._cannotFind()) { return; } @@ -220,7 +220,7 @@ export class FindModelBoundToEditorModel { this._moveToPrevMatch(this._editor.getSelection().getStartPosition()); } - public _moveToNextMatch(after:editorCommon.IEditorPosition, isRecursed:boolean = false): void { + public _moveToNextMatch(after:Position, isRecursed:boolean = false): void { if (this._cannotFind()) { return; } diff --git a/src/vs/editor/contrib/format/common/format.ts b/src/vs/editor/contrib/format/common/format.ts index ef2054662ce..b0ea11924f4 100644 --- a/src/vs/editor/contrib/format/common/format.ts +++ b/src/vs/editor/contrib/format/common/format.ts @@ -9,11 +9,12 @@ import {illegalArgument} from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; import {Range} from 'vs/editor/common/core/range'; -import {IReadOnlyModel, IEditorPosition, IEditorRange, ISingleEditOperation} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel, IEditorRange, ISingleEditOperation} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {DocumentFormattingEditProviderRegistry, DocumentRangeFormattingEditProviderRegistry, OnTypeFormattingEditProviderRegistry, IFormattingOptions} from 'vs/editor/common/modes'; import {IModelService} from 'vs/editor/common/services/modelService'; import {asWinJsPromise} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; export function getDocumentRangeFormattingEdits(model: IReadOnlyModel, range: IEditorRange, options: IFormattingOptions): TPromise { const [support] = DocumentRangeFormattingEditProviderRegistry.ordered(model); @@ -38,7 +39,7 @@ export function getDocumentFormattingEdits(model: IReadOnlyModel, options: IForm }); } -export function getOnTypeFormattingEdits(model: IReadOnlyModel, position: IEditorPosition, ch: string, options: IFormattingOptions): TPromise { +export function getOnTypeFormattingEdits(model: IReadOnlyModel, position: Position, ch: string, options: IFormattingOptions): TPromise { const [support] = OnTypeFormattingEditProviderRegistry.ordered(model); if (!support) { return TPromise.as(undefined); diff --git a/src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts index 66eb496c950..a4643576f5e 100644 --- a/src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts +++ b/src/vs/editor/contrib/goToDeclaration/common/goToDeclaration.ts @@ -7,13 +7,14 @@ import {onUnexpectedError} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {DefinitionProviderRegistry} from 'vs/editor/common/modes'; import {Location} from 'vs/editor/common/modes'; import {asWinJsPromise} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; -export function getDeclarationsAtPosition(model: IReadOnlyModel, position: IEditorPosition): TPromise { +export function getDeclarationsAtPosition(model: IReadOnlyModel, position: Position): TPromise { const provider = DefinitionProviderRegistry.ordered(model); diff --git a/src/vs/editor/contrib/hover/browser/hoverWidgets.ts b/src/vs/editor/contrib/hover/browser/hoverWidgets.ts index 92d2d94124b..75437948eef 100644 --- a/src/vs/editor/contrib/hover/browser/hoverWidgets.ts +++ b/src/vs/editor/contrib/hover/browser/hoverWidgets.ts @@ -8,7 +8,7 @@ import {CommonKeybindings} from 'vs/base/common/keyCodes'; import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {StyleMutator} from 'vs/base/browser/styleMutator'; import {Position} from 'vs/editor/common/core/position'; -import {IEditorPosition, IPosition, IConfigurationChangedEvent} from 'vs/editor/common/editorCommon'; +import {IPosition, IConfigurationChangedEvent} from 'vs/editor/common/editorCommon'; import * as editorBrowser from 'vs/editor/browser/editorBrowser'; import {Widget} from 'vs/base/browser/ui/widget'; @@ -19,7 +19,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent protected _isVisible: boolean; private _containerDomNode: HTMLElement; protected _domNode: HTMLElement; - protected _showAtPosition: IEditorPosition; + protected _showAtPosition: Position; private _stoleFocus: boolean; // Editor.IContentWidget.allowEditorOverflow diff --git a/src/vs/editor/contrib/hover/common/hover.ts b/src/vs/editor/contrib/hover/common/hover.ts index 51766df859a..33b2b77395f 100644 --- a/src/vs/editor/contrib/hover/common/hover.ts +++ b/src/vs/editor/contrib/hover/common/hover.ts @@ -8,12 +8,13 @@ import {coalesce} from 'vs/base/common/arrays'; import {onUnexpectedError} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; 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: IEditorPosition): TPromise { +export function getHover(model: IReadOnlyModel, position: Position): TPromise { const supports = HoverProviderRegistry.ordered(model); const values: Hover[] = []; diff --git a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts index da7a22a1fdb..911e86d6b48 100644 --- a/src/vs/editor/contrib/parameterHints/common/parameterHints.ts +++ b/src/vs/editor/contrib/parameterHints/common/parameterHints.ts @@ -6,12 +6,13 @@ 'use strict'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {SignatureHelp, SignatureHelpProviderRegistry} from 'vs/editor/common/modes'; import {asWinJsPromise} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; -export function provideSignatureHelp(model:IReadOnlyModel, position:IEditorPosition): TPromise { +export function provideSignatureHelp(model:IReadOnlyModel, position:Position): TPromise { let support = SignatureHelpProviderRegistry.ordered(model)[0]; if (!support) { diff --git a/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts index daede675a8e..9847a825266 100644 --- a/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/common/referenceSearch.ts @@ -7,12 +7,13 @@ import {onUnexpectedError} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {Location, ReferenceProviderRegistry} from 'vs/editor/common/modes'; import {asWinJsPromise} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; -export function provideReferences(model: IReadOnlyModel, position: IEditorPosition): TPromise { +export function provideReferences(model: IReadOnlyModel, position: Position): TPromise { // collect references from all providers const promises = ReferenceProviderRegistry.ordered(model).map(provider => { diff --git a/src/vs/editor/contrib/rename/common/rename.ts b/src/vs/editor/contrib/rename/common/rename.ts index 013cbc7d6d7..deedc8f6317 100644 --- a/src/vs/editor/contrib/rename/common/rename.ts +++ b/src/vs/editor/contrib/rename/common/rename.ts @@ -9,11 +9,12 @@ import {localize} from 'vs/nls'; import {sequence, asWinJsPromise} from 'vs/base/common/async'; import {illegalArgument} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {WorkspaceEdit, RenameProviderRegistry} from 'vs/editor/common/modes'; +import {Position} from 'vs/editor/common/core/position'; -export function rename(model: IReadOnlyModel, position: IEditorPosition, newName: string): TPromise { +export function rename(model: IReadOnlyModel, position: Position, newName: string): TPromise { const supports = RenameProviderRegistry.ordered(model); const rejects: string[] = []; diff --git a/src/vs/editor/contrib/suggest/browser/completionModel.ts b/src/vs/editor/contrib/suggest/browser/completionModel.ts index dbb97948a0a..809e9a24bf6 100644 --- a/src/vs/editor/contrib/suggest/browser/completionModel.ts +++ b/src/vs/editor/contrib/suggest/browser/completionModel.ts @@ -8,11 +8,12 @@ import {isFalsyOrEmpty} from 'vs/base/common/arrays'; import {assign} from 'vs/base/common/objects'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {IFilter, IMatch, fuzzyContiguousFilter} from 'vs/base/common/filters'; import {ISuggestResult, ISuggestSupport, ISuggestion} from 'vs/editor/common/modes'; import {ISuggestResult2} from '../common/suggest'; import {asWinJsPromise} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; export class CompletionItem { @@ -30,7 +31,7 @@ export class CompletionItem { this.filter = container.support && container.support.filter || fuzzyContiguousFilter; } - resolveDetails(model:IReadOnlyModel, position:IEditorPosition): TPromise { + resolveDetails(model:IReadOnlyModel, position:Position): TPromise { if (!this._support || typeof this._support.resolveCompletionItem !== 'function') { return TPromise.as(this.suggestion); } diff --git a/src/vs/editor/contrib/suggest/browser/suggestModel.ts b/src/vs/editor/contrib/suggest/browser/suggestModel.ts index d2d6db4b696..73a8221b2ef 100644 --- a/src/vs/editor/contrib/suggest/browser/suggestModel.ts +++ b/src/vs/editor/contrib/suggest/browser/suggestModel.ts @@ -9,7 +9,7 @@ import Event, { Emitter } from 'vs/base/common/event'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; import {startsWith} from 'vs/base/common/strings'; import {TPromise} from 'vs/base/common/winjs.base'; -import {ICommonCodeEditor, ICursorSelectionChangedEvent, IEditorPosition, CursorChangeReason} from 'vs/editor/common/editorCommon'; +import {ICommonCodeEditor, ICursorSelectionChangedEvent, CursorChangeReason} from 'vs/editor/common/editorCommon'; import {ISuggestSupport, ISuggestion, SuggestRegistry} from 'vs/editor/common/modes'; import {CodeSnippet} from 'vs/editor/contrib/snippet/common/snippet'; import {ISuggestResult2, provideCompletionItems} from '../common/suggest'; @@ -229,7 +229,7 @@ export class SuggestModel implements IDisposable { return actuallyCanceled; } - public getRequestPosition(): IEditorPosition { + public getRequestPosition(): Position { if (!this.context) { return null; } diff --git a/src/vs/editor/contrib/suggest/common/suggest.ts b/src/vs/editor/contrib/suggest/common/suggest.ts index 3e84f975bc7..c82e42fa920 100644 --- a/src/vs/editor/contrib/suggest/common/suggest.ts +++ b/src/vs/editor/contrib/suggest/common/suggest.ts @@ -8,10 +8,11 @@ import {sequence, asWinJsPromise} from 'vs/base/common/async'; import {isFalsyOrEmpty} from 'vs/base/common/arrays'; import {onUnexpectedError} from 'vs/base/common/errors'; import {TPromise} from 'vs/base/common/winjs.base'; -import {IReadOnlyModel, IEditorPosition} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel} from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {ISuggestResult, ISuggestSupport, SuggestRegistry} from 'vs/editor/common/modes'; import {SnippetsRegistry} from 'vs/editor/common/modes/supports'; +import {Position} from 'vs/editor/common/core/position'; export var CONTEXT_SUGGEST_WIDGET_VISIBLE = 'suggestWidgetVisible'; export var CONTEXT_SUGGESTION_SUPPORTS_ACCEPT_ON_KEY = 'suggestionSupportsAcceptOnKey'; @@ -21,7 +22,7 @@ export interface ISuggestResult2 extends ISuggestResult { support?: ISuggestSupport; } -export function provideCompletionItems(model: IReadOnlyModel, position: IEditorPosition, groups?: ISuggestSupport[][]): TPromise { +export function provideCompletionItems(model: IReadOnlyModel, position: Position, groups?: ISuggestSupport[][]): TPromise { if (!groups) { groups = SuggestRegistry.orderedGroups(model); diff --git a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts index e8fcca14489..c359b6d04d3 100644 --- a/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts +++ b/src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts @@ -12,8 +12,9 @@ import * as editorCommon from 'vs/editor/common/editorCommon'; import {CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; import {DocumentHighlight, DocumentHighlightKind, DocumentHighlightProviderRegistry} from 'vs/editor/common/modes'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; +import {Position} from 'vs/editor/common/core/position'; -export function getOccurrencesAtPosition(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition):TPromise { +export function getOccurrencesAtPosition(model: editorCommon.IReadOnlyModel, position: Position):TPromise { const orderedByScore = DocumentHighlightProviderRegistry.ordered(model); let foundResult = false; diff --git a/src/vs/editor/test/common/controller/textAreaState.test.ts b/src/vs/editor/test/common/controller/textAreaState.test.ts index 1afd11ba2a5..e196f14088d 100644 --- a/src/vs/editor/test/common/controller/textAreaState.test.ts +++ b/src/vs/editor/test/common/controller/textAreaState.test.ts @@ -8,7 +8,7 @@ import * as assert from 'assert'; import {IENarratorTextAreaState, ISimpleModel, TextAreaState} from 'vs/editor/common/controller/textAreaState'; import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; -import {EndOfLinePreference, IEditorPosition, IRange} from 'vs/editor/common/editorCommon'; +import {EndOfLinePreference, IRange} from 'vs/editor/common/editorCommon'; import {MockTextAreaWrapper} from 'vs/editor/test/common/mocks/mockTextAreaWrapper'; suite('TextAreaState', () => { @@ -467,7 +467,7 @@ class SimpleModel implements ISimpleModel { return this._lines.length; } - public convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): IEditorPosition { + public convertViewPositionToModelPosition(viewLineNumber:number, viewColumn:number): Position { return new Position(viewLineNumber, viewColumn); } } diff --git a/src/vs/languages/typescript/common/languageFeatures.ts b/src/vs/languages/typescript/common/languageFeatures.ts index c8441f550da..19bda729a37 100644 --- a/src/vs/languages/typescript/common/languageFeatures.ts +++ b/src/vs/languages/typescript/common/languageFeatures.ts @@ -17,6 +17,7 @@ import {TypeScriptWorkerProtocol, LanguageServiceDefaults} from 'vs/languages/ty import * as ts from 'vs/languages/typescript/common/lib/typescriptServices'; import {CancellationToken} from 'vs/base/common/cancellation'; import {wireCancellationToken} from 'vs/base/common/async'; +import {Position} from 'vs/editor/common/core/position'; export function register(modelService: IModelService, markerService: IMarkerService, selector: string, defaults:LanguageServiceDefaults, worker: (first: URI, ...more: URI[]) => TPromise): lifecycle.IDisposable { @@ -174,7 +175,7 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport { return true; } - provideCompletionItems(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): Thenable { + provideCompletionItems(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): Thenable { const wordInfo = model.getWordUntilPosition(position); const resource = model.uri; const offset = this._positionToOffset(resource, position); @@ -200,7 +201,7 @@ class SuggestAdapter extends Adapter implements modes.ISuggestSupport { })); } - resolveCompletionItem(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, suggestion: modes.ISuggestion, token: CancellationToken): Thenable { + resolveCompletionItem(model:editorCommon.IReadOnlyModel, position:Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable { const resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { @@ -247,7 +248,7 @@ class SignatureHelpAdapter extends Adapter implements modes.SignatureHelpProvide public signatureHelpTriggerCharacters = ['(', ',']; - provideSignatureHelp(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, token: CancellationToken): Thenable { + provideSignatureHelp(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Thenable { let resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => worker.getSignatureHelpItems(resource.toString(), this._positionToOffset(resource, position))).then(info => { @@ -296,7 +297,7 @@ class SignatureHelpAdapter extends Adapter implements modes.SignatureHelpProvide class QuickInfoAdapter extends Adapter implements modes.HoverProvider { - provideHover(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): Thenable { + provideHover(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): Thenable { let resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { @@ -317,7 +318,7 @@ class QuickInfoAdapter extends Adapter implements modes.HoverProvider { class OccurrencesAdapter extends Adapter implements modes.DocumentHighlightProvider { - public provideDocumentHighlights(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, token: CancellationToken): Thenable { + public provideDocumentHighlights(model: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): Thenable { const resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { @@ -340,7 +341,7 @@ class OccurrencesAdapter extends Adapter implements modes.DocumentHighlightProvi class DefinitionAdapter extends Adapter { - public provideDefinition(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, token:CancellationToken): Thenable { + public provideDefinition(model:editorCommon.IReadOnlyModel, position:Position, token:CancellationToken): Thenable { const resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { @@ -368,7 +369,7 @@ class DefinitionAdapter extends Adapter { class ReferenceAdapter extends Adapter implements modes.ReferenceProvider { - provideReferences(model:editorCommon.IReadOnlyModel, position:editorCommon.IEditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable { + provideReferences(model:editorCommon.IReadOnlyModel, position:Position, context: modes.ReferenceContext, token: CancellationToken): Thenable { const resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { @@ -533,7 +534,7 @@ class FormatOnTypeAdapter extends FormatHelper implements modes.OnTypeFormatting return [';', '}', '\n']; } - provideOnTypeFormattingEdits(model: editorCommon.IReadOnlyModel, position: editorCommon.IEditorPosition, ch: string, options: modes.IFormattingOptions, token: CancellationToken): Thenable { + provideOnTypeFormattingEdits(model: editorCommon.IReadOnlyModel, position: Position, ch: string, options: modes.IFormattingOptions, token: CancellationToken): Thenable { const resource = model.uri; return wireCancellationToken(token, this._worker(resource).then(worker => { diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index c310e9c34db..156bdcb46de 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -11,7 +11,7 @@ import {Remotable, IThreadService} from 'vs/platform/thread/common/thread'; import * as vscode from 'vscode'; import * as TypeConverters from 'vs/workbench/api/node/extHostTypeConverters'; import {Range, Disposable, SignatureHelp, CompletionList} from 'vs/workbench/api/node/extHostTypes'; -import {IReadOnlyModel, IEditorPosition, IPosition, IEditorRange, IRange, ISingleEditOperation} from 'vs/editor/common/editorCommon'; +import {IReadOnlyModel, IPosition, IEditorRange, IRange, ISingleEditOperation} from 'vs/editor/common/editorCommon'; import * as modes from 'vs/editor/common/modes'; import {ExtHostModelService} from 'vs/workbench/api/node/extHostDocuments'; import {ExtHostCommands} from 'vs/workbench/api/node/extHostCommands'; @@ -19,6 +19,7 @@ import {ExtHostDiagnostics} from 'vs/workbench/api/node/extHostDiagnostics'; import {NavigateTypesSupportRegistry, INavigateTypesSupport, ITypeBearing} from 'vs/workbench/parts/search/common/search'; import {asWinJsPromise, ShallowCancelThenPromise, wireCancellationToken} from 'vs/base/common/async'; import {CancellationToken} from 'vs/base/common/cancellation'; +import {Position as EditorPosition} from 'vs/editor/common/core/position'; // --- adapter @@ -875,7 +876,7 @@ export class MainThreadLanguageFeatures { $registerHoverProvider(handle: number, selector: vscode.DocumentSelector): TPromise { this._registrations[handle] = modes.HoverProviderRegistry.register(selector, { - provideHover: (model:IReadOnlyModel, position:IEditorPosition, token:CancellationToken): Thenable => { + provideHover: (model:IReadOnlyModel, position:EditorPosition, token:CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideHover(handle, model.uri, position)); } }); @@ -886,7 +887,7 @@ export class MainThreadLanguageFeatures { $registerDocumentHighlightProvider(handle: number, selector: vscode.DocumentSelector): TPromise { this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(selector, { - provideDocumentHighlights: (model: IReadOnlyModel, position: IEditorPosition, token: CancellationToken): Thenable => { + provideDocumentHighlights: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideDocumentHighlights(handle, model.uri, position)); } }); @@ -897,7 +898,7 @@ export class MainThreadLanguageFeatures { $registerReferenceSupport(handle: number, selector: vscode.DocumentSelector): TPromise { this._registrations[handle] = modes.ReferenceProviderRegistry.register(selector, { - provideReferences: (model:IReadOnlyModel, position:IEditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable => { + provideReferences: (model:IReadOnlyModel, position:EditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideReferences(handle, model.uri, position, context)); } }); @@ -940,7 +941,7 @@ export class MainThreadLanguageFeatures { autoFormatTriggerCharacters, - provideOnTypeFormattingEdits: (model: IReadOnlyModel, position: IEditorPosition, ch: string, options: modes.IFormattingOptions, token: CancellationToken): Thenable => { + provideOnTypeFormattingEdits: (model: IReadOnlyModel, position: EditorPosition, ch: string, options: modes.IFormattingOptions, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideOnTypeFormattingEdits(handle, model.uri, position, ch, options)); } }); @@ -962,7 +963,7 @@ export class MainThreadLanguageFeatures { $registerRenameSupport(handle: number, selector: vscode.DocumentSelector): TPromise { this._registrations[handle] = modes.RenameProviderRegistry.register(selector, { - provideRenameEdits: (model:IReadOnlyModel, position:IEditorPosition, newName: string, token: CancellationToken): Thenable => { + provideRenameEdits: (model:IReadOnlyModel, position:EditorPosition, newName: string, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideRenameEdits(handle, model.uri, position, newName)); } }); @@ -975,10 +976,10 @@ export class MainThreadLanguageFeatures { this._registrations[handle] = modes.SuggestRegistry.register(selector, { triggerCharacters: triggerCharacters, shouldAutotriggerSuggest: true, - provideCompletionItems: (model:IReadOnlyModel, position:IEditorPosition, token:CancellationToken): Thenable => { + provideCompletionItems: (model:IReadOnlyModel, position:EditorPosition, token:CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideCompletionItems(handle, model.uri, position)); }, - resolveCompletionItem: (model:IReadOnlyModel, position:IEditorPosition, suggestion: modes.ISuggestion, token: CancellationToken): Thenable => { + resolveCompletionItem: (model:IReadOnlyModel, position:EditorPosition, suggestion: modes.ISuggestion, token: CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$resolveCompletionItem(handle, model.uri, position, suggestion)); } }); @@ -992,7 +993,7 @@ export class MainThreadLanguageFeatures { signatureHelpTriggerCharacters: triggerCharacter, - provideSignatureHelp: (model:IReadOnlyModel, position:IEditorPosition, token:CancellationToken): Thenable => { + provideSignatureHelp: (model:IReadOnlyModel, position:EditorPosition, token:CancellationToken): Thenable => { return wireCancellationToken(token, this._proxy.$provideSignatureHelp(handle, model.uri, position)); } diff --git a/src/vs/workbench/parts/debug/browser/debugHover.ts b/src/vs/workbench/parts/debug/browser/debugHover.ts index dde080b5679..08422c656dc 100644 --- a/src/vs/workbench/parts/debug/browser/debugHover.ts +++ b/src/vs/workbench/parts/debug/browser/debugHover.ts @@ -12,13 +12,14 @@ import * as nls from 'vs/nls'; import { ITree } from 'vs/base/parts/tree/browser/tree'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { DefaultController, ICancelableEvent } from 'vs/base/parts/tree/browser/treeDefaults'; -import { IConfigurationChangedEvent, IEditorPosition, IEditorRange } from 'vs/editor/common/editorCommon'; +import { IConfigurationChangedEvent, IEditorRange } from 'vs/editor/common/editorCommon'; import editorbrowser = require('vs/editor/browser/editorBrowser'); import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import debug = require('vs/workbench/parts/debug/common/debug'); import {evaluateExpression, Expression} from 'vs/workbench/parts/debug/common/debugModel'; import viewer = require('vs/workbench/parts/debug/browser/debugViewer'); import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent'; +import {Position} from 'vs/editor/common/core/position'; const $ = dom.emmet; const debugTreeOptions = { @@ -38,7 +39,7 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget { private domNode: HTMLElement; public isVisible: boolean; private tree: ITree; - private showAtPosition: IEditorPosition; + private showAtPosition: Position; private highlightDecorations: string[]; private treeContainer: HTMLElement; private valueContainer: HTMLElement; @@ -175,7 +176,7 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget { }).then(() => variables.length === 1 ? TPromise.as(variables[0]) : TPromise.as(null)); } - private doShow(position: IEditorPosition, expression: debug.IExpression, focus: boolean, forceValueHover = false): TPromise { + private doShow(position: Position, expression: debug.IExpression, focus: boolean, forceValueHover = false): TPromise { this.showAtPosition = position; this.isVisible = true; this.stoleFocus = focus;