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

Method onSaveProject

src/tools/ecode/plugins/debugger/debuggerplugin.cpp:186–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void DebuggerPlugin::onSaveProject( const std::string& /*projectFolder*/,
187 const std::string& projectStatePath,
188 bool rewriteStateOnlyIfNeeded ) {
189 std::string debugger( mCurDebugger );
190 std::string configuration( mCurConfiguration );
191 auto expressions( mExpressions );
192 BreakpointsHolder breakpoints;
193 {
194 Lock l( mBreakpointsMutex );
195 breakpoints = mBreakpoints;
196 }
197 mThreadPool->run(
198 [this, debugger = std::move( debugger ), configuration = std::move( configuration ),
199 expressions = std::move( expressions ), breakpoints = std::move( breakpoints ),
200 projectStatePath, rewriteStateOnlyIfNeeded] {
201 nlohmann::json j;
202 auto& config = j["config"];
203 config["debugger"] = std::move( debugger );
204 config["configuration"] = std::move( configuration );
205 auto expArr = nlohmann::json::array();
206 for ( auto& expression : expressions )
207 expArr.push_back( expression );
208 config["expressions"] = std::move( expArr );
209
210 nlohmann::json bpsArr;
211 for ( auto& bpSet : breakpoints ) {
212 auto bpArr = nlohmann::json::array();
213 for ( auto& bp : bpSet.second ) {
214 nlohmann::json jbp;
215 jbp["line"] = bp.line;
216 jbp["enabled"] = bp.enabled;
217 bpArr.push_back( jbp );
218 }
219 if ( !bpArr.empty() )
220 bpsArr[bpSet.first] = std::move( bpArr );
221 }
222 config["breakpoints"] = std::move( bpsArr );
223
224 std::string stateString( j.dump() );
225 if ( stateString == mLastStateJsonDump )
226 return;
227
228 std::string debuggerStatePath( projectStatePath + "debugger.json" );
229 if ( rewriteStateOnlyIfNeeded && FileSystem::fileExists( debuggerStatePath ) &&
230 MD5::fromFile( debuggerStatePath ) == MD5::fromString( stateString ) )
231 return;
232 FileSystem::fileWrite( debuggerStatePath, stateString );
233 mLastStateJsonDump = stateString;
234 } );
235}
236
237void DebuggerPlugin::onLoadProject( const std::string& projectFolder,
238 const std::string& projectStatePath ) {

Callers

nothing calls this directly

Calls 4

fromStringFunction · 0.85
push_backMethod · 0.80
runMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected