MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / Spell

Method Spell

CodeFormatServer/src/Service/CodeActionService.cpp:71–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void CodeActionService::Spell(lsp::Diagnostic &diagnostic, std::shared_ptr<lsp::CodeActionParams> param,
72 std::shared_ptr<lsp::CodeActionResult> result) {
73 auto &originText = diagnostic.data;
74 if (originText.empty()) {
75 return;
76 }
77
78 // add to custom dictionary
79 {
80 auto &action = result->actions.emplace_back();
81
82 action.title = util::format("Add '{}' to workspace dictionary", originText);
83 action.command.title = action.title;
84 action.command.command = _owner->GetService<CommandService>()->GetCommand(
85 CommandService::Command::SpellAddDict);
86 action.command.arguments.emplace_back(originText);
87
88 action.kind = lsp::CodeActionKind::QuickFix;
89 }
90
91 auto spellChecker = _owner->GetService<DiagnosticService>()->GetSpellChecker();
92 auto suggests = spellChecker->GetSuggests(originText);
93 for (auto &suggest: suggests) {
94 if (!suggest.Term.empty()) {
95 if (result->actions.size() >= 15) {
96 break;
97 }
98 auto &action = result->actions.emplace_back();
99 auto &term = suggest.Term;
100
101 action.title = term;
102 action.command.title = term;
103 action.command.command = _owner->GetService<CommandService>()->GetCommand(
104 CommandService::Command::SpellCorrect);
105 action.command.arguments.emplace_back(param->textDocument.uri);
106 action.command.arguments.push_back(diagnostic.range.Serialize());
107 action.command.arguments.emplace_back(term);
108
109 action.kind = lsp::CodeActionKind::QuickFix;
110 }
111 }
112}

Callers

nothing calls this directly

Calls 8

GetCommandMethod · 0.80
GetSpellCheckerMethod · 0.80
GetSuggestsMethod · 0.80
formatFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
SerializeMethod · 0.45

Tested by

no test coverage detected