MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / parseFile

Function parseFile

src/plugins/chat/chatmanager.cpp:35–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33using namespace dpfservice;
34
35QJsonArray parseFile(QStringList files)
36{
37 QJsonArray result;
38 auto editorSrv = dpfGetService(EditorService);
39
40 for (auto file : files) {
41 QJsonObject obj;
42 obj["name"] = QFileInfo(file).fileName();
43 obj["language"] = support_file::Language::id(file);
44
45 QString fileContent = editorSrv->fileText(file);
46
47 if (fileContent.isEmpty()) {
48 QFile content(file);
49 if (content.open(QIODevice::ReadOnly)) {
50 obj["content"] = QString(content.read(20000));
51 }
52 } else {
53 obj["content"] = QString(fileContent.mid(0, 20000));
54 }
55 result.append(obj);
56 }
57
58 return result;
59}
60
61ChatManager *ChatManager::instance()
62{

Callers 1

promptPreProcessingMethod · 0.85

Calls 7

fileNameMethod · 0.80
QStringClass · 0.50
fileTextMethod · 0.45
isEmptyMethod · 0.45
openMethod · 0.45
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected