refactor: Replace singletone for context manager (#151)

This commit is contained in:
Petr Mironychev
2025-04-01 22:29:45 +02:00
committed by GitHub
parent 7e6e526ac8
commit 79218d8412
9 changed files with 114 additions and 37 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Petr Mironychev
* Copyright (C) 2025 Petr Mironychev
*
* This file is part of QodeAssist.
*
@ -23,31 +23,30 @@
#include <QString>
#include "ContentFile.hpp"
#include "IDocumentReader.hpp"
#include "IContextManager.hpp"
#include "ProgrammingLanguage.hpp"
#include "settings/GeneralSettings.hpp"
namespace ProjectExplorer {
class Project;
}
namespace QodeAssist::Context {
class ContextManager : public QObject
class ContextManager : public QObject, public IContextManager
{
Q_OBJECT
public:
static ContextManager &instance();
QString readFile(const QString &filePath) const;
QList<ContentFile> getContentFiles(const QStringList &filePaths) const;
static ProgrammingLanguage getDocumentLanguage(const DocumentInfo &documentInfo);
static bool isSpecifyCompletion(
const DocumentInfo &documentInfo, const Settings::GeneralSettings &generalSettings);
private:
explicit ContextManager(QObject *parent = nullptr);
~ContextManager() = default;
ContextManager(const ContextManager &) = delete;
ContextManager &operator=(const ContextManager &) = delete;
ContentFile createContentFile(const QString &filePath) const;
~ContextManager() override = default;
QString readFile(const QString &filePath) const override;
QList<ContentFile> getContentFiles(const QStringList &filePaths) const override;
QStringList getProjectSourceFiles(ProjectExplorer::Project *project) const override;
ContentFile createContentFile(const QString &filePath) const override;
ProgrammingLanguage getDocumentLanguage(const DocumentInfo &documentInfo) const override;
bool isSpecifyCompletion(const DocumentInfo &documentInfo) const override;
};
} // namespace QodeAssist::Context