MCPcopy Create free account
hub / github.com/SpartanJ/eepp / spellCheckDoc

Method spellCheckDoc

src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp:249–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void SpellCheckerPlugin::spellCheckDoc( std::shared_ptr<TextDocument> doc ) {
250 if ( ( !mLanguagesDisabled.empty() &&
251 mLanguagesDisabled.find( doc->getSyntaxDefinition().getLSPName() ) !=
252 mLanguagesDisabled.end() ) ||
253 doc->isHuge() )
254 return;
255
256 ScopedOp op(
257 [this, doc]() {
258 std::lock_guard l( mWorkMutex );
259 mWorkersCount++;
260 },
261 [this]() {
262 {
263 std::lock_guard l( mWorkMutex );
264 mWorkersCount--;
265 }
266 mWorkerCondition.notify_all();
267 } );
268 if ( !mReady )
269 return;
270
271 mTyposFound = !Sys::which( SPELL_CHECKER_CMD ).empty();
272
273 if ( !mTyposFound )
274 return;
275
276 IOStreamString fileString;
277 mClock.restart();
278 if ( doc->isDirty() || !doc->hasFilepath() ) {
279 std::string tmpPath =
280 Sys::getTempPath() + ".ecode-" + doc->getFilename() + "." + String::randString( 8 );
281
282 doc->save( fileString, true );
283 FileSystem::fileWrite( tmpPath, (Uint8*)fileString.getStreamPointer(),
284 fileString.getSize() );
285 FileSystem::fileHide( tmpPath );
286 runSpellChecker( doc, tmpPath );
287 FileSystem::fileRemove( tmpPath );
288 } else {
289 runSpellChecker( doc, doc->getFilePath() );
290 }
291}
292
293void SpellCheckerPlugin::runSpellChecker( std::shared_ptr<TextDocument> doc,
294 const std::string& path ) {

Callers

nothing calls this directly

Calls 12

isHugeMethod · 0.80
hasFilepathMethod · 0.80
getFilenameMethod · 0.80
getStreamPointerMethod · 0.80
getFilePathMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
restartMethod · 0.45
isDirtyMethod · 0.45
saveMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected