data: stop indexing of files with fatal errors and store them as incomplete (issue 358)

* avoid AST traversial for CXX translation units with fatal errors
* save all files within those translation units as incomplete
* show number of complete files in finished indexing dialog and overview stats
* display incomplete files hatched in graph view
* display incomplete file titles hatched in code view
* mention file incompleteness in tooltips
* removed derived Indexer classes and set ParserType via template parameter instead
* moved getSourceFileFromCDB from IndexerCxxCdb to IndexerCommandCxxCdb

bug id = 358
This commit is contained in:
Eberhard Graether
2017-04-15 01:02:09 +02:00
parent 2b38e0f45e
commit 8dc5ac7cbe
72 changed files with 399 additions and 375 deletions
+6 -1
View File
@@ -293,6 +293,11 @@ void QtCodeFile::setWholeFile(bool isWholeFile, int refCount)
updateRefCount(isWholeFile ? 0 : refCount);
}
void QtCodeFile::setIsComplete(bool isComplete)
{
m_title->setIsComplete(isComplete);
}
void QtCodeFile::setMinimized()
{
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
@@ -376,7 +381,7 @@ void QtCodeFile::updateSnippets()
void QtCodeFile::updateTitleBar()
{
m_title->checkModification();
m_title->updateTexts();
}
void QtCodeFile::clickedMinimizeButton() const
+1
View File
@@ -47,6 +47,7 @@ public:
void updateContent();
void setWholeFile(bool isWholeFile, int refCount);
void setIsComplete(bool isComplete);
void setMinimized();
void setSnippets();
+3 -1
View File
@@ -70,11 +70,12 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath filePath)
return file;
}
void QtCodeFileList::addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimePoint modificationTime)
void QtCodeFileList::addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimePoint modificationTime, bool isComplete)
{
QtCodeFile* file = getFile(filePath);
file->setWholeFile(isWholeFile, refCount);
file->setModificationTime(modificationTime);
file->setIsComplete(isComplete);
}
QScrollArea* QtCodeFileList::getScrollArea()
@@ -99,6 +100,7 @@ void QtCodeFileList::addCodeSnippet(
}
file->setModificationTime(params.modificationTime);
file->setIsComplete(params.locationFile->isComplete());
}
void QtCodeFileList::requestFileContent(const FilePath& filePath, bool isFirstInList)
+1 -1
View File
@@ -28,7 +28,7 @@ public:
void clear();
QtCodeFile* getFile(const FilePath filePath);
void addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimePoint modificationTime);
void addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimePoint modificationTime, bool isComplete);
// QtCodeNaviatebale implementation
virtual QScrollArea* getScrollArea();
+4 -1
View File
@@ -101,6 +101,7 @@ void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params, bool inse
file.filePath = params.locationFile->getFilePath();
file.modificationTime = params.modificationTime;
file.isComplete = params.locationFile->isComplete();
if (params.reduced)
{
@@ -198,7 +199,7 @@ void QtCodeFileSingle::showContents()
void QtCodeFileSingle::onWindowFocus()
{
m_title->checkModification();
m_title->updateTexts();
}
const FilePath& QtCodeFileSingle::getCurrentFilePath() const
@@ -260,11 +261,13 @@ void QtCodeFileSingle::setFileData(const FileData& file)
if (file.title.size())
{
m_title->setProject(file.title);
m_title->setIsComplete(true);
}
else
{
m_title->setFilePath(file.filePath);
m_title->setModificationTime(file.modificationTime);
m_title->setIsComplete(file.isComplete);
}
updateRefCount(m_area->getActiveLocationCount());
@@ -50,6 +50,7 @@ private:
{
FilePath filePath;
TimePoint modificationTime;
bool isComplete;
std::string title;
std::shared_ptr<QtCodeArea> area;
@@ -13,6 +13,7 @@
QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
: QPushButton(parent)
, m_isComplete(true)
{
setObjectName("title_label");
minimumSizeHint(); // force font loading
@@ -49,7 +50,25 @@ void QtCodeFileTitleButton::setModificationTime(const TimePoint modificationTime
if (modificationTime.isValid())
{
m_modificationTime = modificationTime;
checkModification();
updateTexts();
}
}
void QtCodeFileTitleButton::setIsComplete(bool isComplete)
{
m_isComplete = isComplete;
setProperty("complete", isComplete);
if (!isComplete)
{
setStyleSheet((
"background-image: url(" + ResourcePaths::getGuiPath() + "code_view/images/pattern_" +
ColorScheme::getInstance()->getColor("code/file/title/hatching") + ".png);"
).c_str());
}
else
{
setStyleSheet("");
}
}
@@ -74,25 +93,31 @@ void QtCodeFileTitleButton::setProject(const std::string& name)
}
}
void QtCodeFileTitleButton::checkModification()
void QtCodeFileTitleButton::updateTexts()
{
if (Application::getInstance()->isInTrial() || m_filePath.empty())
{
return;
}
std::string title = m_filePath.fileName();
std::string toolTip = "file: " + m_filePath.str();
// cannot use m_filePath.exists() here since it is only checked when FilePath is constructed.
if ((!FileSystem::exists(m_filePath.str())) ||
(FileSystem::getLastWriteTime(m_filePath) > m_modificationTime))
{
setText(QString(m_filePath.fileName().c_str()) + "*");
setToolTip(QString::fromStdString("out of date: " + m_filePath.str()));
title += "*";
toolTip = "out of date " + toolTip;
}
else
if (!m_isComplete)
{
setText(m_filePath.fileName().c_str());
setToolTip(QString::fromStdString(m_filePath.str()));
toolTip = "incomplete " + toolTip;
}
setText(title.c_str());
setToolTip(toolTip.c_str());
}
void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
@@ -17,9 +17,10 @@ public:
void setFilePath(const FilePath& filePath);
void setModificationTime(const TimePoint modificationTime);
void setIsComplete(bool isComplete);
void setProject(const std::string& name);
void checkModification();
void updateTexts();
protected:
void contextMenuEvent(QContextMenuEvent* event);
@@ -30,6 +31,7 @@ private slots:
private:
FilePath m_filePath;
TimePoint m_modificationTime;
bool m_isComplete;
};
#endif // QT_CODE_FILE_TITLE_BUTTON_H
+1 -1
View File
@@ -152,7 +152,7 @@ void QtCodeNavigator::addCodeSnippet(const CodeSnippetParams& params, bool inser
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimePoint modificationTime)
{
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime);
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
if (locationFile->isWhole())
{
+1 -1
View File
@@ -20,7 +20,7 @@ std::shared_ptr<QtCodeSnippet> QtCodeSnippet::merged(
SourceLocationFile* aFile = a->m_codeArea->getSourceLocationFile().get();
SourceLocationFile* bFile = b->m_codeArea->getSourceLocationFile().get();
std::shared_ptr<SourceLocationFile> locationFile = std::make_shared<SourceLocationFile>(aFile->getFilePath(), aFile->isWhole());
std::shared_ptr<SourceLocationFile> locationFile = std::make_shared<SourceLocationFile>(aFile->getFilePath(), aFile->isWhole(), aFile->isWhole());
aFile->forEachSourceLocation(
[&locationFile](SourceLocation* loc)
+5 -3
View File
@@ -180,11 +180,13 @@ void QtDialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount,
);
}
void QtDialogView::finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo)
void QtDialogView::finishedIndexingDialog(
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
float time, ErrorCountInfo errorInfo)
{
std::stringstream ss;
ss << "Finished indexing: ";
ss << fileCount << "/" << totalFileCount << " files; ";
ss << indexedFileCount << "/" << totalIndexedFileCount << " source files indexed; ";
ss << utility::timeToString(time);
ss << "; " << errorInfo.total << " error" << (errorInfo.total != 1 ? "s" : "");
if (errorInfo.fatal > 0)
@@ -199,7 +201,7 @@ void QtDialogView::finishedIndexingDialog(size_t fileCount, size_t totalFileCoun
m_windowStack.clearWindows();
QtIndexingDialog* window = createWindow<QtIndexingDialog>();
window->setupReport(fileCount, totalFileCount, time);
window->setupReport(indexedFileCount, totalIndexedFileCount, completedFileCount, totalFileCount, time);
window->updateErrorCount(errorInfo.total, errorInfo.fatal);
setUIBlocked(false);
+3 -1
View File
@@ -37,7 +37,9 @@ public:
virtual DialogView::IndexMode startIndexingDialog(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh) override;
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath) override;
virtual void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo) override;
virtual void finishedIndexingDialog(
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
float time, ErrorCountInfo errorInfo) override;
int confirm(const std::string& message, const std::vector<std::string>& options) override;
@@ -397,7 +397,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
if (style.hasHatching)
{
QtDeviceScaledPixmap pattern((ResourcePaths::getGuiPath() + "graph_view/images/pattern.png").c_str());
pattern.scaleToHeight(10);
pattern.scaleToHeight(12);
QPixmap pixmap = utility::colorizePixmap(pattern.pixmap(), style.color.hatching.c_str());
pen.setWidth(0);
@@ -19,7 +19,11 @@ QtGraphNodeData::QtGraphNodeData(const Node* data, const std::string& name, bool
this->setName(name);
std::string toolTip = data->getReadableTypeString();
if (!data->isDefined() && !data->isType(Node::NODE_NON_INDEXED))
if (!data->isDefined() && data->isType(Node::NODE_FILE))
{
toolTip = "incomplete " + toolTip;
}
else if (!data->isDefined() && !data->isType(Node::NODE_NON_INDEXED))
{
toolTip = "non-indexed " + toolTip;
}
+15 -16
View File
@@ -131,22 +131,25 @@ void QtIndexingDialog::setupIndexing()
finishSetup();
}
void QtIndexingDialog::setupReport(size_t fileCount, size_t totalFileCount, float time)
void QtIndexingDialog::setupReport(
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
float time)
{
QBoxLayout* layout = createLayout();
addTitle("Finished Indexing", layout);
layout->addSpacing(5);
addMessageLabel(layout);
updateMessage(
QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" + (totalFileCount > 1 ? "s" : "")
createMessageLabel(layout)->setText(
"Source Files indexed: " + QString::number(indexedFileCount) + "/" + QString::number(totalIndexedFileCount)
);
QLabel* timeLabel = new QLabel("Total Time: " + QString::fromStdString(utility::timeToString(time)));
timeLabel->setObjectName("message");
timeLabel->setAlignment(Qt::AlignRight);
layout->addWidget(timeLabel, 0, Qt::AlignRight);
createMessageLabel(layout)->setText(
"Files completed: " + QString::number(completedFileCount) + "/" + QString::number(totalFileCount)
);
layout->addSpacing(12);
createMessageLabel(layout)->setText("Total Time: " + QString::fromStdString(utility::timeToString(time)));
layout->addSpacing(12);
addErrorLabel(layout);
@@ -157,9 +160,9 @@ void QtIndexingDialog::setupReport(size_t fileCount, size_t totalFileCount, floa
updateNextButton("OK");
setCloseVisible(false);
m_sizeHint = QSize(400, 260);
m_sizeHint = QSize(400, 280);
if (fileCount != totalFileCount)
if (indexedFileCount != totalIndexedFileCount)
{
updateTitle("Interrupted Indexing");
}
@@ -364,11 +367,7 @@ void QtIndexingDialog::addPercentLabel(QBoxLayout* layout)
void QtIndexingDialog::addMessageLabel(QBoxLayout* layout)
{
m_messageLabel = new QLabel();
m_messageLabel->setObjectName("message");
m_messageLabel->setAlignment(Qt::AlignRight);
m_messageLabel->setWordWrap(true);
layout->addWidget(m_messageLabel, 0, Qt::AlignRight);
m_messageLabel = createMessageLabel(layout);
}
QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
@@ -377,7 +376,7 @@ QLabel* QtIndexingDialog::createMessageLabel(QBoxLayout* layout)
label->setObjectName("message");
label->setAlignment(Qt::AlignRight);
label->setWordWrap(true);
layout->addWidget(label, 0, Qt::AlignRight);
layout->addWidget(label);
return label;
}
+2 -1
View File
@@ -31,7 +31,8 @@ public:
void setupStart(size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount,
bool forceRefresh, bool needsFullRefresh, std::function<void(bool, bool)> callback);
void setupIndexing();
void setupReport(size_t fileCount, size_t totalFileCount, float time);
void setupReport(
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time);
void setupStatus();
void setupProgress();
@@ -1,7 +1,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
#include "settings/SourceGroupSettingsCxx.h"
#include "data/indexer/IndexerCxxCdb.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource(
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
@@ -36,7 +36,7 @@ void QtProjectWizzardContentCDBSource::load()
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
if (cxxSettings)
{
std::vector<FilePath> filePaths = IndexerCxxCdb::getSourceFilesFromCDB(cxxSettings->getAbsoluteCompilationDatabasePath());
std::vector<FilePath> filePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cxxSettings->getAbsoluteCompilationDatabasePath());
for (FilePath path : filePaths)
{