| 52 | } |
| 53 | |
| 54 | QFuture<LLMQore::ToolResult> ListProjectFilesTool::executeAsync(const QJsonObject &input) |
| 55 | { |
| 56 | Q_UNUSED(input) |
| 57 | |
| 58 | return QtConcurrent::run([this]() -> LLMQore::ToolResult { |
| 59 | QList<ProjectExplorer::Project *> projects = ProjectExplorer::ProjectManager::projects(); |
| 60 | if (projects.isEmpty()) { |
| 61 | QString error = "No projects found"; |
| 62 | throw LLMQore::ToolRuntimeError(error); |
| 63 | } |
| 64 | |
| 65 | QString result; |
| 66 | |
| 67 | for (auto project : projects) { |
| 68 | if (!project) |
| 69 | continue; |
| 70 | |
| 71 | Utils::FilePaths projectFiles = project->files(ProjectExplorer::Project::SourceFiles); |
| 72 | |
| 73 | if (projectFiles.isEmpty()) { |
| 74 | result += QString("Project '%1': No source files found\n\n") |
| 75 | .arg(project->displayName()); |
| 76 | continue; |
| 77 | } |
| 78 | |
| 79 | QStringList fileList; |
| 80 | QString projectPath = project->projectDirectory().toUrlishString(); |
| 81 | QString projectAbsolutePath = project->projectDirectory().toFSPathString(); |
| 82 | |
| 83 | for (const auto &filePath : projectFiles) { |
| 84 | QString absolutePath = filePath.toUrlishString(); |
| 85 | |
| 86 | if (m_ignoreManager->shouldIgnore(absolutePath, project)) { |
| 87 | LOG_MESSAGE( |
| 88 | QString("Ignoring file due to .qodeassistignore: %1").arg(absolutePath)); |
| 89 | continue; |
| 90 | } |
| 91 | |
| 92 | QString relativePath = QDir(projectPath).relativeFilePath(absolutePath); |
| 93 | fileList.append(relativePath); |
| 94 | } |
| 95 | |
| 96 | if (fileList.isEmpty()) { |
| 97 | result += QString("Project '%1': No files after applying .qodeassistignore\n\n") |
| 98 | .arg(project->displayName()); |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | fileList.sort(); |
| 103 | |
| 104 | result += QString("Project '%1' (%2 files):\n") |
| 105 | .arg(project->displayName()) |
| 106 | .arg(fileList.size()); |
| 107 | result += QString("Project root: %1\n\n").arg(projectAbsolutePath); |
| 108 | for (const QString &file : fileList) { |
| 109 | result += QString("- %1\n").arg(file); |
| 110 | } |
| 111 | result += "\n"; |
nothing calls this directly
no test coverage detected