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

Method insertFileToDocument

src/tools/ecode/plugins/aiassistant/chatui.cpp:3212–3245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3210}
3211
3212void LLMChatUI::insertFileToDocument( std::string path, std::shared_ptr<TextDocument> cdoc ) {
3213 std::string prjPath( getPlugin()->getPluginContext()->getCurrentProject() );
3214
3215 if ( FileSystem::isRelativePath( path ) )
3216 path = prjPath + path;
3217
3218 TextDocument doc;
3219 if ( doc.loadFromFile( path ) == TextDocument::LoadStatus::Loaded ) {
3220 std::string nameToDisplay = doc.getFilename();
3221 if ( !prjPath.empty() && String::startsWith( doc.getFilePath(), prjPath ) ) {
3222 nameToDisplay = doc.getFilePath();
3223 FileSystem::filePathRemoveBasePath( prjPath, nameToDisplay );
3224 }
3225 cdoc->resetSelection();
3226 cdoc->moveToEndOfLine();
3227 cdoc->textInput( "\n`" + nameToDisplay + "`:\n" );
3228 cdoc->textInput( "```" + doc.getSyntaxDefinition().getLSPName() );
3229 auto lineToFold = cdoc->getSelection().end().line();
3230 if ( doc.linesCount() >= 1 && !String::startsWith( doc.line( 0 ).getText(), "\n" ) ) {
3231 cdoc->textInput( "\n" );
3232 }
3233 cdoc->textInput( doc.getText() );
3234 if ( doc.linesCount() >= 1 &&
3235 doc.line( doc.linesCount() - 1 ).getText() != String( "\n" ) ) {
3236 cdoc->textInput( "\n" );
3237 }
3238 cdoc->textInput( "```\n" );
3239 cdoc->getFoldRangeService().findRegionsNative();
3240 if ( doc.linesCount() > 30 &&
3241 cdoc->getFoldRangeService().isFoldingRegionInLine( lineToFold ) ) {
3242 mChatInput->toggleFoldUnfold( lineToFold );
3243 }
3244 }
3245}
3246
3247void LLMChatUI::initAttachFile() {
3248 mLocateBarLayout = findByClass<UIVLinearLayoutCommandExecuter>( "llm_chat_attach" );

Callers

nothing calls this directly

Calls 15

getFilenameMethod · 0.80
getFilePathMethod · 0.80
resetSelectionMethod · 0.80
textInputMethod · 0.80
linesCountMethod · 0.80
findRegionsNativeMethod · 0.80
isFoldingRegionInLineMethod · 0.80
toggleFoldUnfoldMethod · 0.80
getPluginContextMethod · 0.45
loadFromFileMethod · 0.45
emptyMethod · 0.45
moveToEndOfLineMethod · 0.45

Tested by

no test coverage detected