Skip to content

Commit

Permalink
Clean up clang-tidy error in table engine
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed May 28, 2024
1 parent 3e14430 commit 89283ee
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 8 deletions.
12 changes: 12 additions & 0 deletions im/table/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
*
*/
#include "context.h"
#include "ime.h"
#include <cstddef>
#include <fcitx-utils/stringutils.h>
#include <fcitx-utils/textformatflags.h>
#include <fcitx/text.h>
#include <libime/core/prediction.h>
#include <libime/core/userlanguagemodel.h>
#include <libime/table/tablebaseddictionary.h>
#include <libime/table/tablecontext.h>
#include <memory>
#include <string>
#include <utility>

namespace fcitx {

Expand Down
3 changes: 3 additions & 0 deletions im/table/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

#include "ime.h"
#include <fcitx/text.h>
#include <libime/core/prediction.h>
#include <libime/table/tablecontext.h>
#include <memory>
#include <string>

namespace fcitx {

Expand Down
23 changes: 20 additions & 3 deletions im/table/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,45 @@
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/stream_buffer.hpp>
#include <cstddef>
#include <exception>
#include <fcitx-config/iniparser.h>
#include <fcitx-config/rawconfig.h>
#include <fcitx-utils/charutils.h>
#include <fcitx-utils/event.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/log.h>
#include <fcitx-utils/macros.h>
#include <fcitx-utils/standardpath.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx-utils/utf8.h>
#include <fcitx/action.h>
#include <fcitx/addoninstance.h>
#include <fcitx/event.h>
#include <fcitx/inputcontext.h>
#include <fcitx/inputcontextmanager.h>
#include <fcitx/inputcontextproperty.h>
#include <fcitx/inputmethodmanager.h>
#include <fcitx/inputpanel.h>
#include <fcitx/instance.h>
#include <fcitx/statusarea.h>
#include <fcitx/userinterfacemanager.h>
#include <fcntl.h>
#include <istream>
#include <libime/core/historybigram.h>
#include <libime/core/languagemodel.h>
#include <libime/core/userlanguagemodel.h>
#include <libime/pinyin/pinyindictionary.h>
#include <libime/pinyin/pinyinencoder.h>
#include <libime/pinyin/shuangpinprofile.h>
#include <libime/table/tablebaseddictionary.h>
#include <map>
#include <memory>
#include <quickphrase_public.h>
#include <unordered_map>
#include <string>
#include <string_view>
#include <unordered_set>

namespace fcitx {

Expand Down Expand Up @@ -167,7 +182,8 @@ void TableEngine::populateConfig() {
}
}

void TableEngine::setSubConfig(const std::string &path, const RawConfig &) {
void TableEngine::setSubConfig(const std::string &path,
const RawConfig & /*unused*/) {
if (path == "reloaddict") {
reloadDict();
}
Expand Down Expand Up @@ -282,7 +298,8 @@ const libime::PinyinDictionary &TableEngine::pinyinDict() {
never_close_handle);
std::istream in(&buffer);
pinyinDict_.load(i, in, libime::PinyinDictFormat::Binary);
} catch (const std::exception &) {
} catch (const std::exception &e) {
TABLE_ERROR() << "Failed to load pinyin dict: " << e.what();
}
}
pinyinLoaded_ = true;
Expand Down
20 changes: 16 additions & 4 deletions im/table/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@

#include "ime.h"
#include <fcitx-config/configuration.h>
#include <fcitx-config/enum.h>
#include <fcitx-config/iniparser.h>
#include <fcitx-config/option.h>
#include <fcitx-config/rawconfig.h>
#include <fcitx-utils/event.h>
#include <fcitx-utils/handlertable.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/key.h>
#include <fcitx/action.h>
#include <fcitx/addonfactory.h>
#include <fcitx/addoninstance.h>
#include <fcitx/addonmanager.h>
#include <fcitx/event.h>
#include <fcitx/inputcontextproperty.h>
#include <fcitx/inputmethodengine.h>
#include <fcitx/instance.h>
#include <libime/core/languagemodel.h>
#include <libime/pinyin/pinyindictionary.h>
#include <map>
#include <memory>
#include <string>
#include <vector>

namespace fcitx {

Expand Down Expand Up @@ -98,12 +109,13 @@ class TableEngine final : public InputMethodEngine {
saveConfig();
}
void populateConfig();
void setSubConfig(const std::string &path, const RawConfig &) override;
void setSubConfig(const std::string &path,
const RawConfig & /*unused*/) override;

const Configuration *
getConfigForInputMethod(const InputMethodEntry &) const override;
void setConfigForInputMethod(const InputMethodEntry &,
const RawConfig &) override;
getConfigForInputMethod(const InputMethodEntry &entry) const override;
void setConfigForInputMethod(const InputMethodEntry &entry,
const RawConfig &config) override;

const libime::PinyinDictionary &pinyinDict();
const libime::LanguageModel &pinyinModel();
Expand Down
5 changes: 4 additions & 1 deletion im/table/ime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <fcitx-utils/stringutils.h>
#include <fcntl.h>
#include <fstream>
#include <ios>
#include <istream>
#include <libime/core/languagemodel.h>
#include <libime/core/userlanguagemodel.h>
Expand Down Expand Up @@ -151,7 +152,9 @@ TableIME::requestDict(const std::string &name) {
std::istream in(&buffer);
dict->load(in);
iter->second.dict = std::move(dict);
} catch (const std::exception &) {
} catch (const std::exception &e) {
TABLE_ERROR() << "Failed to load table: " << *root.config->file
<< ", error: " << e.what();
}

if (auto *dict = iter->second.dict.get()) {
Expand Down
11 changes: 11 additions & 0 deletions im/table/ime.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,25 @@

#include <fcitx-config/configuration.h>
#include <fcitx-config/enum.h>
#include <fcitx-config/option.h>
#include <fcitx-config/rawconfig.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/key.h>
#include <fcitx-utils/keysymgen.h>
#include <fcitx-utils/log.h>
#include <fcitx-utils/macros.h>
#include <fcitx-utils/misc.h>
#include <fcitx/candidatelist.h>
#include <libime/core/languagemodel.h>
#include <libime/core/prediction.h>
#include <libime/core/userlanguagemodel.h>
#include <libime/table/tablebaseddictionary.h>
#include <memory>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace fcitx {

Expand Down
22 changes: 22 additions & 0 deletions im/table/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,44 @@
*
*/
#include "state.h"
#include "context.h"
#include "engine.h"
#include "ime.h"
#include "pinyinhelper_public.h"
#include "punctuation_public.h"
#include "quickphrase_public.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <fcitx-utils/capabilityflags.h>
#include <fcitx-utils/event.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/key.h>
#include <fcitx-utils/keysym.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx-utils/utf8.h>
#include <fcitx/candidatelist.h>
#include <fcitx/event.h>
#include <fcitx/inputcontext.h>
#include <fcitx/inputmethodentry.h>
#include <fcitx/inputpanel.h>
#include <fcitx/text.h>
#include <fcitx/userinterface.h>
#include <fmt/core.h>
#include <fmt/format.h>
#include <initializer_list>
#include <iterator>
#include <libime/core/historybigram.h>
#include <libime/pinyin/pinyinencoder.h>
#include <libime/pinyin/shuangpinprofile.h>
#include <libime/table/tablebaseddictionary.h>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>

namespace fcitx {

Expand Down
11 changes: 11 additions & 0 deletions im/table/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@

#include "context.h"
#include "engine.h"
#include "ime.h"
#include <cstddef>
#include <fcitx-utils/inputbuffer.h>
#include <fcitx/candidatelist.h>
#include <fcitx/event.h>
#include <fcitx/inputcontextproperty.h>
#include <fcitx/inputmethodentry.h>
#include <list>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace fcitx {

Expand Down

0 comments on commit 89283ee

Please sign in to comment.