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:
@@ -49,7 +49,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
|
||||
statsSnippet.reduced = true;
|
||||
|
||||
statsSnippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(), true);
|
||||
statsSnippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(), true, true);
|
||||
|
||||
std::vector<std::string> description = getProjectDescription(statsSnippet.locationFile.get());
|
||||
|
||||
@@ -68,7 +68,8 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
|
||||
|
||||
ss << "\n";
|
||||
ss << "\t" + std::to_string(stats.fileCount) + " files\n";
|
||||
ss << "\t" + std::to_string(stats.fileCount) + " files";
|
||||
ss << (stats.completedFileCount != stats.fileCount ? " (" + std::to_string(stats.completedFileCount) + " complete)" : "") + "\n";
|
||||
ss << "\t" + std::to_string(stats.fileLOCCount) + " lines of code\n";
|
||||
ss << "\n";
|
||||
ss << "\t" + std::to_string(stats.nodeCount) + " symbols\n";
|
||||
@@ -77,9 +78,9 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
ss << "\t" + std::to_string(errorCount.total) + " errors (" + std::to_string(errorCount.fatal) + " fatal)\n";
|
||||
ss << "\n";
|
||||
|
||||
if (errorCount.total > 0)
|
||||
if (stats.completedFileCount != stats.fileCount)
|
||||
{
|
||||
ss << "\tWarning: Indexing may be incomplete as long as it yields fatal errors.\n";
|
||||
ss << "\tWarning: Indexing is incomplete as long as it yields fatal errors.\n";
|
||||
ss << "\tTry resolving them and refresh the project.\n";
|
||||
ss << "\n";
|
||||
}
|
||||
@@ -732,7 +733,7 @@ std::shared_ptr<SourceLocationFile> CodeController::getSourceLocationOfParentSco
|
||||
}
|
||||
);
|
||||
|
||||
std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(location->getFilePath(), false);
|
||||
std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(location->getFilePath(), false, false);
|
||||
if (parent)
|
||||
{
|
||||
file->addSourceLocationCopy(parent);
|
||||
|
||||
@@ -779,19 +779,21 @@ void GraphController::bundleNodes()
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileOrMacroActive)
|
||||
if (fileOrMacroActive)
|
||||
{
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return data->isType(Node::NODE_FILE);
|
||||
},
|
||||
1,
|
||||
false,
|
||||
"Importing Files"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return data->isType(Node::NODE_FILE);
|
||||
},
|
||||
1,
|
||||
false,
|
||||
"Importing Files"
|
||||
);
|
||||
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
@@ -822,28 +824,25 @@ void GraphController::bundleNodes()
|
||||
"Built-in Types"
|
||||
);
|
||||
|
||||
if (!fileOrMacroActive)
|
||||
{
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return info.isDefined && info.isReferencing && !info.layoutVertical;
|
||||
},
|
||||
10,
|
||||
false,
|
||||
"Referencing Symbols"
|
||||
);
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return info.isDefined && info.isReferencing && !info.layoutVertical;
|
||||
},
|
||||
10,
|
||||
false,
|
||||
"Referencing Symbols"
|
||||
);
|
||||
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return info.isDefined && info.isReferenced && !info.layoutVertical;
|
||||
},
|
||||
10,
|
||||
false,
|
||||
"Referenced Symbols"
|
||||
);
|
||||
}
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
{
|
||||
return info.isDefined && info.isReferenced && !info.layoutVertical;
|
||||
},
|
||||
10,
|
||||
false,
|
||||
"Referenced Symbols"
|
||||
);
|
||||
|
||||
bundleNodesAndEdgesMatching(
|
||||
[](const DummyNode::BundleInfo& info, const Node* data)
|
||||
|
||||
@@ -35,7 +35,9 @@ void DialogView::updateIndexingDialog(size_t fileCount, size_t totalFileCount, s
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo)
|
||||
void DialogView::finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
float time, ErrorCountInfo errorInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ public:
|
||||
virtual IndexMode startIndexingDialog(
|
||||
size_t cleanFileCount, size_t indexFileCount, size_t totalFileCount, bool forceRefresh, bool needsFullRefresh);
|
||||
virtual void updateIndexingDialog(size_t fileCount, size_t totalFileCount, std::string sourcePath);
|
||||
virtual void finishedIndexingDialog(size_t fileCount, size_t totalFileCount, float time, ErrorCountInfo errorInfo);
|
||||
virtual void finishedIndexingDialog(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount,
|
||||
float time, ErrorCountInfo errorInfo);
|
||||
|
||||
int confirm(const std::string& message);
|
||||
virtual int confirm(const std::string& message, const std::vector<std::string>& options);
|
||||
|
||||
@@ -31,6 +31,14 @@ void IntermediateStorage::clear()
|
||||
m_nextId = 1;
|
||||
}
|
||||
|
||||
void IntermediateStorage::setFilesIncomplete()
|
||||
{
|
||||
for (StorageFile& file : m_files)
|
||||
{
|
||||
file.complete = false;
|
||||
}
|
||||
}
|
||||
|
||||
size_t IntermediateStorage::getSourceLocationCount() const
|
||||
{
|
||||
return m_sourceLocationNamesToIds.size();
|
||||
@@ -60,9 +68,9 @@ Id IntermediateStorage::addNode(int type, const std::string& serializedName)
|
||||
return id;
|
||||
}
|
||||
|
||||
void IntermediateStorage::addFile(const Id id, const std::string& filePath, const std::string& modificationTime)
|
||||
void IntermediateStorage::addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete)
|
||||
{
|
||||
const StorageFile file(id, filePath, modificationTime);
|
||||
const StorageFile file(id, filePath, modificationTime, complete);
|
||||
const std::string serialized = serialize(file);
|
||||
|
||||
if (m_serializedFiles.find(serialized) == m_serializedFiles.end())
|
||||
|
||||
@@ -16,10 +16,11 @@ public:
|
||||
virtual ~IntermediateStorage();
|
||||
|
||||
void clear();
|
||||
void setFilesIncomplete();
|
||||
size_t getSourceLocationCount() const;
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete);
|
||||
virtual void addSymbol(const Id id, int definitionKind);
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
|
||||
@@ -57,11 +57,16 @@ Id PersistentStorage::addNode(int type, const std::string& serializedName)
|
||||
return id;
|
||||
}
|
||||
|
||||
void PersistentStorage::addFile(const Id id, const std::string& filePath, const std::string& modificationTime)
|
||||
void PersistentStorage::addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete)
|
||||
{
|
||||
if (m_sqliteStorage.getFirstById<StorageFile>(id).id == 0)
|
||||
StorageFile file = m_sqliteStorage.getFirstById<StorageFile>(id);
|
||||
if (file.id == 0)
|
||||
{
|
||||
m_sqliteStorage.addFile(id, filePath, modificationTime);
|
||||
m_sqliteStorage.addFile(id, filePath, modificationTime, complete);
|
||||
}
|
||||
else if (!file.complete && complete)
|
||||
{
|
||||
m_sqliteStorage.setFileComplete(complete, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,7 +1199,7 @@ std::shared_ptr<SourceLocationFile> PersistentStorage::getCommentLocationsInFile
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false);
|
||||
std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
|
||||
std::vector<StorageCommentLocation> storageLocations = m_sqliteStorage.getCommentLocationsInFile(filePath);
|
||||
for (size_t i = 0; i < storageLocations.size(); i++)
|
||||
@@ -1246,6 +1251,7 @@ StorageStats PersistentStorage::getStorageStats() const
|
||||
stats.edgeCount = m_sqliteStorage.getEdgeCount();
|
||||
|
||||
stats.fileCount = m_sqliteStorage.getFileCount();
|
||||
stats.completedFileCount = m_sqliteStorage.getCompletedFileCount();
|
||||
stats.fileLOCCount = m_sqliteStorage.getFileLineSum();
|
||||
|
||||
return stats;
|
||||
@@ -1552,20 +1558,34 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& nodeIds, Graph* g
|
||||
symbolMap[symbol.id] = symbol;
|
||||
}
|
||||
|
||||
std::unordered_map<Id, StorageFile> fileMap;
|
||||
for (const StorageFile& file : m_sqliteStorage.getAllByIds<StorageFile>(nodeIds))
|
||||
{
|
||||
fileMap[file.id] = file;
|
||||
}
|
||||
|
||||
for (const StorageNode& storageNode : m_sqliteStorage.getAllByIds<StorageNode>(nodeIds))
|
||||
{
|
||||
const Node::NodeType type = Node::intToType(storageNode.type);
|
||||
if (type == Node::NODE_FILE)
|
||||
{
|
||||
const FilePath filePath(NameHierarchy::deserialize(storageNode.serializedName).getRawName());
|
||||
|
||||
bool defined = true;
|
||||
auto it = fileMap.find(storageNode.id);
|
||||
if (it != fileMap.end())
|
||||
{
|
||||
defined = it->second.complete;
|
||||
}
|
||||
|
||||
Node* node = graph->createNode(
|
||||
storageNode.id,
|
||||
Node::NODE_FILE,
|
||||
NameHierarchy(filePath.fileName()),
|
||||
true
|
||||
defined
|
||||
);
|
||||
node->addComponentFilePath(std::make_shared<TokenComponentFilePath>(filePath));
|
||||
node->setExplicit(true);
|
||||
node->setExplicit(defined);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
virtual ~PersistentStorage();
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime);
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete);
|
||||
virtual void addSymbol(const Id id, int definitionKind);
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId);
|
||||
virtual Id addLocalSymbol(const std::string& name);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 10;
|
||||
const size_t SqliteStorage::STORAGE_VERSION = 11;
|
||||
|
||||
SqliteStorage::SqliteStorage(const FilePath& dbFilePath)
|
||||
: m_dbFilePath(dbFilePath.canonical())
|
||||
@@ -204,14 +204,14 @@ void SqliteStorage::addSymbol(const int id, const int definitionKind)
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteStorage::addFile(const int id, const std::string& filePath, const std::string& modificationTime)
|
||||
void SqliteStorage::addFile(const int id, const std::string& filePath, const std::string& modificationTime, bool complete)
|
||||
{
|
||||
std::shared_ptr<TextAccess> content = TextAccess::createFromFile(filePath);
|
||||
unsigned int lineCount = content->getLineCount();
|
||||
|
||||
executeStatement(
|
||||
"INSERT INTO file(id, path, modification_time, line_count) VALUES("
|
||||
+ std::to_string(id) + ", '" + filePath + "', '" + modificationTime + "', " + std::to_string(lineCount) + ");"
|
||||
"INSERT INTO file(id, path, modification_time, complete, line_count) VALUES("
|
||||
+ std::to_string(id) + ", '" + filePath + "', '" + modificationTime + "', '" + std::to_string(complete) + "', " + std::to_string(lineCount) + ");"
|
||||
);
|
||||
|
||||
CppSQLite3Statement stmt = m_database.compileStatement((
|
||||
@@ -827,6 +827,13 @@ std::shared_ptr<TextAccess> SqliteStorage::getFileContentByPath(const std::strin
|
||||
return TextAccess::createFromFile(filePath);
|
||||
}
|
||||
|
||||
void SqliteStorage::setFileComplete(bool complete, Id fileId)
|
||||
{
|
||||
executeStatement(
|
||||
"UPDATE file SET complete = " + std::to_string(complete) + " WHERE id == " + std::to_string(fileId) + ";"
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteStorage::setNodeType(int type, Id nodeId)
|
||||
{
|
||||
executeStatement(
|
||||
@@ -848,17 +855,20 @@ StorageSourceLocation SqliteStorage::getSourceLocationByAll(const Id fileNodeId,
|
||||
|
||||
std::shared_ptr<SourceLocationFile> SqliteStorage::getSourceLocationsForFile(const FilePath& filePath) const
|
||||
{
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(filePath, true);
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(filePath, true, false);
|
||||
|
||||
const Id fileNodeId = getFileByPath(filePath.str()).id;
|
||||
if (fileNodeId == 0) // early out
|
||||
const StorageFile file = getFileByPath(filePath.str());
|
||||
if (file.id == 0) // early out
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret->setIsComplete(file.complete);
|
||||
|
||||
std::vector<Id> sourceLocationIds;
|
||||
std::unordered_map<Id, StorageSourceLocation> sourceLocationIdToData;
|
||||
for (const StorageSourceLocation& storageLocation: doGetAll<StorageSourceLocation>("WHERE file_node_id == " + std::to_string(fileNodeId)))
|
||||
for (const StorageSourceLocation& storageLocation:
|
||||
doGetAll<StorageSourceLocation>("WHERE file_node_id == " + std::to_string(file.id)))
|
||||
{
|
||||
sourceLocationIds.push_back(storageLocation.id);
|
||||
sourceLocationIdToData[storageLocation.id] = storageLocation;
|
||||
@@ -1200,6 +1210,11 @@ int SqliteStorage::getFileCount() const
|
||||
return executeScalar("SELECT COUNT(*) FROM file;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getCompletedFileCount() const
|
||||
{
|
||||
return executeScalar("SELECT COUNT(*) FROM file WHERE complete = 1;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getFileLineSum() const
|
||||
{
|
||||
return executeScalar("SELECT SUM(line_count) FROM file;");
|
||||
@@ -1286,6 +1301,7 @@ void SqliteStorage::setupTables()
|
||||
"id INTEGER NOT NULL, "
|
||||
"path TEXT, "
|
||||
"modification_time TEXT, "
|
||||
"complete INTEGER, "
|
||||
"line_count INTEGER, "
|
||||
"UNIQUE(path) ON CONFLICT REPLACE,"
|
||||
"PRIMARY KEY(id), "
|
||||
@@ -1662,7 +1678,7 @@ template <>
|
||||
std::vector<StorageFile> SqliteStorage::doGetAll<StorageFile>(const std::string& query) const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery(
|
||||
"SELECT id, path, modification_time FROM file " + query + ";"
|
||||
"SELECT id, path, modification_time, complete FROM file " + query + ";"
|
||||
);
|
||||
|
||||
std::vector<StorageFile> files;
|
||||
@@ -1671,10 +1687,11 @@ std::vector<StorageFile> SqliteStorage::doGetAll<StorageFile>(const std::string&
|
||||
const Id id = q.getIntField(0, 0);
|
||||
const std::string filePath = q.getStringField(1, "");
|
||||
const std::string modificationTime = q.getStringField(2, "");
|
||||
const bool complete = q.getIntField(3, 0);
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
files.push_back(StorageFile(id, filePath, modificationTime));
|
||||
files.push_back(StorageFile(id, filePath, modificationTime, complete));
|
||||
}
|
||||
q.nextRow();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
Id addNode(const int type, const std::string& serializedName);
|
||||
void addSymbol(const int id, int definitionKind);
|
||||
void addFile(const int id, const std::string& filePath, const std::string& modificationTime);
|
||||
void addFile(const int id, const std::string& filePath, const std::string& modificationTime, bool complete);
|
||||
Id addLocalSymbol(const std::string& name);
|
||||
Id addSourceLocation(Id fileNodeId, uint startLine, uint startCol, uint endLine, uint endCol, int type);
|
||||
bool addOccurrence(Id elementId, Id sourceLocationId);
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
std::shared_ptr<TextAccess> getFileContentByPath(const std::string& filePath) const;
|
||||
std::shared_ptr<TextAccess> getFileContentById(Id fileId) const;
|
||||
|
||||
void setFileComplete(bool complete, Id fileId);
|
||||
void setNodeType(int type, Id nodeId);
|
||||
|
||||
StorageSourceLocation getSourceLocationByAll(const Id fileNodeId, const uint startLine, const uint startCol, const uint endLine, const uint endCol, const int type) const;
|
||||
@@ -162,12 +163,17 @@ public:
|
||||
template <typename ResultType>
|
||||
std::vector<ResultType> getAllByIds(const std::vector<Id>& ids) const
|
||||
{
|
||||
return doGetAll<ResultType>("WHERE id IN (" + utility::join(utility::toStrings(ids), ',') + ")");
|
||||
if (ids.size())
|
||||
{
|
||||
return doGetAll<ResultType>("WHERE id IN (" + utility::join(utility::toStrings(ids), ',') + ")");
|
||||
}
|
||||
return std::vector<ResultType>();
|
||||
}
|
||||
|
||||
int getNodeCount() const;
|
||||
int getEdgeCount() const;
|
||||
int getFileCount() const;
|
||||
int getCompletedFileCount() const;
|
||||
int getFileLineSum() const;
|
||||
int getSourceLocationCount() const;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void Storage::inject(Storage* injected)
|
||||
}
|
||||
const Id ownId = it->second;
|
||||
|
||||
addFile(ownId, injectedData.filePath, injectedData.modificationTime);
|
||||
addFile(ownId, injectedData.filePath, injectedData.modificationTime, injectedData.complete);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
virtual ~Storage();
|
||||
|
||||
virtual Id addNode(int type, const std::string& serializedName) = 0;
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime) = 0;
|
||||
virtual void addFile(const Id id, const std::string& filePath, const std::string& modificationTime, bool complete) = 0;
|
||||
virtual void addSymbol(const Id id, int definitionKind) = 0;
|
||||
virtual Id addEdge(int type, Id sourceId, Id targetId) = 0;
|
||||
virtual Id addLocalSymbol(const std::string& name) = 0;
|
||||
|
||||
@@ -7,6 +7,7 @@ struct StorageStats
|
||||
: nodeCount(0)
|
||||
, edgeCount(0)
|
||||
, fileCount(0)
|
||||
, completedFileCount(0)
|
||||
, fileLOCCount(0)
|
||||
{}
|
||||
|
||||
@@ -14,6 +15,7 @@ struct StorageStats
|
||||
size_t edgeCount;
|
||||
|
||||
size_t fileCount;
|
||||
size_t completedFileCount;
|
||||
size_t fileLOCCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -71,17 +71,20 @@ struct StorageFile
|
||||
: id(0)
|
||||
, filePath("")
|
||||
, modificationTime("")
|
||||
, complete(true)
|
||||
{}
|
||||
|
||||
StorageFile(Id id, const std::string& filePath, const std::string& modificationTime)
|
||||
StorageFile(Id id, const std::string& filePath, const std::string& modificationTime, bool complete)
|
||||
: id(id)
|
||||
, filePath(filePath)
|
||||
, modificationTime(modificationTime)
|
||||
, complete(complete)
|
||||
{}
|
||||
|
||||
Id id;
|
||||
std::string filePath;
|
||||
std::string modificationTime;
|
||||
bool complete;
|
||||
};
|
||||
|
||||
struct StorageLocalSymbol
|
||||
|
||||
@@ -32,22 +32,22 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
}
|
||||
}
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
}
|
||||
}
|
||||
m_storage->buildCaches();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->hideStatusDialog();
|
||||
}
|
||||
}
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
float time = utility::duration(start);
|
||||
@@ -72,15 +72,19 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
int sourceFileCount = 0;
|
||||
blackboard->get("source_file_count", sourceFileCount);
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
if (dialogView)
|
||||
{
|
||||
StorageStats stats = m_storageAccess->getStorageStats();
|
||||
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
}
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
stats.completedFileCount,
|
||||
stats.fileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
}
|
||||
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForFil
|
||||
return m_subject->getSourceLocationsForFile(filePath);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>("", false);
|
||||
return std::make_shared<SourceLocationFile>("", false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForLinesInFile(
|
||||
@@ -245,7 +245,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForLin
|
||||
return m_subject->getSourceLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>("", false);
|
||||
return std::make_shared<SourceLocationFile>("", false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const
|
||||
@@ -255,7 +255,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFil
|
||||
return m_subject->getCommentLocationsInFile(filePath);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>("", false);
|
||||
return std::make_shared<SourceLocationFile>("", false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<TextAccess> StorageAccessProxy::getFileContent(const FilePath& filePath) const
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include "data/indexer/IndexerBase.h"
|
||||
#include "data/parser/ParserClientImpl.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
template <typename IndexerCommandType>
|
||||
class Indexer: public IndexerBase
|
||||
template <typename IndexerCommandType, typename ParserType>
|
||||
class Indexer
|
||||
: public IndexerBase
|
||||
{
|
||||
public:
|
||||
virtual ~Indexer();
|
||||
@@ -15,32 +18,54 @@ public:
|
||||
virtual std::string getKindString() const;
|
||||
|
||||
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommandType> indexerCommand, std::shared_ptr<FileRegister> fileRegister) = 0;
|
||||
};
|
||||
|
||||
template <typename IndexerCommandType>
|
||||
Indexer<IndexerCommandType>::~Indexer()
|
||||
template <typename IndexerCommandType, typename ParserType>
|
||||
Indexer<IndexerCommandType, ParserType>::~Indexer()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename IndexerCommandType>
|
||||
std::string Indexer<IndexerCommandType>::getKindString() const
|
||||
template <typename IndexerCommandType, typename ParserType>
|
||||
std::string Indexer<IndexerCommandType, ParserType>::getKindString() const
|
||||
{
|
||||
return IndexerCommandType::getIndexerKindString();
|
||||
}
|
||||
|
||||
template <typename IndexerCommandType>
|
||||
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType>::index(std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
||||
template <typename IndexerCommandType, typename ParserType>
|
||||
std::shared_ptr<IntermediateStorage> Indexer<IndexerCommandType, ParserType>::index(std::shared_ptr<IndexerCommand> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
|
||||
{
|
||||
if (std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand))
|
||||
std::shared_ptr<IndexerCommandType> castedCommand = std::dynamic_pointer_cast<IndexerCommandType>(indexerCommand);
|
||||
if (!castedCommand)
|
||||
{
|
||||
return index(castedCommand, fileRegister);
|
||||
LOG_ERROR("Trying to process " + indexerCommand->getKindString() + " indexer command with " + getKindString() + " indexer.");
|
||||
return std::shared_ptr<IntermediateStorage>();
|
||||
}
|
||||
|
||||
LOG_ERROR("Trying to process " + indexerCommand->getKindString() + " indexer command with " + getKindString() + " indexer.");
|
||||
return std::shared_ptr<IntermediateStorage>();
|
||||
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
|
||||
std::shared_ptr<ParserType> parser = std::make_shared<ParserType>(parserClient, fileRegister);
|
||||
|
||||
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
|
||||
parserClient->setStorage(storage);
|
||||
|
||||
parser->buildIndex(castedCommand);
|
||||
|
||||
parserClient->resetStorage();
|
||||
|
||||
if (parserClient->hasFatalErrors())
|
||||
{
|
||||
storage->setFilesIncomplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileRegister->markIndexingFilesIndexed();
|
||||
}
|
||||
|
||||
if (interrupted())
|
||||
{
|
||||
return std::shared_ptr<IntermediateStorage>();
|
||||
}
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
||||
#endif // INDEXER_H
|
||||
|
||||
@@ -113,7 +113,7 @@ SourceLocationFile* SourceLocationCollection::createSourceLocationFile(const Fil
|
||||
return file;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> filePtr = std::make_shared<SourceLocationFile>(filePath, false);
|
||||
std::shared_ptr<SourceLocationFile> filePtr = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
m_files.emplace(filePath, filePtr);
|
||||
return filePtr.get();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
|
||||
SourceLocationFile::SourceLocationFile(const FilePath& filePath, bool isWhole)
|
||||
SourceLocationFile::SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete)
|
||||
: m_filePath(filePath)
|
||||
, m_isWhole(isWhole)
|
||||
, m_isComplete(isComplete)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,6 +26,16 @@ bool SourceLocationFile::isWhole() const
|
||||
return m_isWhole;
|
||||
}
|
||||
|
||||
void SourceLocationFile::setIsComplete(bool isComplete)
|
||||
{
|
||||
m_isComplete = isComplete;
|
||||
}
|
||||
|
||||
bool SourceLocationFile::isComplete() const
|
||||
{
|
||||
return m_isComplete;
|
||||
}
|
||||
|
||||
const std::multiset<std::shared_ptr<SourceLocation>, SourceLocationFile::LocationComp>& SourceLocationFile::getSourceLocations() const
|
||||
{
|
||||
return m_locations;
|
||||
@@ -141,7 +152,7 @@ void SourceLocationFile::forEachEndSourceLocation(std::function<void(SourceLocat
|
||||
|
||||
std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByLines(size_t firstLineNumber, size_t lastLineNumber) const
|
||||
{
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(getFilePath(), false);
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(getFilePath(), false, isComplete());
|
||||
|
||||
for (std::shared_ptr<SourceLocation> location : m_locations)
|
||||
{
|
||||
@@ -156,7 +167,7 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByLines(size_
|
||||
|
||||
std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByType(LocationType type) const
|
||||
{
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(getFilePath(), false);
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(getFilePath(), false, isComplete());
|
||||
|
||||
for (std::shared_ptr<SourceLocation> location : m_locations)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
SourceLocationFile(const FilePath& filePath, bool isWhole);
|
||||
SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete);
|
||||
virtual ~SourceLocationFile();
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
void setIsWhole(bool isWhole);
|
||||
bool isWhole() const;
|
||||
|
||||
void setIsComplete(bool isComplete);
|
||||
bool isComplete() const;
|
||||
|
||||
const std::multiset<std::shared_ptr<SourceLocation>, LocationComp>& getSourceLocations() const;
|
||||
|
||||
size_t getSourceLocationCount() const;
|
||||
@@ -52,6 +55,7 @@ public:
|
||||
private:
|
||||
const FilePath m_filePath;
|
||||
bool m_isWhole;
|
||||
bool m_isComplete;
|
||||
|
||||
std::multiset<std::shared_ptr<SourceLocation>, LocationComp> m_locations;
|
||||
std::map<Id, SourceLocation*> m_locationIndex;
|
||||
|
||||
@@ -72,9 +72,25 @@ std::string ParserClient::addLocationSuffix(
|
||||
}
|
||||
|
||||
ParserClient::ParserClient()
|
||||
: m_hasFatalErrors(false)
|
||||
{
|
||||
}
|
||||
|
||||
ParserClient::~ParserClient()
|
||||
{
|
||||
}
|
||||
|
||||
void ParserClient::onErrorParsed(const ParseLocation& location, const std::string& message, bool fatal, bool indexed)
|
||||
{
|
||||
this->onError(location, message, fatal, indexed);
|
||||
|
||||
if (fatal)
|
||||
{
|
||||
m_hasFatalErrors = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParserClient::hasFatalErrors() const
|
||||
{
|
||||
return m_hasFatalErrors;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ public:
|
||||
ParserClient();
|
||||
virtual ~ParserClient();
|
||||
|
||||
virtual void startParsingFile() = 0;
|
||||
virtual void finishParsingFile() = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
@@ -53,6 +50,13 @@ public:
|
||||
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);
|
||||
|
||||
bool hasFatalErrors() const;
|
||||
|
||||
protected:
|
||||
bool m_hasFatalErrors;
|
||||
};
|
||||
|
||||
#endif // PARSER_CLIENT_H
|
||||
|
||||
@@ -18,19 +18,15 @@ ParserClientImpl::~ParserClientImpl()
|
||||
void ParserClientImpl::setStorage(std::shared_ptr<IntermediateStorage> storage)
|
||||
{
|
||||
m_storage = storage;
|
||||
|
||||
m_hasFatalErrors = 0;
|
||||
}
|
||||
|
||||
void ParserClientImpl::resetStorage()
|
||||
{
|
||||
m_storage.reset();
|
||||
}
|
||||
|
||||
void ParserClientImpl::startParsingFile()
|
||||
{
|
||||
}
|
||||
|
||||
void ParserClientImpl::finishParsingFile()
|
||||
{
|
||||
m_hasFatalErrors = 0;
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
@@ -236,7 +232,7 @@ void ParserClientImpl::addFile(Id id, const FilePath& filePath, const std::strin
|
||||
return;
|
||||
}
|
||||
|
||||
m_storage->addFile(id, filePath.str(), modificationTime);
|
||||
m_storage->addFile(id, filePath.str(), modificationTime, true);
|
||||
}
|
||||
|
||||
void ParserClientImpl::addSymbol(Id id, DefinitionKind definitionKind)
|
||||
|
||||
@@ -19,9 +19,6 @@ public:
|
||||
void setStorage(std::shared_ptr<IntermediateStorage> storage);
|
||||
void resetStorage();
|
||||
|
||||
virtual void startParsingFile();
|
||||
virtual void finishParsingFile();
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
@@ -270,6 +270,7 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
}
|
||||
|
||||
std::set<FilePath> filesToClean;
|
||||
if (!needsFullRefresh)
|
||||
{
|
||||
std::set<FilePath> unchangedFilePaths;
|
||||
std::set<FilePath> changedFilePaths;
|
||||
|
||||
Reference in New Issue
Block a user