File indexing completed on 2024-05-12 05:51:44

0001 /*  This file is part of the Kate project.
0002  *
0003  *  SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
0004  *
0005  *  SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 #include "clazycurrent.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include <KTextEditor/Document>
0012 #include <KTextEditor/MainWindow>
0013 #include <KTextEditor/View>
0014 
0015 KateProjectCodeAnalysisToolClazyCurrent::KateProjectCodeAnalysisToolClazyCurrent(QObject *parent)
0016     : KateProjectCodeAnalysisToolClazy(parent)
0017 {
0018 }
0019 
0020 QString KateProjectCodeAnalysisToolClazyCurrent::name() const
0021 {
0022     return i18n("Clazy - Current File");
0023 }
0024 
0025 QString KateProjectCodeAnalysisToolClazyCurrent::description() const
0026 {
0027     return i18n("clang-tidy is a clang-based C++ “linter” tool");
0028 }
0029 
0030 QStringList KateProjectCodeAnalysisToolClazyCurrent::arguments()
0031 {
0032     if (!m_project || !m_mainWindow || !m_mainWindow->activeView()) {
0033         return {};
0034     }
0035 
0036     QString compileCommandsDir = compileCommandsDirectory();
0037 
0038     QStringList args;
0039     if (!compileCommandsDir.isEmpty()) {
0040         args << QStringList{QStringLiteral("-p"), compileCommandsDir};
0041     }
0042     setActualFilesCount(1);
0043 
0044     const QString file = m_mainWindow->activeView()->document()->url().toLocalFile();
0045     args.append(file);
0046 
0047     return args;
0048 }