Path: blob/main/src/vs/editor/browser/services/renameSymbolTrackerService.ts
5241 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IObservable, observableValue } from '../../../base/common/observable.js';6import { Position } from '../../common/core/position.js';7import { Range } from '../../common/core/range.js';8import { ITextModel } from '../../common/model.js';9import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';1011export const IRenameSymbolTrackerService = createDecorator<IRenameSymbolTrackerService>('renameSymbolTrackerService');1213/**14* Represents a tracked word that is being edited by the user.15*/16export interface ITrackedWord {17/**18* The model in which the word is being tracked.19*/20readonly model: ITextModel;21/**22* The original word text when tracking started.23*/24readonly originalWord: string;25/**26* The original position where the word was found.27*/28readonly originalPosition: Position;29/**30* The original range of the word when tracking started.31*/32readonly originalRange: Range;33/**34* The current word text after edits.35*/36readonly currentWord: string;37/**38* The current range of the word after edits.39*/40readonly currentRange: Range;41}4243export interface IRenameSymbolTrackerService {44readonly _serviceBrand: undefined;4546/**47* Observable that emits the currently tracked word, or undefined if no word is being tracked.48*/49readonly trackedWord: IObservable<ITrackedWord | undefined>;50}5152export class NullRenameSymbolTrackerService implements IRenameSymbolTrackerService {53declare readonly _serviceBrand: undefined;5455private readonly _trackedWord = observableValue<ITrackedWord | undefined>(this, undefined);56public readonly trackedWord: IObservable<ITrackedWord | undefined> = this._trackedWord;57constructor() {58this._trackedWord.set(undefined, undefined);59}60}616263