logic: flag FilterUndefinedNodesFromGraph in ApplicationSettings
If set to true the flag filters all undefined nodes from the graph, unless every active node is undefined.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- BOOL: 0, 1 -->
|
||||
<!-- INTEGER: int e.g 123 -->
|
||||
<!-- DECIMAL: float e.g 123.456 -->
|
||||
<!-- STRING: string e.g hello -->
|
||||
@@ -8,6 +9,8 @@
|
||||
<config>
|
||||
<StartupProject><!-- STRING: path to project settings xml file --></StartupProject>
|
||||
|
||||
<FilterUndefinedNodesFromGraph><!-- BOOL: filter out undefined nodes in graph --></FilterUndefinedNodesFromGraph>
|
||||
|
||||
<source>
|
||||
<CompilerFlags>
|
||||
<CompilerFlag><!-- STRING: compiler flag, including the dash e.g. -v --></CompilerFlag>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- BOOL: 0, 1 -->
|
||||
<!-- INTEGER: int e.g 123 -->
|
||||
<!-- DECIMAL: float e.g 123.456 -->
|
||||
<!-- STRING: string e.g hello -->
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "data/query/QueryCommand.h"
|
||||
#include "data/query/QueryTree.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
Storage::Storage()
|
||||
{
|
||||
@@ -839,6 +840,32 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
|
||||
}
|
||||
}
|
||||
|
||||
if (ApplicationSettings::getInstance()->filterUndefinedNodesFromGraph())
|
||||
{
|
||||
bool allUndefined = true;
|
||||
Node::NodeTypeMask undefinedMask =
|
||||
Node::NODE_UNDEFINED | Node::NODE_UNDEFINED_TYPE |
|
||||
Node::NODE_UNDEFINED_VARIABLE | Node::NODE_UNDEFINED_FUNCTION;
|
||||
for (Id tokenId : tokenIds)
|
||||
{
|
||||
Token* token = m_graph.getTokenById(tokenId);
|
||||
if (token && token->isNode() && !dynamic_cast<Node*>(token)->isType(undefinedMask))
|
||||
{
|
||||
allUndefined = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allUndefined)
|
||||
{
|
||||
QueryTree tree("!'undefined'");
|
||||
std::shared_ptr<Graph> outGraph = std::make_shared<Graph>();
|
||||
|
||||
GraphFilterConductor().filter(&tree, graph.get(), outGraph.get());
|
||||
return outGraph;
|
||||
}
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ void GraphFilterConductor::filterCommandNode(const QueryCommand* node, const Fil
|
||||
{
|
||||
switch (node->getType())
|
||||
{
|
||||
case QueryCommand::COMMAND_UNDEFINED:
|
||||
GraphFilterCommandNodeType(
|
||||
Node::NODE_UNDEFINED | Node::NODE_UNDEFINED_TYPE |
|
||||
Node::NODE_UNDEFINED_VARIABLE | Node::NODE_UNDEFINED_FUNCTION).apply(in, out);
|
||||
break;
|
||||
case QueryCommand::COMMAND_MEMBER:
|
||||
GraphFilterCommandMember().apply(in, out);
|
||||
break;
|
||||
|
||||
@@ -11,6 +11,8 @@ std::map<std::string, QueryCommand::CommandType> QueryCommand::getCommandTypeMap
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
commandMap.emplace("undefined", COMMAND_UNDEFINED);
|
||||
|
||||
commandMap.emplace("member", COMMAND_MEMBER);
|
||||
commandMap.emplace("child", COMMAND_MEMBER);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ public:
|
||||
{
|
||||
COMMAND_INVALID,
|
||||
|
||||
COMMAND_UNDEFINED,
|
||||
|
||||
COMMAND_MEMBER,
|
||||
COMMAND_PARENT,
|
||||
COMMAND_FUNCTION,
|
||||
|
||||
@@ -21,6 +21,11 @@ std::string ApplicationSettings::getStartupProjectFilePath() const
|
||||
return getValue<std::string>("StartupProject", "");
|
||||
}
|
||||
|
||||
bool ApplicationSettings::filterUndefinedNodesFromGraph() const
|
||||
{
|
||||
return getValue<bool>("FilterUndefinedNodesFromGraph", false);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
{
|
||||
return getValue<int>("code/TabWidth", 4);
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
~ApplicationSettings();
|
||||
|
||||
std::string getStartupProjectFilePath() const;
|
||||
bool filterUndefinedNodesFromGraph() const;
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
|
||||
Reference in New Issue
Block a user