data: Option to run only C/C++ preprocessor when indexing (issue 297)
* Added as checkbox to indexing start dialog * Only shown for C/C++ projects * Files will be marked incomplete
This commit is contained in:
@@ -25,10 +25,10 @@ void DialogView::hideProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
DialogView::IndexMode DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh
|
||||
){
|
||||
return INDEX_ABORT;
|
||||
DialogView::IndexingOptions DialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options)
|
||||
{
|
||||
return IndexingOptions();
|
||||
}
|
||||
|
||||
void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath)
|
||||
|
||||
@@ -11,11 +11,23 @@ class StorageAccess;
|
||||
class DialogView
|
||||
{
|
||||
public:
|
||||
enum IndexMode
|
||||
struct IndexingOptions
|
||||
{
|
||||
INDEX_ABORT,
|
||||
INDEX_REFRESH,
|
||||
INDEX_FULL
|
||||
IndexingOptions()
|
||||
: startIndexing(false)
|
||||
, fullRefreshVisible(false)
|
||||
, fullRefresh(false)
|
||||
, preprocessorOnlyVisible(false)
|
||||
, preprocessorOnly(false)
|
||||
{}
|
||||
|
||||
bool startIndexing;
|
||||
|
||||
bool fullRefreshVisible;
|
||||
bool fullRefresh;
|
||||
|
||||
bool preprocessorOnlyVisible;
|
||||
bool preprocessorOnly;
|
||||
};
|
||||
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
@@ -27,8 +39,8 @@ public:
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
virtual IndexMode startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh);
|
||||
virtual IndexingOptions startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, IndexingOptions options);
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
virtual void finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
|
||||
@@ -57,7 +57,7 @@ std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::in
|
||||
|
||||
parserClient->resetStorage();
|
||||
|
||||
if (parserClient->hasFatalErrors())
|
||||
if (parserClient->hasFatalErrors() || indexerCommand->preprocessorOnly())
|
||||
{
|
||||
storage->setAllFilesIncomplete();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ public:
|
||||
bool cancelOnFatalErrors() const;
|
||||
void setCancelOnFatalErrors(bool cancelOnFatalErrors);
|
||||
|
||||
virtual bool preprocessorOnly() const = 0;
|
||||
virtual void setPreprocessorOnly(bool preprocessorOnly) = 0;
|
||||
|
||||
private:
|
||||
FilePath m_sourceFilePath;
|
||||
std::set<FilePath> m_indexedPaths;
|
||||
|
||||
+30
-16
@@ -336,33 +336,45 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
}
|
||||
|
||||
std::set<FilePath> filesToIndex;
|
||||
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
sourceGroup->fetchSourceFilePathsToIndex(staticSourceFilePaths);
|
||||
utility::append(filesToIndex, sourceGroup->getSourceFilePathsToIndex());
|
||||
}
|
||||
|
||||
|
||||
bool hasCXXSourceGroup = false;
|
||||
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
|
||||
{
|
||||
if (sourceGroup->getLanguage() == LANGUAGE_C || sourceGroup->getLanguage() == LANGUAGE_CPP)
|
||||
{
|
||||
hasCXXSourceGroup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool fullRefresh = forceRefresh | needsFullRefresh;
|
||||
bool preprocessorOnly = false;
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
DialogView::IndexMode mode = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(),
|
||||
forceRefresh, needsFullRefresh
|
||||
);
|
||||
DialogView::IndexingOptions options;
|
||||
options.fullRefreshVisible = !needsFullRefresh;
|
||||
options.fullRefresh = forceRefresh;
|
||||
|
||||
switch (mode)
|
||||
options.preprocessorOnlyVisible = hasCXXSourceGroup;
|
||||
options.preprocessorOnly = false;
|
||||
|
||||
options = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(), options);
|
||||
|
||||
if (!options.startIndexing)
|
||||
{
|
||||
case DialogView::INDEX_ABORT:
|
||||
return false;
|
||||
case DialogView::INDEX_REFRESH:
|
||||
fullRefresh = false;
|
||||
break;
|
||||
case DialogView::INDEX_FULL:
|
||||
fullRefresh = true;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
fullRefresh = options.fullRefresh | needsFullRefresh;
|
||||
preprocessorOnly = options.preprocessorOnly;
|
||||
}
|
||||
|
||||
if (fullRefresh)
|
||||
@@ -379,12 +391,12 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
|
||||
MessageStatus((fullRefresh ? "Reindexing Project" : "Refreshing Project"), false, true).dispatch();
|
||||
|
||||
buildIndex(filesToClean, fullRefresh);
|
||||
buildIndex(filesToClean, fullRefresh, preprocessorOnly);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh)
|
||||
void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh, bool preprocessorOnly)
|
||||
{
|
||||
MessageClearErrorCount().dispatch();
|
||||
|
||||
@@ -414,6 +426,8 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
|
||||
for (std::shared_ptr<IndexerCommand> command: sourceGroup->getIndexerCommands(fullRefresh))
|
||||
{
|
||||
command->setCancelOnFatalErrors(cancelIndexingOnFatalErrors);
|
||||
command->setPreprocessorOnly(preprocessorOnly);
|
||||
|
||||
indexerCommandList->addCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public: // todo: make private again
|
||||
private:
|
||||
bool requestIndex(bool forceRefresh, bool needsFullRefresh);
|
||||
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh);
|
||||
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh, bool preprocessorOnly);
|
||||
|
||||
std::shared_ptr<ProjectSettings> m_settings;
|
||||
StorageAccessProxy* const m_storageAccessProxy;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
add_files(
|
||||
LIB_CXX_FILES
|
||||
|
||||
data/indexer/IndexerCommandCxx.cpp
|
||||
data/indexer/IndexerCommandCxx.h
|
||||
data/indexer/IndexerCommandCxxCdb.cpp
|
||||
data/indexer/IndexerCommandCxxCdb.h
|
||||
data/indexer/IndexerCommandCxxManual.cpp
|
||||
@@ -33,7 +35,6 @@ add_files(
|
||||
data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp
|
||||
data/parser/cxx/name_resolver/CxxTypeNameResolver.h
|
||||
|
||||
data/parser/cxx/ASTAction.cpp
|
||||
data/parser/cxx/ASTAction.h
|
||||
data/parser/cxx/ASTActionFactory.cpp
|
||||
data/parser/cxx/ASTActionFactory.h
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "data/indexer/IndexerCommandCxx.h"
|
||||
|
||||
IndexerCommandCxx::IndexerCommandCxx(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
const std::vector<std::string>& compilerFlags
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
, m_systemHeaderSearchPaths(systemHeaderSearchPaths)
|
||||
, m_frameworkSearchPaths(frameworkSearchPaths)
|
||||
, m_compilerFlags(compilerFlags)
|
||||
, m_preprocessorOnly(false)
|
||||
{
|
||||
}
|
||||
|
||||
IndexerCommandCxx::~IndexerCommandCxx()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxx::getSystemHeaderSearchPaths() const
|
||||
{
|
||||
return m_systemHeaderSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxx::getFrameworkSearchPaths() const
|
||||
{
|
||||
return m_frameworkSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> IndexerCommandCxx::getCompilerFlags() const
|
||||
{
|
||||
return m_compilerFlags;
|
||||
}
|
||||
|
||||
bool IndexerCommandCxx::preprocessorOnly() const
|
||||
{
|
||||
return m_preprocessorOnly;
|
||||
}
|
||||
|
||||
void IndexerCommandCxx::setPreprocessorOnly(bool preprocessorOnly)
|
||||
{
|
||||
m_preprocessorOnly = preprocessorOnly;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef INDEXER_COMMAND_CXX_H
|
||||
#define INDEXER_COMMAND_CXX_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class IndexerCommandCxx
|
||||
: public IndexerCommand
|
||||
{
|
||||
public:
|
||||
IndexerCommandCxx(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
const std::vector<std::string>& compilerFlags);
|
||||
|
||||
virtual ~IndexerCommandCxx();
|
||||
|
||||
std::vector<FilePath> getSystemHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
|
||||
bool preprocessorOnly() const override;
|
||||
void setPreprocessorOnly(bool preprocessorOnly) override;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> m_systemHeaderSearchPaths;
|
||||
std::vector<FilePath> m_frameworkSearchPaths;
|
||||
std::vector<std::string> m_compilerFlags;
|
||||
|
||||
bool m_preprocessorOnly;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_CXXL_H
|
||||
@@ -35,11 +35,8 @@ IndexerCommandCxxCdb::IndexerCommandCxxCdb(
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludedPaths, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
, m_workingDirectory(workingDirectory)
|
||||
, m_compilerFlags(compilerFlags)
|
||||
, m_systemHeaderSearchPaths(systemHeaderSearchPaths)
|
||||
, m_frameworkSearchPaths(frameworkSearchPaths)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,18 +53,3 @@ FilePath IndexerCommandCxxCdb::getWorkingDirectory() const
|
||||
{
|
||||
return m_workingDirectory;
|
||||
}
|
||||
|
||||
std::vector<std::string> IndexerCommandCxxCdb::getCompilerFlags() const
|
||||
{
|
||||
return m_compilerFlags;
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxxCdb::getSystemHeaderSearchPaths() const
|
||||
{
|
||||
return m_systemHeaderSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxxCdb::getFrameworkSearchPaths() const
|
||||
{
|
||||
return m_frameworkSearchPaths;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#ifndef INDEXER_COMMAND_CXX_CDB_H
|
||||
#define INDEXER_COMMAND_CXX_CDB_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
#include "data/indexer/IndexerCommandCxx.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
namespace clang
|
||||
@@ -14,7 +12,8 @@ namespace clang
|
||||
}
|
||||
}
|
||||
|
||||
class IndexerCommandCxxCdb: public IndexerCommand
|
||||
class IndexerCommandCxxCdb
|
||||
: public IndexerCommandCxx
|
||||
{
|
||||
public:
|
||||
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
|
||||
@@ -34,15 +33,9 @@ public:
|
||||
virtual std::string getKindString() const;
|
||||
|
||||
FilePath getWorkingDirectory() const;
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
std::vector<FilePath> getSystemHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
|
||||
private:
|
||||
FilePath m_workingDirectory;
|
||||
std::vector<std::string> m_compilerFlags;
|
||||
std::vector<FilePath> m_systemHeaderSearchPaths;
|
||||
std::vector<FilePath> m_frameworkSearchPaths;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_CXX_CDB_H
|
||||
|
||||
@@ -15,11 +15,8 @@ IndexerCommandCxxManual::IndexerCommandCxxManual(
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
const std::vector<std::string>& compilerFlags
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludedPaths, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
, m_languageStandard(languageStandard)
|
||||
, m_systemHeaderSearchPaths(systemHeaderSearchPaths)
|
||||
, m_frameworkSearchPaths(frameworkSearchPaths)
|
||||
, m_compilerFlags(compilerFlags)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,18 +33,3 @@ std::string IndexerCommandCxxManual::getLanguageStandard() const
|
||||
{
|
||||
return m_languageStandard;
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxxManual::getSystemHeaderSearchPaths() const
|
||||
{
|
||||
return m_systemHeaderSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> IndexerCommandCxxManual::getFrameworkSearchPaths() const
|
||||
{
|
||||
return m_frameworkSearchPaths;
|
||||
}
|
||||
|
||||
std::vector<std::string> IndexerCommandCxxManual::getCompilerFlags() const
|
||||
{
|
||||
return m_compilerFlags;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
#ifndef INDEXER_COMMAND_CXX_MANUAL_H
|
||||
#define INDEXER_COMMAND_CXX_MANUAL_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
#include "data/indexer/IndexerCommandCxx.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class IndexerCommandCxxManual: public IndexerCommand
|
||||
class IndexerCommandCxxManual
|
||||
: public IndexerCommandCxx
|
||||
{
|
||||
public:
|
||||
static std::string getIndexerKindString();
|
||||
@@ -25,15 +23,9 @@ public:
|
||||
virtual std::string getKindString() const;
|
||||
|
||||
std::string getLanguageStandard() const;
|
||||
std::vector<FilePath> getSystemHeaderSearchPaths() const;
|
||||
std::vector<FilePath> getFrameworkSearchPaths() const;
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
|
||||
private:
|
||||
std::string m_languageStandard;
|
||||
std::vector<FilePath> m_systemHeaderSearchPaths;
|
||||
std::vector<FilePath> m_frameworkSearchPaths;
|
||||
std::vector<std::string> m_compilerFlags;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_CXX_MANUAL_H
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "data/parser/cxx/ASTAction.h"
|
||||
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
|
||||
#include "data/parser/cxx/CommentHandler.h"
|
||||
#include "data/parser/cxx/PreprocessorCallbacks.h"
|
||||
|
||||
ASTAction::ASTAction(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
||||
: m_client(client)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_commentHandler(client, fileRegister)
|
||||
{
|
||||
}
|
||||
|
||||
ASTAction::~ASTAction()
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<clang::ASTConsumer> ASTAction::CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile)
|
||||
{
|
||||
return std::unique_ptr<clang::ASTConsumer>(new ASTConsumer(&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_fileRegister));
|
||||
}
|
||||
|
||||
bool ASTAction::BeginSourceFileAction(clang::CompilerInstance& compiler, llvm::StringRef filePath)
|
||||
{
|
||||
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
|
||||
preprocessor.addPPCallbacks(
|
||||
llvm::make_unique<PreprocessorCallbacks>(compiler.getSourceManager(), m_client, m_fileRegister));
|
||||
preprocessor.addCommentHandler(&m_commentHandler);
|
||||
return true;
|
||||
}
|
||||
@@ -5,27 +5,46 @@
|
||||
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Frontend/FrontendAction.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
|
||||
#include "data/parser/cxx/ASTConsumer.h"
|
||||
#include "data/parser/cxx/CommentHandler.h"
|
||||
#include "data/parser/cxx/PreprocessorCallbacks.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
class ASTAction : public clang::ASTFrontendAction
|
||||
template <typename ASTActionBase>
|
||||
class ASTAction
|
||||
: public ASTActionBase
|
||||
{
|
||||
public:
|
||||
explicit ASTAction(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
|
||||
virtual ~ASTAction();
|
||||
explicit ASTAction(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
||||
: m_client(client)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_commentHandler(client, fileRegister)
|
||||
{}
|
||||
|
||||
virtual ~ASTAction() {}
|
||||
|
||||
protected:
|
||||
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile);
|
||||
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance& compiler, llvm::StringRef inFile)
|
||||
{
|
||||
return std::unique_ptr<clang::ASTConsumer>(
|
||||
new ASTConsumer(&compiler.getASTContext(), &compiler.getPreprocessor(), m_client, m_fileRegister));
|
||||
}
|
||||
|
||||
virtual bool BeginSourceFileAction(clang::CompilerInstance& compiler, llvm::StringRef filePath);
|
||||
virtual bool BeginSourceFileAction(clang::CompilerInstance& compiler, llvm::StringRef filePath)
|
||||
{
|
||||
clang::Preprocessor& preprocessor = compiler.getPreprocessor();
|
||||
preprocessor.addPPCallbacks(
|
||||
llvm::make_unique<PreprocessorCallbacks>(compiler.getSourceManager(), m_client, m_fileRegister));
|
||||
preprocessor.addCommentHandler(&m_commentHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ParserClient> m_client;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
CommentHandler m_commentHandler;
|
||||
|
||||
};
|
||||
|
||||
#endif // AST_ACTION_H
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
#include "data/parser/cxx/ASTActionFactory.h"
|
||||
|
||||
ASTActionFactory::ASTActionFactory(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
|
||||
#include "clang/Frontend/FrontendActions.h"
|
||||
|
||||
ASTActionFactory::ASTActionFactory(
|
||||
std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister, bool preprocessorOnly
|
||||
)
|
||||
: m_client(client)
|
||||
, m_fileRegister(fileRegister)
|
||||
, m_preprocessorOnly(preprocessorOnly)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -12,5 +17,12 @@ ASTActionFactory::~ASTActionFactory()
|
||||
|
||||
clang::FrontendAction* ASTActionFactory::create()
|
||||
{
|
||||
return new ASTAction(m_client, m_fileRegister);
|
||||
if (m_preprocessorOnly)
|
||||
{
|
||||
return new ASTAction<clang::PreprocessOnlyAction>(m_client, m_fileRegister);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ASTAction<clang::ASTFrontendAction>(m_client, m_fileRegister);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
#include "data/parser/cxx/ASTAction.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
class ASTActionFactory : public clang::tooling::FrontendActionFactory
|
||||
class ASTActionFactory
|
||||
: public clang::tooling::FrontendActionFactory
|
||||
{
|
||||
public:
|
||||
explicit ASTActionFactory(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
|
||||
explicit ASTActionFactory(
|
||||
std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister, bool preprocessorOnly);
|
||||
virtual ~ASTActionFactory();
|
||||
|
||||
virtual clang::FrontendAction* create();
|
||||
@@ -17,6 +19,8 @@ public:
|
||||
private:
|
||||
std::shared_ptr<ParserClient> m_client;
|
||||
std::shared_ptr<FileRegister> m_fileRegister;
|
||||
|
||||
bool m_preprocessorOnly;
|
||||
};
|
||||
|
||||
#endif // AST_ACTION_FACTORY
|
||||
|
||||
@@ -84,7 +84,7 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(true);
|
||||
tool.setDiagnosticConsumer(diagnostics.get());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister);
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, indexerCommand->preprocessorOnly());
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
|
||||
@@ -97,14 +97,14 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxManual> indexerComma
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(true);
|
||||
tool.setDiagnosticConsumer(diagnostics.get());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister);
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, indexerCommand->preprocessorOnly());
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
|
||||
void CxxParser::buildIndex(const std::string& fileName, std::shared_ptr<TextAccess> fileContent)
|
||||
{
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(false);
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister);
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, false);
|
||||
|
||||
std::vector<std::string> args = getCommandlineArgumentsEssential(std::vector<std::string>(1, "-std=c++1z"), std::vector<FilePath>(), std::vector<FilePath>());
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ add_files(
|
||||
qt/element/QtDirectoryListBox.h
|
||||
qt/element/QtFontPicker.cpp
|
||||
qt/element/QtFontPicker.h
|
||||
qt/element/QtHelpButton.cpp
|
||||
qt/element/QtHelpButton.h
|
||||
qt/element/QtIconButton.cpp
|
||||
qt/element/QtIconButton.h
|
||||
qt/element/QtLineEdit.cpp
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
|
||||
: QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
|
||||
parent)
|
||||
, m_helpText(helpText)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setMouseTracking(true);
|
||||
|
||||
setToolTip("help");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
|
||||
}
|
||||
|
||||
void QtHelpButton::handleHelpPress()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Help");
|
||||
msgBox.setInformativeText(m_helpText);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef QT_HELP_BUTTON_H
|
||||
#define QT_HELP_BUTTON_H
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
class QtHelpButton
|
||||
: public QtIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void handleHelpPress();
|
||||
|
||||
private:
|
||||
QString m_helpText;
|
||||
};
|
||||
|
||||
#endif // QT_HELP_BUTTON_H
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "qt/element/QtIconButton.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent)
|
||||
: QPushButton("", parent)
|
||||
, m_iconPath(iconPath)
|
||||
, m_hoveredIconPath(hoveredIconPath)
|
||||
, m_color(Qt::transparent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
@@ -14,11 +17,17 @@ QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* p
|
||||
leaveEvent(nullptr);
|
||||
}
|
||||
|
||||
void QtIconButton::setColor(QColor color)
|
||||
{
|
||||
m_color = color;
|
||||
leaveEvent(nullptr);
|
||||
}
|
||||
|
||||
void QtIconButton::enterEvent(QEvent *event)
|
||||
{
|
||||
if (m_hoveredIconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_hoveredIconPath)));
|
||||
setIconFromPath(m_hoveredIconPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +35,18 @@ void QtIconButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
if (m_iconPath.size())
|
||||
{
|
||||
setIcon(QIcon(QPixmap(m_iconPath)));
|
||||
setIconFromPath(m_iconPath);
|
||||
}
|
||||
}
|
||||
|
||||
void QtIconButton::setIconFromPath(QString path)
|
||||
{
|
||||
QPixmap pixmap = QPixmap(path);
|
||||
|
||||
if (m_color != Qt::transparent)
|
||||
{
|
||||
pixmap = utility::colorizePixmap(pixmap, m_color);
|
||||
}
|
||||
|
||||
setIcon(QIcon(pixmap));
|
||||
}
|
||||
|
||||
@@ -9,13 +9,19 @@ class QtIconButton
|
||||
public:
|
||||
QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent = nullptr);
|
||||
|
||||
void setColor(QColor color);
|
||||
|
||||
protected:
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
|
||||
private:
|
||||
void setIconFromPath(QString path);
|
||||
|
||||
QString m_iconPath;
|
||||
QString m_hoveredIconPath;
|
||||
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
#endif // QT_ICON_BUTTON_H
|
||||
|
||||
@@ -111,23 +111,20 @@ void QtDialogView::hideProgressDialog()
|
||||
}
|
||||
|
||||
|
||||
DialogView::IndexMode QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh)
|
||||
DialogView::IndexingOptions QtDialogView::startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options)
|
||||
{
|
||||
IndexMode result = INDEX_ABORT;
|
||||
DialogView::IndexingOptions result;
|
||||
m_resultReady = false;
|
||||
|
||||
m_onQtThread(
|
||||
[=, &result]()
|
||||
{
|
||||
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, forceRefresh, needsFullRefresh,
|
||||
[&](bool start, bool fullRefresh)
|
||||
window->setupStart(cleanFileCount, indexFileCount, totalFileCount, options,
|
||||
[&](DialogView::IndexingOptions o)
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
result = (!fullRefresh && !needsFullRefresh ? INDEX_REFRESH : INDEX_FULL);
|
||||
}
|
||||
result = o;
|
||||
m_resultReady = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress) override;
|
||||
virtual void hideProgressDialog() override;
|
||||
|
||||
virtual DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh) override;
|
||||
virtual DialogView::IndexingOptions startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, DialogView::IndexingOptions options) override;
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
|
||||
virtual void finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
#include "qt/element/QtProgressBar.h"
|
||||
#include "utility/messaging/type/MessageInterruptTasks.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
@@ -22,11 +23,11 @@ QtIndexingDialog::QtIndexingDialog(QWidget* parent)
|
||||
, m_messageLabel(nullptr)
|
||||
, m_filePathLabel(nullptr)
|
||||
, m_errorLabel(nullptr)
|
||||
, m_checkBox(nullptr)
|
||||
, m_fullRefreshCheckBox(nullptr)
|
||||
, m_preprocessorOnlyCheckBox(nullptr)
|
||||
, m_sizeHint(QSize(450, 450))
|
||||
, m_callback([](bool, bool){})
|
||||
, m_callback([](DialogView::IndexingOptions){})
|
||||
{
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
setSizeGripStyle(false);
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ QtIndexingDialog::DialogType QtIndexingDialog::getType() const
|
||||
|
||||
void QtIndexingDialog::setupStart(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback)
|
||||
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback)
|
||||
{
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
@@ -59,46 +60,65 @@ void QtIndexingDialog::setupStart(
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
if (needsFullRefresh)
|
||||
if (options.fullRefreshVisible)
|
||||
{
|
||||
m_fullRefreshCheckBox = new QCheckBox("full refresh", this);
|
||||
m_fullRefreshCheckBox->setObjectName("message");
|
||||
|
||||
connect(m_fullRefreshCheckBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
clearLabel->setVisible(!checked);
|
||||
indexLabel->setVisible(!checked);
|
||||
fullLabel->setVisible(checked);
|
||||
}
|
||||
);
|
||||
|
||||
m_fullRefreshCheckBox->setChecked(!options.fullRefresh);
|
||||
m_fullRefreshCheckBox->setChecked(options.fullRefresh);
|
||||
|
||||
QHBoxLayout* subLayout = new QHBoxLayout();
|
||||
subLayout->addStretch();
|
||||
subLayout->addWidget(m_fullRefreshCheckBox);
|
||||
|
||||
layout->addLayout(subLayout);
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
}
|
||||
else
|
||||
|
||||
if (options.preprocessorOnlyVisible)
|
||||
{
|
||||
m_checkBox = new QCheckBox("full refresh", this);
|
||||
m_checkBox->setObjectName("message");
|
||||
m_preprocessorOnlyCheckBox = new QCheckBox("C/C++ preprocessor only", this);
|
||||
m_preprocessorOnlyCheckBox->setObjectName("message");
|
||||
m_preprocessorOnlyCheckBox->setChecked(options.preprocessorOnly);
|
||||
|
||||
connect(m_checkBox, static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::toggled),
|
||||
[=](bool checked = false)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
clearLabel->hide();
|
||||
indexLabel->hide();
|
||||
fullLabel->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
clearLabel->show();
|
||||
indexLabel->show();
|
||||
fullLabel->hide();
|
||||
}
|
||||
}
|
||||
);
|
||||
QtHelpButton* button = new QtHelpButton(
|
||||
"Run only the C/C++ preprocessor on the files. This will quickly show include errors and help fix problems "
|
||||
"in the project setup faster.\n\nThe files will not be indexed and show up as incomplete.");
|
||||
button->setColor(Qt::white);
|
||||
|
||||
m_checkBox->setChecked(!forceRefresh);
|
||||
m_checkBox->setChecked(forceRefresh);
|
||||
QHBoxLayout* subLayout = new QHBoxLayout();
|
||||
subLayout->addStretch();
|
||||
subLayout->addWidget(m_preprocessorOnlyCheckBox);
|
||||
subLayout->addSpacing(10);
|
||||
subLayout->addWidget(button);
|
||||
|
||||
layout->addWidget(m_checkBox, 0, Qt::AlignRight);
|
||||
layout->addSpacing(30);
|
||||
layout->addLayout(subLayout);
|
||||
}
|
||||
|
||||
if (m_fullRefreshCheckBox || m_preprocessorOnlyCheckBox)
|
||||
{
|
||||
layout->addSpacing(20);
|
||||
}
|
||||
|
||||
addButtons(layout);
|
||||
updateNextButton("Start");
|
||||
updateCloseButton("Cancel");
|
||||
|
||||
m_sizeHint = QSize(350, 250);
|
||||
m_sizeHint = QSize(350, 270);
|
||||
m_callback = callback;
|
||||
|
||||
finishSetup();
|
||||
@@ -277,7 +297,11 @@ void QtIndexingDialog::handleNext()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(true, !m_checkBox || m_checkBox->isChecked());
|
||||
DialogView::IndexingOptions options;
|
||||
options.startIndexing = true;
|
||||
options.fullRefresh = m_fullRefreshCheckBox && m_fullRefreshCheckBox->isChecked();
|
||||
options.preprocessorOnly = m_preprocessorOnlyCheckBox && m_preprocessorOnlyCheckBox->isChecked();
|
||||
m_callback(options);
|
||||
}
|
||||
|
||||
QtWindow::handleNext();
|
||||
@@ -287,7 +311,8 @@ void QtIndexingDialog::handleClose()
|
||||
{
|
||||
if (m_type == DIALOG_MESSAGE)
|
||||
{
|
||||
m_callback(false, false);
|
||||
DialogView::IndexingOptions options;
|
||||
m_callback(options);
|
||||
}
|
||||
|
||||
if (m_type == DIALOG_INDEXING)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
class QCheckBox;
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
DialogType getType() const;
|
||||
|
||||
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
|
||||
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
|
||||
DialogView::IndexingOptions options, std::function<void(DialogView::IndexingOptions)> callback);
|
||||
void setupIndexing();
|
||||
void setupReport(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time);
|
||||
@@ -77,11 +78,14 @@ private:
|
||||
QLabel* m_messageLabel;
|
||||
QLabel* m_filePathLabel;
|
||||
QPushButton* m_errorLabel;
|
||||
QCheckBox* m_checkBox;
|
||||
|
||||
// start indexing
|
||||
QCheckBox* m_fullRefreshCheckBox;
|
||||
QCheckBox* m_preprocessorOnlyCheckBox;
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
std::function<void(bool, bool)> m_callback;
|
||||
std::function<void(DialogView::IndexingOptions)> m_callback;
|
||||
QString m_sourcePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,41 +2,9 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "qt/window/QtTextEditDialog.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
QtHelpButton::QtHelpButton(const QString& helpText, QWidget* parent)
|
||||
: QtIconButton(
|
||||
(ResourcePaths::getGuiPath() + "window/help.png").c_str(),
|
||||
(ResourcePaths::getGuiPath() + "window/help_hover.png").c_str(),
|
||||
parent)
|
||||
, m_helpText(helpText)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
setMouseTracking(true);
|
||||
|
||||
setToolTip("help");
|
||||
|
||||
leaveEvent(nullptr);
|
||||
|
||||
connect(this, SIGNAL(clicked()), this, SLOT(handleHelpPress()));
|
||||
}
|
||||
|
||||
void QtHelpButton::handleHelpPress()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Help");
|
||||
msgBox.setInformativeText(m_helpText);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContent::QtProjectWizzardContent(QtProjectWizzardWindow* window)
|
||||
: QWidget(window)
|
||||
, m_window(window)
|
||||
|
||||
@@ -6,29 +6,13 @@
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include "qt/element/QtIconButton.h"
|
||||
#include "qt/element/QtHelpButton.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
class QtTextEditDialog;
|
||||
|
||||
class QtHelpButton
|
||||
: public QtIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtHelpButton(const QString& helpText, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void handleHelpPress();
|
||||
|
||||
private:
|
||||
QString m_helpText;
|
||||
};
|
||||
|
||||
|
||||
class QtProjectWizzardContent
|
||||
: public QWidget
|
||||
{
|
||||
|
||||
@@ -29,3 +29,12 @@ std::vector<FilePath> IndexerCommandJava::getClassPath() const
|
||||
{
|
||||
return m_classPath;
|
||||
}
|
||||
|
||||
bool IndexerCommandJava::preprocessorOnly() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void IndexerCommandJava::setPreprocessorOnly(bool preprocessorOnly)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class IndexerCommandJava: public IndexerCommand
|
||||
class IndexerCommandJava
|
||||
: public IndexerCommand
|
||||
{
|
||||
public:
|
||||
static std::string getIndexerKindString();
|
||||
@@ -18,10 +19,13 @@ public:
|
||||
const std::vector<FilePath>& classPath);
|
||||
virtual ~IndexerCommandJava();
|
||||
|
||||
virtual std::string getKindString() const;
|
||||
std::string getKindString() const override;
|
||||
|
||||
std::vector<FilePath> getClassPath() const;
|
||||
|
||||
bool preprocessorOnly() const override;
|
||||
void setPreprocessorOnly(bool preprocessorOnly) override;
|
||||
|
||||
private:
|
||||
std::vector<FilePath> m_classPath;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user