2025-05-21 12:28:04 +00:00
|
|
|
import { IFilePathStateHolder } from "src/IFilePathStateHolder";
|
|
|
|
|
|
|
|
|
|
export class InMemoryFilePathStateHolder implements IFilePathStateHolder {
|
|
|
|
|
private states: Map<string, string>;
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
this.states = new Map<string, string>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public setByPath(filePath: string, text: string): void {
|
2025-07-05 11:27:48 +00:00
|
|
|
// console.log(`InMemoryFileStateHolder: Setting state for "${filePath}"`);
|
2025-05-21 12:28:04 +00:00
|
|
|
this.states.set(filePath, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getByPath(filePath: string): string | undefined {
|
|
|
|
|
const state = this.states.get(filePath);
|
2025-07-05 11:27:48 +00:00
|
|
|
// console.log(`InMemoryFileStateHolder: Getting state for "${filePath}". Found: ${!!state}`);
|
2025-05-21 12:28:04 +00:00
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Вспомогательные методы для тестов (не часть интерфейса, но полезны)
|
|
|
|
|
public clear(): void {
|
|
|
|
|
this.states.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public getInternalState(filePath: string): string | undefined {
|
|
|
|
|
return this.states.get(filePath); // Для прямых проверок в тестах
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public setInitialStates(initialStates: Record<string, string>): void {
|
|
|
|
|
for (const path in initialStates) {
|
|
|
|
|
this.states.set(path, initialStates[path]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|