logic: record and display include edges for non-indexed files
* non-indexed files are shown in graph view and in code view * non-indexed files are ignored in search view, overview, stats and refresh dialog
This commit is contained in:
@@ -46,7 +46,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
||||
|
||||
statsSnippet.reduced = true;
|
||||
|
||||
statsSnippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(), true, true);
|
||||
statsSnippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(), true, true, true);
|
||||
|
||||
std::vector<std::string> description = getProjectDescription(statsSnippet.locationFile.get());
|
||||
|
||||
|
||||
@@ -172,6 +172,30 @@ void GraphController::handleMessage(MessageActivateTrail* message)
|
||||
std::shared_ptr<Graph> graph = m_storageAccess->getGraphForTrail(
|
||||
message->originId, message->targetId, message->trailType, message->depth);
|
||||
|
||||
// remove non-indexed files from include graph if indexed file is origin
|
||||
if (message->trailType & Edge::EDGE_INCLUDE)
|
||||
{
|
||||
Node* fileNode = graph->getNodeById(message->originId ? message->originId : message->targetId);
|
||||
if (fileNode && fileNode->isDefined())
|
||||
{
|
||||
std::vector<Node*> nodesToRemove;
|
||||
graph->forEachNode(
|
||||
[&nodesToRemove](Node* node)
|
||||
{
|
||||
if (!node->isDefined())
|
||||
{
|
||||
nodesToRemove.push_back(node);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
for (Node* node : nodesToRemove)
|
||||
{
|
||||
graph->removeNode(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (graph->getNodeCount() > 1000)
|
||||
{
|
||||
int r = Application::getInstance()->handleDialog(
|
||||
|
||||
@@ -697,6 +697,9 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
|
||||
|
||||
case Edge::EDGE_INCLUDE:
|
||||
style.zValue = isActive ? 2 : -3;
|
||||
case Edge::EDGE_MACRO_USAGE:
|
||||
style.originOffset.y = 0;
|
||||
style.targetOffset.y = 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForFil
|
||||
return m_subject->getSourceLocationsForFile(filePath);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForLinesInFile(
|
||||
@@ -268,7 +268,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsForLin
|
||||
return m_subject->getSourceLocationsForLinesInFile(filePath, startLine, endLine);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsOfTypeInFile(
|
||||
@@ -280,7 +280,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getSourceLocationsOfType
|
||||
return m_subject->getSourceLocationsOfTypeInFile(filePath, type);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFile(const FilePath& filePath) const
|
||||
@@ -290,7 +290,7 @@ std::shared_ptr<SourceLocationFile> StorageAccessProxy::getCommentLocationsInFil
|
||||
return m_subject->getCommentLocationsInFile(filePath);
|
||||
}
|
||||
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false);
|
||||
return std::make_shared<SourceLocationFile>(FilePath(), false, false, false);
|
||||
}
|
||||
|
||||
std::shared_ptr<TextAccess> StorageAccessProxy::getFileContent(const FilePath& filePath) const
|
||||
|
||||
@@ -41,7 +41,7 @@ void Graph::forEachToken(std::function<void(Token*)> func) const
|
||||
forEachEdge(func);
|
||||
}
|
||||
|
||||
Node* Graph::createNode(Id id, NodeType type, const NameHierarchy& nameHierarchy, bool defined)
|
||||
Node* Graph::createNode(Id id, NodeType type, const NameHierarchy& nameHierarchy, DefinitionKind definitionKind)
|
||||
{
|
||||
Node* n = getNodeById(id);
|
||||
if (n)
|
||||
@@ -49,7 +49,7 @@ Node* Graph::createNode(Id id, NodeType type, const NameHierarchy& nameHierarchy
|
||||
return n;
|
||||
}
|
||||
|
||||
std::shared_ptr<Node> node = std::make_shared<Node>(id, type, nameHierarchy, defined);
|
||||
std::shared_ptr<Node> node = std::make_shared<Node>(id, type, nameHierarchy, definitionKind);
|
||||
m_nodes.emplace(node->getId(), node);
|
||||
return node.get();
|
||||
}
|
||||
@@ -122,24 +122,36 @@ void Graph::removeNode(Node* node)
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Node*> childNodesToRemove;
|
||||
node->forEachEdgeOfType(
|
||||
Edge::EDGE_MEMBER,
|
||||
[this, node](Edge* e)
|
||||
[node, &childNodesToRemove](Edge* e)
|
||||
{
|
||||
if (node == e->getFrom())
|
||||
{
|
||||
this->removeNode(e->getTo());
|
||||
childNodesToRemove.push_back(e->getTo());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
for (Node* childNode : childNodesToRemove)
|
||||
{
|
||||
removeNode(childNode);
|
||||
}
|
||||
|
||||
std::vector<Edge*> edgesToRemove;
|
||||
node->forEachEdge(
|
||||
[this](Edge* e)
|
||||
[&edgesToRemove](Edge* e)
|
||||
{
|
||||
this->removeEdgeInternal(e);
|
||||
edgesToRemove.push_back(e);
|
||||
}
|
||||
);
|
||||
|
||||
for (Edge* edge : edgesToRemove)
|
||||
{
|
||||
removeEdgeInternal(edge);
|
||||
}
|
||||
|
||||
if (node->getEdgeCount())
|
||||
{
|
||||
LOG_ERROR("Node still has edges.");
|
||||
@@ -349,11 +361,10 @@ void Graph::printBasic(std::wostream& ostream) const
|
||||
|
||||
void Graph::removeEdgeInternal(Edge* edge)
|
||||
{
|
||||
std::map<Id, std::shared_ptr<Edge> >::const_iterator it = m_edges.find(edge->getId());
|
||||
std::map<Id, std::shared_ptr<Edge>>::const_iterator it = m_edges.find(edge->getId());
|
||||
if (it != m_edges.end() && it->second.get() == edge)
|
||||
{
|
||||
m_edges.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
void forEachEdge(std::function<void(Edge*)> func) const;
|
||||
void forEachToken(std::function<void(Token*)> func) const;
|
||||
|
||||
Node* createNode(Id id, NodeType type, const NameHierarchy& nameHierarchy, bool defined);
|
||||
Node* createNode(Id id, NodeType type, const NameHierarchy& nameHierarchy, DefinitionKind definitionKind);
|
||||
Edge* createEdge(Id id, Edge::EdgeType type, Node* from, Node* to);
|
||||
|
||||
size_t getNodeCount() const;
|
||||
|
||||
@@ -9,13 +9,11 @@
|
||||
#include "data/graph/token_component/TokenComponentConst.h"
|
||||
#include "data/graph/token_component/TokenComponentStatic.h"
|
||||
|
||||
Node::Node(Id id, NodeType type, const NameHierarchy& nameHierarchy, bool defined)
|
||||
Node::Node(Id id, NodeType type, const NameHierarchy& nameHierarchy, DefinitionKind definitionKind)
|
||||
: Token(id)
|
||||
, m_type(type)
|
||||
, m_nameHierarchy(nameHierarchy)
|
||||
, m_defined(defined)
|
||||
, m_implicit(false)
|
||||
, m_explicit(false)
|
||||
, m_definitionKind(definitionKind)
|
||||
, m_childCount(0)
|
||||
{
|
||||
}
|
||||
@@ -24,9 +22,7 @@ Node::Node(const Node& other)
|
||||
: Token(other)
|
||||
, m_type(other.m_type)
|
||||
, m_nameHierarchy(other.m_nameHierarchy)
|
||||
, m_defined(other.m_defined)
|
||||
, m_implicit(other.m_implicit)
|
||||
, m_explicit(other.m_explicit)
|
||||
, m_definitionKind(other.m_definitionKind)
|
||||
, m_childCount(other.m_childCount)
|
||||
{
|
||||
}
|
||||
@@ -75,32 +71,17 @@ NameHierarchy Node::getNameHierarchy() const
|
||||
|
||||
bool Node::isDefined() const
|
||||
{
|
||||
return m_defined;
|
||||
}
|
||||
|
||||
void Node::setDefined(bool defined)
|
||||
{
|
||||
m_defined = defined;
|
||||
return m_definitionKind != DEFINITION_NONE;
|
||||
}
|
||||
|
||||
bool Node::isImplicit() const
|
||||
{
|
||||
return m_implicit;
|
||||
}
|
||||
|
||||
void Node::setImplicit(bool implicit)
|
||||
{
|
||||
m_implicit = implicit;
|
||||
return m_definitionKind == DEFINITION_IMPLICIT;
|
||||
}
|
||||
|
||||
bool Node::isExplicit() const
|
||||
{
|
||||
return m_explicit;
|
||||
}
|
||||
|
||||
void Node::setExplicit(bool bExplicit)
|
||||
{
|
||||
m_explicit = bExplicit;
|
||||
return m_definitionKind == DEFINITION_EXPLICIT;
|
||||
}
|
||||
|
||||
size_t Node::getChildCount() const
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "data/DefinitionKind.h"
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/name/NameHierarchy.h"
|
||||
@@ -15,7 +16,7 @@ class Node
|
||||
: public Token
|
||||
{
|
||||
public:
|
||||
Node(Id id, NodeType type, const NameHierarchy& nameHierarchy, bool defined);
|
||||
Node(Id id, NodeType type, const NameHierarchy& nameHierarchy, DefinitionKind definitionKind);
|
||||
Node(const Node& other);
|
||||
virtual ~Node();
|
||||
|
||||
@@ -28,13 +29,8 @@ public:
|
||||
NameHierarchy getNameHierarchy() const;
|
||||
|
||||
bool isDefined() const;
|
||||
void setDefined(bool defined);
|
||||
|
||||
bool isImplicit() const;
|
||||
void setImplicit(bool implicit);
|
||||
|
||||
bool isExplicit() const;
|
||||
void setExplicit(bool bExplicit);
|
||||
|
||||
size_t getChildCount() const;
|
||||
void setChildCount(size_t childCount);
|
||||
@@ -73,9 +69,7 @@ private:
|
||||
|
||||
NodeType m_type;
|
||||
NameHierarchy m_nameHierarchy;
|
||||
bool m_defined;
|
||||
bool m_implicit;
|
||||
bool m_explicit;
|
||||
DefinitionKind m_definitionKind;
|
||||
|
||||
size_t m_childCount;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
|
||||
TokenComponentFilePath::TokenComponentFilePath(const FilePath& path)
|
||||
TokenComponentFilePath::TokenComponentFilePath(const FilePath& path, bool complete)
|
||||
: m_path(path)
|
||||
, m_complete(complete)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,3 +19,8 @@ const FilePath& TokenComponentFilePath::getFilePath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
|
||||
bool TokenComponentFilePath::isComplete() const
|
||||
{
|
||||
return m_complete;
|
||||
}
|
||||
|
||||
@@ -9,15 +9,17 @@ class TokenComponentFilePath
|
||||
: public TokenComponent
|
||||
{
|
||||
public:
|
||||
TokenComponentFilePath(const FilePath& path);
|
||||
TokenComponentFilePath(const FilePath& path, bool complete);
|
||||
virtual ~TokenComponentFilePath();
|
||||
|
||||
virtual std::shared_ptr<TokenComponent> copy() const;
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
bool isComplete() const;
|
||||
|
||||
private:
|
||||
const FilePath m_path;
|
||||
const bool m_complete;
|
||||
};
|
||||
|
||||
#endif // TOKEN_COMPONENT_FILE_PATH_H
|
||||
|
||||
@@ -67,28 +67,30 @@ inline StorageNode fromShared(const SharedStorageNode& node)
|
||||
struct SharedStorageFile
|
||||
{
|
||||
SharedStorageFile(
|
||||
Id id, const std::string& filePath, const std::string& modificationTime, bool complete, SharedMemory::Allocator* allocator
|
||||
Id id, const std::string& filePath, const std::string& modificationTime, bool indexed, bool complete, SharedMemory::Allocator* allocator
|
||||
)
|
||||
: id(id)
|
||||
, filePath(filePath.c_str(), allocator)
|
||||
, modificationTime(modificationTime.c_str(), allocator)
|
||||
, indexed(indexed)
|
||||
, complete(complete)
|
||||
{}
|
||||
|
||||
Id id;
|
||||
SharedMemory::String filePath;
|
||||
SharedMemory::String modificationTime;
|
||||
bool indexed;
|
||||
bool complete;
|
||||
};
|
||||
|
||||
inline SharedStorageFile toShared(const StorageFile& file, SharedMemory::Allocator* allocator)
|
||||
{
|
||||
return SharedStorageFile(file.id, utility::encodeToUtf8(file.filePath), file.modificationTime, file.complete, allocator);
|
||||
return SharedStorageFile(file.id, utility::encodeToUtf8(file.filePath), file.modificationTime, file.indexed, file.complete, allocator);
|
||||
}
|
||||
|
||||
inline StorageFile fromShared(const SharedStorageFile& file)
|
||||
{
|
||||
return StorageFile(file.id, utility::decodeFromUtf8(file.filePath.c_str()), file.modificationTime.c_str(), file.complete);
|
||||
return StorageFile(file.id, utility::decodeFromUtf8(file.filePath.c_str()), file.modificationTime.c_str(), file.indexed, file.complete);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ SourceLocationFile* SourceLocationCollection::createSourceLocationFile(const Fil
|
||||
return file;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> filePtr = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
std::shared_ptr<SourceLocationFile> filePtr = std::make_shared<SourceLocationFile>(filePath, false, false, false);
|
||||
m_files.emplace(filePath, filePtr);
|
||||
return filePtr.get();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
|
||||
SourceLocationFile::SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete)
|
||||
SourceLocationFile::SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete, bool isIndexed)
|
||||
: m_filePath(filePath)
|
||||
, m_isWhole(isWhole)
|
||||
, m_isComplete(isComplete)
|
||||
, m_isIndexed(isIndexed)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,6 +37,16 @@ bool SourceLocationFile::isComplete() const
|
||||
return m_isComplete;
|
||||
}
|
||||
|
||||
void SourceLocationFile::setIsIndexed(bool isIndexed)
|
||||
{
|
||||
m_isIndexed = isIndexed;
|
||||
}
|
||||
|
||||
bool SourceLocationFile::isIndexed() const
|
||||
{
|
||||
return m_isIndexed;
|
||||
}
|
||||
|
||||
const std::multiset<std::shared_ptr<SourceLocation>, SourceLocationFile::LocationComp>& SourceLocationFile::getSourceLocations() const
|
||||
{
|
||||
return m_locations;
|
||||
@@ -167,9 +178,11 @@ void SourceLocationFile::forEachEndSourceLocation(std::function<void(SourceLocat
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByLines(size_t firstLineNumber, size_t lastLineNumber) const
|
||||
std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByLines(
|
||||
size_t firstLineNumber, size_t lastLineNumber) const
|
||||
{
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(getFilePath(), false, isComplete());
|
||||
std::shared_ptr<SourceLocationFile> ret =
|
||||
std::make_shared<SourceLocationFile>(getFilePath(), false, isComplete(), isIndexed());
|
||||
|
||||
for (const std::shared_ptr<SourceLocation>& location : m_locations)
|
||||
{
|
||||
@@ -184,7 +197,8 @@ 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, isComplete());
|
||||
std::shared_ptr<SourceLocationFile> ret =
|
||||
std::make_shared<SourceLocationFile>(getFilePath(), false, isComplete(), isIndexed());
|
||||
|
||||
for (const std::shared_ptr<SourceLocation>& location : m_locations)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete);
|
||||
SourceLocationFile(const FilePath& filePath, bool isWhole, bool isComplete, bool isIndexed);
|
||||
virtual ~SourceLocationFile();
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
@@ -34,6 +34,9 @@ public:
|
||||
void setIsComplete(bool isComplete);
|
||||
bool isComplete() const;
|
||||
|
||||
void setIsIndexed(bool isIndexed);
|
||||
bool isIndexed() const;
|
||||
|
||||
const std::multiset<std::shared_ptr<SourceLocation>, LocationComp>& getSourceLocations() const;
|
||||
|
||||
size_t getSourceLocationCount() const;
|
||||
@@ -60,6 +63,7 @@ private:
|
||||
const FilePath m_filePath;
|
||||
bool m_isWhole;
|
||||
bool m_isComplete;
|
||||
bool m_isIndexed;
|
||||
|
||||
std::multiset<std::shared_ptr<SourceLocation>, LocationComp> m_locations;
|
||||
std::map<Id, SourceLocation*> m_locationIndex;
|
||||
|
||||
@@ -51,9 +51,9 @@ public:
|
||||
|
||||
void recordError(
|
||||
const ParseLocation& location, const std::wstring& message, bool fatal, bool indexed);
|
||||
|
||||
|
||||
virtual void recordLocalSymbol(const std::wstring& name, const ParseLocation& location) = 0;
|
||||
virtual void recordFile(const FileInfo& fileInfo) = 0;
|
||||
virtual void recordFile(const FileInfo& fileInfo, bool indexed) = 0;
|
||||
virtual void recordComment(const ParseLocation& location) = 0;
|
||||
|
||||
bool hasFatalErrors() const;
|
||||
|
||||
@@ -79,10 +79,10 @@ void ParserClientImpl::recordLocalSymbol(const std::wstring& name, const ParseLo
|
||||
addSourceLocation(localSymbolId, location, locationTypeToInt(LOCATION_LOCAL_SYMBOL));
|
||||
}
|
||||
|
||||
void ParserClientImpl::recordFile(const FileInfo& fileInfo)
|
||||
void ParserClientImpl::recordFile(const FileInfo& fileInfo, bool indexed)
|
||||
{
|
||||
const Id nodeId = addNodeHierarchy(NameHierarchy(fileInfo.path.wstr(), NAME_DELIMITER_FILE), NodeType::NODE_FILE);
|
||||
addFile(nodeId, fileInfo.path, fileInfo.lastWriteTime.toString());
|
||||
addFile(nodeId, fileInfo.path, fileInfo.lastWriteTime.toString(), indexed);
|
||||
}
|
||||
|
||||
void ParserClientImpl::recordComment(const ParseLocation& location)
|
||||
@@ -225,14 +225,12 @@ Id ParserClientImpl::addNode(NodeType nodeType, const NameHierarchy& nameHierarc
|
||||
return m_storage->addNode(StorageNodeData(utility::nodeTypeToInt(nodeType.getType()), NameHierarchy::serialize(nameHierarchy)));
|
||||
}
|
||||
|
||||
void ParserClientImpl::addFile(Id id, const FilePath& filePath, const std::string& modificationTime)
|
||||
void ParserClientImpl::addFile(Id id, const FilePath& filePath, const std::string& modificationTime, bool indexed)
|
||||
{
|
||||
if (!m_storage)
|
||||
if (m_storage)
|
||||
{
|
||||
return;
|
||||
m_storage->addFile(StorageFile(id, filePath.wstr(), modificationTime, indexed, true));
|
||||
}
|
||||
|
||||
m_storage->addFile(StorageFile(id, filePath.wstr(), modificationTime, true));
|
||||
}
|
||||
|
||||
void ParserClientImpl::addSymbol(Id id, DefinitionKind definitionKind)
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
const NameHierarchy& qualifierName, const ParseLocation& location) override;
|
||||
|
||||
virtual void recordLocalSymbol(const std::wstring& name, const ParseLocation& location) override;
|
||||
virtual void recordFile(const FileInfo& fileInfo) override;
|
||||
virtual void recordFile(const FileInfo& fileInfo, bool indexed) override;
|
||||
virtual void recordComment(const ParseLocation& location) override;
|
||||
|
||||
private:
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
Id addNodeHierarchy(const NameHierarchy& nameHierarchy, NodeType nodeType = NodeType::NODE_SYMBOL);
|
||||
|
||||
Id addNode(NodeType nodeType, const NameHierarchy& nameHierarchy);
|
||||
void addFile(Id id, const FilePath& filePath, const std::string& modificationTime);
|
||||
void addFile(Id id, const FilePath& filePath, const std::string& modificationTime, bool indexed);
|
||||
void addSymbol(Id id, DefinitionKind definitionKind);
|
||||
Id addEdge(int type, Id sourceId, Id targetId);
|
||||
Id addLocalSymbol(const std::wstring& name);
|
||||
|
||||
@@ -83,10 +83,17 @@ void PersistentStorage::addFile(const StorageFile& data)
|
||||
{
|
||||
m_sqliteIndexStorage.addFile(data);
|
||||
}
|
||||
|
||||
if (!storedFile.complete && data.complete)
|
||||
else
|
||||
{
|
||||
m_sqliteIndexStorage.setFileComplete(data.complete, storedFile.id);
|
||||
if (!storedFile.indexed && data.indexed)
|
||||
{
|
||||
m_sqliteIndexStorage.setFileIndexed(storedFile.id, data.indexed);
|
||||
}
|
||||
|
||||
if (!storedFile.complete && data.complete)
|
||||
{
|
||||
m_sqliteIndexStorage.setFileComplete(storedFile.id, data.complete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,6 +297,7 @@ void PersistentStorage::clearCaches()
|
||||
m_fileNodeIds.clear();
|
||||
m_fileNodePaths.clear();
|
||||
m_fileNodeComplete.clear();
|
||||
m_fileNodeIndexed.clear();
|
||||
m_symbolDefinitionKinds.clear();
|
||||
|
||||
m_hierarchyCache.clear();
|
||||
@@ -336,13 +344,18 @@ void PersistentStorage::clearFileElements(const std::vector<FilePath>& filePaths
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FileInfo> PersistentStorage::getFileInfoForAllFiles() const
|
||||
std::vector<FileInfo> PersistentStorage::getFileInfoForAllIndexedFiles() const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::vector<FileInfo> fileInfos;
|
||||
for (StorageFile file : m_sqliteIndexStorage.getAll<StorageFile>())
|
||||
{
|
||||
if (!file.indexed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boost::posix_time::ptime modificationTime = boost::posix_time::not_a_date_time;
|
||||
if (file.modificationTime != "not-a-date-time")
|
||||
{
|
||||
@@ -376,6 +389,17 @@ std::set<FilePath> PersistentStorage::getIncompleteFiles() const
|
||||
return incompleteFiles;
|
||||
}
|
||||
|
||||
bool PersistentStorage::getFilePathIndexed(const FilePath& path) const
|
||||
{
|
||||
Id fileId = getFileNodeId(path);
|
||||
if (fileId)
|
||||
{
|
||||
return getFileNodeIndexed(fileId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PersistentStorage::buildCaches()
|
||||
{
|
||||
TRACE();
|
||||
@@ -863,8 +887,6 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForAll() const
|
||||
{
|
||||
TRACE();
|
||||
|
||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||
|
||||
std::vector<Id> tokenIds;
|
||||
for (StorageNode& node: m_sqliteIndexStorage.getAll<StorageNode>())
|
||||
{
|
||||
@@ -879,11 +901,15 @@ std::shared_ptr<Graph> PersistentStorage::getGraphForAll() const
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& p : m_fileNodePaths)
|
||||
for (const auto& p : m_fileNodeIndexed)
|
||||
{
|
||||
tokenIds.push_back(p.first);
|
||||
if (p.second)
|
||||
{
|
||||
tokenIds.push_back(p.first);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||
addNodesToGraph(tokenIds, graph.get(), false);
|
||||
|
||||
return graph;
|
||||
@@ -1296,7 +1322,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getSourceLocationsF
|
||||
std::shared_ptr<SourceLocationCollection> collection = std::make_shared<SourceLocationCollection>();
|
||||
for (const FilePath& path : filePaths)
|
||||
{
|
||||
collection->addSourceLocationFile(std::make_shared<SourceLocationFile>(path, true, false));
|
||||
collection->addSourceLocationFile(std::make_shared<SourceLocationFile>(path, true, false, false));
|
||||
}
|
||||
|
||||
if (nonFileIds.size())
|
||||
@@ -1421,7 +1447,7 @@ std::shared_ptr<SourceLocationFile> PersistentStorage::getCommentLocationsInFile
|
||||
{
|
||||
TRACE();
|
||||
|
||||
const std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false, false);
|
||||
const std::shared_ptr<SourceLocationFile> file = std::make_shared<SourceLocationFile>(filePath, false, false, false);
|
||||
|
||||
const std::vector<StorageCommentLocation> storageLocations = m_sqliteIndexStorage.getCommentLocationsInFile(filePath);
|
||||
for (size_t i = 0; i < storageLocations.size(); i++)
|
||||
@@ -1836,8 +1862,13 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isFile() && m_fileNodePaths.find(node.id) != m_fileNodePaths.end())
|
||||
if (type.isFile())
|
||||
{
|
||||
if (!getFileNodeIndexed(node.id))
|
||||
{
|
||||
info.title = L"non-indexed " + info.title;
|
||||
}
|
||||
|
||||
if (!getFileNodeComplete(node.id))
|
||||
{
|
||||
info.title = L"incomplete " + info.title;
|
||||
@@ -1884,7 +1915,7 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no
|
||||
TooltipSnippet snippet;
|
||||
snippet.code = nameHierarchy.getQualifiedNameWithSignature();
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? L"main.java" : L"main.cpp"), true, true);
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? L"main.java" : L"main.cpp"), true, true, true);
|
||||
|
||||
if (nameHierarchy.hasSignature())
|
||||
{
|
||||
@@ -1994,7 +2025,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForSourceLocationIdsAndLocalSymbolI
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
snippet.code = nameHierarchy.getQualifiedName();
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? L"main.java" : L"main.cpp"), true, true);
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? L"main.java" : L"main.cpp"), true, true, true);
|
||||
|
||||
snippet.locationFile->addSourceLocation(
|
||||
LOCATION_TOKEN, 0, std::vector<Id>(1, node.id), 1, 1, 1, snippet.code.size());
|
||||
@@ -2013,7 +2044,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForSourceLocationIdsAndLocalSymbolI
|
||||
TooltipSnippet snippet;
|
||||
|
||||
snippet.code = L"local symbol";
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(L"main.cpp"), true, true);
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(FilePath(L"main.cpp"), true, true, true);
|
||||
snippet.locationFile->addSourceLocation(
|
||||
LOCATION_LOCAL_SYMBOL, 0, std::vector<Id>(1, id), 1, 1, 1, snippet.code.size());
|
||||
|
||||
@@ -2081,21 +2112,21 @@ FilePath PersistentStorage::getFileNodePath(Id fileId) const
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
bool PersistentStorage::getFilePathComplete(const FilePath& filePath) const
|
||||
bool PersistentStorage::getFileNodeComplete(Id fileId) const
|
||||
{
|
||||
auto it = m_fileNodeIds.find(filePath);
|
||||
if (it != m_fileNodeIds.end())
|
||||
auto it = m_fileNodeComplete.find(fileId);
|
||||
if (it != m_fileNodeComplete.end())
|
||||
{
|
||||
return getFileNodeComplete(it->second);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStorage::getFileNodeComplete(Id fileId) const
|
||||
bool PersistentStorage::getFileNodeIndexed(Id fileId) const
|
||||
{
|
||||
auto it = m_fileNodeComplete.find(fileId);
|
||||
if (it != m_fileNodeComplete.end())
|
||||
auto it = m_fileNodeIndexed.find(fileId);
|
||||
if (it != m_fileNodeIndexed.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
@@ -2299,21 +2330,16 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& newNodeIds, Graph
|
||||
{
|
||||
const FilePath filePath(NameHierarchy::deserialize(storageNode.serializedName).getRawName());
|
||||
|
||||
bool defined = false;
|
||||
auto it = m_fileNodeComplete.find(storageNode.id);
|
||||
if (it != m_fileNodeComplete.end())
|
||||
{
|
||||
defined = it->second;
|
||||
}
|
||||
bool complete = getFileNodeComplete(storageNode.id);
|
||||
bool indexed = getFileNodeIndexed(storageNode.id);
|
||||
|
||||
Node* node = graph->createNode(
|
||||
storageNode.id,
|
||||
type,
|
||||
NameHierarchy(filePath.fileName(), NAME_DELIMITER_FILE),
|
||||
defined
|
||||
indexed ? DEFINITION_EXPLICIT : DEFINITION_NONE
|
||||
);
|
||||
node->addComponent(std::make_shared<TokenComponentFilePath>(filePath));
|
||||
node->setExplicit(defined);
|
||||
node->addComponent(std::make_shared<TokenComponentFilePath>(filePath, complete));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2326,21 +2352,7 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& newNodeIds, Graph
|
||||
defKind = it->second;
|
||||
}
|
||||
|
||||
Node* node = graph->createNode(
|
||||
storageNode.id,
|
||||
type,
|
||||
nameHierarchy,
|
||||
defKind != DEFINITION_NONE
|
||||
);
|
||||
|
||||
if (defKind == DEFINITION_IMPLICIT)
|
||||
{
|
||||
node->setImplicit(true);
|
||||
}
|
||||
else if (defKind == DEFINITION_EXPLICIT)
|
||||
{
|
||||
node->setExplicit(true);
|
||||
}
|
||||
Node* node = graph->createNode(storageNode.id, type, nameHierarchy, defKind);
|
||||
|
||||
if (addChildCount)
|
||||
{
|
||||
@@ -2609,7 +2621,9 @@ void PersistentStorage::addCompleteFlagsToSourceLocationCollection(SourceLocatio
|
||||
collection->forEachSourceLocationFile(
|
||||
[this](std::shared_ptr<SourceLocationFile> file)
|
||||
{
|
||||
file->setIsComplete(getFilePathComplete(file->getFilePath()));
|
||||
Id fileId = getFileNodeId(file->getFilePath());
|
||||
file->setIsComplete(getFileNodeComplete(fileId));
|
||||
file->setIsIndexed(getFileNodeIndexed(fileId));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2691,6 +2705,7 @@ void PersistentStorage::buildFilePathMaps()
|
||||
m_fileNodeIds.emplace(path, file.id);
|
||||
m_fileNodePaths.emplace(file.id, path);
|
||||
m_fileNodeComplete.emplace(file.id, file.complete);
|
||||
m_fileNodeIndexed.emplace(file.id, file.indexed);
|
||||
|
||||
if (!m_hasJavaFiles && path.extension() == L".java")
|
||||
{
|
||||
@@ -2715,6 +2730,12 @@ void PersistentStorage::buildSearchIndex()
|
||||
NodeType type = utility::intToType(node.type);
|
||||
if (type.isFile())
|
||||
{
|
||||
bool indexed = getFileNodeIndexed(node.id);
|
||||
if (!indexed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto it = m_fileNodePaths.find(node.id);
|
||||
if (it != m_fileNodePaths.end())
|
||||
{
|
||||
|
||||
@@ -63,8 +63,9 @@ public:
|
||||
|
||||
void clearFileElements(const std::vector<FilePath>& filePaths, std::function<void(int)> updateStatusCallback);
|
||||
|
||||
std::vector<FileInfo> getFileInfoForAllFiles() const;
|
||||
std::vector<FileInfo> getFileInfoForAllIndexedFiles() const;
|
||||
std::set<FilePath> getIncompleteFiles() const;
|
||||
bool getFilePathIndexed(const FilePath& path) const;
|
||||
|
||||
void buildCaches();
|
||||
|
||||
@@ -153,8 +154,8 @@ private:
|
||||
std::vector<Id> getFileNodeIds(const std::vector<FilePath>& filePaths) const;
|
||||
std::set<Id> getFileNodeIds(const std::set<FilePath>& filePaths) const;
|
||||
FilePath getFileNodePath(Id fileId) const;
|
||||
bool getFilePathComplete(const FilePath& filePath) const;
|
||||
bool getFileNodeComplete(Id fileId) const;
|
||||
bool getFileNodeIndexed(Id fileId) const;
|
||||
|
||||
std::unordered_map<Id, std::set<Id>> getFileIdToIncludingFileIdMap() const;
|
||||
std::unordered_map<Id, std::set<Id>> getFileIdToIncludedFileIdMap() const;
|
||||
@@ -201,6 +202,7 @@ private:
|
||||
std::map<FilePath, Id> m_fileNodeIds;
|
||||
std::map<Id, FilePath> m_fileNodePaths;
|
||||
std::map<Id, bool> m_fileNodeComplete;
|
||||
std::map<Id, bool> m_fileNodeIndexed;
|
||||
|
||||
std::map<Id, DefinitionKind> m_symbolDefinitionKinds;
|
||||
std::map<Id, Id> m_memberEdgeIdOrderMap;
|
||||
|
||||
@@ -50,7 +50,7 @@ void Storage::inject(Storage* injected)
|
||||
if (it != injectedIdToOwnId.end())
|
||||
{
|
||||
const Id ownId = it->second;
|
||||
addFile(StorageFile(ownId, injectedData.filePath, injectedData.modificationTime, injectedData.complete));
|
||||
addFile(StorageFile(ownId, injectedData.filePath, injectedData.modificationTime, injectedData.indexed, injectedData.complete));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "data/location/SourceLocationCollection.h"
|
||||
#include "data/location/SourceLocationFile.h"
|
||||
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 15;
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 16;
|
||||
|
||||
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath.getCanonical())
|
||||
@@ -68,21 +68,27 @@ void SqliteIndexStorage::addFile(const StorageFile& data)
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<TextAccess> content = TextAccess::createFromFile(FilePath(data.filePath));
|
||||
const int lineCount = content->getLineCount();
|
||||
std::shared_ptr<TextAccess> content;
|
||||
int lineCount = 0;
|
||||
if (data.indexed)
|
||||
{
|
||||
content = TextAccess::createFromFile(FilePath(data.filePath));
|
||||
lineCount = content->getLineCount();
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
{
|
||||
m_insertFileStmt.bind(1, int(data.id));
|
||||
m_insertFileStmt.bind(2, utility::encodeToUtf8(data.filePath).c_str());
|
||||
m_insertFileStmt.bind(3, data.modificationTime.c_str());
|
||||
m_insertFileStmt.bind(4, data.complete);
|
||||
m_insertFileStmt.bind(5, lineCount);
|
||||
m_insertFileStmt.bind(4, data.indexed);
|
||||
m_insertFileStmt.bind(5, data.complete);
|
||||
m_insertFileStmt.bind(6, lineCount);
|
||||
success = executeStatement(m_insertFileStmt);
|
||||
m_insertFileStmt.reset();
|
||||
}
|
||||
|
||||
if (success)
|
||||
if (success && content)
|
||||
{
|
||||
m_insertFileContentStmt.bind(1, int(data.id));
|
||||
m_insertFileContentStmt.bind(2, content->getText().c_str());
|
||||
@@ -632,7 +638,14 @@ std::shared_ptr<TextAccess> SqliteIndexStorage::getFileContentByPath(const std::
|
||||
return TextAccess::createFromFile(FilePath(filePath));
|
||||
}
|
||||
|
||||
void SqliteIndexStorage::setFileComplete(bool complete, Id fileId)
|
||||
void SqliteIndexStorage::setFileIndexed(Id fileId, bool indexed)
|
||||
{
|
||||
executeStatement(
|
||||
"UPDATE file SET indexed = " + std::to_string(indexed) + " WHERE id == " + std::to_string(fileId) + ";"
|
||||
);
|
||||
}
|
||||
|
||||
void SqliteIndexStorage::setFileComplete(Id fileId, bool complete)
|
||||
{
|
||||
executeStatement(
|
||||
"UPDATE file SET complete = " + std::to_string(complete) + " WHERE id == " + std::to_string(fileId) + ";"
|
||||
@@ -649,7 +662,7 @@ void SqliteIndexStorage::setNodeType(int type, Id nodeId)
|
||||
std::shared_ptr<SourceLocationFile> SqliteIndexStorage::getSourceLocationsForFile(
|
||||
const FilePath& filePath, const std::string& query) const
|
||||
{
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(filePath, true, false);
|
||||
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(filePath, true, false, false);
|
||||
|
||||
const StorageFile file = getFileByPath(filePath.wstr());
|
||||
if (file.id == 0) // early out
|
||||
@@ -658,6 +671,7 @@ std::shared_ptr<SourceLocationFile> SqliteIndexStorage::getSourceLocationsForFil
|
||||
}
|
||||
|
||||
ret->setIsComplete(file.complete);
|
||||
ret->setIsIndexed(file.indexed);
|
||||
|
||||
std::vector<Id> sourceLocationIds;
|
||||
std::unordered_map<Id, StorageSourceLocation> sourceLocationIdToData;
|
||||
@@ -802,12 +816,12 @@ int SqliteIndexStorage::getEdgeCount() const
|
||||
|
||||
int SqliteIndexStorage::getFileCount() const
|
||||
{
|
||||
return executeStatementScalar("SELECT COUNT(*) FROM file;", 0);
|
||||
return executeStatementScalar("SELECT COUNT(*) FROM file WHERE indexed = 1;", 0);
|
||||
}
|
||||
|
||||
int SqliteIndexStorage::getCompletedFileCount() const
|
||||
{
|
||||
return executeStatementScalar("SELECT COUNT(*) FROM file WHERE complete = 1;", 0);
|
||||
return executeStatementScalar("SELECT COUNT(*) FROM file WHERE indexed = 1 AND complete = 1;", 0);
|
||||
}
|
||||
|
||||
int SqliteIndexStorage::getFileLineSum() const
|
||||
@@ -954,6 +968,7 @@ void SqliteIndexStorage::setupTables()
|
||||
"id INTEGER NOT NULL, "
|
||||
"path TEXT, "
|
||||
"modification_time TEXT, "
|
||||
"indexed INTEGER, "
|
||||
"complete INTEGER, "
|
||||
"line_count INTEGER, "
|
||||
"PRIMARY KEY(id), "
|
||||
@@ -1057,7 +1072,7 @@ void SqliteIndexStorage::setupPrecompiledStatements()
|
||||
"INSERT INTO symbol(id, definition_kind) VALUES(?, ?);"
|
||||
);
|
||||
m_insertFileStmt = m_database.compileStatement(
|
||||
"INSERT INTO file(id, path, modification_time, complete, line_count) VALUES(?, ?, ?, ?, ?);"
|
||||
"INSERT INTO file(id, path, modification_time, indexed, complete, line_count) VALUES(?, ?, ?, ?, ?, ?);"
|
||||
);
|
||||
m_insertFileContentStmt = m_database.compileStatement(
|
||||
"INSERT INTO filecontent(id, content) VALUES(?, ?);"
|
||||
@@ -1198,7 +1213,7 @@ template <>
|
||||
std::vector<StorageFile> SqliteIndexStorage::doGetAll<StorageFile>(const std::string& query) const
|
||||
{
|
||||
CppSQLite3Query q = executeQuery(
|
||||
"SELECT id, path, modification_time, complete FROM file " + query + ";"
|
||||
"SELECT id, path, modification_time, indexed, complete FROM file " + query + ";"
|
||||
);
|
||||
|
||||
std::vector<StorageFile> files;
|
||||
@@ -1207,11 +1222,12 @@ std::vector<StorageFile> SqliteIndexStorage::doGetAll<StorageFile>(const std::st
|
||||
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);
|
||||
const bool indexed = q.getIntField(3, 0);
|
||||
const bool complete = q.getIntField(4, 0);
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
files.push_back(StorageFile(id, utility::decodeFromUtf8(filePath), modificationTime, complete));
|
||||
files.push_back(StorageFile(id, utility::decodeFromUtf8(filePath), modificationTime, indexed, complete));
|
||||
}
|
||||
q.nextRow();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ public:
|
||||
std::shared_ptr<TextAccess> getFileContentByPath(const std::wstring& filePath) const;
|
||||
std::shared_ptr<TextAccess> getFileContentById(Id fileId) const;
|
||||
|
||||
void setFileComplete(bool complete, Id fileId);
|
||||
void setFileIndexed(Id fileId, bool indexed);
|
||||
void setFileComplete(Id fileId, bool complete);
|
||||
void setNodeType(int type, Id nodeId);
|
||||
|
||||
std::shared_ptr<SourceLocationFile> getSourceLocationsForFile(
|
||||
|
||||
@@ -11,19 +11,22 @@ struct StorageFile
|
||||
: id(0)
|
||||
, filePath(L"")
|
||||
, modificationTime("")
|
||||
, indexed(true)
|
||||
, complete(true)
|
||||
{}
|
||||
|
||||
StorageFile(Id id, const std::wstring& filePath, const std::string& modificationTime, bool complete)
|
||||
StorageFile(Id id, const std::wstring& filePath, const std::string& modificationTime, bool indexed, bool complete)
|
||||
: id(id)
|
||||
, filePath(filePath)
|
||||
, modificationTime(modificationTime)
|
||||
, indexed(indexed)
|
||||
, complete(complete)
|
||||
{}
|
||||
|
||||
Id id;
|
||||
std::wstring filePath;
|
||||
std::string modificationTime;
|
||||
bool indexed;
|
||||
bool complete;
|
||||
};
|
||||
|
||||
|
||||
@@ -352,11 +352,11 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView)
|
||||
{
|
||||
m_storage->clear();
|
||||
}
|
||||
else if (info.filesToClear.size())
|
||||
else if (info.filesToClear.size() || info.nonIndexedFilesToClear.size())
|
||||
{
|
||||
taskSequential->addTask(std::make_shared<TaskCleanStorage>(
|
||||
m_storage.get(),
|
||||
utility::toVector(info.filesToClear)
|
||||
utility::toVector(utility::concat(info.filesToClear, info.nonIndexedFilesToClear))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ RefreshInfo Project::getRefreshInfoForUpdatedFiles() const
|
||||
{
|
||||
std::set<FilePath> alreadyIndexedPaths;
|
||||
|
||||
const std::vector<FileInfo> fileInfos = m_storage->getFileInfoForAllFiles();
|
||||
const std::vector<FileInfo> fileInfos = m_storage->getFileInfoForAllIndexedFiles();
|
||||
|
||||
for (const std::shared_ptr<SourceGroup>& sourceGroup : m_sourceGroups)
|
||||
{
|
||||
@@ -635,12 +635,20 @@ RefreshInfo Project::getRefreshInfoForIncompleteFiles() const
|
||||
if (!incompleteFiles.empty())
|
||||
{
|
||||
utility::append(incompleteFiles, m_storage->getReferencing(incompleteFiles));
|
||||
utility::append(info.filesToClear, incompleteFiles);
|
||||
|
||||
std::set<FilePath> staticSourceFilePaths = getAllSourceFilePaths();
|
||||
for (const FilePath& path: incompleteFiles)
|
||||
{
|
||||
staticSourceFilePaths.erase(path);
|
||||
|
||||
if (m_storage->getFilePathIndexed(path))
|
||||
{
|
||||
info.filesToClear.insert(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.nonIndexedFilesToClear.insert(path);
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<SourceGroup>& sourceGroup: m_sourceGroups)
|
||||
|
||||
@@ -17,6 +17,8 @@ struct RefreshInfo
|
||||
{
|
||||
std::set<FilePath> filesToIndex;
|
||||
std::set<FilePath> filesToClear;
|
||||
std::set<FilePath> nonIndexedFilesToClear;
|
||||
|
||||
RefreshMode mode = REFRESH_NONE;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,22 +31,20 @@ void PreprocessorCallbacks::FileChanged(
|
||||
{
|
||||
m_currentPath = FilePath();
|
||||
|
||||
FilePath filePath;
|
||||
|
||||
const clang::FileEntry* fileEntry = m_sourceManager.getFileEntryForID(m_sourceManager.getFileID(location));
|
||||
if (fileEntry != nullptr && fileEntry->isValid())
|
||||
{
|
||||
filePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
m_currentPath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
}
|
||||
|
||||
if (!filePath.empty() && m_fileRegister->hasFilePath(filePath))
|
||||
if (!m_currentPath.empty())
|
||||
{
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(filePath)); // todo: fix for tests
|
||||
bool hasFilePath = m_fileRegister->hasFilePath(m_currentPath);
|
||||
|
||||
if (!m_fileRegister->fileIsIndexed(filePath))
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(m_currentPath), hasFilePath); // todo: fix for tests
|
||||
|
||||
if (hasFilePath && !m_fileRegister->fileIsIndexed(m_currentPath))
|
||||
{
|
||||
m_currentPath = std::move(filePath);
|
||||
|
||||
if (reason == EnterFile)
|
||||
{
|
||||
m_fileRegister->markFileIndexing(m_currentPath);
|
||||
@@ -62,25 +60,22 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
){
|
||||
if (!m_currentPath.empty() && fileEntry)
|
||||
{
|
||||
FilePath includedFilePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
if (m_fileRegister->hasFilePath(includedFilePath))
|
||||
{
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.wstr(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.wstr(), NAME_DELIMITER_FILE);
|
||||
const FilePath includedFilePath = m_canonicalFilePathCache->getCanonicalFilePath(fileEntry);
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.wstr(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.wstr(), NAME_DELIMITER_FILE);
|
||||
|
||||
m_client->recordReference(
|
||||
REFERENCE_INCLUDE,
|
||||
referencedNameHierarchy,
|
||||
contextNameHierarchy,
|
||||
getParseLocation(fileNameRange.getAsRange())
|
||||
);
|
||||
}
|
||||
m_client->recordReference(
|
||||
REFERENCE_INCLUDE,
|
||||
referencedNameHierarchy,
|
||||
contextNameHierarchy,
|
||||
getParseLocation(fileNameRange.getAsRange())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, const clang::MacroDirective* macroDirective)
|
||||
{
|
||||
if (!m_currentPath.empty())
|
||||
if (!m_currentPath.empty() && m_fileRegister->hasFilePath(m_currentPath) && !m_fileRegister->fileIsIndexed(m_currentPath) /*TODO: remove this last check if indexed isn't important anymore*/)
|
||||
{
|
||||
// ignore builtin macros
|
||||
if (m_sourceManager.getSpellingLoc(macroNameToken.getLocation()).printToString(m_sourceManager)[0] == '<')
|
||||
@@ -133,7 +128,7 @@ void PreprocessorCallbacks::MacroExpands(
|
||||
|
||||
void PreprocessorCallbacks::onMacroUsage(const clang::Token& macroNameToken)
|
||||
{
|
||||
if (!m_currentPath.empty() && isLocatedInProjectFile(macroNameToken.getLocation()))
|
||||
if (!m_currentPath.empty() && m_fileRegister->hasFilePath(m_currentPath) && !m_fileRegister->fileIsIndexed(m_currentPath) /*TODO: remove this last check if indexed isn't important anymore*/ && isLocatedInProjectFile(macroNameToken.getLocation()))
|
||||
{
|
||||
const ParseLocation loc = getParseLocation(macroNameToken);
|
||||
|
||||
|
||||
@@ -301,6 +301,11 @@ void QtCodeFile::setIsComplete(bool isComplete)
|
||||
m_titleBar->setIsComplete(isComplete);
|
||||
}
|
||||
|
||||
void QtCodeFile::setIsIndexed(bool isIndexed)
|
||||
{
|
||||
m_titleBar->setIsIndexed(isIndexed);
|
||||
}
|
||||
|
||||
void QtCodeFile::setMinimized()
|
||||
{
|
||||
for (QtCodeSnippet* snippet : m_snippets)
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
void setWholeFile(bool isWholeFile, int refCount);
|
||||
void setIsComplete(bool isComplete);
|
||||
void setIsIndexed(bool isIndexed);
|
||||
|
||||
void setMinimized();
|
||||
void setSnippets();
|
||||
|
||||
@@ -117,12 +117,13 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath filePath)
|
||||
return file;
|
||||
}
|
||||
|
||||
void QtCodeFileList::addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimeStamp modificationTime, bool isComplete)
|
||||
void QtCodeFileList::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime)
|
||||
{
|
||||
QtCodeFile* file = getFile(filePath);
|
||||
file->setWholeFile(isWholeFile, refCount);
|
||||
QtCodeFile* file = getFile(locationFile->getFilePath());
|
||||
file->setWholeFile(locationFile->isWhole(), refCount);
|
||||
file->setModificationTime(modificationTime);
|
||||
file->setIsComplete(isComplete);
|
||||
file->setIsComplete(locationFile->isComplete());
|
||||
file->setIsIndexed(locationFile->isIndexed());
|
||||
}
|
||||
|
||||
QScrollArea* QtCodeFileList::getScrollArea()
|
||||
@@ -145,6 +146,7 @@ void QtCodeFileList::addCodeSnippet(const CodeSnippetParams& params)
|
||||
|
||||
file->setModificationTime(params.modificationTime);
|
||||
file->setIsComplete(params.locationFile->isComplete());
|
||||
file->setIsIndexed(params.locationFile->isIndexed());
|
||||
}
|
||||
|
||||
void QtCodeFileList::updateCodeSnippet(const CodeSnippetParams& params)
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
void clearSnippetTitleAndScrollBar();
|
||||
|
||||
QtCodeFile* getFile(const FilePath filePath);
|
||||
void addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimeStamp modificationTime, bool isComplete);
|
||||
void addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime);
|
||||
|
||||
// QtCodeNaviatebale implementation
|
||||
virtual QScrollArea* getScrollArea();
|
||||
|
||||
@@ -89,6 +89,7 @@ void QtCodeFileSingle::addCodeSnippet(const CodeSnippetParams& params)
|
||||
file.filePath = params.locationFile->getFilePath();
|
||||
file.modificationTime = params.modificationTime;
|
||||
file.isComplete = params.locationFile->isComplete();
|
||||
file.isIndexed = params.locationFile->isIndexed();
|
||||
|
||||
if (params.reduced)
|
||||
{
|
||||
@@ -327,12 +328,14 @@ void QtCodeFileSingle::setFileData(const FileData& file)
|
||||
{
|
||||
titleButton->setProject(file.title);
|
||||
m_titleBar->setIsComplete(true);
|
||||
m_titleBar->setIsIndexed(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
titleButton->setFilePath(file.filePath);
|
||||
titleButton->setModificationTime(file.modificationTime);
|
||||
m_titleBar->setIsComplete(file.isComplete);
|
||||
m_titleBar->setIsIndexed(file.isIndexed);
|
||||
}
|
||||
|
||||
updateRefCount(m_area->getActiveLocationCount());
|
||||
|
||||
@@ -62,6 +62,7 @@ private:
|
||||
FilePath filePath;
|
||||
TimeStamp modificationTime;
|
||||
bool isComplete = false;
|
||||
bool isIndexed = false;
|
||||
std::wstring title;
|
||||
|
||||
QtCodeArea* area = nullptr;
|
||||
|
||||
@@ -115,6 +115,11 @@ void QtCodeFileTitleBar::setIsComplete(bool isComplete)
|
||||
m_showErrorsButton->setVisible(!isComplete);
|
||||
}
|
||||
|
||||
void QtCodeFileTitleBar::setIsIndexed(bool isIndexed)
|
||||
{
|
||||
m_titleButton->setIsIndexed(isIndexed);
|
||||
}
|
||||
|
||||
void QtCodeFileTitleBar::updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount)
|
||||
{
|
||||
if (refCount > 0)
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
QtCodeFileTitleButton* getTitleButton() const;
|
||||
|
||||
void setIsComplete(bool isComplete);
|
||||
void setIsIndexed(bool isIndexed);
|
||||
void updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount);
|
||||
|
||||
void setMinimized();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
||||
: QtSelfRefreshIconButton("", FilePath(), "code/file/title", parent)
|
||||
, m_isComplete(true)
|
||||
, m_isIndexed(true)
|
||||
{
|
||||
setObjectName("title_button");
|
||||
minimumSizeHint(); // force font loading
|
||||
@@ -39,12 +40,9 @@ void QtCodeFileTitleButton::setFilePath(const FilePath& filePath)
|
||||
{
|
||||
setEnabled(true);
|
||||
|
||||
if (m_filePath.empty())
|
||||
{
|
||||
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"));
|
||||
}
|
||||
|
||||
m_filePath = filePath;
|
||||
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::setModificationTime(const TimeStamp modificationTime)
|
||||
@@ -62,7 +60,7 @@ void QtCodeFileTitleButton::setProject(const std::wstring& name)
|
||||
setText(QString::fromStdWString(name));
|
||||
setToolTip("edit project");
|
||||
|
||||
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"));
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
bool QtCodeFileTitleButton::isComplete() const
|
||||
@@ -80,6 +78,24 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
|
||||
m_isComplete = isComplete;
|
||||
setProperty("complete", isComplete);
|
||||
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
bool QtCodeFileTitleButton::isIndexed() const
|
||||
{
|
||||
return m_isIndexed;
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::setIsIndexed(bool isIndexed)
|
||||
{
|
||||
if (m_isIndexed == isIndexed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_isIndexed = isIndexed;
|
||||
setProperty("nonindexed", !isIndexed);
|
||||
|
||||
updateHatching();
|
||||
}
|
||||
|
||||
@@ -93,11 +109,9 @@ void QtCodeFileTitleButton::updateTexts()
|
||||
std::wstring title = m_filePath.fileName();
|
||||
std::wstring toolTip = L"file: " + m_filePath.wstr();
|
||||
|
||||
if ((!m_filePath.recheckExists()) ||
|
||||
(FileSystem::getLastWriteTime(m_filePath) > m_modificationTime))
|
||||
if (!m_isIndexed)
|
||||
{
|
||||
title += L"*";
|
||||
toolTip = L"out of date " + toolTip;
|
||||
toolTip = L"non-indexed " + toolTip;
|
||||
}
|
||||
|
||||
if (!m_isComplete)
|
||||
@@ -105,6 +119,13 @@ void QtCodeFileTitleButton::updateTexts()
|
||||
toolTip = L"incomplete " + toolTip;
|
||||
}
|
||||
|
||||
if ((!m_filePath.recheckExists()) ||
|
||||
(FileSystem::getLastWriteTime(m_filePath) > m_modificationTime))
|
||||
{
|
||||
title += L"*";
|
||||
toolTip = L"out-of-date " + toolTip;
|
||||
}
|
||||
|
||||
setText(QString::fromStdWString(title));
|
||||
setToolTip(QString::fromStdWString(toolTip));
|
||||
}
|
||||
@@ -122,6 +143,7 @@ void QtCodeFileTitleButton::updateFromOther(const QtCodeFileTitleButton* other)
|
||||
|
||||
setModificationTime(other->m_modificationTime);
|
||||
setIsComplete(other->m_isComplete);
|
||||
setIsIndexed(other->m_isIndexed);
|
||||
updateTexts();
|
||||
}
|
||||
|
||||
@@ -164,9 +186,25 @@ void QtCodeFileTitleButton::clickedTitle()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::updateIcon()
|
||||
{
|
||||
if (m_filePath.empty())
|
||||
{
|
||||
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"));
|
||||
}
|
||||
else if (!m_isComplete)
|
||||
{
|
||||
setIconPath(ResourcePaths::getGuiPath().concatenate(L"graph_view/images/file_incomplete.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"));
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::updateHatching()
|
||||
{
|
||||
if (!m_isComplete)
|
||||
if (!m_isIndexed)
|
||||
{
|
||||
FilePath hatchingFilePath = ResourcePaths::getGuiPath().concatenate(L"code_view/images/pattern_" +
|
||||
utility::decodeFromUtf8(ColorScheme::getInstance()->getColor("code/file/title/hatching")) + L".png"
|
||||
|
||||
@@ -24,6 +24,9 @@ public:
|
||||
bool isComplete() const;
|
||||
void setIsComplete(bool isComplete);
|
||||
|
||||
bool isIndexed() const;
|
||||
void setIsIndexed(bool isIndexed);
|
||||
|
||||
void updateTexts();
|
||||
void updateFromOther(const QtCodeFileTitleButton* other);
|
||||
|
||||
@@ -36,11 +39,13 @@ private slots:
|
||||
void clickedTitle();
|
||||
|
||||
private:
|
||||
void updateIcon();
|
||||
void updateHatching();
|
||||
|
||||
FilePath m_filePath;
|
||||
TimeStamp m_modificationTime;
|
||||
bool m_isComplete;
|
||||
bool m_isIndexed;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_FILE_TITLE_BUTTON_H
|
||||
|
||||
@@ -148,7 +148,7 @@ void QtCodeNavigator::updateCodeSnippet(const CodeSnippetParams& params)
|
||||
|
||||
void QtCodeNavigator::addFile(std::shared_ptr<SourceLocationFile> locationFile, int refCount, TimeStamp modificationTime)
|
||||
{
|
||||
m_list->addFile(locationFile->getFilePath(), locationFile->isWhole(), refCount, modificationTime, locationFile->isComplete());
|
||||
m_list->addFile(locationFile, refCount, modificationTime);
|
||||
|
||||
if (locationFile->isWhole())
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ QtCodeSnippet* QtCodeSnippet::merged(
|
||||
SourceLocationFile* bFile = b->m_codeArea->getSourceLocationFile().get();
|
||||
|
||||
std::shared_ptr<SourceLocationFile> locationFile =
|
||||
std::make_shared<SourceLocationFile>(aFile->getFilePath(), aFile->isWhole(), aFile->isWhole());
|
||||
std::make_shared<SourceLocationFile>(aFile->getFilePath(), aFile->isWhole(), aFile->isComplete(), aFile->isIndexed());
|
||||
|
||||
aFile->forEachSourceLocation(
|
||||
[&locationFile](SourceLocation* loc)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "utility/messaging/type/MessageDeactivateEdge.h"
|
||||
#include "utility/messaging/type/MessageFocusIn.h"
|
||||
#include "utility/messaging/type/MessageFocusOut.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
|
||||
@@ -28,9 +29,10 @@ const Node* QtGraphNodeData::getData() const
|
||||
|
||||
FilePath QtGraphNodeData::getFilePath() const
|
||||
{
|
||||
if (m_data->getType().isFile())
|
||||
TokenComponentFilePath* component = m_data->getComponent<TokenComponentFilePath>();
|
||||
if (component)
|
||||
{
|
||||
return m_data->getComponent<TokenComponentFilePath>()->getFilePath();
|
||||
return component->getFilePath();
|
||||
}
|
||||
|
||||
return FilePath();
|
||||
@@ -61,6 +63,13 @@ void QtGraphNodeData::updateStyle()
|
||||
{
|
||||
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleForNodeType(
|
||||
m_data->getType(), m_data->isExplicit(), m_isActive, m_isHovering, m_childVisible, m_hasQualifier);
|
||||
|
||||
TokenComponentFilePath* component = m_data->getComponent<TokenComponentFilePath>();
|
||||
if (component && !component->isComplete())
|
||||
{
|
||||
style.iconPath = ResourcePaths::getGuiPath().concatenate(L"graph_view/images/file_incomplete.png");
|
||||
}
|
||||
|
||||
setStyle(style);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ void JavaParser::buildIndex(
|
||||
{
|
||||
m_currentFilePath = sourceFilePath;
|
||||
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(sourceFilePath));
|
||||
m_client->recordFile(FileSystem::getFileInfoForPath(sourceFilePath), true);
|
||||
|
||||
// remove tabs because they screw with javaparser's location resolver
|
||||
std::string fileContent = utility::replace(textAccess->getText(), "\t", " ");
|
||||
|
||||
+29
-29
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
void test_nodes_are_nodes()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
|
||||
TS_ASSERT(a.isNode());
|
||||
TS_ASSERT(!a.isEdge());
|
||||
@@ -98,8 +98,8 @@ public:
|
||||
|
||||
void test_edges_are_edges()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(!e.isNode());
|
||||
@@ -108,27 +108,27 @@ public:
|
||||
|
||||
void test_set_type_of_node_from_constructor()
|
||||
{
|
||||
Node n(1, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node n(1, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
TS_ASSERT_EQUALS(NodeType(NodeType::NODE_FUNCTION), n.getType());
|
||||
}
|
||||
|
||||
void test_set_type_of_node_from_non_indexed()
|
||||
{
|
||||
Node n(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node n(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
n.setType(NodeType(NodeType::NODE_CLASS));
|
||||
TS_ASSERT_EQUALS(NodeType(NodeType::NODE_CLASS), n.getType());
|
||||
}
|
||||
|
||||
void test_can_not_change_type_of_node_after_it_was_set()
|
||||
{
|
||||
Node n(3, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node n(3, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
n.setType(NodeType(NodeType::NODE_CLASS));
|
||||
TS_ASSERT_DIFFERS(NodeType(NodeType::NODE_CLASS), n.getType());
|
||||
}
|
||||
|
||||
void test_node_can_be_copied_and_keeps_same_id()
|
||||
{
|
||||
Node n(4, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node n(4, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node n2(n);
|
||||
|
||||
TS_ASSERT_DIFFERS(&n, &n2);
|
||||
@@ -139,15 +139,15 @@ public:
|
||||
|
||||
void test_node_type_bit_masking()
|
||||
{
|
||||
Node n(1, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node n(1, NodeType(NodeType::NODE_NAMESPACE), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
TS_ASSERT(n.isType(NodeType::NODE_FUNCTION | NodeType::NODE_NAMESPACE | NodeType::NODE_CLASS));
|
||||
TS_ASSERT(!n.isType(NodeType::NODE_FUNCTION | NodeType::NODE_METHOD | NodeType::NODE_CLASS));
|
||||
}
|
||||
|
||||
void test_get_type_of_edges()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT_EQUALS(Edge::EDGE_USAGE, e.getType());
|
||||
@@ -155,8 +155,8 @@ public:
|
||||
|
||||
void test_edge_can_be_copied_and_keeps_same_id()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
Edge e2(e, &a, &b);
|
||||
|
||||
@@ -167,8 +167,8 @@ public:
|
||||
|
||||
void test_edge_type_bit_masking()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL | Edge::EDGE_USAGE));
|
||||
@@ -177,9 +177,9 @@ public:
|
||||
|
||||
void test_node_finds_child_node()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -196,9 +196,9 @@ public:
|
||||
|
||||
void test_node_can_not_find_child_node()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -214,9 +214,9 @@ public:
|
||||
|
||||
void test_node_visits_child_nodes()
|
||||
{
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), false);
|
||||
Node a(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node b(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node c(3, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"C", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -236,8 +236,8 @@ public:
|
||||
void test_graph_saves_nodes()
|
||||
{
|
||||
Graph graph;
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node* b = graph.createNode(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node* b = graph.createNode(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
|
||||
TS_ASSERT_EQUALS(2, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
|
||||
@@ -255,8 +255,8 @@ public:
|
||||
{
|
||||
Graph graph;
|
||||
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
Node* b = graph.createNode(2, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
Node* b = graph.createNode(2, NodeType(NodeType::NODE_FUNCTION), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
|
||||
Edge* e = graph.createEdge(3, Edge::EDGE_CALL, a, b);
|
||||
|
||||
@@ -271,8 +271,8 @@ public:
|
||||
{
|
||||
Graph graph;
|
||||
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), false);
|
||||
graph.createNode(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), false);
|
||||
Node* a = graph.createNode(1, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"A", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
graph.createNode(2, NodeType(NodeType::NODE_SYMBOL), NameHierarchy(L"B", NAME_DELIMITER_CXX), DEFINITION_EXPLICIT);
|
||||
|
||||
TS_ASSERT_EQUALS(2, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
std::shared_ptr<IntermediateStorage> intermetiateStorage = std::make_shared<IntermediateStorage>();
|
||||
Id id = intermetiateStorage->addNode(StorageNodeData(utility::nodeTypeToInt(NodeType::NODE_FILE), NameHierarchy::serialize(NameHierarchy(filePath, NAME_DELIMITER_FILE))));
|
||||
intermetiateStorage->addFile(StorageFile(id, filePath, "someTime", true));
|
||||
intermetiateStorage->addFile(StorageFile(id, filePath, "someTime", true, true));
|
||||
|
||||
storage.inject(intermetiateStorage.get());
|
||||
|
||||
|
||||
@@ -83,9 +83,9 @@ public:
|
||||
recordLine(L"LOCAL_SYMBOL: " + addLocationSuffix(name + L" [" + location.filePath.fileName(), location) + L"]\n");
|
||||
}
|
||||
|
||||
virtual void recordFile(const FileInfo& fileInfo) override
|
||||
virtual void recordFile(const FileInfo& fileInfo, bool indexed) override
|
||||
{
|
||||
recordLine(L"FILE: " + fileInfo.path.fileName() + L"\n");
|
||||
recordLine(L"FILE: " + fileInfo.path.fileName() + (indexed ? L"" : L" non-indexed") + L"\n");
|
||||
}
|
||||
|
||||
virtual void recordComment(const ParseLocation& location) override
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
localSymbols.push_back(addLocationSuffix(name, location));
|
||||
}
|
||||
|
||||
virtual void recordFile(const FileInfo& fileInfo) override
|
||||
virtual void recordFile(const FileInfo& fileInfo, bool indexed) override
|
||||
{
|
||||
files.insert(fileInfo.path.wstr());
|
||||
}
|
||||
@@ -163,9 +163,9 @@ public:
|
||||
|
||||
private:
|
||||
virtual void doRecordError(
|
||||
const ParseLocation& location,
|
||||
const ParseLocation& location,
|
||||
const std::wstring& message,
|
||||
bool fatal,
|
||||
bool fatal,
|
||||
bool indexed) override
|
||||
{
|
||||
errors.push_back(addLocationSuffix(message, location));
|
||||
|
||||
Reference in New Issue
Block a user