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

Method replaceInVal

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

Source from the content-addressed store, hash-verified

1172}
1173
1174bool DebuggerPlugin::replaceInVal( std::string& val,
1175 const std::optional<ProjectBuildStep>& runConfig,
1176 ProjectBuild* buildConfig, int randomPort ) {
1177
1178 if ( runConfig ) {
1179 String::replaceAll( val, KEY_FILE, runConfig->cmd );
1180 String::replaceAll( val, KEY_CWD, runConfig->workingDir );
1181 String::replaceAll( val, KEY_FILEDIRNAME, runConfig->workingDir );
1182 std::string fileRelativePath( runConfig->cmd );
1183 FileSystem::filePathRemoveBasePath( mProjectPath, fileRelativePath );
1184 String::replaceAll( val, KEY_RELATIVE_FILE, fileRelativePath );
1185 std::string fileDirName( FileSystem::fileRemoveFileName( fileRelativePath ) );
1186 FileSystem::dirRemoveSlashAtEnd( fileDirName );
1187 String::replaceAll( val, KEY_RELATIVE_FILE_DIRNAME, fileDirName );
1188 String::replaceAll( val, KEY_FILE_BASENAME,
1189 FileSystem::fileNameFromPath( fileRelativePath ) );
1190 String::replaceAll(
1191 val, KEY_FILE_BASENAME_NOEXTENSION,
1192 FileSystem::fileRemoveExtension( FileSystem::fileNameFromPath( fileRelativePath ) ) );
1193 String::replaceAll( val, KEY_FILE_EXTNAME, FileSystem::fileExtension( fileRelativePath ) );
1194 String::replaceAll( val, KEY_FILE_DIRNAME_BASENAME,
1195 FileSystem::fileNameFromPath( fileDirName ) );
1196 }
1197
1198 if ( buildConfig ) {
1199 String::replaceAll( val, KEY_DEFAULT_BUILD_TASK, buildConfig->getName() );
1200 }
1201
1202 String::replaceAll( val, KEY_WORKSPACEFOLDER, mProjectPath );
1203 String::replaceAll( val, KEY_WORKSPACEROOT, mProjectPath );
1204 String::replaceAll( val, KEY_USER_HOME, Sys::getUserDirectory() );
1205 String::replaceAll( val, KEY_WORKSPACEFOLDER_BASENAME,
1206 FileSystem::fileNameFromPath( mProjectPath ) );
1207 String::replaceAll( val, KEY_FILE_WORKSPACEFOLDER, mProjectPath );
1208 String::replaceAll( val, KEY_EXEC_PATH, Sys::getProcessFilePath() );
1209 String::replaceAll( val, KEY_PATH_SEPARATOR, FileSystem::getOSSlash() );
1210 String::replaceAll( val, KEY_PATH_SEPARATOR_ABBR, FileSystem::getOSSlash() );
1211 String::replaceAll( val, KEY_UUID, UUID().toString() );
1212 String::replaceAll( val, KEY_TIMESTAMP,
1213 std::to_string( std::chrono::system_clock::to_time_t(
1214 std::chrono::system_clock::now() ) ) );
1215
1216 auto* editor = getPluginContext()->getSplitter()->getCurEditor();
1217 if ( getPluginContext()->getSplitter()->getCurEditor() ) {
1218 String::replaceAll(
1219 val, KEY_LINE_NUMBER,
1220 String::toString( editor->getDocument().getSelection().start().line() ) );
1221 String::replaceAll( val, KEY_SELECTED_TEXT,
1222 editor->getDocument().getSelectedText().toUtf8() );
1223 }
1224
1225 if ( String::contains( val, KEY_RANDPORT ) )
1226 String::replaceAll( val, KEY_RANDPORT, String::toString( randomPort ) );
1227
1228 return replaceEnvVars( val, this->getPluginContext() );
1229}
1230
1231std::pair<bool, std::vector<std::string>> DebuggerPlugin::replaceKeyInString(

Callers

nothing calls this directly

Calls 14

UUIDFunction · 0.85
replaceEnvVarsFunction · 0.85
getCurEditorMethod · 0.80
getDocumentMethod · 0.80
toUtf8Method · 0.80
getSelectedTextMethod · 0.80
toStringFunction · 0.50
containsFunction · 0.50
getNameMethod · 0.45
toStringMethod · 0.45
getSplitterMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected