mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-14 23:12:49 +03:00
ecode: Added Code Formatter module. Improved Linter module.
This commit is contained in:
46
src/tools/codeeditor/formattermodule.hpp
Normal file
46
src/tools/codeeditor/formattermodule.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef FORMATTERMODULE_HPP
|
||||
#define FORMATTERMODULE_HPP
|
||||
|
||||
#include <eepp/config.hpp>
|
||||
#include <eepp/system/mutex.hpp>
|
||||
#include <eepp/system/threadpool.hpp>
|
||||
#include <eepp/ui/uicodeeditor.hpp>
|
||||
#include <set>
|
||||
using namespace EE;
|
||||
using namespace EE::System;
|
||||
using namespace EE::UI;
|
||||
|
||||
class FormatterModule : public UICodeEditorModule {
|
||||
public:
|
||||
FormatterModule( const std::string& formatterPath, std::shared_ptr<ThreadPool> pool );
|
||||
|
||||
virtual ~FormatterModule();
|
||||
|
||||
void onRegister( UICodeEditor* );
|
||||
|
||||
void onUnregister( UICodeEditor* );
|
||||
|
||||
protected:
|
||||
enum class FormatterType { Inplace, Output };
|
||||
|
||||
struct Formatter {
|
||||
std::vector<std::string> files;
|
||||
std::string command;
|
||||
FormatterType type{ FormatterType::Output };
|
||||
};
|
||||
|
||||
std::shared_ptr<ThreadPool> mPool;
|
||||
std::vector<Formatter> mFormatters;
|
||||
std::set<UICodeEditor*> mEditors;
|
||||
bool mClosing{ false };
|
||||
|
||||
bool mReady{ false };
|
||||
|
||||
void load( const std::string& formatterPath );
|
||||
|
||||
void formatDoc( UICodeEditor* editor );
|
||||
|
||||
FormatterModule::Formatter supportsFormatter( std::shared_ptr<TextDocument> doc );
|
||||
};
|
||||
|
||||
#endif // FORMATTERMODULE_HPP
|
||||
Reference in New Issue
Block a user