ui: renamed undefined to non-indexed and made node/edge names more readable
This commit is contained in:
@@ -605,13 +605,13 @@ std::set<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(const st
|
||||
match.indices = result.indices;
|
||||
match.score = result.score;
|
||||
match.nodeType = Node::intToType(firstNode->type);
|
||||
match.typeName = Node::getTypeString(match.nodeType);
|
||||
match.typeName = Node::getReadableTypeString(match.nodeType);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
if (storageSymbolMap.find(firstNode->id) == storageSymbolMap.end() &&
|
||||
match.nodeType != Node::NODE_UNDEFINED)
|
||||
match.nodeType != Node::NODE_NON_INDEXED)
|
||||
{
|
||||
match.typeName = "undefined " + match.typeName;
|
||||
match.typeName = "non-indexed " + match.typeName;
|
||||
}
|
||||
|
||||
matches.insert(match);
|
||||
@@ -642,7 +642,7 @@ std::set<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const std:
|
||||
match.score = result.score;
|
||||
|
||||
match.nodeType = Node::NODE_FILE;
|
||||
match.typeName = Node::getTypeString(match.nodeType);
|
||||
match.typeName = Node::getReadableTypeString(match.nodeType);
|
||||
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const
|
||||
{
|
||||
return m_subject->getNodeTypeForNodeWithId(id);
|
||||
}
|
||||
return Node::NODE_UNDEFINED;
|
||||
return Node::NODE_NON_INDEXED;
|
||||
}
|
||||
|
||||
NameHierarchy StorageAccessProxy::getNameHierarchyForNodeWithId(Id id) const
|
||||
|
||||
+18
-13
@@ -106,7 +106,7 @@ Node* Edge::getTo() const
|
||||
|
||||
std::string Edge::getName() const
|
||||
{
|
||||
return getTypeString() + ":" + getFrom()->getFullName() + "->" + getTo()->getFullName();
|
||||
return getReadableTypeString() + ":" + getFrom()->getFullName() + "->" + getTo()->getFullName();
|
||||
}
|
||||
|
||||
bool Edge::isNode() const
|
||||
@@ -127,7 +127,7 @@ void Edge::addComponentAggregation(std::shared_ptr<TokenComponentAggregation> co
|
||||
}
|
||||
else if (m_type != EDGE_AGGREGATION)
|
||||
{
|
||||
LOG_ERROR("TokenComponentAggregation can't be set on edge of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentAggregation can't be set on edge of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -135,7 +135,12 @@ void Edge::addComponentAggregation(std::shared_ptr<TokenComponentAggregation> co
|
||||
}
|
||||
}
|
||||
|
||||
std::string Edge::getTypeString(EdgeType type)
|
||||
std::string Edge::getUnderscoredTypeString(EdgeType type)
|
||||
{
|
||||
return utility::replace(utility::replace(getReadableTypeString(type), "-", "_"), " ", "_");
|
||||
}
|
||||
|
||||
std::string Edge::getReadableTypeString(EdgeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -144,7 +149,7 @@ std::string Edge::getTypeString(EdgeType type)
|
||||
case EDGE_MEMBER:
|
||||
return "child";
|
||||
case EDGE_TYPE_USAGE:
|
||||
return "type_use";
|
||||
return "type use";
|
||||
case EDGE_USAGE:
|
||||
return "use";
|
||||
case EDGE_CALL:
|
||||
@@ -154,15 +159,15 @@ std::string Edge::getTypeString(EdgeType type)
|
||||
case EDGE_OVERRIDE:
|
||||
return "override";
|
||||
case EDGE_TEMPLATE_ARGUMENT:
|
||||
return "template_argument";
|
||||
return "template argument";
|
||||
case EDGE_TYPE_ARGUMENT:
|
||||
return "type_argument";
|
||||
return "type argument";
|
||||
case EDGE_TEMPLATE_DEFAULT_ARGUMENT:
|
||||
return "template_default_argument";
|
||||
return "template default argument";
|
||||
case EDGE_TEMPLATE_SPECIALIZATION:
|
||||
return "template_specialization";
|
||||
return "template specialization";
|
||||
case EDGE_TEMPLATE_MEMBER_SPECIALIZATION:
|
||||
return "template_member_specialization";
|
||||
return "template member specialization";
|
||||
case EDGE_INCLUDE:
|
||||
return "include";
|
||||
case EDGE_IMPORT:
|
||||
@@ -170,21 +175,21 @@ std::string Edge::getTypeString(EdgeType type)
|
||||
case EDGE_AGGREGATION:
|
||||
return "aggregation";
|
||||
case EDGE_MACRO_USAGE:
|
||||
return "macro_use";
|
||||
return "macro use";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string Edge::getTypeString() const
|
||||
std::string Edge::getReadableTypeString() const
|
||||
{
|
||||
return getTypeString(m_type);
|
||||
return getReadableTypeString(m_type);
|
||||
}
|
||||
|
||||
std::string Edge::getAsString() const
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "[" << getId() << "] " << getTypeString() << ": \"" << m_from->getName() << "\" -> \"" + m_to->getName() << "\"";
|
||||
str << "[" << getId() << "] " << getReadableTypeString() << ": \"" << m_from->getName() << "\" -> \"" + m_to->getName() << "\"";
|
||||
|
||||
TokenComponentAggregation* aggregation = getComponent<TokenComponentAggregation>();
|
||||
if (aggregation)
|
||||
|
||||
@@ -58,9 +58,10 @@ public:
|
||||
// Component setters
|
||||
void addComponentAggregation(std::shared_ptr<TokenComponentAggregation> component);
|
||||
|
||||
static std::string getUnderscoredTypeString(EdgeType type);
|
||||
static std::string getReadableTypeString(EdgeType type);
|
||||
// Logging.
|
||||
static std::string getTypeString(EdgeType type);
|
||||
virtual std::string getTypeString() const;
|
||||
virtual std::string getReadableTypeString() const;
|
||||
std::string getAsString() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -311,7 +311,7 @@ void Graph::printBasic(std::ostream& ostream) const
|
||||
forEachNode(
|
||||
[&ostream](Node* n)
|
||||
{
|
||||
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
|
||||
ostream << ' ' << n->getReadableTypeString() << ':' << n->getFullName();
|
||||
}
|
||||
);
|
||||
ostream << '\n';
|
||||
|
||||
+27
-21
@@ -3,6 +3,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentAbstraction.h"
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
@@ -11,18 +12,23 @@
|
||||
#include "data/graph/token_component/TokenComponentFilePath.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_UNDEFINED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_USEABLE_TYPE = Node::NODE_UNDEFINED | Node::NODE_BUILTIN_TYPE |
|
||||
const Node::NodeTypeMask Node::NODE_NOT_VISIBLE = Node::NODE_NON_INDEXED | Node::NODE_NAMESPACE | Node::NODE_PACKAGE;
|
||||
const Node::NodeTypeMask Node::NODE_USEABLE_TYPE = Node::NODE_NON_INDEXED | Node::NODE_BUILTIN_TYPE |
|
||||
Node::NODE_BUILTIN_TYPE | Node::NODE_STRUCT | Node::NODE_CLASS | Node::NODE_INTERFACE | Node::NODE_TYPEDEF;
|
||||
|
||||
std::string Node::getTypeString(NodeType type)
|
||||
std::string Node::getUnderscoredTypeString(NodeType type)
|
||||
{
|
||||
return utility::replace(utility::replace(getReadableTypeString(type), "-", "_"), " ", "_");
|
||||
}
|
||||
|
||||
std::string Node::getReadableTypeString(NodeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case NODE_UNDEFINED:
|
||||
return "undefined";
|
||||
case NODE_NON_INDEXED:
|
||||
return "non-indexed";
|
||||
case NODE_BUILTIN_TYPE:
|
||||
return "builtin_type";
|
||||
return "built-in type";
|
||||
case NODE_TYPE:
|
||||
return "type";
|
||||
case NODE_NAMESPACE:
|
||||
@@ -36,7 +42,7 @@ std::string Node::getTypeString(NodeType type)
|
||||
case NODE_INTERFACE:
|
||||
return "interface";
|
||||
case NODE_GLOBAL_VARIABLE:
|
||||
return "global_variable";
|
||||
return "global variable";
|
||||
case NODE_FIELD:
|
||||
return "field";
|
||||
case NODE_FUNCTION:
|
||||
@@ -46,13 +52,13 @@ std::string Node::getTypeString(NodeType type)
|
||||
case NODE_ENUM:
|
||||
return "enum";
|
||||
case NODE_ENUM_CONSTANT:
|
||||
return "enum_constant";
|
||||
return "enum constant";
|
||||
case NODE_TYPEDEF:
|
||||
return "typedef";
|
||||
case NODE_TEMPLATE_PARAMETER_TYPE:
|
||||
return "template_parameter_type";
|
||||
return "template parameter type";
|
||||
case NODE_TYPE_PARAMETER:
|
||||
return "type_parameter";
|
||||
return "type parameter";
|
||||
case NODE_FILE:
|
||||
return "file";
|
||||
case NODE_MACRO:
|
||||
@@ -109,7 +115,7 @@ Node::NodeType Node::intToType(int value)
|
||||
return NODE_MACRO;
|
||||
}
|
||||
|
||||
return NODE_UNDEFINED;
|
||||
return NODE_NON_INDEXED;
|
||||
}
|
||||
|
||||
Node::Node(Id id, NodeType type, NameHierarchy nameHierarchy, bool defined)
|
||||
@@ -133,10 +139,10 @@ Node::NodeType Node::getType() const
|
||||
|
||||
void Node::setType(NodeType type)
|
||||
{
|
||||
if (!isType(type | NODE_UNDEFINED))
|
||||
if (!isType(type | NODE_NON_INDEXED))
|
||||
{
|
||||
LOG_WARNING(
|
||||
"Cannot change NodeType after it was already set from " + getTypeString() + " to " + getTypeString(type)
|
||||
"Cannot change NodeType after it was already set from " + getReadableTypeString() + " to " + getReadableTypeString(type)
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -362,7 +368,7 @@ void Node::addComponentAbstraction(std::shared_ptr<TokenComponentAbstraction> co
|
||||
}
|
||||
else if (!isType(NODE_METHOD))
|
||||
{
|
||||
LOG_ERROR("TokenComponentAbstraction can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentAbstraction can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -379,7 +385,7 @@ void Node::addComponentConst(std::shared_ptr<TokenComponentConst> component)
|
||||
}
|
||||
else if (!isType(NODE_METHOD))
|
||||
{
|
||||
LOG_ERROR("TokenComponentConst can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentConst can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -396,7 +402,7 @@ void Node::addComponentStatic(std::shared_ptr<TokenComponentStatic> component)
|
||||
}
|
||||
else if (!isType(NODE_GLOBAL_VARIABLE | NODE_FIELD | NODE_FUNCTION | NODE_METHOD))
|
||||
{
|
||||
LOG_ERROR("TokenComponentStatic can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentStatic can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -413,7 +419,7 @@ void Node::addComponentFilePath(std::shared_ptr<TokenComponentFilePath> componen
|
||||
}
|
||||
else if (!isType(NODE_FILE))
|
||||
{
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -430,7 +436,7 @@ void Node::addComponentSignature(std::shared_ptr<TokenComponentSignature> compon
|
||||
}
|
||||
else if (!isType(NODE_FUNCTION | NODE_METHOD))
|
||||
{
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getReadableTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -451,15 +457,15 @@ void Node::addComponentAccess(std::shared_ptr<TokenComponentAccess> component)
|
||||
}
|
||||
}
|
||||
|
||||
std::string Node::getTypeString() const
|
||||
std::string Node::getReadableTypeString() const
|
||||
{
|
||||
return getTypeString(m_type);
|
||||
return getReadableTypeString(m_type);
|
||||
}
|
||||
|
||||
std::string Node::getAsString() const
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "[" << getId() << "] " << getTypeString() << ": " << "\"" << getName() << "\"";
|
||||
str << "[" << getId() << "] " << getReadableTypeString() << ": " << "\"" << getName() << "\"";
|
||||
|
||||
TokenComponentAccess* access = getComponent<TokenComponentAccess>();
|
||||
if (access)
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
typedef int NodeTypeMask;
|
||||
enum NodeType : NodeTypeMask
|
||||
{ // make sure that the value of 0x0 is not used here because it doesn't work for bitmasking.
|
||||
NODE_UNDEFINED = 0x1,
|
||||
NODE_NON_INDEXED = 0x1,
|
||||
NODE_TYPE = 0x2,
|
||||
NODE_BUILTIN_TYPE = 0x4,
|
||||
|
||||
@@ -48,7 +48,9 @@ public:
|
||||
NODE_MACRO = 0x40000
|
||||
};
|
||||
|
||||
static std::string getTypeString(NodeType type);
|
||||
static std::string getUnderscoredTypeString(NodeType type);
|
||||
static std::string getReadableTypeString(NodeType type);
|
||||
|
||||
static int typeToInt(NodeType type);
|
||||
static NodeType intToType(int value);
|
||||
|
||||
@@ -107,7 +109,7 @@ public:
|
||||
void addComponentAccess(std::shared_ptr<TokenComponentAccess> component);
|
||||
|
||||
// Logging.
|
||||
virtual std::string getTypeString() const;
|
||||
virtual std::string getReadableTypeString() const;
|
||||
std::string getAsString() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
std::shared_ptr<ComponentType> removeComponent();
|
||||
|
||||
// Logging.
|
||||
virtual std::string getTypeString() const = 0;
|
||||
virtual std::string getReadableTypeString() const = 0;
|
||||
|
||||
protected:
|
||||
Token(const Token& other);
|
||||
|
||||
@@ -32,16 +32,16 @@ public:
|
||||
virtual void finishParsingFile() = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionKind definitionKind) = 0;
|
||||
|
||||
|
||||
@@ -34,34 +34,34 @@ void ParserClientImpl::finishParsingFile()
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = addNodeHierarchy(symbolName, symbolKindToNodeType(symbolType));
|
||||
Id nodeId = addNodeHierarchy(symbolName, symbolKindToNodeType(symbolKind));
|
||||
addSymbol(nodeId, definitionKind);
|
||||
addAccess(nodeId, access);
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, access, definitionKind);
|
||||
Id nodeId = recordSymbol(symbolName, symbolKind, access, definitionKind);
|
||||
addSourceLocation(nodeId, location, locationTypeToInt(LOCATION_TOKEN));
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
Id ParserClientImpl::recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionKind definitionKind
|
||||
)
|
||||
{
|
||||
Id nodeId = recordSymbol(symbolName, symbolType, location, access, definitionKind);
|
||||
Id nodeId = recordSymbol(symbolName, symbolKind, location, access, definitionKind);
|
||||
addSourceLocation(nodeId, scopeLocation, locationTypeToInt(LOCATION_SCOPE));
|
||||
return nodeId;
|
||||
}
|
||||
@@ -102,9 +102,9 @@ void ParserClientImpl::onCommentParsed(const ParseLocation& location)
|
||||
addCommentLocation(location);
|
||||
}
|
||||
|
||||
Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolType) const
|
||||
Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolKind) const
|
||||
{
|
||||
switch (symbolType)
|
||||
switch (symbolKind)
|
||||
{
|
||||
case SYMBOL_BUILTIN_TYPE:
|
||||
return Node::NODE_BUILTIN_TYPE;
|
||||
@@ -143,7 +143,7 @@ Node::NodeType ParserClientImpl::symbolKindToNodeType(SymbolKind symbolType) con
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Node::NODE_UNDEFINED;
|
||||
return Node::NODE_NON_INDEXED;
|
||||
}
|
||||
|
||||
Edge::EdgeType ParserClientImpl::referenceKindToEdgeType(ReferenceKind referenceKind) const
|
||||
@@ -204,7 +204,7 @@ Id ParserClientImpl::addNodeHierarchy(NameHierarchy nameHierarchy, Node::NodeTyp
|
||||
{
|
||||
currentNameHierarchy.push(nameHierarchy[i]);
|
||||
const bool currentIsLastElement = (i == nameHierarchy.size() - 1);
|
||||
const Node::NodeType currentType = (currentIsLastElement ? nodeType : Node::NODE_UNDEFINED); // TODO: rename to unknown!
|
||||
const Node::NodeType currentType = (currentIsLastElement ? nodeType : Node::NODE_NON_INDEXED); // TODO: rename to unknown!
|
||||
|
||||
Id nodeId = addNode(currentType, currentNameHierarchy);
|
||||
|
||||
|
||||
@@ -23,16 +23,16 @@ public:
|
||||
virtual void finishParsingFile();
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
virtual Id recordSymbol(
|
||||
const NameHierarchy& symbolName, SymbolKind symbolType,
|
||||
const NameHierarchy& symbolName, SymbolKind symbolKind,
|
||||
const ParseLocation& location, const ParseLocation& scopeLocation,
|
||||
AccessKind access, DefinitionKind definitionKind);
|
||||
|
||||
@@ -49,7 +49,7 @@ private:
|
||||
Node::NodeType symbolKindToNodeType(SymbolKind symbolType) const;
|
||||
Edge::EdgeType referenceKindToEdgeType(ReferenceKind referenceKind) const;
|
||||
void addAccess(Id nodeId, AccessKind access);
|
||||
Id addNodeHierarchy(NameHierarchy nameHierarchy, Node::NodeType nodeType = Node::NODE_UNDEFINED);
|
||||
Id addNodeHierarchy(NameHierarchy nameHierarchy, Node::NodeType nodeType = Node::NODE_NON_INDEXED);
|
||||
|
||||
Id addNode(Node::NodeType nodeType, NameHierarchy nameHierarchy);
|
||||
void addFile(Id id, const FilePath& filePath, const std::string& modificationTime);
|
||||
|
||||
@@ -191,9 +191,9 @@ std::string SearchMatch::getFullName() const
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string SearchMatch::getNodeTypeAsString() const
|
||||
std::string SearchMatch::getNodeTypeAsUnderscoredString() const
|
||||
{
|
||||
return Node::getTypeString(nodeType);
|
||||
return Node::getUnderscoredTypeString(nodeType);
|
||||
}
|
||||
|
||||
std::string SearchMatch::getSearchTypeName() const
|
||||
|
||||
@@ -48,7 +48,7 @@ struct SearchMatch
|
||||
void print(std::ostream& ostream) const;
|
||||
|
||||
std::string getFullName() const;
|
||||
std::string getNodeTypeAsString() const;
|
||||
std::string getNodeTypeAsUnderscoredString() const;
|
||||
std::string getSearchTypeName() const;
|
||||
|
||||
std::string name;
|
||||
|
||||
Reference in New Issue
Block a user