loom
1#include "InputSupplier.h"
2#include "simodo/inout/token/RefBufferStream.h"
3#include "simodo/inout/token/BufferStream.h"
4#include "simodo/inout/token/FileStream.h"
5
6using namespace simodo;
7
8std::shared_ptr<inout::InputStream_interface> InputSupplier::supply(const std::string & path)
9{
10if (path == _base_file_path) {
11std::shared_ptr<inout::InputStream_interface> stream = std::make_shared<inout::RefBufferStream>(_text.data());
12return stream;
13}
14
15if (const lsp::DocumentContext * doc = _server.findDocument(path); doc) {
16/// \note Такая последовательность нужна для выполнения разграничения доступа внутри методов
17/// классов пространства имён lsp
18std::shared_ptr<inout::InputStream_interface> stream = std::make_shared<inout::BufferStream>();
19doc->copyContent(dynamic_cast<inout::BufferStream *>(stream.get())->buffer());
20return stream;
21}
22
23return std::make_shared<inout::FileStream>(path);
24}