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
@@ -97,6 +97,8 @@
<hover>#BBBBBB</hover>
<press>#AAAAAA</press>
<icon>black</icon>
<border>#B1B1B1</border>
<hatching>grey</hatching>
</title>
<ref_count>
@@ -331,6 +333,9 @@
<icon>
<normal>#FFFFFF</normal>
</icon>
<hatching>
<normal>#999999</normal>
</hatching>
</file>
<macro>
<like>file</like>
+2
View File
@@ -97,6 +97,8 @@
<hover>#B2B2B2</hover>
<press>#626262</press>
<icon>black</icon>
<border>white</border>
<hatching>bright</hatching>
</title>
<ref_count>
+2
View File
@@ -97,6 +97,8 @@
<hover>#555555</hover>
<press>#444444</press>
<icon>white</icon>
<border>#272728</border>
<hatching>dark</hatching>
</title>
<ref_count>
+14 -21
View File
@@ -96,24 +96,35 @@
padding-right: 5px;
}
#code_file #title_label {
#code_file #title_label, #single_file_title_bar #file_title {
background-color: <color:code/file/title/normal>;
border: none;
border-radius: 3px;
color: <color:code/file/title/text>;
font-size: <setting:font_size>px;
padding: 2px 4px;
}
#code_file #title_label {
margin: 1px 8px 3px;
}
#code_file #title_label:hover {
#single_file_title_bar #file_title {
margin: 3px 8px;
}
#code_file #title_label:hover, #single_file_title_bar #file_title:hover {
background-color: <color:code/file/title/hover>;
}
#code_file #title_label:pressed {
#code_file #title_label:pressed, #single_file_title_bar #file_title:pressed {
background-color: <color:code/file/title/press>;
}
#code_file #title_label[complete=false], #single_file_title_bar #file_title[complete=false] {
border: 1px solid <color:code/file/title/border>;
}
#code_file #references_label, #single_file_title_bar #references_label {
background-color: <color:code/file/ref_count/background>;
border: none;
@@ -209,21 +220,3 @@
background-color: <color:code/file/background>;
padding-right: 5px;
}
#single_file_title_bar #file_title {
background-color: <color:code/file/title/normal>;
border: none;
border-radius: 3px;
color: <color:code/file/title/text>;
font-size: <setting:font_size>px;
padding: 2px 4px;
margin: 3px 8px;
}
#single_file_title_bar #file_title:hover {
background-color: <color:code/file/title/hover>;
}
#single_file_title_bar #file_title:pressed {
background-color: <color:code/file/title/press>;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -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)
+3 -1
View File
@@ -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)
{
}
+3 -1
View File
@@ -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);
+10 -2
View File
@@ -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())
+2 -1
View File
@@ -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);
+26 -6
View File
@@ -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
{
+1 -1
View File
@@ -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);
+27 -10
View File
@@ -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();
}
+8 -2
View File
@@ -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;
+1 -1
View File
@@ -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);
}
);
+1 -1
View File
@@ -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;
+2
View File
@@ -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;
};
+4 -1
View File
@@ -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
+21 -17
View File
@@ -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;
}
+3 -3
View File
@@ -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
+40 -15
View File
@@ -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();
}
+14 -3
View File
@@ -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)
{
+5 -1
View File
@@ -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;
+16
View File
@@ -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;
}
+7 -3
View File
@@ -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
+4 -8
View File
@@ -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)
-3
View File
@@ -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);
+1
View File
@@ -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;
+4 -8
View File
@@ -1,20 +1,16 @@
add_files(
LIB_CXX_FILES
data/indexer/IndexerCommandCxxCdb.cpp
data/indexer/IndexerCommandCxxCdb.h
data/indexer/IndexerCommandCxxManual.cpp
data/indexer/IndexerCommandCxxManual.h
data/indexer/IndexerCxxCdb.cpp
data/indexer/IndexerCxxCdb.h
data/indexer/IndexerCxxManual.cpp
data/indexer/IndexerCxxManual.h
data/indexer/IndexerFactoryModuleCxxCdb.cpp
data/indexer/IndexerFactoryModuleCxxCdb.h
data/indexer/IndexerFactoryModuleCxxManual.cpp
data/indexer/IndexerFactoryModuleCxxManual.h
data/parser/cxx/name/CxxDeclName.cpp
data/parser/cxx/name/CxxDeclName.h
data/parser/cxx/name/CxxFunctionDeclName.cpp
@@ -25,7 +21,7 @@ add_files(
data/parser/cxx/name/CxxQualifierFlags.h
data/parser/cxx/name/CxxTypeName.cpp
data/parser/cxx/name/CxxTypeName.h
data/parser/cxx/name_resolver/CxxDeclNameResolver.cpp
data/parser/cxx/name_resolver/CxxDeclNameResolver.h
data/parser/cxx/name_resolver/CxxNameResolver.cpp
@@ -73,7 +69,7 @@ add_files(
data/parser/cxx/PreprocessorCallbacks.h
data/parser/cxx/utilityCxxAstVisitor.cpp
data/parser/cxx/utilityCxxAstVisitor.h
project/SourceGroupCxx.cpp
project/SourceGroupCxx.h
project/SourceGroupFactoryModuleCpp.cpp
@@ -1,6 +1,25 @@
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
std::vector<FilePath> IndexerCommandCxxCdb::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
{
std::string error;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
std::vector<FilePath> filePaths;
if (cdb)
{
std::vector<std::string> files = cdb->getAllFiles();
for (const std::string& file : files)
{
filePaths.push_back(FilePath(file));
}
}
return filePaths;
}
std::string IndexerCommandCxxCdb::getIndexerKindString()
{
@@ -17,6 +17,8 @@ namespace clang
class IndexerCommandCxxCdb: public IndexerCommand
{
public:
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
static std::string getIndexerKindString();
IndexerCommandCxxCdb(
@@ -1,47 +0,0 @@
#include "data/indexer/IndexerCxxCdb.h"
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "data/parser/ParserClientImpl.h"
#include "data/parser/cxx/CxxParser.h"
#include "utility/file/FileRegister.h"
std::vector<FilePath> IndexerCxxCdb::getSourceFilesFromCDB(const FilePath& compilationDatabasePath)
{
std::string error;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
(clang::tooling::JSONCompilationDatabase::loadFromFile(compilationDatabasePath.str(), error));
std::vector<FilePath> filePaths;
if (cdb)
{
std::vector<std::string> files = cdb->getAllFiles();
for (const std::string& file : files)
{
filePaths.push_back(FilePath(file));
}
}
return filePaths;
}
std::shared_ptr<IntermediateStorage> IndexerCxxCdb::index(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<CxxParser> parser = std::make_shared<CxxParser>(parserClient, fileRegister);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
parserClient->setStorage(storage);
parserClient->startParsingFile();
parser->buildIndex(indexerCommand);
fileRegister->markIndexingFilesIndexed();
parserClient->finishParsingFile();
parserClient->resetStorage();
if (interrupted())
{
return std::shared_ptr<IntermediateStorage>();
}
return storage;
}
-20
View File
@@ -1,20 +0,0 @@
#ifndef INDEXER_CXX_CDB_H
#define INDEXER_CXX_CDB_H
#include <vector>
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "utility/file/FilePath.h"
class IndexerCxxCdb: public Indexer<IndexerCommandCxxCdb>
{
public:
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
private:
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
};
#endif // INDEXER_CXX_CDB_H
@@ -1,28 +0,0 @@
#include "data/indexer/IndexerCxxManual.h"
#include "data/parser/ParserClientImpl.h"
#include "data/parser/cxx/CxxParser.h"
#include "utility/file/FileRegister.h"
std::shared_ptr<IntermediateStorage> IndexerCxxManual::index(std::shared_ptr<IndexerCommandCxxManual> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<CxxParser> parser = std::make_shared<CxxParser>(parserClient, fileRegister);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
parserClient->setStorage(storage);
parserClient->startParsingFile();
parser->buildIndex(indexerCommand);
fileRegister->markIndexingFilesIndexed();
parserClient->finishParsingFile();
parserClient->resetStorage();
if (interrupted())
{
return std::shared_ptr<IntermediateStorage>();
}
return storage;
}
@@ -1,13 +0,0 @@
#ifndef INDEXER_CXX_MANUAL_H
#define INDEXER_CXX_MANUAL_H
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandCxxManual.h"
class IndexerCxxManual: public Indexer<IndexerCommandCxxManual>
{
private:
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommandCxxManual> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
};
#endif // INDEXER_CXX_MANUAL_H
@@ -1,6 +1,8 @@
#include "data/indexer/IndexerFactoryModuleCxxCdb.h"
#include "data/indexer/IndexerCxxCdb.h"
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "data/parser/cxx/CxxParser.h"
IndexerFactoryModuleCxxCdb::~IndexerFactoryModuleCxxCdb()
{
@@ -8,5 +10,5 @@ IndexerFactoryModuleCxxCdb::~IndexerFactoryModuleCxxCdb()
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxCdb::createIndexer()
{
return std::make_shared<IndexerCxxCdb>();
return std::make_shared<Indexer<IndexerCommandCxxCdb, CxxParser>>();
}
@@ -1,6 +1,8 @@
#include "data/indexer/IndexerFactoryModuleCxxManual.h"
#include "data/indexer/IndexerCxxManual.h"
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandCxxManual.h"
#include "data/parser/cxx/CxxParser.h"
IndexerFactoryModuleCxxManual::~IndexerFactoryModuleCxxManual()
{
@@ -8,5 +10,5 @@ IndexerFactoryModuleCxxManual::~IndexerFactoryModuleCxxManual()
std::shared_ptr<IndexerBase> IndexerFactoryModuleCxxManual::createIndexer()
{
return std::make_shared<IndexerCxxManual>();
return std::make_shared<Indexer<IndexerCommandCxxManual, CxxParser>>();
}
@@ -13,6 +13,7 @@
#include "data/parser/cxx/CxxAstVisitorComponentImplicitCode.h"
#include "data/parser/cxx/CxxAstVisitorComponentIndexer.h"
#include "data/parser/cxx/utilityCxxAstVisitor.h"
#include "data/parser/ParserClient.h"
#include "data/parser/ParseLocation.h"
@@ -282,6 +283,11 @@ bool CxxAstVisitor::TraverseTemplateTemplateParmDecl(clang::TemplateTemplateParm
return true;
}
bool CxxAstVisitor::VisitTranslationUnitDecl(clang::TranslationUnitDecl *d)
{
return !m_client->hasFatalErrors();
}
bool CxxAstVisitor::TraverseNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc loc)
{
bool ret = true;
@@ -117,6 +117,7 @@ public:
virtual bool VisitNonTypeTemplateParmDecl(clang::NonTypeTemplateParmDecl* d);
virtual bool VisitTemplateTypeParmDecl(clang::TemplateTypeParmDecl* d);
virtual bool VisitTemplateTemplateParmDecl(clang::TemplateTemplateParmDecl* d);
virtual bool VisitTranslationUnitDecl(clang::TranslationUnitDecl *d);
virtual bool VisitTypeLoc(clang::TypeLoc tl);
@@ -81,7 +81,7 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
ParseLocation location(filePath, line, column);
m_client->onError(
m_client->onErrorParsed(
location,
message,
level == clang::DiagnosticsEngine::Fatal,
+2 -2
View File
@@ -5,7 +5,7 @@
#include "clang/Tooling/JSONCompilationDatabase.h"
#include "data/indexer/IndexerCommandCxxManual.h"
#include "data/indexer/IndexerCxxCdb.h"
#include "data/indexer/IndexerCommandCxxCdb.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FileRegister.h"
#include "utility/file/FileSystem.h"
@@ -59,7 +59,7 @@ void SourceGroupCxx::fetchAllSourceFilePaths()
FilePath cdbPath = m_settings->getAbsoluteCompilationDatabasePath();
if (cdbPath.exists())
{
sourcePaths = IndexerCxxCdb::getSourceFilesFromCDB(cdbPath);
sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
}
else
{
+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)
{
+3 -5
View File
@@ -6,21 +6,19 @@ add_files(
data/indexer/IndexerCommandJava.h
data/indexer/IndexerFactoryModuleJava.cpp
data/indexer/IndexerFactoryModuleJava.h
data/indexer/IndexerJava.cpp
data/indexer/IndexerJava.h
data/parser/java/JavaParser.cpp
data/parser/java/JavaParser.h
data/parser/java/JavaEnvironment.cpp
data/parser/java/JavaEnvironment.h
data/parser/java/JavaEnvironmentFactory.cpp
data/parser/java/JavaEnvironmentFactory.h
project/SourceGroupJava.cpp
project/SourceGroupJava.h
project/SourceGroupFactoryModuleJava.cpp
project/SourceGroupFactoryModuleJava.h
utility/utilityMaven.cpp
utility/utilityMaven.h
)
@@ -1,6 +1,8 @@
#include "data/indexer/IndexerFactoryModuleJava.h"
#include "data/indexer/IndexerJava.h"
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandJava.h"
#include "data/parser/java/JavaParser.h"
IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
{
@@ -8,5 +10,5 @@ IndexerFactoryModuleJava::~IndexerFactoryModuleJava()
std::shared_ptr<IndexerBase> IndexerFactoryModuleJava::createIndexer()
{
return std::make_shared<IndexerJava>();
return std::make_shared<Indexer<IndexerCommandJava, JavaParser>>();
}
-37
View File
@@ -1,37 +0,0 @@
#include "data/indexer/IndexerJava.h"
#include "data/parser/ParserClientImpl.h"
#include "data/parser/java/JavaParser.h"
#include "utility/file/FileRegister.h"
IndexerJava::IndexerJava()
{
}
IndexerJava::~IndexerJava()
{
}
std::shared_ptr<IntermediateStorage> IndexerJava::index(std::shared_ptr<IndexerCommandJava> indexerCommand, std::shared_ptr<FileRegister> fileRegister)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
parserClient->setStorage(storage);
parserClient->startParsingFile();
fileRegister->markFileIndexing(indexerCommand->getSourceFilePath());
parser->buildIndex(indexerCommand);
fileRegister->markIndexingFilesIndexed();
parserClient->finishParsingFile();
parserClient->resetStorage();
if (interrupted())
{
return std::shared_ptr<IntermediateStorage>();
}
return storage;
}
-17
View File
@@ -1,17 +0,0 @@
#ifndef INDEXER_JAVA_H
#define INDEXER_JAVA_H
#include "data/indexer/Indexer.h"
#include "data/indexer/IndexerCommandJava.h"
class IndexerJava: public Indexer<IndexerCommandJava>
{
public:
IndexerJava();
virtual ~IndexerJava();
private:
virtual std::shared_ptr<IntermediateStorage> index(std::shared_ptr<IndexerCommandJava> indexerCommand, std::shared_ptr<FileRegister> fileRegister);
};
#endif // INDEXER_JAVA_H
+1 -1
View File
@@ -11,7 +11,7 @@
#include "utility/text/TextAccess.h"
#include "utility/utilityString.h"
JavaParser::JavaParser(std::shared_ptr<ParserClient> client)
JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister)
: Parser(client)
, m_id(s_nextParserId++)
, m_currentFilePath("")
+1 -2
View File
@@ -29,7 +29,7 @@ class FileRegister;
class JavaParser: public Parser
{
public:
JavaParser(std::shared_ptr<ParserClient> client);
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
~JavaParser();
void buildIndex(std::shared_ptr<IndexerCommandJava> indexerCommand);
@@ -168,7 +168,6 @@ private:
void doRecordComment(jint beginLine, jint beginColumn, jint endLine, jint endColumn);
void doRecordError(jstring jMessage, jint jFatal, jint jIndexed, jint beginLine, jint beginColumn, jint endLine, jint endColumn);
std::shared_ptr<FileRegister> m_fileRegister;
std::shared_ptr<JavaEnvironment> m_javaEnvironment;
const int m_id;
+1 -2
View File
@@ -10,7 +10,6 @@
#include "data/parser/java/JavaEnvironmentFactory.h"
#include "data/parser/java/JavaParser.h"
#include "helper/TestFileRegister.h"
#include "helper/TestParserClient.h"
@@ -842,7 +841,7 @@ private:
setupJavaEnvironmentFactory();
JavaParser parser(parserClient);
JavaParser parser(parserClient, nullptr);
parser.buildIndex("input.cc", textAccess);
return parserClient;
+1 -1
View File
@@ -24,7 +24,7 @@ public:
std::shared_ptr<IntermediateStorage> intermetiateStorage = std::make_shared<IntermediateStorage>();
Id id = intermetiateStorage->addNode(Node::typeToInt(Node::NODE_FILE), NameHierarchy::serialize(NameHierarchy(filePath)));
intermetiateStorage->addFile(id, filePath, "someTime");
intermetiateStorage->addFile(id, filePath, "someTime", true);
storage.inject(intermetiateStorage.get());
-8
View File
@@ -7,14 +7,6 @@
class TestParserClient: public ParserClient
{
public:
virtual void startParsingFile()
{
}
virtual void finishParsingFile()
{
}
virtual Id recordSymbol(
const NameHierarchy& symbolName, SymbolKind symbolKind,
AccessKind access, DefinitionKind definitionKind)