mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 22:15:07 +00:00

Projects now contain a set of TextDocument objects. Each TextDocument represents a member file in the project. TextDocuments may not have their file contents loaded at all times, but they will be loaded on demand when calling TextDocument::contents(). "Find in files" works by iterating over the documents in the project and calling find(needle) on each one. The return value from find() is a vector of line numbers where the needle was found. This is obviously going to need a bunch more work. :^)
31 lines
688 B
C++
31 lines
688 B
C++
#pragma once
|
|
|
|
#include "TextDocument.h"
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/NonnullRefPtrVector.h>
|
|
#include <AK/OwnPtr.h>
|
|
#include <LibGUI/GModel.h>
|
|
|
|
class Project {
|
|
AK_MAKE_NONCOPYABLE(Project)
|
|
AK_MAKE_NONMOVABLE(Project)
|
|
public:
|
|
static OwnPtr<Project> load_from_file(const String& path);
|
|
|
|
GModel& model() { return *m_model; }
|
|
|
|
template<typename Callback>
|
|
void for_each_text_file(Callback callback) const
|
|
{
|
|
for (auto& file : m_files) {
|
|
callback(file);
|
|
}
|
|
}
|
|
|
|
private:
|
|
friend class ProjectModel;
|
|
explicit Project(Vector<String>&& files);
|
|
|
|
RefPtr<GModel> m_model;
|
|
NonnullRefPtrVector<TextDocument> m_files;
|
|
};
|