| 78 | } |
| 79 | |
| 80 | QString CodeLensTree::readLine(const QString &filePath, int line) |
| 81 | { |
| 82 | if (line < 0) |
| 83 | return {}; |
| 84 | |
| 85 | if (!editSrv) |
| 86 | editSrv = dpfGetService(EditorService); |
| 87 | |
| 88 | static QStringList openedFileList; |
| 89 | if (!onceReadFlag) { |
| 90 | openedFileList = editSrv->openedFiles(); |
| 91 | onceReadFlag = true; |
| 92 | } |
| 93 | |
| 94 | if (!openedFileList.contains(filePath)) |
| 95 | return readFileLine(filePath, line); |
| 96 | |
| 97 | auto fileText = editSrv->fileText(filePath); |
| 98 | auto textLines = fileText.split('\n'); |
| 99 | if (textLines.size() > line) |
| 100 | return textLines.at(line); |
| 101 | |
| 102 | return {}; |
| 103 | } |
| 104 | |
| 105 | QString CodeLensTree::readFileLine(const QString &filePath, int line) |
| 106 | { |
no test coverage detected