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

Method setData

src/plugins/codeeditor/codelens/codelenstree.cpp:46–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void CodeLensTree::setData(const lsp::References &refs)
47{
48 onceReadFlag = false;
49 auto model = qobject_cast<QStandardItemModel *>(CodeLensTree::model());
50 model->clear();
51 QHash<QString, QStandardItem *> cache {};
52 for (auto ref : refs) {
53 lsp::Range range = ref.range;
54 if (range.start.line != range.end.line)
55 continue;
56
57 QString filePath = ref.fileUrl.toLocalFile();
58 QStandardItem *fileItem = nullptr;
59 if (cache.contains(filePath)) {
60 fileItem = cache[filePath];
61 } else {
62 fileItem = new QStandardItem(filePath);
63 cache[filePath] = fileItem;
64 model->appendRow(fileItem);
65 }
66
67 QString text = readLine(filePath, range.start.line);
68 if (text.isEmpty())
69 continue;
70
71 QStandardItem *item = new QStandardItem(text);
72 item->setData(range.start.line, CodeLensItemRole::LineRole);
73 item->setData(range.start.character, CodeLensItemRole::TermStartRole);
74 item->setData(range.end.character, CodeLensItemRole::TermEndRole);
75 item->setTextAlignment(Qt::AlignVCenter);
76 fileItem->appendRow(item);
77 }
78}
79
80QString CodeLensTree::readLine(const QString &filePath, int line)
81{

Callers 8

createRowsMethod · 0.45
createRowMethod · 0.45
createConsoleMethod · 0.45
displayMethod · 0.45
createSymbolItemMethod · 0.45
setSymbolPathMethod · 0.45
displayReferenceMethod · 0.45
setOpenedFilesMethod · 0.45

Calls 6

modelClass · 0.85
readLineFunction · 0.85
clearMethod · 0.45
containsMethod · 0.45
appendRowMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected