loom
1#include "DocumentOperationFactory.h"
2#include "fuze/FuzeDocumentOperation.h"
3#include "script/ScriptDocumentOperation.h"
4
5#if __cplusplus >= __cpp_2017
6#include <filesystem>
7namespace fs = std::filesystem;
8#else
9#include <experimental/filesystem>
10namespace fs = std::filesystem::experimental;
11#endif
12
13using namespace simodo;
14
15DocumentOperationFactory::DocumentOperationFactory(const std::string & loom_dir)
16: _loom_dir(fs::path(loom_dir).lexically_normal().string())
17{
18}
19
20std::unique_ptr<lsp::DocumentOperation_interface> DocumentOperationFactory::create(lsp::DocumentContext & doc,
21const std::string & languageId)
22{
23doc.server().log().debug("DocumentOperationFactory::create called for '" + languageId + "'");
24doc.server().log().debug("DocumentOperationFactory::create loom_dir '" + _loom_dir + "'");
25
26if (languageId == "fuze")
27return std::make_unique<FuzeDocumentOperation>(doc, *this, languageId);
28
29return std::make_unique<ScriptDocumentOperation>(doc, *this, languageId);
30}