data: Save command line info for CXX indexer commands to errors and show within errors table (issue #351)
bug id = 351
This commit is contained in:
@@ -26,14 +26,14 @@ public:
|
||||
|
||||
void Show() const;
|
||||
|
||||
int SameInRow( Token token, int amount ) const;
|
||||
int SameInRow( Toen token, int amount ) const;
|
||||
|
||||
bool InRange( const Move& move ) const;
|
||||
bool IsEmpty( const Move& move ) const;
|
||||
bool IsFull() const;
|
||||
|
||||
void MakeMove( const Move& move, Token token );
|
||||
void ClearMove( const Move& move );
|
||||
void ClearMve( const Move& move );
|
||||
|
||||
private:
|
||||
Token** grid_;
|
||||
|
||||
@@ -143,7 +143,7 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
is->addError("The translation unit threw an exception during indexing. Please check if the source file "
|
||||
"conforms to the specified language standard and all necessary options are defined within your project "
|
||||
"setup.", path, 1, 1, true, true);
|
||||
"setup.", "", path, 1, 1, true, true);
|
||||
LOG_INFO_STREAM(<< "crashed translation unit: " << path.str());
|
||||
}
|
||||
m_storageProvider->insert(is);
|
||||
|
||||
@@ -108,6 +108,7 @@ struct SharedStorageError
|
||||
SharedStorageError(
|
||||
Id id,
|
||||
const std::string& message,
|
||||
const std::string& commandline,
|
||||
const std::string& filePath,
|
||||
uint lineNumber,
|
||||
uint columnNumber,
|
||||
@@ -117,6 +118,7 @@ struct SharedStorageError
|
||||
)
|
||||
: id(id)
|
||||
, message(message.c_str(), allocator)
|
||||
, commandline(commandline.c_str(), allocator)
|
||||
, filePath(filePath.c_str(), allocator)
|
||||
, lineNumber(lineNumber)
|
||||
, columnNumber(columnNumber)
|
||||
@@ -126,6 +128,7 @@ struct SharedStorageError
|
||||
|
||||
Id id;
|
||||
SharedMemory::String message;
|
||||
SharedMemory::String commandline;
|
||||
|
||||
SharedMemory::String filePath;
|
||||
uint lineNumber;
|
||||
@@ -138,14 +141,14 @@ struct SharedStorageError
|
||||
inline SharedStorageError toShared(const StorageError& error, SharedMemory::Allocator* allocator)
|
||||
{
|
||||
return SharedStorageError(
|
||||
error.id, error.message, error.filePath.str(),
|
||||
error.id, error.message, error.commandline, error.filePath.str(),
|
||||
error.lineNumber, error.columnNumber, error.fatal, error.indexed, allocator);
|
||||
}
|
||||
|
||||
inline StorageError fromShared(const SharedStorageError& error)
|
||||
{
|
||||
return StorageError(
|
||||
error.id, error.message.c_str(), FilePath(error.filePath.c_str()),
|
||||
error.id, error.message.c_str(), error.commandline.c_str(), FilePath(error.filePath.c_str()),
|
||||
error.lineNumber, error.columnNumber, error.fatal, error.indexed);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,9 +79,10 @@ ParserClient::~ParserClient()
|
||||
{
|
||||
}
|
||||
|
||||
void ParserClient::onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
void ParserClient::onErrorParsed(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline, bool fatal, bool indexed)
|
||||
{
|
||||
this->onError(location, message, fatal, indexed);
|
||||
this->onError(location, message, commandline, fatal, indexed);
|
||||
|
||||
if (fatal)
|
||||
{
|
||||
|
||||
@@ -46,12 +46,14 @@ public:
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location) = 0;
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed) = 0;
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed) = 0;
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location) = 0;
|
||||
virtual void onFileParsed(const FileInfo& fileInfo) = 0;
|
||||
virtual void onCommentParsed(const ParseLocation& location) = 0;
|
||||
|
||||
void onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
|
||||
void onErrorParsed(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
|
||||
bool hasFatalErrors() const;
|
||||
|
||||
|
||||
@@ -67,11 +67,12 @@ void ParserClientImpl::recordReference(
|
||||
addSourceLocation(edgeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
}
|
||||
|
||||
void ParserClientImpl::onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
void ParserClientImpl::onError(
|
||||
const ParseLocation& location, const std::string& message, const std::string& commandline,bool fatal, bool indexed)
|
||||
{
|
||||
if (location.isValid())
|
||||
{
|
||||
addError(message, fatal, indexed, location);
|
||||
addError(message, commandline, fatal, indexed, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,12 +326,14 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location)
|
||||
);
|
||||
}
|
||||
|
||||
void ParserClientImpl::addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location)
|
||||
void ParserClientImpl::addError(
|
||||
const std::string& message, const std::string& commandline, bool fatal, bool indexed, const ParseLocation& location)
|
||||
{
|
||||
if (!m_storage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_storage->addError(message, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed);
|
||||
m_storage->addError(
|
||||
message, commandline, location.filePath, location.startLineNumber, location.startColumnNumber, fatal, indexed);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
ReferenceKind referenceKind, const NameHierarchy& referencedName, const NameHierarchy& contextName,
|
||||
const ParseLocation& location);
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed);
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed);
|
||||
virtual void onLocalSymbolParsed(const std::string& name, const ParseLocation& location);
|
||||
virtual void onFileParsed(const FileInfo& fileInfo);
|
||||
virtual void onCommentParsed(const ParseLocation& location);
|
||||
@@ -55,7 +56,8 @@ private:
|
||||
void addSourceLocation(Id elementId, const ParseLocation& location, int type);
|
||||
void addComponentAccess(Id nodeId , int type);
|
||||
void addCommentLocation(const ParseLocation& location);
|
||||
void addError(const std::string& message, bool fatal, bool indexed, const ParseLocation& location);
|
||||
void addError(const std::string& message, const std::string& commandline, bool fatal, bool indexed,
|
||||
const ParseLocation& location);
|
||||
|
||||
std::shared_ptr<IntermediateStorage> m_storage;
|
||||
};
|
||||
|
||||
@@ -44,6 +44,7 @@ size_t IntermediateStorage::getByteSize() const
|
||||
byteSize += sizeof(StorageError);
|
||||
byteSize += storageError.filePath.str().size();
|
||||
byteSize += storageError.message.size();
|
||||
byteSize += storageError.commandline.size();
|
||||
}
|
||||
|
||||
for (const StorageNode& storageNode: getStorageNodes())
|
||||
@@ -244,11 +245,13 @@ void IntermediateStorage::addCommentLocation(Id fileNodeId, uint startLine, uint
|
||||
}
|
||||
|
||||
void IntermediateStorage::addError(
|
||||
const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
{
|
||||
const StorageError error(
|
||||
0,
|
||||
message,
|
||||
commandline,
|
||||
filePath,
|
||||
startLine,
|
||||
startCol,
|
||||
@@ -558,6 +561,3 @@ std::string IntermediateStorage::serialize(const StorageError& error) const
|
||||
std::to_string(error.columnNumber)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const;
|
||||
|
||||
@@ -135,10 +135,12 @@ void PersistentStorage::addCommentLocation(Id fileNodeId, uint startLine, uint s
|
||||
}
|
||||
|
||||
void PersistentStorage::addError(
|
||||
const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed)
|
||||
{
|
||||
m_sqliteIndexStorage.addError(
|
||||
message,
|
||||
commandline,
|
||||
filePath,
|
||||
startLine,
|
||||
startCol,
|
||||
|
||||
@@ -29,7 +29,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId);
|
||||
virtual void addComponentAccess(Id nodeId , int type);
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed);
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const;
|
||||
|
||||
@@ -190,6 +190,7 @@ void Storage::inject(Storage* injected)
|
||||
{
|
||||
addError(
|
||||
injectedData.message,
|
||||
injectedData.commandline,
|
||||
injectedData.filePath,
|
||||
injectedData.lineNumber,
|
||||
injectedData.columnNumber,
|
||||
|
||||
@@ -23,7 +23,8 @@ public:
|
||||
virtual void addOccurrence(Id elementId, Id sourceLocationId) = 0;
|
||||
virtual void addComponentAccess(Id nodeId , int type) = 0;
|
||||
virtual void addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol) = 0;
|
||||
virtual void addError(const std::string& message, const FilePath& filePath, uint startLine, uint startCol, bool fatal, bool indexed) = 0;
|
||||
virtual void addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint startLine, uint startCol, bool fatal, bool indexed) = 0;
|
||||
|
||||
virtual void forEachNode(std::function<void(const StorageNode& /*data*/)> callback) const = 0;
|
||||
virtual void forEachFile(std::function<void(const StorageFile& /*data*/)> callback) const = 0;
|
||||
|
||||
@@ -211,6 +211,7 @@ struct StorageError
|
||||
StorageError(
|
||||
Id id,
|
||||
const std::string& message,
|
||||
const std::string& commandline,
|
||||
const FilePath& filePath,
|
||||
uint lineNumber,
|
||||
uint columnNumber,
|
||||
@@ -219,6 +220,7 @@ struct StorageError
|
||||
)
|
||||
: id(id)
|
||||
, message(message)
|
||||
, commandline(commandline)
|
||||
, filePath(filePath)
|
||||
, lineNumber(lineNumber)
|
||||
, columnNumber(columnNumber)
|
||||
@@ -228,6 +230,7 @@ struct StorageError
|
||||
|
||||
Id id;
|
||||
std::string message;
|
||||
std::string commandline;
|
||||
|
||||
FilePath filePath;
|
||||
uint lineNumber;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 12;
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 13;
|
||||
|
||||
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath.canonical())
|
||||
@@ -247,7 +247,8 @@ Id SqliteIndexStorage::addCommentLocation(Id fileNodeId, uint startLine, uint st
|
||||
return id;
|
||||
}
|
||||
|
||||
Id SqliteIndexStorage::addError(const std::string& message, const FilePath& filePath, uint lineNumber, uint columnNumber, bool fatal, bool indexed)
|
||||
Id SqliteIndexStorage::addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint lineNumber, uint columnNumber, bool fatal, bool indexed)
|
||||
{
|
||||
const std::string sanitizedMessage = utility::replace(message, "'", "''");
|
||||
|
||||
@@ -270,12 +271,15 @@ Id SqliteIndexStorage::addError(const std::string& message, const FilePath& file
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
const std::string sanitizedCommandline = utility::replace(commandline, "'", "''");
|
||||
|
||||
m_insertErrorStmt.bind(1, sanitizedMessage.c_str());
|
||||
m_insertErrorStmt.bind(2, fatal);
|
||||
m_insertErrorStmt.bind(3, indexed);
|
||||
m_insertErrorStmt.bind(4, filePath.str().c_str());
|
||||
m_insertErrorStmt.bind(5, int(lineNumber));
|
||||
m_insertErrorStmt.bind(6, int(columnNumber));
|
||||
m_insertErrorStmt.bind(2, sanitizedCommandline.c_str());
|
||||
m_insertErrorStmt.bind(3, fatal);
|
||||
m_insertErrorStmt.bind(4, indexed);
|
||||
m_insertErrorStmt.bind(5, filePath.str().c_str());
|
||||
m_insertErrorStmt.bind(6, int(lineNumber));
|
||||
m_insertErrorStmt.bind(7, int(columnNumber));
|
||||
|
||||
const bool success = executeStatement(m_insertErrorStmt);
|
||||
if (success)
|
||||
@@ -952,6 +956,7 @@ void SqliteIndexStorage::setupTables()
|
||||
"CREATE TABLE IF NOT EXISTS error("
|
||||
"id INTEGER NOT NULL, "
|
||||
"message TEXT, "
|
||||
"commandline TEXT, "
|
||||
"fatal INTEGER NOT NULL, "
|
||||
"indexed INTEGER NOT NULL, "
|
||||
"file_path TEXT, "
|
||||
@@ -1039,7 +1044,7 @@ void SqliteIndexStorage::setupPrecompiledStatements()
|
||||
"LIMIT 1;"
|
||||
);
|
||||
m_insertErrorStmt = m_database.compileStatement(
|
||||
"INSERT INTO error(message, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?);"
|
||||
"INSERT INTO error(message, commandline, fatal, indexed, file_path, line_number, column_number) VALUES(?, ?, ?, ?, ?, ?, ?);"
|
||||
);
|
||||
}
|
||||
catch (CppSQLite3Exception& e)
|
||||
@@ -1285,7 +1290,7 @@ template <>
|
||||
std::vector<StorageError> SqliteIndexStorage::doGetAll<StorageError>(const std::string& query) const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery(
|
||||
"SELECT message, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";"
|
||||
"SELECT message, commandline, fatal, indexed, file_path, line_number, column_number FROM error " + query + ";"
|
||||
);
|
||||
|
||||
std::vector<StorageError> errors;
|
||||
@@ -1293,15 +1298,17 @@ std::vector<StorageError> SqliteIndexStorage::doGetAll<StorageError>(const std::
|
||||
while (!q.eof())
|
||||
{
|
||||
const std::string message = q.getStringField(0, "");
|
||||
const bool fatal = q.getIntField(1, 0);
|
||||
const bool indexed = q.getIntField(2, 0);
|
||||
const std::string filePath = q.getStringField(3, "");
|
||||
const int lineNumber = q.getIntField(4, -1);
|
||||
const int columnNumber = q.getIntField(5, -1);
|
||||
const std::string commandline = q.getStringField(1, "");
|
||||
const bool fatal = q.getIntField(2, 0);
|
||||
const bool indexed = q.getIntField(3, 0);
|
||||
const std::string filePath = q.getStringField(4, "");
|
||||
const int lineNumber = q.getIntField(5, -1);
|
||||
const int columnNumber = q.getIntField(6, -1);
|
||||
|
||||
if (lineNumber != -1 && columnNumber != -1)
|
||||
{
|
||||
errors.push_back(StorageError(id, message, FilePath(filePath), lineNumber, columnNumber, fatal, indexed));
|
||||
errors.push_back(StorageError(
|
||||
id, message, commandline, FilePath(filePath), lineNumber, columnNumber, fatal, indexed));
|
||||
id++;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
bool addOccurrence(Id elementId, Id sourceLocationId);
|
||||
Id addComponentAccess(Id nodeId, int type);
|
||||
Id addCommentLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol);
|
||||
Id addError(const std::string& message, const FilePath& filePath, uint lineNumber, uint columnNumber, bool fatal, bool indexed);
|
||||
Id addError(const std::string& message, const std::string& commandline, const FilePath& filePath,
|
||||
uint lineNumber, uint columnNumber, bool fatal, bool indexed);
|
||||
|
||||
void removeElement(Id id);
|
||||
void removeElements(const std::vector<Id>& ids);
|
||||
|
||||
@@ -31,8 +31,13 @@ void SqliteStorage::setup()
|
||||
|
||||
executeStatement("PRAGMA foreign_keys=ON;");
|
||||
setupMetaTable();
|
||||
setupTables();
|
||||
setupPrecompiledStatements();
|
||||
|
||||
if (isEmpty() || !isIncompatible())
|
||||
{
|
||||
setupTables();
|
||||
setupPrecompiledStatements();
|
||||
}
|
||||
|
||||
m_mode = STORAGE_MODE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,14 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
m_client->onErrorParsed(
|
||||
location,
|
||||
message,
|
||||
m_commandline,
|
||||
level == clang::DiagnosticsEngine::Fatal,
|
||||
m_register->hasFilePath(location.filePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void CxxDiagnosticConsumer::setCommandLine(const std::string& commandline)
|
||||
{
|
||||
m_commandline = commandline;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,15 @@ public:
|
||||
|
||||
void HandleDiagnostic(clang::DiagnosticsEngine::Level level, const clang::Diagnostic& info);
|
||||
|
||||
void setCommandLine(const std::string& commandline);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ParserClient> m_client;
|
||||
std::shared_ptr<FileRegister> m_register;
|
||||
std::shared_ptr<FilePathCache> m_canonicalFilePathCache;
|
||||
|
||||
std::string m_commandline;
|
||||
|
||||
bool m_isParsingFile;
|
||||
bool m_useLogging;
|
||||
};
|
||||
|
||||
@@ -79,38 +79,14 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
|
||||
}
|
||||
|
||||
CxxCompilationDatabaseSingle compilationDatabase(compileCommand);
|
||||
clang::tooling::ClangTool tool(compilationDatabase, std::vector<std::string>(1, indexerCommand->getSourceFilePath().str()));
|
||||
|
||||
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
|
||||
{
|
||||
return FilePath(fileName).canonical();
|
||||
}
|
||||
);
|
||||
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(canonicalFilePathCache, true);
|
||||
tool.setDiagnosticConsumer(diagnostics.get());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, false);
|
||||
tool.run(&actionFactory);
|
||||
runTool(&compilationDatabase, indexerCommand->getSourceFilePath());
|
||||
}
|
||||
|
||||
void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxManual> indexerCommand)
|
||||
{
|
||||
std::shared_ptr<clang::tooling::CompilationDatabase> compilationDatabase = getCompilationDatabase(indexerCommand);
|
||||
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, indexerCommand->getSourceFilePath().str()));
|
||||
|
||||
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
|
||||
{
|
||||
return FilePath(fileName).canonical();
|
||||
}
|
||||
);
|
||||
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(canonicalFilePathCache, true);
|
||||
tool.setDiagnosticConsumer(diagnostics.get());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, false);
|
||||
tool.run(&actionFactory);
|
||||
runTool(compilationDatabase.get(), indexerCommand->getSourceFilePath());
|
||||
}
|
||||
|
||||
void CxxParser::buildIndex(const std::string& fileName, std::shared_ptr<TextAccess> fileContent)
|
||||
@@ -135,6 +111,35 @@ void CxxParser::buildIndex(const std::string& fileName, std::shared_ptr<TextAcce
|
||||
);
|
||||
}
|
||||
|
||||
void CxxParser::runTool(clang::tooling::CompilationDatabase* compilationDatabase, const FilePath& sourceFilePath)
|
||||
{
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, sourceFilePath.str()));
|
||||
|
||||
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
|
||||
{
|
||||
return FilePath(fileName).canonical();
|
||||
}
|
||||
);
|
||||
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(canonicalFilePathCache, true);
|
||||
|
||||
std::vector<clang::tooling::CompileCommand> compileCommands = compilationDatabase->getCompileCommands(sourceFilePath.str());
|
||||
if (compileCommands.size() == 1)
|
||||
{
|
||||
std::string commandline;
|
||||
for (const std::string& str : compileCommands[0].CommandLine)
|
||||
{
|
||||
commandline += str + " ";
|
||||
}
|
||||
diagnostics->setCommandLine(commandline);
|
||||
}
|
||||
|
||||
tool.setDiagnosticConsumer(diagnostics.get());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, m_fileRegister, canonicalFilePathCache, false);
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxParser::getCommandlineArgumentsEssential(
|
||||
const std::vector<std::string>& compilerFlags, const std::vector<FilePath>& systemHeaderSearchPaths, const std::vector<FilePath>& frameworkSearchPaths
|
||||
) const {
|
||||
|
||||
@@ -11,7 +11,12 @@ class IndexerCommandCxxCdb;
|
||||
class IndexerCommandCxxManual;
|
||||
class TaskParseCxx;
|
||||
|
||||
namespace clang { namespace tooling { class FixedCompilationDatabase; } }
|
||||
namespace clang {
|
||||
namespace tooling {
|
||||
class CompilationDatabase;
|
||||
class FixedCompilationDatabase;
|
||||
}
|
||||
}
|
||||
|
||||
class CxxParser: public Parser
|
||||
{
|
||||
@@ -24,6 +29,8 @@ public:
|
||||
void buildIndex(const std::string& fileName, std::shared_ptr<TextAccess> fileContent);
|
||||
|
||||
private:
|
||||
void runTool(clang::tooling::CompilationDatabase* compilationDatabase, const FilePath& sourceFilePath);
|
||||
|
||||
std::vector<std::string> getCommandlineArgumentsEssential(
|
||||
const std::vector<std::string>& compilerFlags,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
|
||||
@@ -86,6 +86,16 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
|
||||
m_errorButton.setText(
|
||||
QString::number(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "") +
|
||||
(errorCount.fatal > 0 ? " (" + QString::number(errorCount.fatal) + " fatal)" : ""));
|
||||
|
||||
if (errorCount.fatal > 0)
|
||||
{
|
||||
m_errorButton.setStyleSheet("QPushButton { color: #D00000; margin-right: 0; spacing: none; }");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_errorButton.setStyleSheet("QPushButton { color: #000000; margin-right: 0; spacing: none; }");
|
||||
}
|
||||
|
||||
m_errorButton.show();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -79,15 +79,16 @@ void QtErrorView::initView()
|
||||
m_table->setItemDelegate(new SelectableDelegate());
|
||||
|
||||
// Setup Table Headers
|
||||
m_model->setColumnCount(6);
|
||||
m_table->setColumnWidth(COLUMN::TYPE, 70);
|
||||
m_model->setColumnCount(7);
|
||||
m_table->setColumnWidth(COLUMN::TYPE, 80);
|
||||
m_table->setColumnWidth(COLUMN::MESSAGE, 450);
|
||||
m_table->setColumnWidth(COLUMN::FILE, 300);
|
||||
m_table->setColumnWidth(COLUMN::LINE, 50);
|
||||
m_table->setColumnWidth(COLUMN::COMMANDLINE, 120);
|
||||
m_table->setColumnHidden(COLUMN::ID, true);
|
||||
|
||||
QStringList headers;
|
||||
headers << "Type" << "Message" << "File" << "Line" << "Indexed";
|
||||
headers << "Type" << "Message" << "File" << "Line" << "Command Line" << "Indexed";
|
||||
m_model->setHorizontalHeaderLabels(headers);
|
||||
|
||||
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
@@ -299,16 +300,19 @@ void QtErrorView::addErrorToTable(const ErrorInfo& error)
|
||||
}
|
||||
|
||||
m_model->setItem(rowNumber, COLUMN::TYPE, new QStandardItem(error.fatal ? "FATAL" : "ERROR"));
|
||||
m_model->item(rowNumber, COLUMN::TYPE)->setForeground(QBrush(Qt::red));
|
||||
m_model->item(rowNumber, COLUMN::TYPE)->setTextAlignment(Qt::AlignCenter);
|
||||
if (error.fatal)
|
||||
{
|
||||
m_model->item(rowNumber, COLUMN::TYPE)->setForeground(QBrush(Qt::red));
|
||||
}
|
||||
m_model->item(rowNumber, COLUMN::TYPE)->setIcon(s_errorIcon);
|
||||
|
||||
m_model->setItem(rowNumber, COLUMN::MESSAGE, new QStandardItem(error.message.c_str()));
|
||||
m_model->item(rowNumber, COLUMN::MESSAGE)->setIcon(s_errorIcon);
|
||||
|
||||
m_model->setItem(rowNumber, COLUMN::FILE, new QStandardItem(error.filePath.str().c_str()));
|
||||
m_model->item(rowNumber, COLUMN::FILE)->setToolTip(error.filePath.str().c_str());
|
||||
|
||||
m_model->setItem(rowNumber, COLUMN::LINE, new QStandardItem(QString::number(error.lineNumber)));
|
||||
m_model->setItem(rowNumber, COLUMN::COMMANDLINE, new QStandardItem(error.commandline.c_str()));
|
||||
|
||||
m_model->setItem(rowNumber, COLUMN::INDEXED, new QStandardItem(error.indexed ? "yes" : "no"));
|
||||
|
||||
|
||||
@@ -47,8 +47,9 @@ private:
|
||||
MESSAGE = 1,
|
||||
FILE = 2,
|
||||
LINE = 3,
|
||||
INDEXED = 4,
|
||||
ID = 5
|
||||
COMMANDLINE = 4,
|
||||
INDEXED = 5,
|
||||
ID = 6
|
||||
};
|
||||
|
||||
void doRefreshView();
|
||||
|
||||
@@ -298,6 +298,7 @@ void JavaParser::doRecordError(
|
||||
m_client->onError(
|
||||
ParseLocation(m_currentFilePath, beginLine, beginColumn, endLine, endColumn),
|
||||
m_javaEnvironment->toStdString(jMessage),
|
||||
"",
|
||||
fatal, indexed
|
||||
);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, const std::string& commandline,
|
||||
bool fatal, bool indexed)
|
||||
{
|
||||
errors.push_back(addLocationSuffix(message, location));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user