1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00

HackStudio: Rename TextDocument => ProjectFile

TextDocument was not the right name, and got even more confusing with
the addition of GTextDocument in LibGUI.
This commit is contained in:
Andreas Kling 2019-11-01 18:40:32 +01:00
parent 45e0c841ad
commit b81f6f2c43
5 changed files with 15 additions and 15 deletions

View file

@ -2,7 +2,7 @@ include ../../Makefile.common
OBJS = \ OBJS = \
Project.o \ Project.o \
TextDocument.o \ ProjectFile.o \
TerminalWrapper.o \ TerminalWrapper.o \
FindInFilesWidget.o \ FindInFilesWidget.o \
ProcessStateWidget.o \ ProcessStateWidget.o \

View file

@ -37,7 +37,7 @@ Project::Project(const String& path, Vector<String>&& filenames)
: m_path(path) : m_path(path)
{ {
for (auto& filename : filenames) { for (auto& filename : filenames) {
m_files.append(TextDocument::construct_with_name(filename)); m_files.append(ProjectFile::construct_with_name(filename));
} }
m_model = adopt(*new ProjectModel(*this)); m_model = adopt(*new ProjectModel(*this));
} }
@ -75,12 +75,12 @@ bool Project::add_file(const String& filename)
if (!project_file->close()) if (!project_file->close())
return false; return false;
m_files.append(TextDocument::construct_with_name(filename)); m_files.append(ProjectFile::construct_with_name(filename));
m_model->update(); m_model->update();
return true; return true;
} }
TextDocument* Project::get_file(const String& filename) ProjectFile* Project::get_file(const String& filename)
{ {
for (auto& file : m_files) { for (auto& file : m_files) {
if (file.name() == filename) if (file.name() == filename)

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "TextDocument.h" #include "ProjectFile.h"
#include <AK/Noncopyable.h> #include <AK/Noncopyable.h>
#include <AK/NonnullRefPtrVector.h> #include <AK/NonnullRefPtrVector.h>
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
@ -14,7 +14,7 @@ public:
[[nodiscard]] bool add_file(const String& filename); [[nodiscard]] bool add_file(const String& filename);
TextDocument* get_file(const String& filename); ProjectFile* get_file(const String& filename);
GModel& model() { return *m_model; } GModel& model() { return *m_model; }
@ -33,5 +33,5 @@ private:
String m_path; String m_path;
RefPtr<GModel> m_model; RefPtr<GModel> m_model;
NonnullRefPtrVector<TextDocument> m_files; NonnullRefPtrVector<ProjectFile> m_files;
}; };

View file

@ -1,8 +1,8 @@
#include "TextDocument.h" #include "ProjectFile.h"
#include <LibCore/CFile.h> #include <LibCore/CFile.h>
#include <string.h> #include <string.h>
const GTextDocument& TextDocument::document() const const GTextDocument& ProjectFile::document() const
{ {
if (!m_document) { if (!m_document) {
m_document = GTextDocument::create(nullptr); m_document = GTextDocument::create(nullptr);
@ -11,7 +11,7 @@ const GTextDocument& TextDocument::document() const
return *m_document; return *m_document;
} }
const ByteBuffer& TextDocument::contents() const const ByteBuffer& ProjectFile::contents() const
{ {
if (m_contents.is_null()) { if (m_contents.is_null()) {
auto file = CFile::construct(m_name); auto file = CFile::construct(m_name);
@ -21,7 +21,7 @@ const ByteBuffer& TextDocument::contents() const
return m_contents; return m_contents;
} }
Vector<int> TextDocument::find(const StringView& needle) const Vector<int> ProjectFile::find(const StringView& needle) const
{ {
// NOTE: This forces us to load the contents if we hadn't already. // NOTE: This forces us to load the contents if we hadn't already.
contents(); contents();

View file

@ -6,11 +6,11 @@
#include <AK/String.h> #include <AK/String.h>
#include <LibGUI/GTextDocument.h> #include <LibGUI/GTextDocument.h>
class TextDocument : public RefCounted<TextDocument> { class ProjectFile : public RefCounted<ProjectFile> {
public: public:
static NonnullRefPtr<TextDocument> construct_with_name(const String& name) static NonnullRefPtr<ProjectFile> construct_with_name(const String& name)
{ {
return adopt(*new TextDocument(name)); return adopt(*new ProjectFile(name));
} }
const String& name() const { return m_name; } const String& name() const { return m_name; }
@ -22,7 +22,7 @@ public:
const GTextDocument& document() const; const GTextDocument& document() const;
private: private:
explicit TextDocument(const String& name) explicit ProjectFile(const String& name)
: m_name(name) : m_name(name)
{ {
} }