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

Method lintDoc

src/tools/ecode/plugins/linter/linterplugin.cpp:794–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794void LinterPlugin::lintDoc( std::shared_ptr<TextDocument> doc ) {
795 if ( mShuttingDown )
796 return;
797
798 if ( !mLanguagesDisabled.empty() &&
799 mLanguagesDisabled.find( doc->getSyntaxDefinition().getLSPName() ) !=
800 mLanguagesDisabled.end() )
801 return;
802
803 ScopedOp op(
804 [this, doc]() {
805 std::lock_guard l( mWorkMutex );
806 mWorkersCount++;
807 },
808 [this]() {
809 {
810 std::lock_guard l( mWorkMutex );
811 mWorkersCount--;
812 }
813 mWorkerCondition.notify_all();
814 } );
815
816 if ( !mReady || mShuttingDown )
817 return;
818 auto linter = supportsLinter( doc );
819 if ( linter.command.empty() )
820 return;
821
822 bool binaryFound = linter.isNative;
823 if ( !linter.isNative ) {
824 auto parts = String::split( linter.command, ' ' );
825 if ( !parts.empty() ) {
826 if ( parts[0].find_first_of( "\\/" ) != std::string::npos ) {
827 binaryFound = FileSystem::fileExists( parts[0] );
828 } else {
829 binaryFound = !Sys::which( parts[0] ).empty();
830 }
831 }
832 }
833 if ( !binaryFound )
834 return;
835
836 IOStreamString fileString;
837 mClock.restart();
838 if ( doc->isDirty() || !doc->hasFilepath() ) {
839 std::string tmpPath;
840 if ( !doc->hasFilepath() ) {
841 tmpPath =
842 Sys::getTempPath() + ".ecode-" + doc->getFilename() + "." + String::randString( 8 );
843 } else if ( linter.useTmpFolder ) {
844 tmpPath = Sys::getTempPath() + doc->getFilename();
845 if ( FileSystem::fileExists( tmpPath ) ) {
846 tmpPath = Sys::getTempPath() + ".ecode-" + doc->getFilename() + "." +
847 String::randString( 8 );
848 }
849 } else {
850 std::string fileDir( FileSystem::fileRemoveFileName( doc->getFilePath() ) );
851 FileSystem::dirAddSlashAtEnd( fileDir );

Callers

nothing calls this directly

Calls 12

find_first_ofMethod · 0.80
hasFilepathMethod · 0.80
getFilenameMethod · 0.80
getFilePathMethod · 0.80
getStreamPointerMethod · 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