ui: improved file nodes
* added colors for file nodes and dependency edges * use TokenComponentFilePath on file nodes to store FilePath
This commit is contained in:
@@ -99,6 +99,9 @@
|
||||
<normal>#ededed</normal>
|
||||
<hover>#dddddd</hover>
|
||||
</template_parameter_type>
|
||||
}
|
||||
<file>
|
||||
<normal>#A3BA8A</normal>
|
||||
<hover>#87BA50</hover>
|
||||
</file>
|
||||
</colors>
|
||||
</config>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "QtGraphPostprocessor.h"
|
||||
|
||||
// remark: maybe those two values could at some point be moved to an external config file (?)
|
||||
unsigned int QtGraphPostprocessor::s_cellSize = 20;
|
||||
unsigned int QtGraphPostprocessor::s_cellSize = 5;
|
||||
unsigned int QtGraphPostprocessor::s_cellPadding = 10;
|
||||
|
||||
void QtGraphPostprocessor::doPostprocessing(std::list<std::shared_ptr<QtGraphNode>>& nodes)
|
||||
|
||||
@@ -464,6 +464,9 @@ void QtGraphEdge::updateLine()
|
||||
case Edge::EDGE_AGGREGATION:
|
||||
color = QColor("#F8F8F8");
|
||||
break;
|
||||
case Edge::EDGE_INCLUDE:
|
||||
color = QColor("#87BA50");
|
||||
break;
|
||||
default:
|
||||
color = QColor("#878787");
|
||||
break;
|
||||
|
||||
@@ -56,12 +56,9 @@ QFont QtGraphNode::getFontForNodeType(Node::NodeType type)
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
case Node::NODE_FUNCTION:
|
||||
case Node::NODE_METHOD:
|
||||
font.setPixelSize(11);
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
@@ -355,28 +352,11 @@ void QtGraphNode::setStyle()
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
useUndefinedPattern = true;
|
||||
useUndefinedColor = true;
|
||||
case Node::NODE_FUNCTION:
|
||||
case Node::NODE_METHOD:
|
||||
if (m_isActive || m_isHovering)
|
||||
{
|
||||
color = ApplicationSettings::getInstance()->getNodeTypeColor(m_data->getType(), "hover").c_str();
|
||||
font.setWeight(QFont::Bold);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = ApplicationSettings::getInstance()->getNodeTypeColor(m_data->getType()).c_str();
|
||||
}
|
||||
|
||||
radius = 8.0f;
|
||||
padding.x = 5;
|
||||
padding.y = 3;
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
useUndefinedPattern = true;
|
||||
useUndefinedColor = true;
|
||||
case Node::NODE_GLOBAL_VARIABLE:
|
||||
case Node::NODE_FIELD:
|
||||
case Node::NODE_ENUM_CONSTANT:
|
||||
|
||||
@@ -105,6 +105,8 @@ add_files(
|
||||
data/graph/token_component/TokenComponentAggregation.h
|
||||
data/graph/token_component/TokenComponentConst.cpp
|
||||
data/graph/token_component/TokenComponentConst.h
|
||||
data/graph/token_component/TokenComponentFilePath.cpp
|
||||
data/graph/token_component/TokenComponentFilePath.h
|
||||
data/graph/token_component/TokenComponentName.cpp
|
||||
data/graph/token_component/TokenComponentName.h
|
||||
data/graph/token_component/TokenComponentSignature.cpp
|
||||
|
||||
@@ -134,6 +134,13 @@ void Project::parseCode()
|
||||
headerSearchPaths.push_back(includePaths[i]);
|
||||
}
|
||||
|
||||
// std::cout << "parse files" << std::endl;
|
||||
// for (const FilePath& path : filesToParse)
|
||||
// {
|
||||
// std::cout << path.absoluteStr() << std::endl;
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
|
||||
CxxParser parser(m_storage.get(), m_fileManager.get());
|
||||
clock_t time = clock();
|
||||
parser.parseFiles(
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "data/graph/token_component/TokenComponentConst.h"
|
||||
#include "data/graph/token_component/TokenComponentName.h"
|
||||
#include "data/graph/token_component/TokenComponentStatic.h"
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/SubGraph.h"
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
@@ -46,13 +47,13 @@ void Storage::clearFileData(const std::set<FilePath>& filePaths)
|
||||
{
|
||||
for (const FilePath& filePath : filePaths)
|
||||
{
|
||||
TokenLocationFile* errorFile = m_errorLocationCollection.findTokenLocationFileByPath(filePath.str());
|
||||
TokenLocationFile* errorFile = m_errorLocationCollection.findTokenLocationFileByPath(filePath);
|
||||
if (errorFile)
|
||||
{
|
||||
m_errorLocationCollection.removeTokenLocationFile(errorFile);
|
||||
}
|
||||
|
||||
TokenLocationFile* file = m_locationCollection.findTokenLocationFileByPath(filePath.str());
|
||||
TokenLocationFile* file = m_locationCollection.findTokenLocationFileByPath(filePath);
|
||||
if (!file)
|
||||
{
|
||||
continue;
|
||||
@@ -105,7 +106,7 @@ std::set<FilePath> Storage::getDependingFilePathsAndRemoveFileNodes(const std::s
|
||||
|
||||
for (const FilePath& filePath : filePaths)
|
||||
{
|
||||
SearchNode* searchNode = m_tokenIndex.getNode(filePath.absoluteStr());
|
||||
SearchNode* searchNode = m_tokenIndex.getNode(filePath.fileName());
|
||||
if (!searchNode || searchNode->getTokenIds().size() != 1)
|
||||
{
|
||||
continue;
|
||||
@@ -118,6 +119,13 @@ std::set<FilePath> Storage::getDependingFilePathsAndRemoveFileNodes(const std::s
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fileNode->getComponent<TokenComponentFilePath>() ||
|
||||
fileNode->getComponent<TokenComponentFilePath>()->getFilePath() != filePath)
|
||||
{
|
||||
LOG_ERROR("Node is not resolving to the same file.");
|
||||
continue;
|
||||
}
|
||||
|
||||
addDependingFilePathsAndRemoveFileNodesRecursive(fileNode, &dependingFilePaths);
|
||||
}
|
||||
|
||||
@@ -640,7 +648,7 @@ Id Storage::onFileParsed(const std::string& filePath)
|
||||
{
|
||||
log("file", filePath, ParseLocation());
|
||||
|
||||
Node* fileNode = addNodeHierarchy(Node::NODE_FILE, std::vector<std::string>(1, FilePath(filePath).absoluteStr()));
|
||||
Node* fileNode = addFileNode(filePath);
|
||||
return fileNode->getId();
|
||||
}
|
||||
|
||||
@@ -648,8 +656,8 @@ Id Storage::onFileIncludeParsed(const ParseLocation& location, const std::string
|
||||
{
|
||||
log("include", includedPath, location);
|
||||
|
||||
Node* fileNode = addNodeHierarchy(Node::NODE_FILE, std::vector<std::string>(1, FilePath(filePath).absoluteStr()));
|
||||
Node* includedFileNode = addNodeHierarchy(Node::NODE_FILE, std::vector<std::string>(1, FilePath(includedPath).absoluteStr()));
|
||||
Node* fileNode = addFileNode(filePath);
|
||||
Node* includedFileNode = addFileNode(includedPath);
|
||||
|
||||
Edge* edge = m_graph.createEdge(Edge::EDGE_INCLUDE, fileNode, includedFileNode);
|
||||
addTokenLocation(edge, location);
|
||||
@@ -1071,6 +1079,18 @@ Node* Storage::addNodeHierarchyWithDistinctSignature(Node::NodeType type, const
|
||||
return m_graph.createNodeHierarchyWithDistinctSignature(type, searchNode, signature);
|
||||
}
|
||||
|
||||
Node* Storage::addFileNode(const FilePath& filePath)
|
||||
{
|
||||
Node* fileNode = addNodeHierarchy(Node::NODE_FILE, std::vector<std::string>(1, filePath.fileName()));
|
||||
|
||||
if (!fileNode->getComponent<TokenComponentFilePath>())
|
||||
{
|
||||
fileNode->addComponentFilePath(std::make_shared<TokenComponentFilePath>(filePath));
|
||||
}
|
||||
|
||||
return fileNode;
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType Storage::convertAccessType(ParserClient::AccessType access) const
|
||||
{
|
||||
switch (access)
|
||||
@@ -1259,7 +1279,7 @@ bool Storage::getQuerySearchResults(const std::string& query, const std::string&
|
||||
|
||||
void Storage::addDependingFilePathsAndRemoveFileNodesRecursive(Node* fileNode, std::set<FilePath>* filePaths)
|
||||
{
|
||||
bool inserted = filePaths->insert(FilePath(fileNode->getFullName())).second;
|
||||
bool inserted = filePaths->insert(fileNode->getComponent<TokenComponentFilePath>()->getFilePath()).second;
|
||||
if (!inserted)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -139,6 +139,8 @@ private:
|
||||
Node* addNodeHierarchy(Node::NodeType type, std::vector<std::string> nameHierarchy);
|
||||
Node* addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
|
||||
Node* addFileNode(const FilePath& filePath);
|
||||
|
||||
TokenComponentAccess::AccessType convertAccessType(ParserClient::AccessType access) const;
|
||||
TokenComponentAccess* addAccess(Node* node, ParserClient::AccessType access);
|
||||
|
||||
|
||||
@@ -52,14 +52,7 @@ void FilterableGraph::printBasic(std::ostream& ostream) const
|
||||
forEachNode(
|
||||
[&ostream](Node* n)
|
||||
{
|
||||
if (n->isType(Node::NODE_FILE))
|
||||
{
|
||||
ostream << ' ' << n->getTypeString() << ':' << n->getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
|
||||
}
|
||||
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
|
||||
}
|
||||
);
|
||||
ostream << '\n';
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "data/graph/token_component/TokenComponentName.h"
|
||||
#include "data/graph/token_component/TokenComponentStatic.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
|
||||
Node::Node(NodeType type, std::shared_ptr<TokenComponentName> nameComponent)
|
||||
: m_type(type)
|
||||
@@ -52,14 +53,7 @@ bool Node::isType(NodeTypeMask mask) const
|
||||
|
||||
std::string Node::getName() const
|
||||
{
|
||||
if (isType(NODE_FILE))
|
||||
{
|
||||
return FileSystem::fileName(m_nameComponent->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_nameComponent->getName();
|
||||
}
|
||||
return m_nameComponent->getName();
|
||||
}
|
||||
|
||||
std::string Node::getFullName() const
|
||||
@@ -317,6 +311,22 @@ void Node::addComponentSignature(std::shared_ptr<TokenComponentSignature> compon
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addComponentFilePath(std::shared_ptr<TokenComponentFilePath> component)
|
||||
{
|
||||
if (getComponent<TokenComponentFilePath>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentFilePath has been set before!");
|
||||
}
|
||||
else if (!isType(NODE_FILE))
|
||||
{
|
||||
LOG_ERROR("TokenComponentSignature can't be set on node of type: " + getTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
addComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Node::getTypeString(NodeType type)
|
||||
{
|
||||
switch (type)
|
||||
|
||||
@@ -14,6 +14,7 @@ class TokenComponentConst;
|
||||
class TokenComponentName;
|
||||
class TokenComponentStatic;
|
||||
class TokenComponentSignature;
|
||||
class TokenComponentFilePath;
|
||||
|
||||
class Node: public Token
|
||||
{
|
||||
@@ -85,6 +86,7 @@ public:
|
||||
void addComponentConst(std::shared_ptr<TokenComponentConst> component);
|
||||
void addComponentStatic(std::shared_ptr<TokenComponentStatic> component);
|
||||
void addComponentSignature(std::shared_ptr<TokenComponentSignature> component);
|
||||
void addComponentFilePath(std::shared_ptr<TokenComponentFilePath> component);
|
||||
|
||||
// Logging.
|
||||
virtual std::string getTypeString() const;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
|
||||
TokenComponentFilePath::TokenComponentFilePath(const FilePath& path)
|
||||
: m_path(path)
|
||||
{
|
||||
}
|
||||
|
||||
TokenComponentFilePath::~TokenComponentFilePath()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<TokenComponent> TokenComponentFilePath::copy() const
|
||||
{
|
||||
return std::make_shared<TokenComponentFilePath>(*this);
|
||||
}
|
||||
|
||||
const FilePath& TokenComponentFilePath::getFilePath() const
|
||||
{
|
||||
return m_path;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef TOKEN_COMPONENT_FILE_PATH_H
|
||||
#define TOKEN_COMPONENT_FILE_PATH_H
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponent.h"
|
||||
|
||||
class TokenComponentFilePath
|
||||
: public TokenComponent
|
||||
{
|
||||
public:
|
||||
TokenComponentFilePath(const FilePath& path);
|
||||
virtual ~TokenComponentFilePath();
|
||||
|
||||
virtual std::shared_ptr<TokenComponent> copy() const;
|
||||
|
||||
const FilePath& getFilePath() const;
|
||||
|
||||
private:
|
||||
const FilePath m_path;
|
||||
};
|
||||
|
||||
#endif // TOKEN_COMPONENT_FILE_PATH_H
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef FILE_MANAGER_H
|
||||
#define FILE_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -75,5 +75,5 @@ bool FilePath::operator!=(const FilePath& other) const
|
||||
|
||||
bool FilePath::operator<(const FilePath& other) const
|
||||
{
|
||||
return m_path.compare(other.m_path) < 0;
|
||||
return boost::filesystem::absolute(m_path).compare(boost::filesystem::absolute(other.m_path)) < 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user