MCPcopy Create free account
hub / github.com/Palm1r/QodeAssist / readFileContent

Method readFileContent

context/ChangesManager.cpp:1083–1113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081}
1082
1083QString ChangesManager::readFileContent(const QString &filePath) const
1084{
1085 LOG_MESSAGE(QString("Reading current file content: %1").arg(filePath));
1086
1087 auto editors = Core::EditorManager::visibleEditors();
1088 for (auto *editor : editors) {
1089 if (!editor || !editor->document()) {
1090 continue;
1091 }
1092
1093 QString editorPath = editor->document()->filePath().toFSPathString();
1094 if (editorPath == filePath) {
1095 QByteArray contentBytes = editor->document()->contents();
1096 QString content = QString::fromUtf8(contentBytes);
1097 LOG_MESSAGE(QString(" Read from open editor: %1 bytes").arg(content.size()));
1098 return content;
1099 }
1100 }
1101
1102 QFile file(filePath);
1103 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1104 LOG_MESSAGE(QString(" Failed to read file: %1").arg(file.errorString()));
1105 return QString();
1106 }
1107
1108 QString content = QString::fromUtf8(file.readAll());
1109 file.close();
1110
1111 LOG_MESSAGE(QString(" Read from disk: %1 bytes").arg(content.size()));
1112 return content;
1113}
1114
1115bool ChangesManager::performFileEditWithDiff(
1116 const QString &filePath,

Callers

nothing calls this directly

Calls 4

documentMethod · 0.80
contentsMethod · 0.80
sizeMethod · 0.80
filePathMethod · 0.45

Tested by

no test coverage detected