utility: added FilePath abstraction and rewrote data management to use it
The utility class FilePath wraps an instance of boost::filesystem::path. Using FilePath allows for easy comparision of file paths on different platforms using absolute or relative paths. Whereever file paths are compared, this wrapper should be used.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "data/parser/ParserClient.h"
|
||||
|
||||
class FilePath;
|
||||
class TextAccess;
|
||||
|
||||
class Parser
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
virtual ~Parser();
|
||||
|
||||
virtual void parseFiles(
|
||||
const std::vector<std::string>& filePaths,
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths) = 0;
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess) = 0;
|
||||
|
||||
@@ -59,7 +59,7 @@ CxxParser::~CxxParser()
|
||||
}
|
||||
|
||||
void CxxParser::parseFiles(
|
||||
const std::vector<std::string>& filePaths,
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths
|
||||
){
|
||||
@@ -113,12 +113,18 @@ void CxxParser::parseFiles(
|
||||
|
||||
FileRegister fileRegister(m_fileManager, filePaths);
|
||||
|
||||
std::vector<std::string> sourcePaths;
|
||||
for (const FilePath& path : fileRegister.getSourceFilePaths())
|
||||
{
|
||||
sourcePaths.push_back(path.absoluteStr());
|
||||
}
|
||||
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client);
|
||||
|
||||
ASTActionFactory actionFactory(m_client, &fileRegister);
|
||||
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, fileRegister.getSourceFilePaths());
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, sourcePaths);
|
||||
tool.setDiagnosticConsumer(&reporter);
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
@@ -131,7 +137,7 @@ void CxxParser::parseFile(std::shared_ptr<TextAccess> textAccess)
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, false);
|
||||
|
||||
FileRegister fileRegister(m_fileManager, std::vector<std::string>());
|
||||
FileRegister fileRegister(m_fileManager, std::vector<FilePath>());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, &fileRegister);
|
||||
runToolOnCodeWithArgs(&reporter, actionFactory.create(), textAccess->getText(), args);
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
~CxxParser();
|
||||
|
||||
virtual void parseFiles(
|
||||
const std::vector<std::string>& filePaths,
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths);
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess);
|
||||
|
||||
Reference in New Issue
Block a user