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