mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
use idGenerator
This commit is contained in:
parent
d301b07e47
commit
372dbdb7bd
|
@ -14,7 +14,9 @@ export class IdGenerator {
|
|||
this._lastId = 0;
|
||||
}
|
||||
|
||||
public generate(): string {
|
||||
public nextId(): string {
|
||||
return this._prefix + (++this._lastId);
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultGenerator = new IdGenerator('id#');
|
|
@ -415,7 +415,7 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
|
|||
private _addDecorationImpl(eventBuilder:DeferredEventsBuilder, ownerId:number, range:editorCommon.IEditorRange, options:ModelDecorationOptions): string {
|
||||
var rangeId = this.addTrackedRange(range, options.stickiness);
|
||||
|
||||
var decoration = new ModelInternalDecoration(this._decorationIdGenerator.generate(), ownerId, rangeId, options);
|
||||
var decoration = new ModelInternalDecoration(this._decorationIdGenerator.nextId(), ownerId, rangeId, options);
|
||||
|
||||
this.decorations[decoration.id] = decoration;
|
||||
this.rangeIdToDecorationId[rangeId] = decoration.id;
|
||||
|
@ -432,7 +432,7 @@ export class TextModelWithDecorations extends TextModelWithTrackedRanges impleme
|
|||
for (let i = 0, len = newDecorations.length; i < len; i++) {
|
||||
let rangeId = rangeIds[i];
|
||||
|
||||
var decoration = new ModelInternalDecoration(this._decorationIdGenerator.generate(), ownerId, rangeId, newDecorations[i].options);
|
||||
var decoration = new ModelInternalDecoration(this._decorationIdGenerator.nextId(), ownerId, rangeId, newDecorations[i].options);
|
||||
|
||||
this.decorations[decoration.id] = decoration;
|
||||
this.rangeIdToDecorationId[rangeId] = decoration.id;
|
||||
|
|
|
@ -72,7 +72,7 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
|
|||
_addMarker(lineNumber:number, column:number, stickToPreviousCharacter:boolean): string {
|
||||
var pos = this.validatePosition(new Position(lineNumber, column));
|
||||
|
||||
var marker = new LineMarker(this._markerIdGenerator.generate(), pos.column, stickToPreviousCharacter);
|
||||
var marker = new LineMarker(this._markerIdGenerator.nextId(), pos.column, stickToPreviousCharacter);
|
||||
this._markerIdToMarker[marker.id] = marker;
|
||||
|
||||
this._lines[pos.lineNumber - 1].addMarker(marker);
|
||||
|
@ -89,7 +89,7 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
|
|||
for (let i = 0, len = newMarkers.length; i < len; i++) {
|
||||
let newMarker = newMarkers[i];
|
||||
|
||||
let marker = new LineMarker(this._markerIdGenerator.generate(), newMarker.column, newMarker.stickToPreviousCharacter);
|
||||
let marker = new LineMarker(this._markerIdGenerator.nextId(), newMarker.column, newMarker.stickToPreviousCharacter);
|
||||
this._markerIdToMarker[marker.id] = marker;
|
||||
|
||||
if (!addMarkersPerLine[newMarker.lineNumber]) {
|
||||
|
|
|
@ -140,7 +140,7 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
|
|||
var startMarkerId = this._addMarker(textRange.startLineNumber, textRange.startColumn, startMarkerSticksToPreviousCharacter);
|
||||
var endMarkerId = this._addMarker(textRange.endLineNumber, textRange.endColumn, endMarkerSticksToPreviousCharacter);
|
||||
|
||||
var range = new TrackedRange(this._rangeIdGenerator.generate(), startMarkerId, endMarkerId);
|
||||
var range = new TrackedRange(this._rangeIdGenerator.nextId(), startMarkerId, endMarkerId);
|
||||
this._ranges[range.id] = range;
|
||||
this._markerIdToRangeId[startMarkerId] = range.id;
|
||||
this._markerIdToRangeId[endMarkerId] = range.id;
|
||||
|
@ -176,7 +176,7 @@ export class TextModelWithTrackedRanges extends TextModelWithMarkers implements
|
|||
let startMarkerId = markerIds[2 * i];
|
||||
let endMarkerId = markerIds[2 * i + 1];
|
||||
|
||||
let range = new TrackedRange(this._rangeIdGenerator.generate(), startMarkerId, endMarkerId);
|
||||
let range = new TrackedRange(this._rangeIdGenerator.nextId(), startMarkerId, endMarkerId);
|
||||
this._ranges[range.id] = range;
|
||||
this._markerIdToRangeId[startMarkerId] = range.id;
|
||||
this._markerIdToRangeId[endMarkerId] = range.id;
|
||||
|
|
|
@ -9,7 +9,7 @@ import Event, {fromEventEmitter} from 'vs/base/common/event';
|
|||
import {basename, dirname} from 'vs/base/common/paths';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import {generateUuid} from 'vs/base/common/uuid';
|
||||
import {defaultGenerator} from 'vs/base/common/idGenerator';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IEditorService} from 'vs/platform/editor/common/editor';
|
||||
import {Range} from 'vs/editor/common/core/range';
|
||||
|
@ -25,7 +25,7 @@ export class OneReference {
|
|||
private _range: IRange,
|
||||
private _eventBus: EventEmitter
|
||||
) {
|
||||
this._id = generateUuid();
|
||||
this._id = defaultGenerator.nextId();
|
||||
}
|
||||
|
||||
public get id(): string {
|
||||
|
|
Loading…
Reference in a new issue