mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
HackStudio: Start adding a "find in files" function
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. :^)
This commit is contained in:
parent
41289e652f
commit
d3e81d2ba8
6 changed files with 209 additions and 38 deletions
29
DevTools/HackStudio/TextDocument.h
Normal file
29
DevTools/HackStudio/TextDocument.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
class TextDocument : public RefCounted<TextDocument> {
|
||||
public:
|
||||
static NonnullRefPtr<TextDocument> construct_with_name(const String& name)
|
||||
{
|
||||
return adopt(*new TextDocument(name));
|
||||
}
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
|
||||
const ByteBuffer& contents() const;
|
||||
|
||||
Vector<int> find(const StringView&) const;
|
||||
|
||||
private:
|
||||
explicit TextDocument(const String& name)
|
||||
: m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
String m_name;
|
||||
mutable ByteBuffer m_contents;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue