File indexing completed on 2024-04-21 04:34:32

0001 /*
0002  * This file is part of KDevelop Krazy2 Plugin.
0003  *
0004  * Copyright 2012 Daniel Calviño Sánchez <danxuliu@gmail.com>
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License
0008  * as published by the Free Software Foundation; either version 2
0009  * of the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program. If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef ANALYSISPARAMETERS_H
0021 #define ANALYSISPARAMETERS_H
0022 
0023 #include <QList>
0024 #include <QStringList>
0025 
0026 class Checker;
0027 
0028 /**
0029  * Analysis parameters to run krazy2.
0030  * The AnalysisParameters stores the available checkers to run in the analysis,
0031  * the checkers to run in the analysis, and the files and directories to
0032  * analyze.
0033  */
0034 class AnalysisParameters {
0035 public:
0036 
0037     /**
0038      * Creates a new AnalysisParameters.
0039      */
0040     AnalysisParameters();
0041 
0042     /**
0043      * Deletes the available checkers.
0044      */
0045     virtual ~AnalysisParameters();
0046 
0047     /**
0048      * Returns whether the checkers were initialized or not.
0049      *
0050      * @return True if the checkers were initialized, false otherwise.
0051      */
0052     bool wereCheckersInitialized() const;
0053 
0054     /**
0055      * Initializes the checkers.
0056      * All the normal (not extra) checkers will be added to the checkers to run.
0057      * The AnalysisParameters takes ownership of the given checkers.
0058      *
0059      * @param availableCheckers The available checkers.
0060      */
0061     void initializeCheckers(const QList<const Checker*>& availableCheckers);
0062 
0063     /**
0064      * Returns the available checkers.
0065      *
0066      * @return The available checkers.
0067      */
0068     const QList<const Checker*>& availableCheckers() const;
0069 
0070     /**
0071      * Returns the checkers to run.
0072      *
0073      * @return The checkers to run.
0074      */
0075     const QList<const Checker*>& checkersToRun() const;
0076 
0077     /**
0078      * Sets the checkers to run.
0079      * If a checker is not in the list of available checkers it is ignored.
0080      *
0081      * @param checkersToRun The checkers to run.
0082      */
0083     void setCheckersToRun(const QList<const Checker*>& checkersToRun);
0084 
0085     /**
0086      * Returns the canonical file paths of the files to be analyzed.
0087      * The paths to directories are replaced by all the files in that directory
0088      * (and, recursively, in all its subdirectories).
0089      * Only local paths are taken into account.
0090      *
0091      * @return The canonical file paths of the files to be analyzed.
0092      */
0093     QStringList filesToBeAnalyzed() const;
0094 
0095     /**
0096      * Returns the files and directories.
0097      *
0098      * @return The files and directories.
0099      */
0100     const QStringList& filesAndDirectories() const;
0101 
0102     /**
0103      * Sets the paths to the files and directories.
0104      *
0105      * @param paths The paths.
0106      */
0107     void setFilesAndDirectories(const QStringList& paths);
0108 
0109 private:
0110 
0111     /**
0112      * Whether the checkers were initialized or not.
0113      */
0114     bool m_checkersInitialized;
0115 
0116     /**
0117      * The available checkers.
0118      */
0119     QList<const Checker*> m_availableCheckers;
0120 
0121     /**
0122      * The checkers to run.
0123      */
0124     QList<const Checker*> m_checkersToRun;
0125 
0126     /**
0127      * The paths to the files and directories.
0128      */
0129     QStringList m_filesAndDirectories;
0130 
0131     /**
0132      * Returns a list with the canonical file paths of all the files in the
0133      * given directory.
0134      *
0135      * @param directory The directory to get its files.
0136      * @return The canonical file paths.
0137      */
0138     QStringList findFiles(const QString& directory) const;
0139 
0140 };
0141 
0142 #endif