parent
a6ee11199d
commit
5527b1ee42
1 changed files with 12 additions and 11 deletions
|
@ -17,10 +17,11 @@ import { coalesce, equals } from 'vs/base/common/arrays';
|
|||
|
||||
export class Disposable {
|
||||
|
||||
static from(...disposables: { dispose(): any }[]): Disposable {
|
||||
static from(...inDisposables: { dispose(): any }[]): Disposable {
|
||||
let disposables: ReadonlyArray<{ dispose(): any }> | undefined = inDisposables;
|
||||
return new Disposable(function () {
|
||||
if (disposables) {
|
||||
for (let disposable of disposables) {
|
||||
for (const disposable of disposables) {
|
||||
if (disposable && typeof disposable.dispose === 'function') {
|
||||
disposable.dispose();
|
||||
}
|
||||
|
@ -30,7 +31,7 @@ export class Disposable {
|
|||
});
|
||||
}
|
||||
|
||||
private _callOnDispose: Function;
|
||||
private _callOnDispose?: Function;
|
||||
|
||||
constructor(callOnDispose: Function) {
|
||||
this._callOnDispose = callOnDispose;
|
||||
|
@ -154,7 +155,7 @@ export class Position {
|
|||
|
||||
translate(change: { lineDelta?: number; characterDelta?: number; }): Position;
|
||||
translate(lineDelta?: number, characterDelta?: number): Position;
|
||||
translate(lineDeltaOrChange: number | { lineDelta?: number; characterDelta?: number; }, characterDelta: number = 0): Position {
|
||||
translate(lineDeltaOrChange: number | undefined | { lineDelta?: number; characterDelta?: number; }, characterDelta: number = 0): Position {
|
||||
|
||||
if (lineDeltaOrChange === null || characterDelta === null) {
|
||||
throw illegalArgument();
|
||||
|
@ -178,7 +179,7 @@ export class Position {
|
|||
|
||||
with(change: { line?: number; character?: number; }): Position;
|
||||
with(line?: number, character?: number): Position;
|
||||
with(lineOrChange: number | { line?: number; character?: number; }, character: number = this.character): Position {
|
||||
with(lineOrChange: number | undefined | { line?: number; character?: number; }, character: number = this.character): Position {
|
||||
|
||||
if (lineOrChange === null || character === null) {
|
||||
throw illegalArgument();
|
||||
|
@ -234,8 +235,8 @@ export class Range {
|
|||
constructor(start: Position, end: Position);
|
||||
constructor(startLine: number, startColumn: number, endLine: number, endColumn: number);
|
||||
constructor(startLineOrStart: number | Position, startColumnOrEnd: number | Position, endLine?: number, endColumn?: number) {
|
||||
let start: Position;
|
||||
let end: Position;
|
||||
let start: Position | undefined;
|
||||
let end: Position | undefined;
|
||||
|
||||
if (typeof startLineOrStart === 'number' && typeof startColumnOrEnd === 'number' && typeof endLine === 'number' && typeof endColumn === 'number') {
|
||||
start = new Position(startLineOrStart, startColumnOrEnd);
|
||||
|
@ -279,7 +280,7 @@ export class Range {
|
|||
return this._start.isEqual(other._start) && this._end.isEqual(other._end);
|
||||
}
|
||||
|
||||
intersection(other: Range): Range {
|
||||
intersection(other: Range): Range | undefined {
|
||||
let start = Position.Max(other.start, this._start);
|
||||
let end = Position.Min(other.end, this._end);
|
||||
if (start.isAfter(end)) {
|
||||
|
@ -312,7 +313,7 @@ export class Range {
|
|||
|
||||
with(change: { start?: Position, end?: Position }): Range;
|
||||
with(start?: Position, end?: Position): Range;
|
||||
with(startOrChange: Position | { start?: Position, end?: Position }, end: Position = this.end): Range {
|
||||
with(startOrChange: Position | undefined | { start?: Position, end?: Position }, end: Position = this.end): Range {
|
||||
|
||||
if (startOrChange === null || end === null) {
|
||||
throw illegalArgument();
|
||||
|
@ -371,8 +372,8 @@ export class Selection extends Range {
|
|||
constructor(anchor: Position, active: Position);
|
||||
constructor(anchorLine: number, anchorColumn: number, activeLine: number, activeColumn: number);
|
||||
constructor(anchorLineOrAnchor: number | Position, anchorColumnOrActive: number | Position, activeLine?: number, activeColumn?: number) {
|
||||
let anchor: Position;
|
||||
let active: Position;
|
||||
let anchor: Position | undefined;
|
||||
let active: Position | undefined;
|
||||
|
||||
if (typeof anchorLineOrAnchor === 'number' && typeof anchorColumnOrActive === 'number' && typeof activeLine === 'number' && typeof activeColumn === 'number') {
|
||||
anchor = new Position(anchorLineOrAnchor, anchorColumnOrActive);
|
||||
|
|
Loading…
Reference in a new issue