logic: add name delimiter to NameHierarchy
* NameHierarchy now looks like this: <delimiter>\tm<all the rest> * made new baseclasses for SettingsMigration and SettingsMigrator * Use the migration system for SqliteBookmarkStorage as well
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
\n
|
||||
\tIf you ask yourself where to start, click the symbol linked below.\n
|
||||
\n
|
||||
[com\ts\tp\tngithub\ts\tp\tnjavaparser\ts\tp\tnast\ts\tp\tnbody\ts\tp\tnClassOrInterfaceDeclaration\ts\tp] // <- start here!\n\n
|
||||
[.\tmcom\ts\tp\tngithub\ts\tp\tnjavaparser\ts\tp\tnast\ts\tp\tnbody\ts\tp\tnClassOrInterfaceDeclaration\ts\tp] // <- start here!\n\n
|
||||
</description>
|
||||
<source_groups>
|
||||
<source_group_7a9e75fc-2cad-42d5-8c5b-c86d02f7b4e4>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
LET'S GET STARTED!\n
|
||||
\tTo keep things simple just click the "main" symbol below to start the tour.\n
|
||||
\n
|
||||
[main\tsint\tp()](); // <- start here\n\n
|
||||
[::\tmmain\tsint\tp()](); // <- start here\n\n
|
||||
</description>
|
||||
<source_groups>
|
||||
<source_group_75041cb3-37c8-45c6-bb8a-1b8b79040f59>
|
||||
|
||||
@@ -67,7 +67,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
m_fileContent = fileContent;
|
||||
m_typeSolver = typeSolver;
|
||||
|
||||
m_context.add(new DeclContext(filePath + "\ts\tp"));
|
||||
m_context.add(new DeclContext("/\tm" + filePath + "\ts\tp"));
|
||||
}
|
||||
|
||||
// --- record declarations ---
|
||||
@@ -794,7 +794,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
|
||||
JavaIndexer.logError(m_callbackId, e + " at " + m_filePath + "<"+ beginLine + ", " + beginColumn + ">");
|
||||
JavaIndexer.recordSymbolWithLocation(
|
||||
m_callbackId, "unsolved-symbol\ts\tp", SymbolKind.TYPE_MAX,
|
||||
m_callbackId, ".\tmunsolved-symbol\ts\tp", SymbolKind.TYPE_MAX,
|
||||
n.getRange(),
|
||||
AccessKind.DEFAULT,
|
||||
DefinitionKind.EXPLICIT
|
||||
@@ -861,7 +861,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
}
|
||||
else // todo: move this implementation somewhere else
|
||||
{
|
||||
qualifiedName = method.declaringType().getQualifiedName();
|
||||
qualifiedName = ".\tm" + method.declaringType().getQualifiedName();
|
||||
qualifiedName = qualifiedName.replace(".", "\ts\tp\tn");
|
||||
|
||||
qualifiedName += "\ts\tp\tn" + method.getName() + "\ts";
|
||||
@@ -896,7 +896,7 @@ public class JavaAstVisitor extends JavaAstVisitorAdapter
|
||||
}
|
||||
else // todo: move this implementation somewhere else
|
||||
{
|
||||
qualifiedName = constructor.declaringType().getQualifiedName();
|
||||
qualifiedName = ".\tm" + constructor.declaringType().getQualifiedName();
|
||||
qualifiedName = qualifiedName.replace(".", "\ts\tp\tn");
|
||||
|
||||
qualifiedName += "\ts\tp\tn" + constructor.getName() + "\ts\tp(";
|
||||
|
||||
@@ -71,7 +71,7 @@ public class JavaDeclName
|
||||
|
||||
public String toSerializedNameHierarchy()
|
||||
{
|
||||
String nameHierarchy = "";
|
||||
String nameHierarchy = ".\tm";
|
||||
if (m_parent != null)
|
||||
{
|
||||
nameHierarchy = m_parent.toSerializedNameHierarchy();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class JavaTypeName
|
||||
|
||||
public String toSerializedNameHierarchy()
|
||||
{
|
||||
String nameHierarchy = "";
|
||||
String nameHierarchy = ".\tm";
|
||||
if (m_parent != null)
|
||||
{
|
||||
nameHierarchy = m_parent.toSerializedNameHierarchy();
|
||||
|
||||
+18
-9
@@ -180,6 +180,8 @@ add_files(
|
||||
data/location/SourceLocationFile.cpp
|
||||
data/location/SourceLocationFile.h
|
||||
|
||||
data/name/NameDelimiterType.cpp
|
||||
data/name/NameDelimiterType.h
|
||||
data/name/NameElement.cpp
|
||||
data/name/NameElement.h
|
||||
data/name/NameHierarchy.cpp
|
||||
@@ -226,6 +228,11 @@ add_files(
|
||||
data/SqliteIndexStorage.h
|
||||
data/SqliteStorage.cpp
|
||||
data/SqliteStorage.h
|
||||
data/SqliteStorageMigration.cpp
|
||||
data/SqliteStorageMigration.h
|
||||
data/SqliteStorageMigrationLambda.cpp
|
||||
data/SqliteStorageMigrationLambda.h
|
||||
data/SqliteStorageMigrator.h
|
||||
data/Storage.cpp
|
||||
data/Storage.h
|
||||
data/StorageCache.cpp
|
||||
@@ -254,15 +261,14 @@ add_files(
|
||||
project/SourceGroup.cpp
|
||||
project/SourceGroup.h
|
||||
|
||||
settings/migration/Migration.cpp
|
||||
settings/migration/Migration.h
|
||||
settings/migration/MigrationDeleteKey.cpp
|
||||
settings/migration/MigrationDeleteKey.h
|
||||
settings/migration/MigrationLambda.cpp
|
||||
settings/migration/MigrationLambda.h
|
||||
settings/migration/MigrationMoveKey.cpp
|
||||
settings/migration/MigrationMoveKey.h
|
||||
settings/migration/SettingsMigrator.cpp
|
||||
settings/migration/SettingsMigration.cpp
|
||||
settings/migration/SettingsMigration.h
|
||||
settings/migration/SettingsMigrationDeleteKey.cpp
|
||||
settings/migration/SettingsMigrationDeleteKey.h
|
||||
settings/migration/SettingsMigrationLambda.cpp
|
||||
settings/migration/SettingsMigrationLambda.h
|
||||
settings/migration/SettingsMigrationMoveKey.cpp
|
||||
settings/migration/SettingsMigrationMoveKey.h
|
||||
settings/migration/SettingsMigrator.h
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
@@ -416,6 +422,9 @@ add_files(
|
||||
utility/messaging/MessageListenerBase.h
|
||||
utility/messaging/MessageQueue.cpp
|
||||
utility/messaging/MessageQueue.h
|
||||
|
||||
utility/migration/Migration.h
|
||||
utility/migration/Migrator.h
|
||||
|
||||
utility/scheduling/Blackboard.cpp
|
||||
utility/scheduling/Blackboard.h
|
||||
|
||||
@@ -34,7 +34,7 @@ void ActivationController::handleMessage(MessageActivateEdge* message)
|
||||
m.tokenIds = message->aggregationIds;
|
||||
m.setKeepContent(false);
|
||||
m.isAggregation = true;
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName()));
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName(), message->sourceNameHierarchy.getDelimiterrr()));
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
else
|
||||
@@ -42,7 +42,7 @@ void ActivationController::handleMessage(MessageActivateEdge* message)
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds.push_back(message->tokenId);
|
||||
m.isEdge = true;
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName()));
|
||||
m.tokenNames.push_back(NameHierarchy(message->getFullName(), message->sourceNameHierarchy.getDelimiterrr()));
|
||||
m.dispatchImmediately();
|
||||
}
|
||||
}
|
||||
@@ -53,11 +53,11 @@ void ActivationController::handleMessage(MessageActivateFile* message)
|
||||
|
||||
if (fileId)
|
||||
{
|
||||
MessageActivateTokens m(message);
|
||||
m.tokenIds.push_back(fileId);
|
||||
m.tokenNames.push_back(message->filePath.str());
|
||||
m.searchMatches = m_storageAccess->getSearchMatchesForTokenIds({ fileId });
|
||||
m.dispatchImmediately();
|
||||
MessageActivateTokens messageActivateTokens(message);
|
||||
messageActivateTokens.tokenIds.push_back(fileId);
|
||||
messageActivateTokens.tokenNames.push_back(NameHierarchy(message->filePath.str(), NAME_DELIMITER_FILE));
|
||||
messageActivateTokens.searchMatches = m_storageAccess->getSearchMatchesForTokenIds({ fileId });
|
||||
messageActivateTokens.dispatchImmediately();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1578,33 +1578,33 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
|
||||
std::shared_ptr<Graph> graph = std::make_shared<Graph>();
|
||||
|
||||
std::function<void(Id, Node::NodeType)> createNodes(
|
||||
[&](Id id, Node::NodeType type)
|
||||
std::function<void(Id, Node::NodeType, NameDelimiterType)> createNodes(
|
||||
[&](Id id, Node::NodeType type, NameDelimiterType delimiter)
|
||||
{
|
||||
std::string name = Node::getReadableTypeString(type);
|
||||
graph->createNode(id + 1, type, NameHierarchy(name), true);
|
||||
graph->createNode(id + 2, type, NameHierarchy("focused " + name), true);
|
||||
graph->createNode(id + 3, type, NameHierarchy("active " + name), true);
|
||||
graph->createNode(id + 1, type, NameHierarchy(name, delimiter), true);
|
||||
graph->createNode(id + 2, type, NameHierarchy("focused " + name, delimiter), true);
|
||||
graph->createNode(id + 3, type, NameHierarchy("active " + name, delimiter), true);
|
||||
|
||||
graph->createNode(id + 4, type, NameHierarchy("Non-indexed " + name), true);
|
||||
graph->createNode(id + 5, type, NameHierarchy("Non-indexed focused " + name), true);
|
||||
graph->createNode(id + 6, type, NameHierarchy("Non-indexed active " + name), true);
|
||||
graph->createNode(id + 4, type, NameHierarchy("Non-indexed " + name, delimiter), true);
|
||||
graph->createNode(id + 5, type, NameHierarchy("Non-indexed focused " + name, delimiter), true);
|
||||
graph->createNode(id + 6, type, NameHierarchy("Non-indexed active " + name, delimiter), true);
|
||||
}
|
||||
);
|
||||
|
||||
createNodes( 0, Node::NODE_FUNCTION);
|
||||
createNodes(10, Node::NODE_GLOBAL_VARIABLE);
|
||||
createNodes(20, Node::NODE_NON_INDEXED);
|
||||
createNodes(30, Node::NODE_TYPE);
|
||||
createNodes(40, Node::NODE_TYPEDEF);
|
||||
createNodes(50, Node::NODE_NAMESPACE);
|
||||
createNodes(60, Node::NODE_FILE);
|
||||
createNodes(70, Node::NODE_MACRO);
|
||||
createNodes( 0, Node::NODE_FUNCTION, NAME_DELIMITER_CXX);
|
||||
createNodes(10, Node::NODE_GLOBAL_VARIABLE, NAME_DELIMITER_CXX);
|
||||
createNodes(20, Node::NODE_NON_INDEXED, NAME_DELIMITER_CXX);
|
||||
createNodes(30, Node::NODE_TYPE, NAME_DELIMITER_CXX);
|
||||
createNodes(40, Node::NODE_TYPEDEF, NAME_DELIMITER_CXX);
|
||||
createNodes(50, Node::NODE_NAMESPACE, NAME_DELIMITER_CXX);
|
||||
createNodes(60, Node::NODE_FILE, NAME_DELIMITER_FILE);
|
||||
createNodes(70, Node::NODE_MACRO, NAME_DELIMITER_CXX);
|
||||
|
||||
std::function<Node*(Node*, Id, Node::NodeType, std::string, AccessKind)> createChild(
|
||||
[&](Node* parent, Id id, Node::NodeType type, std::string name, AccessKind access)
|
||||
{
|
||||
Node* node = graph->createNode(id + 1000, type, NameHierarchy(name), true);
|
||||
Node* node = graph->createNode(id + 1000, type, NameHierarchy(name, NAME_DELIMITER_CXX), true);
|
||||
graph->createEdge(id + 10000, Edge::EDGE_MEMBER, parent, node);
|
||||
|
||||
if (access != ACCESS_NONE)
|
||||
@@ -1620,7 +1620,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
[&](Id id, std::string name)
|
||||
{
|
||||
Node* enumNode = graph->createNode(id, Node::NODE_ENUM,
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_ENUM)), true);
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_ENUM), NAME_DELIMITER_CXX), true);
|
||||
createChild(enumNode, id + 10, Node::NODE_ENUM_CONSTANT, name + Node::getReadableTypeString(Node::NODE_ENUM_CONSTANT), ACCESS_NONE);
|
||||
}
|
||||
);
|
||||
@@ -1636,7 +1636,7 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
std::function<void(Id, Node::NodeType, std::string)> createClass(
|
||||
[&](Id id, Node::NodeType type, std::string name)
|
||||
{
|
||||
Node* classNode = graph->createNode(id, type, NameHierarchy(name + Node::getReadableTypeString(type)), true);
|
||||
Node* classNode = graph->createNode(id, type, NameHierarchy(name + Node::getReadableTypeString(type), NAME_DELIMITER_CXX), true);
|
||||
|
||||
if (type == Node::NODE_CLASS)
|
||||
{
|
||||
@@ -1676,24 +1676,24 @@ void GraphController::handleMessage(MessageColorSchemeTest* message)
|
||||
if (origin == Node::NODE_METHOD)
|
||||
{
|
||||
Node* classNode = graph->createNode(id + 101, Node::NODE_CLASS,
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_CLASS)), true);
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_CLASS), NAME_DELIMITER_CXX), true);
|
||||
originNode = createChild(classNode, id + 111, Node::NODE_METHOD, name + Edge::getReadableTypeString(type), ACCESS_PUBLIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
originNode = graph->createNode(id + 1, origin, NameHierarchy(name + Edge::getReadableTypeString(type)), true);
|
||||
originNode = graph->createNode(id + 1, origin, NameHierarchy(name + Edge::getReadableTypeString(type), NAME_DELIMITER_CXX), true);
|
||||
}
|
||||
|
||||
Node* targetNode;
|
||||
if (target == Node::NODE_METHOD)
|
||||
{
|
||||
Node* classNode = graph->createNode(id + 201, Node::NODE_CLASS,
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_CLASS)), true);
|
||||
NameHierarchy(name + Node::getReadableTypeString(Node::NODE_CLASS), NAME_DELIMITER_CXX), true);
|
||||
targetNode = createChild(classNode, id + 211, Node::NODE_METHOD, name + Edge::getReadableTypeString(type), ACCESS_PUBLIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetNode = graph->createNode(id + 11, target, NameHierarchy(name + Edge::getReadableTypeString(type)), true);
|
||||
targetNode = graph->createNode(id + 11, target, NameHierarchy(name + Edge::getReadableTypeString(type), NAME_DELIMITER_CXX), true);
|
||||
}
|
||||
|
||||
Edge* edge = graph->createEdge(id, type, originNode, targetNode);
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
, layoutBucket(0, 0)
|
||||
, bundledNodeCount(0)
|
||||
, bundledNodeType(Node::NODE_NON_INDEXED)
|
||||
, qualifierName(NAME_DELIMITER_UNKNOWN)
|
||||
, textNode(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -457,6 +457,8 @@ void PersistentStorage::setup()
|
||||
{
|
||||
m_sqliteIndexStorage.setup();
|
||||
m_sqliteBookmarkStorage.setup();
|
||||
|
||||
m_sqliteBookmarkStorage.migrateIfNecessary();
|
||||
}
|
||||
|
||||
void PersistentStorage::clear()
|
||||
@@ -552,11 +554,14 @@ void PersistentStorage::optimizeMemory()
|
||||
{
|
||||
TRACE();
|
||||
|
||||
m_sqliteIndexStorage.setVersion();
|
||||
m_sqliteIndexStorage.setVersion(m_sqliteIndexStorage.getStaticVersion());
|
||||
m_sqliteIndexStorage.setTime();
|
||||
m_sqliteIndexStorage.optimizeMemory();
|
||||
|
||||
m_sqliteBookmarkStorage.setVersion();
|
||||
if (m_sqliteBookmarkStorage.isEmpty())
|
||||
{
|
||||
m_sqliteBookmarkStorage.setVersion(m_sqliteBookmarkStorage.getStaticVersion());
|
||||
}
|
||||
m_sqliteBookmarkStorage.optimizeMemory();
|
||||
}
|
||||
|
||||
@@ -813,6 +818,8 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionSymbolMatches(
|
||||
match.text = name.getRange(idx, name.size()).getQualifiedName();
|
||||
match.subtext = name.getRange(0, idx).getQualifiedName();
|
||||
|
||||
match.delimiter = name.getDelimiterrr();
|
||||
|
||||
match.indices = result.indices;
|
||||
match.score = result.score;
|
||||
match.nodeType = Node::intToType(firstNode->type);
|
||||
@@ -848,6 +855,8 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionFileMatches(const s
|
||||
match.text = path.fileName();
|
||||
match.subtext = path.str();
|
||||
|
||||
match.delimiter = NAME_DELIMITER_FILE;
|
||||
|
||||
match.indices = result.indices;
|
||||
match.score = result.score;
|
||||
|
||||
@@ -875,6 +884,9 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionCommandMatches(cons
|
||||
|
||||
match.name = result.text;
|
||||
match.text = result.text;
|
||||
|
||||
match.delimiter = NAME_DELIMITER_UNKNOWN;
|
||||
|
||||
match.indices = result.indices;
|
||||
match.score = result.score;
|
||||
|
||||
@@ -918,6 +930,8 @@ std::vector<SearchMatch> PersistentStorage::getSearchMatchesForTokenIds(const st
|
||||
match.nodeType = Node::intToType(node.type);
|
||||
match.searchType = SearchMatch::SEARCH_TOKEN;
|
||||
|
||||
match.delimiter = nameHierarchy.getDelimiterrr();
|
||||
|
||||
if (match.nodeType == Node::NODE_FILE)
|
||||
{
|
||||
match.text = FilePath(match.text).fileName();
|
||||
@@ -1752,7 +1766,7 @@ void PersistentStorage::addNodesToGraph(const std::vector<Id>& nodeIds, Graph* g
|
||||
Node* node = graph->createNode(
|
||||
storageNode.id,
|
||||
Node::NODE_FILE,
|
||||
NameHierarchy(filePath.fileName()),
|
||||
NameHierarchy(filePath.fileName(), NAME_DELIMITER_FILE),
|
||||
defined
|
||||
);
|
||||
node->addComponentFilePath(std::make_shared<TokenComponentFilePath>(filePath));
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "data/SqliteStorageMigrationLambda.h"
|
||||
#include "data/SqliteStorageMigrator.h"
|
||||
|
||||
const size_t SqliteBookmarkStorage::s_storageVersion = 1;
|
||||
const size_t SqliteBookmarkStorage::s_storageVersion = 2;
|
||||
|
||||
SqliteBookmarkStorage::SqliteBookmarkStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath)
|
||||
@@ -15,6 +17,24 @@ SqliteBookmarkStorage::~SqliteBookmarkStorage()
|
||||
{
|
||||
}
|
||||
|
||||
size_t SqliteBookmarkStorage::getStaticVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
void SqliteBookmarkStorage::migrateIfNecessary()
|
||||
{
|
||||
SqliteStorageMigrator migrator;
|
||||
|
||||
migrator.addMigration(2, std::make_shared<SqliteStorageMigrationLambda>([](const SqliteStorageMigration* migration, SqliteStorage* storage){
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_node SET serialized_node_name = '::\tm' || serialized_node_name");
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_source_node_name = '::\tm' || serialized_source_node_name");
|
||||
migration->executeStatementInStorage(storage, "UPDATE bookmarked_edge SET serialized_target_node_name = '::\tm' || serialized_target_node_name");
|
||||
}));
|
||||
|
||||
bool migrated = migrator.migrate(this, SqliteBookmarkStorage::s_storageVersion);
|
||||
}
|
||||
|
||||
Id SqliteBookmarkStorage::addBookmarkCategory(const std::string& name)
|
||||
{
|
||||
std::string statement = "INSERT INTO bookmark_category(id, name) "
|
||||
@@ -34,7 +54,6 @@ Id SqliteBookmarkStorage::addBookmark(const std::string& name, const std::string
|
||||
std::string statement = "INSERT INTO bookmark(id, name, comment, timestamp, category_id) "
|
||||
"VALUES (NULL, ?, ?, ?, " + std::to_string(categoryId) + ");";
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
CppSQLite3Statement stmt = m_database.compileStatement(statement.c_str());
|
||||
@@ -128,11 +147,6 @@ void SqliteBookmarkStorage::removeBookmarkCategory(Id id)
|
||||
);
|
||||
}
|
||||
|
||||
size_t SqliteBookmarkStorage::getStaticStorageVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, SqliteDatabaseIndex>> SqliteBookmarkStorage::getIndices() const
|
||||
{
|
||||
return std::vector<std::pair<int, SqliteDatabaseIndex>>();
|
||||
|
||||
@@ -17,6 +17,10 @@ public:
|
||||
SqliteBookmarkStorage(const FilePath& dbFilePath);
|
||||
virtual ~SqliteBookmarkStorage();
|
||||
|
||||
virtual size_t getStaticVersion() const;
|
||||
|
||||
void migrateIfNecessary();
|
||||
|
||||
Id addBookmarkCategory(const std::string& name);
|
||||
Id addBookmark(const std::string& name, const std::string& comment, const std::string& timestamp, const Id categoryId);
|
||||
Id addBookmarkedNode(const Id bookmarkId, const std::string& nodeName);
|
||||
@@ -37,7 +41,6 @@ public:
|
||||
private:
|
||||
static const size_t s_storageVersion;
|
||||
|
||||
virtual size_t getStaticStorageVersion() const;
|
||||
virtual std::vector<std::pair<int, SqliteDatabaseIndex>> getIndices() const;
|
||||
virtual void clearTables();
|
||||
virtual void setupTables();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 11;
|
||||
const size_t SqliteIndexStorage::s_storageVersion = 12;
|
||||
|
||||
SqliteIndexStorage::SqliteIndexStorage(const FilePath& dbFilePath)
|
||||
: SqliteStorage(dbFilePath.canonical())
|
||||
@@ -19,6 +19,11 @@ SqliteIndexStorage::~SqliteIndexStorage()
|
||||
{
|
||||
}
|
||||
|
||||
size_t SqliteIndexStorage::getStaticVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
std::string SqliteIndexStorage::getProjectSettingsText() const
|
||||
{
|
||||
return getMetaValue("project_settings");
|
||||
@@ -922,11 +927,6 @@ void SqliteIndexStorage::setupTables()
|
||||
}
|
||||
}
|
||||
|
||||
size_t SqliteIndexStorage::getStaticStorageVersion() const
|
||||
{
|
||||
return s_storageVersion;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::vector<StorageEdge> SqliteIndexStorage::doGetAll<StorageEdge>(const std::string& query) const
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
|
||||
class TextAccess;
|
||||
class Version;
|
||||
struct ParseLocation;
|
||||
@@ -26,6 +25,8 @@ public:
|
||||
SqliteIndexStorage(const FilePath& dbFilePath);
|
||||
virtual ~SqliteIndexStorage();
|
||||
|
||||
virtual size_t getStaticVersion() const;
|
||||
|
||||
std::string getProjectSettingsText() const;
|
||||
void setProjectSettingsText(std::string text);
|
||||
|
||||
@@ -127,7 +128,6 @@ public:
|
||||
private:
|
||||
static const size_t s_storageVersion;
|
||||
|
||||
virtual size_t getStaticStorageVersion() const;
|
||||
virtual std::vector<std::pair<int, SqliteDatabaseIndex>> getIndices() const;
|
||||
virtual void clearTables();
|
||||
virtual void setupTables();
|
||||
|
||||
@@ -44,6 +44,23 @@ void SqliteStorage::clear()
|
||||
setup();
|
||||
}
|
||||
|
||||
size_t SqliteStorage::getVersion() const
|
||||
{
|
||||
std::string storageVersionStr = getMetaValue("storage_version");
|
||||
|
||||
if (storageVersionStr.size())
|
||||
{
|
||||
return std::stoi(storageVersionStr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SqliteStorage::setVersion(size_t version)
|
||||
{
|
||||
insertOrUpdateMetaValue("storage_version", std::to_string(version));
|
||||
}
|
||||
|
||||
void SqliteStorage::setMode(const StorageModeType mode)
|
||||
{
|
||||
if (mode == m_mode)
|
||||
@@ -93,20 +110,13 @@ FilePath SqliteStorage::getDbFilePath() const
|
||||
|
||||
bool SqliteStorage::isEmpty() const
|
||||
{
|
||||
size_t storageVersion = getStorageVersion();
|
||||
if (storageVersion > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Version applicationVersion = getApplicationVersion();
|
||||
return applicationVersion.isEmpty();
|
||||
return getVersion() <= 0;
|
||||
}
|
||||
|
||||
bool SqliteStorage::isIncompatible() const
|
||||
{
|
||||
size_t storageVersion = getStorageVersion();
|
||||
if (storageVersion == 0 || storageVersion != getStaticStorageVersion())
|
||||
size_t storageVersion = getVersion();
|
||||
if (isEmpty() || storageVersion != getStaticVersion())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -114,12 +124,6 @@ bool SqliteStorage::isIncompatible() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void SqliteStorage::setVersion()
|
||||
{
|
||||
setStorageVersion();
|
||||
setApplicationVersion();
|
||||
}
|
||||
|
||||
void SqliteStorage::setTime()
|
||||
{
|
||||
insertOrUpdateMetaValue("timestamp", TimePoint::now().toString());
|
||||
@@ -273,37 +277,3 @@ void SqliteStorage::insertOrUpdateMetaValue(const std::string& key, const std::s
|
||||
stmt.bind(3, value.c_str());
|
||||
executeStatement(stmt);
|
||||
}
|
||||
|
||||
size_t SqliteStorage::getStorageVersion() const
|
||||
{
|
||||
std::string storageVersionStr = getMetaValue("storage_version");
|
||||
|
||||
if (storageVersionStr.size())
|
||||
{
|
||||
return std::stoi(storageVersionStr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SqliteStorage::setStorageVersion()
|
||||
{
|
||||
insertOrUpdateMetaValue("storage_version", std::to_string(getStaticStorageVersion()));
|
||||
}
|
||||
|
||||
Version SqliteStorage::getApplicationVersion() const
|
||||
{
|
||||
std::string versionStr = getMetaValue("application_version");
|
||||
|
||||
if (versionStr.size())
|
||||
{
|
||||
return Version::fromString(versionStr);
|
||||
}
|
||||
|
||||
return Version();
|
||||
}
|
||||
|
||||
void SqliteStorage::setApplicationVersion()
|
||||
{
|
||||
insertOrUpdateMetaValue("application_version", Version::getApplicationVersion().toString());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
class SqliteStorageMigration;
|
||||
class TimePoint;
|
||||
|
||||
class SqliteStorage
|
||||
@@ -26,6 +27,9 @@ public:
|
||||
void setup();
|
||||
void clear();
|
||||
|
||||
size_t getVersion() const;
|
||||
void setVersion(size_t version);
|
||||
|
||||
void setMode(const StorageModeType mode);
|
||||
|
||||
void beginTransaction();
|
||||
@@ -39,7 +43,6 @@ public:
|
||||
bool isEmpty() const;
|
||||
bool isIncompatible() const;
|
||||
|
||||
void setVersion();
|
||||
void setTime();
|
||||
TimePoint getTime() const;
|
||||
|
||||
@@ -58,24 +61,20 @@ protected:
|
||||
std::string getMetaValue(const std::string& key) const;
|
||||
void insertOrUpdateMetaValue(const std::string& key, const std::string& value);
|
||||
|
||||
size_t getStorageVersion() const;
|
||||
void setStorageVersion();
|
||||
|
||||
Version getApplicationVersion() const;
|
||||
void setApplicationVersion();
|
||||
|
||||
mutable CppSQLite3DB m_database;
|
||||
FilePath m_dbFilePath;
|
||||
|
||||
StorageModeType m_mode;
|
||||
|
||||
private:
|
||||
virtual size_t getStaticStorageVersion() const = 0;
|
||||
virtual size_t getStaticVersion() const = 0;
|
||||
virtual std::vector<std::pair<int, SqliteDatabaseIndex>> getIndices() const = 0;
|
||||
virtual void clearTables() = 0;
|
||||
virtual void setupTables() = 0;
|
||||
|
||||
std::vector<std::pair<int, SqliteDatabaseIndex>> m_indices;
|
||||
|
||||
friend SqliteStorageMigration;
|
||||
};
|
||||
|
||||
#endif // SQLITE_STORAGE_H
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "data/SqliteStorageMigration.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
SqliteStorageMigration::~SqliteStorageMigration()
|
||||
{
|
||||
}
|
||||
|
||||
bool SqliteStorageMigration::executeStatementInStorage(SqliteStorage* storage, const std::string& statement) const
|
||||
{
|
||||
return storage->executeStatement(statement);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef SQLITE_STORAGE_MIGRATION_H
|
||||
#define SQLITE_STORAGE_MIGRATION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "data/SqliteStorage.h"
|
||||
#include "utility/migration/Migration.h"
|
||||
|
||||
class SqliteStorageMigration: public Migration<SqliteStorage>
|
||||
{
|
||||
public:
|
||||
virtual ~SqliteStorageMigration();
|
||||
|
||||
bool executeStatementInStorage(SqliteStorage* storage, const std::string& statement) const;
|
||||
};
|
||||
|
||||
#endif // SQLITE_STORAGE_MIGRATION_H
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "data/SqliteStorageMigrationLambda.h"
|
||||
|
||||
|
||||
SqliteStorageMigrationLambda::SqliteStorageMigrationLambda(std::function<void(const SqliteStorageMigration*, SqliteStorage*)> m_lambda)
|
||||
: m_lambda(m_lambda)
|
||||
{
|
||||
}
|
||||
|
||||
SqliteStorageMigrationLambda::~SqliteStorageMigrationLambda()
|
||||
{
|
||||
}
|
||||
|
||||
void SqliteStorageMigrationLambda::apply(SqliteStorage* migratable) const
|
||||
{
|
||||
m_lambda(this, migratable);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SQLITE_STORAGE_MIGRATION_LAMBDA_H
|
||||
#define SQLITE_STORAGE_MIGRATION_LAMBDA_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "data/SqliteStorageMigration.h"
|
||||
|
||||
class SqliteStorageMigrationLambda: public SqliteStorageMigration
|
||||
{
|
||||
public:
|
||||
SqliteStorageMigrationLambda(std::function<void(const SqliteStorageMigration*, SqliteStorage*)> m_lambda);
|
||||
virtual ~SqliteStorageMigrationLambda();
|
||||
virtual void apply(SqliteStorage* migratable) const;
|
||||
|
||||
private:
|
||||
std::function<void(const SqliteStorageMigration*, SqliteStorage*)> m_lambda;
|
||||
};
|
||||
|
||||
#endif // SQLITE_STORAGE_MIGRATION_LAMBDA_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef SQLITE_STORAGE_MIGRATOR_H
|
||||
#define SQLITE_STORAGE_MIGRATOR_H
|
||||
|
||||
#include "utility/migration/Migrator.h"
|
||||
|
||||
class SqliteStorage;
|
||||
|
||||
typedef Migrator<SqliteStorage> SqliteStorageMigrator;
|
||||
|
||||
#endif // SQLITE_STORAGE_MIGRATOR_H
|
||||
@@ -73,7 +73,7 @@ NameHierarchy StorageAccessProxy::getNameHierarchyForNodeId(Id id) const
|
||||
return m_subject->getNameHierarchyForNodeId(id);
|
||||
}
|
||||
|
||||
return NameHierarchy();
|
||||
return NameHierarchy(NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
|
||||
std::vector<NameHierarchy> StorageAccessProxy::getNameHierarchiesForNodeIds(const std::vector<Id> nodeIds) const
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "data/name/NameDelimiterType.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
std::string nameDelimiterTypeToString(NameDelimiterType delimiter)
|
||||
{
|
||||
switch(delimiter)
|
||||
{
|
||||
case NAME_DELIMITER_FILE:
|
||||
return "/";
|
||||
case NAME_DELIMITER_CXX:
|
||||
return "::";
|
||||
case NAME_DELIMITER_JAVA:
|
||||
return ".";
|
||||
}
|
||||
return "@";
|
||||
}
|
||||
|
||||
NameDelimiterType stringToNameDelimiterType(const std::string& s)
|
||||
{
|
||||
if (s == nameDelimiterTypeToString(NAME_DELIMITER_FILE))
|
||||
{
|
||||
return NAME_DELIMITER_FILE;
|
||||
}
|
||||
if (s == nameDelimiterTypeToString(NAME_DELIMITER_CXX))
|
||||
{
|
||||
return NAME_DELIMITER_CXX;
|
||||
}
|
||||
if (s == nameDelimiterTypeToString(NAME_DELIMITER_JAVA))
|
||||
{
|
||||
return NAME_DELIMITER_JAVA;
|
||||
}
|
||||
return NAME_DELIMITER_UNKNOWN;
|
||||
}
|
||||
|
||||
NameDelimiterType detectDelimiterType(const std::string& name)
|
||||
{
|
||||
std::vector<NameDelimiterType> allDelimiters {NAME_DELIMITER_FILE, NAME_DELIMITER_CXX, NAME_DELIMITER_JAVA};
|
||||
|
||||
for (NameDelimiterType delimiter: allDelimiters)
|
||||
{
|
||||
if (name.find(nameDelimiterTypeToString(delimiter)) != std::string::npos)
|
||||
{
|
||||
return delimiter;
|
||||
}
|
||||
}
|
||||
|
||||
return NAME_DELIMITER_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef NAME_DELIMITER_TYPE_H
|
||||
#define NAME_DELIMITER_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum NameDelimiterType
|
||||
{
|
||||
NAME_DELIMITER_UNKNOWN,
|
||||
NAME_DELIMITER_FILE,
|
||||
NAME_DELIMITER_CXX,
|
||||
NAME_DELIMITER_JAVA
|
||||
};
|
||||
|
||||
std::string nameDelimiterTypeToString(NameDelimiterType delimiter);
|
||||
NameDelimiterType stringToNameDelimiterType(const std::string& s);
|
||||
|
||||
NameDelimiterType detectDelimiterType(const std::string& name);
|
||||
|
||||
#endif // NAME_DELIMITER_TYPE_H
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
std::string NameHierarchy::serialize(NameHierarchy nameHierarchy)
|
||||
{
|
||||
std::string serializedName = "";
|
||||
std::string serializedName = nameDelimiterTypeToString(nameHierarchy.getDelimiterrr()) + "\tm";
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
@@ -20,16 +20,24 @@ std::string NameHierarchy::serialize(NameHierarchy nameHierarchy)
|
||||
|
||||
NameHierarchy NameHierarchy::deserialize(const std::string& serializedName)
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
std::vector<std::string> serializedNameAndMetaElements = utility::splitToVector(serializedName, "\tm");
|
||||
if (serializedNameAndMetaElements.size() != 2)
|
||||
{
|
||||
LOG_ERROR("unable to deserialize name hierarchy: " + serializedName); // todo: obfuscate serializedName!
|
||||
return NameHierarchy(NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
|
||||
std::vector<std::string> serializedNameElements = utility::splitToVector(serializedName, "\tn");
|
||||
const NameDelimiterType delimiter = stringToNameDelimiterType(serializedNameAndMetaElements[0]);
|
||||
NameHierarchy nameHierarchy(delimiter);
|
||||
|
||||
std::vector<std::string> serializedNameElements = utility::splitToVector(serializedNameAndMetaElements[1], "\tn");
|
||||
for (size_t i = 0; i < serializedNameElements.size(); i++)
|
||||
{
|
||||
std::vector<std::string> nameParts = utility::splitToVector(serializedNameElements[i], "\ts");
|
||||
if (nameParts.size() != 2)
|
||||
{
|
||||
LOG_ERROR("unable to deserialize name hierarchy: " + serializedName); // todo: obfuscate serializedName!
|
||||
return NameHierarchy();
|
||||
return NameHierarchy(delimiter);
|
||||
}
|
||||
nameHierarchy.push(std::make_shared<NameElement>(nameParts[0], NameElement::Signature::deserialize(nameParts[1])));
|
||||
}
|
||||
@@ -37,26 +45,29 @@ NameHierarchy NameHierarchy::deserialize(const std::string& serializedName)
|
||||
return nameHierarchy;
|
||||
}
|
||||
|
||||
const std::string& NameHierarchy::getDelimiter()
|
||||
NameDelimiterType NameHierarchy::getDelimiterrr() const
|
||||
{
|
||||
return s_delimiter;
|
||||
return m_delimiter;
|
||||
}
|
||||
|
||||
void NameHierarchy::setDelimiter(const std::string& delimiter)
|
||||
void NameHierarchy::setDelimiterrr(const NameDelimiterType delimiter)
|
||||
{
|
||||
s_delimiter = delimiter;
|
||||
m_delimiter = delimiter;
|
||||
}
|
||||
|
||||
NameHierarchy::NameHierarchy()
|
||||
NameHierarchy::NameHierarchy(const NameDelimiterType delimiter)
|
||||
: m_delimiter(delimiter)
|
||||
{
|
||||
}
|
||||
|
||||
NameHierarchy::NameHierarchy(const std::string& name)
|
||||
NameHierarchy::NameHierarchy(const std::string& name, const NameDelimiterType delimiter)
|
||||
: m_delimiter(delimiter)
|
||||
{
|
||||
push(std::make_shared<NameElement>(name));
|
||||
}
|
||||
|
||||
NameHierarchy::NameHierarchy(const std::vector<std::string>& names)
|
||||
NameHierarchy::NameHierarchy(const std::vector<std::string>& names, const NameDelimiterType delimiter)
|
||||
: m_delimiter(delimiter)
|
||||
{
|
||||
for (const std::string& name : names)
|
||||
{
|
||||
@@ -94,7 +105,7 @@ std::shared_ptr<NameElement> NameHierarchy::operator[](size_t pos) const
|
||||
|
||||
NameHierarchy NameHierarchy::getRange(size_t first, size_t last) const
|
||||
{
|
||||
NameHierarchy hierarchy;
|
||||
NameHierarchy hierarchy(m_delimiter);
|
||||
|
||||
for (size_t i = first; i < last; i++)
|
||||
{
|
||||
@@ -116,7 +127,7 @@ std::string NameHierarchy::getQualifiedName() const
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
name += s_delimiter;
|
||||
name += nameDelimiterTypeToString(m_delimiter);
|
||||
}
|
||||
name += m_elements[i]->getName();
|
||||
}
|
||||
@@ -150,5 +161,3 @@ std::string NameHierarchy::getRawNameWithSignature() const
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string NameHierarchy::s_delimiter = "@";
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "data/name/NameDelimiterType.h"
|
||||
#include "data/name/NameElement.h"
|
||||
|
||||
class NameHierarchy
|
||||
@@ -13,14 +14,14 @@ public:
|
||||
static std::string serialize(NameHierarchy nameHierarchy);
|
||||
static NameHierarchy deserialize(const std::string& serializedName);
|
||||
|
||||
static const std::string& getDelimiter();
|
||||
static void setDelimiter(const std::string& delimiter);
|
||||
|
||||
NameHierarchy();
|
||||
NameHierarchy(const std::string& name);
|
||||
NameHierarchy(const std::vector<std::string>& names);
|
||||
NameHierarchy(const NameDelimiterType delimiter);
|
||||
NameHierarchy(const std::string& name, const NameDelimiterType delimiter);
|
||||
NameHierarchy(const std::vector<std::string>& names, const NameDelimiterType delimiter);
|
||||
~NameHierarchy();
|
||||
|
||||
NameDelimiterType getDelimiterrr() const;
|
||||
void setDelimiterrr(const NameDelimiterType delimiter);
|
||||
|
||||
void push(std::shared_ptr<NameElement> element);
|
||||
void pop();
|
||||
|
||||
@@ -37,9 +38,8 @@ public:
|
||||
std::string getRawNameWithSignature() const;
|
||||
|
||||
private:
|
||||
static std::string s_delimiter;
|
||||
|
||||
std::vector<std::shared_ptr<NameElement>> m_elements;
|
||||
NameDelimiterType m_delimiter;
|
||||
};
|
||||
|
||||
#endif // NAME_ELEMENT_H
|
||||
|
||||
@@ -84,7 +84,7 @@ void ParserClientImpl::onLocalSymbolParsed(const std::string& name, const ParseL
|
||||
|
||||
void ParserClientImpl::onFileParsed(const FileInfo& fileInfo)
|
||||
{
|
||||
const Id nodeId = addNodeHierarchy(NameHierarchy(fileInfo.path.str()), Node::NODE_FILE);
|
||||
const Id nodeId = addNodeHierarchy(NameHierarchy(fileInfo.path.str(), NAME_DELIMITER_FILE), Node::NODE_FILE);
|
||||
addFile(nodeId, fileInfo.path, fileInfo.lastWriteTime.toString());
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ Id ParserClientImpl::addNodeHierarchy(NameHierarchy nameHierarchy, Node::NodeTyp
|
||||
}
|
||||
|
||||
Id parentNodeId = 0;
|
||||
NameHierarchy currentNameHierarchy;
|
||||
NameHierarchy currentNameHierarchy(nameHierarchy.getDelimiterrr());
|
||||
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
@@ -199,7 +199,6 @@ Id ParserClientImpl::addNodeHierarchy(NameHierarchy nameHierarchy, Node::NodeTyp
|
||||
|
||||
Id nodeId = addNode(currentType, currentNameHierarchy);
|
||||
|
||||
// Todo: performance optimization: check if node exists. dont add edge if it existed before...
|
||||
if (parentNodeId != 0)
|
||||
{
|
||||
addEdge(Edge::EDGE_MEMBER, parentNodeId, nodeId);
|
||||
@@ -287,7 +286,7 @@ void ParserClientImpl::addSourceLocation(Id elementId, const ParseLocation& loca
|
||||
}
|
||||
|
||||
Id sourceLocationId = m_storage->addSourceLocation(
|
||||
addNodeHierarchy(NameHierarchy(location.filePath.str()), Node::NODE_FILE),
|
||||
addNodeHierarchy(NameHierarchy(location.filePath.str(), NAME_DELIMITER_FILE), Node::NODE_FILE),
|
||||
location.startLineNumber,
|
||||
location.startColumnNumber,
|
||||
location.endLineNumber,
|
||||
@@ -319,7 +318,7 @@ void ParserClientImpl::addCommentLocation(const ParseLocation& location)
|
||||
}
|
||||
|
||||
m_storage->addCommentLocation(
|
||||
addNodeHierarchy(NameHierarchy(location.filePath.str()), Node::NODE_FILE),
|
||||
addNodeHierarchy(NameHierarchy(location.filePath.str(), NAME_DELIMITER_FILE), Node::NODE_FILE),
|
||||
location.startLineNumber,
|
||||
location.startColumnNumber,
|
||||
location.endLineNumber,
|
||||
|
||||
@@ -60,6 +60,8 @@ struct SearchMatch
|
||||
std::string text;
|
||||
std::string subtext;
|
||||
|
||||
NameDelimiterType delimiter;
|
||||
|
||||
std::string typeName;
|
||||
|
||||
Node::NodeType nodeType;
|
||||
|
||||
@@ -174,11 +174,6 @@ bool Project::refresh(bool forceRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_sourceGroups.empty())
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(m_sourceGroups.front()->getLanguage()));
|
||||
}
|
||||
|
||||
if (requestIndex(forceRefresh, needsFullRefresh))
|
||||
{
|
||||
m_storageAccessProxy->setSubject(m_storage.get());
|
||||
@@ -267,10 +262,6 @@ void Project::load()
|
||||
m_storage->setup();
|
||||
|
||||
m_sourceGroups = SourceGroupFactory::getInstance()->createSourceGroups(m_settings->getAllSourceGroupSettings());
|
||||
if (!m_sourceGroups.empty())
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(m_sourceGroups.front()->getLanguage()));
|
||||
}
|
||||
|
||||
if (canLoad)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
#include "settings/migration/SettingsMigrationMoveKey.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/Status.h"
|
||||
#include "utility/utility.h"
|
||||
@@ -39,19 +39,19 @@ bool ApplicationSettings::load(const FilePath& filePath)
|
||||
|
||||
SettingsMigrator migrator;
|
||||
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>(
|
||||
"source/header_search_paths/header_search_path",
|
||||
"indexing/cxx/header_search_paths/header_search_path"
|
||||
));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>(
|
||||
"source/framework_search_paths/framework_search_path",
|
||||
"indexing/cxx/framework_search_paths/framework_search_path"
|
||||
));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>(
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>(
|
||||
"application/indexer_thread_count",
|
||||
"indexing/indexer_thread_count"
|
||||
));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>(
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>(
|
||||
"network/coati_port",
|
||||
"network/sourcetrail_port"
|
||||
));
|
||||
|
||||
@@ -33,21 +33,6 @@ LanguageType stringToLanguageType(std::string s)
|
||||
return LANGUAGE_UNKNOWN;
|
||||
}
|
||||
|
||||
std::string getSymbolNameDelimiterForLanguage(LanguageType t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case LANGUAGE_C:
|
||||
case LANGUAGE_CPP:
|
||||
return "::";
|
||||
case LANGUAGE_JAVA:
|
||||
return ".";
|
||||
case LANGUAGE_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
return "@";
|
||||
}
|
||||
|
||||
LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
|
||||
{
|
||||
switch (t)
|
||||
|
||||
@@ -16,7 +16,6 @@ enum LanguageType
|
||||
std::string languageTypeToString(LanguageType t);
|
||||
LanguageType stringToLanguageType(std::string s);
|
||||
|
||||
std::string getSymbolNameDelimiterForLanguage(LanguageType t);
|
||||
LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t);
|
||||
|
||||
#endif // LANGUAGE_TYPE_H
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
#include "settings/migration/MigrationDeleteKey.h"
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
#include "settings/migration/SettingsMigrationDeleteKey.h"
|
||||
#include "settings/migration/SettingsMigrationLambda.h"
|
||||
#include "settings/migration/SettingsMigrationMoveKey.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "utility/utility.h"
|
||||
@@ -280,8 +280,8 @@ FilePath ProjectSettings::makePathAbsolute(const FilePath& path) const
|
||||
SettingsMigrator ProjectSettings::getMigrations() const
|
||||
{
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationLambda>(
|
||||
[](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
const std::string standard = migration->getValueFromSettings<std::string>(settings, "language_settings/standard", "");
|
||||
@@ -300,23 +300,23 @@ SettingsMigrator ProjectSettings::getMigrations() const
|
||||
|
||||
const std::string sourceGroupKey = "source_groups/source_group_" + utility::getUuidString();
|
||||
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("info/description", "description"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("language_settings/standard", sourceGroupKey + "/standard"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("info/description", "description"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("language_settings/standard", sourceGroupKey + "/standard"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests"));
|
||||
|
||||
migrator.addMigration(3, std::make_shared<MigrationLambda>(
|
||||
[=](const Migration* migration, Settings* settings)
|
||||
migrator.addMigration(3, std::make_shared<SettingsMigrationLambda>(
|
||||
[=](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
|
||||
@@ -354,9 +354,9 @@ SettingsMigrator ProjectSettings::getMigrations() const
|
||||
}
|
||||
));
|
||||
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("language_settings/language"));
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("source/build_file_path/vs_solution_path"));
|
||||
migrator.addMigration(4, std::make_shared<MigrationDeleteKey>("source/extensions/header_extensions"));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("language_settings/language"));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("source/build_file_path/vs_solution_path"));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("source/extensions/header_extensions"));
|
||||
|
||||
return migrator;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "utility/ConfigManager.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class Migration;
|
||||
class SettingsMigration;
|
||||
|
||||
class Settings
|
||||
{
|
||||
@@ -64,7 +64,7 @@ protected:
|
||||
private:
|
||||
FilePath m_filePath;
|
||||
|
||||
friend Migration;
|
||||
friend SettingsMigration;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
Migration::~Migration()
|
||||
{
|
||||
}
|
||||
|
||||
bool Migration::isValueDefinedInSettings(const Settings* settings, const std::string& key) const
|
||||
{
|
||||
return settings->isValueDefined(key);
|
||||
}
|
||||
|
||||
void Migration::removeValuesInSettings(Settings* settings, const std::string& key) const
|
||||
{
|
||||
settings->removeValues(key);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "settings/migration/MigrationDeleteKey.h"
|
||||
|
||||
MigrationDeleteKey::MigrationDeleteKey(const std::string& key)
|
||||
: m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationDeleteKey::apply(Settings* settings) const
|
||||
{
|
||||
removeValuesInSettings(settings, m_key);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef MIGRATION_DELETE_KEY_H
|
||||
#define MIGRATION_DELETE_KEY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationDeleteKey: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationDeleteKey(const std::string& key);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
const std::string m_key;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_DELETE_KEY_H
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
|
||||
MigrationLambda::MigrationLambda(std::function<void(const Migration*, Settings*)> m_lambda)
|
||||
: m_lambda(m_lambda)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationLambda::apply(Settings* settings) const
|
||||
{
|
||||
m_lambda(this, settings);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef MIGRATION_LAMBDA_H
|
||||
#define MIGRATION_LAMBDA_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationLambda: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationLambda(std::function<void(const Migration*, Settings*)> m_lambda);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
std::function<void(const Migration*, Settings*)> m_lambda;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_LAMBDA_H
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
|
||||
MigrationMoveKey::MigrationMoveKey(const std::string& oldKey, const std::string& newKey)
|
||||
: m_oldKey(oldKey)
|
||||
, m_newKey(newKey)
|
||||
{
|
||||
}
|
||||
|
||||
void MigrationMoveKey::apply(Settings* settings) const
|
||||
{
|
||||
if (!isValueDefinedInSettings(settings, m_newKey))
|
||||
{
|
||||
setValuesInSettings<std::string>(
|
||||
settings,
|
||||
m_newKey,
|
||||
getValuesFromSettings<std::string>(settings, m_oldKey, std::vector<std::string>())
|
||||
);
|
||||
removeValuesInSettings(settings, m_oldKey);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef MIGRATION_MOVE_KEY_H
|
||||
#define MIGRATION_MOVE_KEY_H
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
|
||||
class MigrationMoveKey: public Migration
|
||||
{
|
||||
public:
|
||||
MigrationMoveKey(const std::string& oldKey, const std::string& newKey);
|
||||
virtual void apply(Settings* settings) const;
|
||||
|
||||
private:
|
||||
const std::string m_oldKey;
|
||||
const std::string m_newKey;
|
||||
};
|
||||
|
||||
#endif // MIGRATION_MOVE_KEY_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "settings/migration/SettingsMigration.h"
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
SettingsMigration::~SettingsMigration()
|
||||
{
|
||||
}
|
||||
|
||||
bool SettingsMigration::isValueDefinedInSettings(const Settings* settings, const std::string& key) const
|
||||
{
|
||||
return settings->isValueDefined(key);
|
||||
}
|
||||
|
||||
void SettingsMigration::removeValuesInSettings(Settings* settings, const std::string& key) const
|
||||
{
|
||||
settings->removeValues(key);
|
||||
}
|
||||
+10
-10
@@ -1,16 +1,16 @@
|
||||
#ifndef MIGRATION_H
|
||||
#define MIGRATION_H
|
||||
#ifndef SETTINGS_MIGRATION_H
|
||||
#define SETTINGS_MIGRATION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "utility/migration/Migration.h"
|
||||
|
||||
class Migration
|
||||
class SettingsMigration: public Migration<Settings>
|
||||
{
|
||||
public:
|
||||
virtual ~Migration();
|
||||
virtual void apply(Settings* settings) const = 0;
|
||||
virtual ~SettingsMigration();
|
||||
|
||||
bool isValueDefinedInSettings(const Settings* settings, const std::string& key) const;
|
||||
|
||||
@@ -30,27 +30,27 @@ public:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T Migration::getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const
|
||||
T SettingsMigration::getValueFromSettings(Settings* settings, const std::string& key, T defaultValue) const
|
||||
{
|
||||
return settings->getValue(key, defaultValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> Migration::getValuesFromSettings(Settings* settings, const std::string& key, std::vector<T> defaultValues) const
|
||||
std::vector<T> SettingsMigration::getValuesFromSettings(Settings* settings, const std::string& key, std::vector<T> defaultValues) const
|
||||
{
|
||||
return settings->getValues(key, defaultValues);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Migration::setValueInSettings(Settings* settings, const std::string& key, T value) const
|
||||
bool SettingsMigration::setValueInSettings(Settings* settings, const std::string& key, T value) const
|
||||
{
|
||||
return settings->setValue(key, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Migration::setValuesInSettings(Settings* settings, const std::string& key, std::vector<T> values) const
|
||||
bool SettingsMigration::setValuesInSettings(Settings* settings, const std::string& key, std::vector<T> values) const
|
||||
{
|
||||
return settings->setValues(key, values);
|
||||
}
|
||||
|
||||
#endif // MIGRATION_H
|
||||
#endif // SETTINGS_MIGRATION_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "settings/migration/SettingsMigrationDeleteKey.h"
|
||||
|
||||
SettingsMigrationDeleteKey::SettingsMigrationDeleteKey(const std::string& key)
|
||||
: m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrationDeleteKey::~SettingsMigrationDeleteKey()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrationDeleteKey::apply(Settings* migratable) const
|
||||
{
|
||||
removeValuesInSettings(migratable, m_key);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SETTINGS_MIGRATION_DELETE_KEY_H
|
||||
#define SETTINGS_MIGRATION_DELETE_KEY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "settings/migration/SettingsMigration.h"
|
||||
|
||||
class SettingsMigrationDeleteKey: public SettingsMigration
|
||||
{
|
||||
public:
|
||||
SettingsMigrationDeleteKey(const std::string& key);
|
||||
virtual ~SettingsMigrationDeleteKey();
|
||||
virtual void apply(Settings* migratable) const;
|
||||
|
||||
private:
|
||||
const std::string m_key;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_MIGRATION_DELETE_KEY_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "settings/migration/SettingsMigrationLambda.h"
|
||||
|
||||
SettingsMigrationLambda::SettingsMigrationLambda(std::function<void(const SettingsMigration*, Settings*)> m_lambda)
|
||||
: m_lambda(m_lambda)
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrationLambda::~SettingsMigrationLambda()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrationLambda::apply(Settings* migratable) const
|
||||
{
|
||||
m_lambda(this, migratable);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SETTINGS_MIGRATION_LAMBDA_H
|
||||
#define SETTINGS_MIGRATION_LAMBDA_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "settings/migration/SettingsMigration.h"
|
||||
|
||||
class SettingsMigrationLambda: public SettingsMigration
|
||||
{
|
||||
public:
|
||||
SettingsMigrationLambda(std::function<void(const SettingsMigration*, Settings*)> m_lambda);
|
||||
virtual ~SettingsMigrationLambda();
|
||||
virtual void apply(Settings* migratable) const;
|
||||
|
||||
private:
|
||||
std::function<void(const SettingsMigration*, Settings*)> m_lambda;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_MIGRATION_LAMBDA_H
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "settings/migration/SettingsMigrationMoveKey.h"
|
||||
|
||||
SettingsMigrationMoveKey::SettingsMigrationMoveKey(const std::string& oldKey, const std::string& newKey)
|
||||
: m_oldKey(oldKey)
|
||||
, m_newKey(newKey)
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrationMoveKey::~SettingsMigrationMoveKey()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrationMoveKey::apply(Settings* migratable) const
|
||||
{
|
||||
if (!isValueDefinedInSettings(migratable, m_newKey))
|
||||
{
|
||||
setValuesInSettings<std::string>(
|
||||
migratable,
|
||||
m_newKey,
|
||||
getValuesFromSettings<std::string>(migratable, m_oldKey, std::vector<std::string>())
|
||||
);
|
||||
removeValuesInSettings(migratable, m_oldKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef SETTINGS_MIGRATION_MOVE_KEY_H
|
||||
#define SETTINGS_MIGRATION_MOVE_KEY_H
|
||||
|
||||
#include "settings/migration/SettingsMigration.h"
|
||||
|
||||
class SettingsMigrationMoveKey: public SettingsMigration
|
||||
{
|
||||
public:
|
||||
SettingsMigrationMoveKey(const std::string& oldKey, const std::string& newKey);
|
||||
virtual ~SettingsMigrationMoveKey();
|
||||
virtual void apply(Settings* migratable) const;
|
||||
|
||||
private:
|
||||
const std::string m_oldKey;
|
||||
const std::string m_newKey;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_MIGRATION_MOVE_KEY_H
|
||||
@@ -1,65 +0,0 @@
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
|
||||
#include "settings/migration/Migration.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
SettingsMigrator::SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
SettingsMigrator::~SettingsMigrator()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsMigrator::addMigration(size_t targetVersion, std::shared_ptr<Migration> migration)
|
||||
{
|
||||
if (migration)
|
||||
{
|
||||
m_migrations.emplace(targetVersion, migration);
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsMigrator::willMigrate(const Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator, std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SettingsMigrator::migrate(Settings* settings, size_t targetVersion) const
|
||||
{
|
||||
size_t originVersion = settings->getVersion();
|
||||
|
||||
if (originVersion < targetVersion)
|
||||
{
|
||||
for (; originVersion <= targetVersion; originVersion++)
|
||||
{
|
||||
std::pair<std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator, std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(originVersion);
|
||||
|
||||
for (std::multimap<size_t, std::shared_ptr<Migration>>::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
it->second->apply(settings);
|
||||
}
|
||||
}
|
||||
|
||||
settings->setVersion(targetVersion);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,26 +1,10 @@
|
||||
#ifndef SETTNGS_MIGRATOR_H
|
||||
#define SETTNGS_MIGRATOR_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "utility/migration/Migrator.h"
|
||||
|
||||
class Migration;
|
||||
class Settings;
|
||||
|
||||
class SettingsMigrator
|
||||
{
|
||||
public:
|
||||
SettingsMigrator();
|
||||
virtual ~SettingsMigrator();
|
||||
|
||||
void addMigration(size_t targetVersion, std::shared_ptr<Migration> migration);
|
||||
|
||||
bool willMigrate(const Settings* settings, size_t targetVersion) const;
|
||||
bool migrate(Settings* settings, size_t targetVersion) const;
|
||||
|
||||
private:
|
||||
std::multimap<size_t, std::shared_ptr<Migration>> m_migrations;
|
||||
};
|
||||
typedef Migrator<Settings> SettingsMigrator;
|
||||
|
||||
#endif // SETTINGS_MIGRATOR_H
|
||||
|
||||
@@ -38,7 +38,7 @@ ValType Cache<KeyType, ValType, Hasher>::getValue(KeyType key)
|
||||
}
|
||||
++m_missCount;
|
||||
ValType val = m_calculator(key);
|
||||
m_map[key] = val;
|
||||
m_map.insert(std::pair<KeyType, ValType>(key, val));
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ class MessageActivateNodes
|
||||
public:
|
||||
struct ActiveNode
|
||||
{
|
||||
ActiveNode()
|
||||
: nodeId(0)
|
||||
, nameHierarchy(NAME_DELIMITER_UNKNOWN)
|
||||
{ }
|
||||
Id nodeId;
|
||||
NameHierarchy nameHierarchy;
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
{
|
||||
if (!m_matches[i].subtext.empty())
|
||||
{
|
||||
ss << m_matches[i].subtext << NameHierarchy::getDelimiter();
|
||||
ss << m_matches[i].subtext << m_matches[i].delimiter;
|
||||
}
|
||||
ss << m_matches[i].name;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef MIGRATION_H
|
||||
#define MIGRATION_H
|
||||
|
||||
template <typename MigratableType>
|
||||
class Migration
|
||||
{
|
||||
public:
|
||||
virtual ~Migration();
|
||||
virtual void apply(MigratableType* migratable) const = 0;
|
||||
};
|
||||
|
||||
template <typename MigratableType>
|
||||
Migration<MigratableType>::~Migration()
|
||||
{
|
||||
}
|
||||
|
||||
#endif // MIGRATION_H
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef MIGRATOR_H
|
||||
#define MIGRATOR_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "utility/migration/Migration.h"
|
||||
|
||||
template <typename MigratableType>
|
||||
class Migrator
|
||||
{
|
||||
public:
|
||||
virtual ~Migrator();
|
||||
|
||||
void addMigration(size_t targetVersion, std::shared_ptr<Migration<MigratableType>> migration);
|
||||
|
||||
bool willMigrate(const MigratableType* migratable, size_t targetVersion) const;
|
||||
bool migrate(MigratableType* migratable, size_t targetVersion) const;
|
||||
|
||||
private:
|
||||
typedef std::multimap<size_t, std::shared_ptr<Migration<MigratableType>>> MigrationMap;
|
||||
MigrationMap m_migrations;
|
||||
};
|
||||
|
||||
|
||||
template <typename MigratableType>
|
||||
Migrator<MigratableType>::~Migrator()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename MigratableType>
|
||||
void Migrator<MigratableType>::addMigration(size_t targetVersion, std::shared_ptr<Migration<MigratableType>> migration)
|
||||
{
|
||||
if (migration)
|
||||
{
|
||||
m_migrations.emplace(targetVersion, migration);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename MigratableType>
|
||||
bool Migrator<MigratableType>::willMigrate(const MigratableType* migratable, size_t targetVersion) const
|
||||
{
|
||||
size_t sourceVersion = migratable->getVersion();
|
||||
|
||||
if (sourceVersion < targetVersion)
|
||||
{
|
||||
for (; sourceVersion <= targetVersion; sourceVersion++)
|
||||
{
|
||||
std::pair<MigrationMap::const_iterator, MigrationMap::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(sourceVersion);
|
||||
|
||||
for (MigrationMap::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename MigratableType>
|
||||
bool Migrator<MigratableType>::migrate(MigratableType* migratable, size_t targetVersion) const
|
||||
{
|
||||
size_t sourceVersion = migratable->getVersion();
|
||||
|
||||
if (sourceVersion < targetVersion)
|
||||
{
|
||||
for (; sourceVersion <= targetVersion; sourceVersion++)
|
||||
{
|
||||
std::pair<MigrationMap::const_iterator, MigrationMap::const_iterator> ret;
|
||||
ret = m_migrations.equal_range(sourceVersion);
|
||||
|
||||
for (MigrationMap::const_iterator it = ret.first; it != ret.second; it++)
|
||||
{
|
||||
it->second->apply(migratable);
|
||||
}
|
||||
}
|
||||
|
||||
migratable->setVersion(targetVersion);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // MIGRATOR_H
|
||||
@@ -40,7 +40,7 @@ CxxAstVisitor::CxxAstVisitor(
|
||||
return declName->toNameHierarchy();
|
||||
}
|
||||
}
|
||||
return NameHierarchy("global");
|
||||
return NameHierarchy("global", NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
);
|
||||
m_typeNameCache = std::make_shared<TypeNameCache>([](const clang::Type* type) -> NameHierarchy
|
||||
@@ -53,7 +53,7 @@ CxxAstVisitor::CxxAstVisitor(
|
||||
return typeName->toNameHierarchy();
|
||||
}
|
||||
}
|
||||
return NameHierarchy("global");
|
||||
return NameHierarchy("global", NAME_DELIMITER_UNKNOWN);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ void CxxAstVisitorComponentIndexer::visitUsingDirectiveDecl(clang::UsingDirectiv
|
||||
m_client->recordReference(
|
||||
REFERENCE_USAGE,
|
||||
nameHierarchy,
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str())),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE)),
|
||||
loc
|
||||
);
|
||||
}
|
||||
@@ -397,7 +397,7 @@ void CxxAstVisitorComponentIndexer::visitUsingDecl(clang::UsingDecl* d)
|
||||
m_client->recordReference(
|
||||
REFERENCE_USAGE,
|
||||
getAstVisitor()->getDeclNameCache()->getValue(d),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str())),
|
||||
getAstVisitor()->getComponent<CxxAstVisitorComponentContext>()->getContextName(NameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE)),
|
||||
loc
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "data/indexer/IndexerCommandCxxCdb.h"
|
||||
#include "data/indexer/IndexerCommandCxxManual.h"
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/parser/cxx/ASTActionFactory.h"
|
||||
#include "data/parser/cxx/CxxCompilationDatabaseSingle.h"
|
||||
#include "data/parser/cxx/CxxDiagnosticConsumer.h"
|
||||
@@ -69,8 +68,6 @@ CxxParser::~CxxParser()
|
||||
|
||||
void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(LANGUAGE_CPP));
|
||||
|
||||
clang::tooling::CompileCommand compileCommand;
|
||||
compileCommand.Filename = indexerCommand->getSourceFilePath().str();
|
||||
compileCommand.Directory = indexerCommand->getWorkingDirectory().str();
|
||||
@@ -101,8 +98,6 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxCdb> indexerCommand)
|
||||
|
||||
void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxManual> indexerCommand)
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(LANGUAGE_CPP));
|
||||
|
||||
std::shared_ptr<clang::tooling::CompilationDatabase> compilationDatabase = getCompilationDatabase(indexerCommand);
|
||||
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, indexerCommand->getSourceFilePath().str()));
|
||||
@@ -122,8 +117,6 @@ void CxxParser::buildIndex(std::shared_ptr<IndexerCommandCxxManual> indexerComma
|
||||
|
||||
void CxxParser::buildIndex(const std::string& fileName, std::shared_ptr<TextAccess> fileContent)
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(LANGUAGE_CPP));
|
||||
|
||||
std::shared_ptr<FilePathCache> canonicalFilePathCache = std::make_shared<FilePathCache>([](std::string fileName) -> FilePath
|
||||
{
|
||||
return FilePath(fileName).canonical();
|
||||
|
||||
@@ -62,8 +62,8 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
FilePath includedFilePath = m_canonicalFilePathCache->getValue(fileEntry->getName());
|
||||
if (m_fileRegister->hasFilePath(includedFilePath))
|
||||
{
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.str());
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.str());
|
||||
const NameHierarchy referencedNameHierarchy(includedFilePath.str(), NAME_DELIMITER_FILE);
|
||||
const NameHierarchy contextNameHierarchy(m_currentPath.str(), NAME_DELIMITER_FILE);
|
||||
|
||||
m_client->recordReference(
|
||||
REFERENCE_INCLUDE,
|
||||
@@ -85,7 +85,7 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con
|
||||
return;
|
||||
}
|
||||
|
||||
const NameHierarchy nameHierarchy(macroNameToken.getIdentifierInfo()->getName().str());
|
||||
const NameHierarchy nameHierarchy(macroNameToken.getIdentifierInfo()->getName().str(), NAME_DELIMITER_CXX);
|
||||
|
||||
m_client->recordSymbol(
|
||||
nameHierarchy,
|
||||
@@ -134,8 +134,8 @@ void PreprocessorCallbacks::onMacroUsage(const clang::Token& macroNameToken)
|
||||
{
|
||||
const ParseLocation loc = getParseLocation(macroNameToken);
|
||||
|
||||
const NameHierarchy referencedNameHierarchy(macroNameToken.getIdentifierInfo()->getName().str());
|
||||
const NameHierarchy contextNameHierarchy(loc.filePath.str());
|
||||
const NameHierarchy referencedNameHierarchy(macroNameToken.getIdentifierInfo()->getName().str(), NAME_DELIMITER_CXX);
|
||||
const NameHierarchy contextNameHierarchy(loc.filePath.str(), NAME_DELIMITER_FILE);
|
||||
|
||||
m_client->recordReference(
|
||||
REFERENCE_MACRO_USAGE,
|
||||
|
||||
@@ -38,7 +38,7 @@ NameHierarchy CxxDeclName::toNameHierarchy() const
|
||||
nameString += ">";
|
||||
}
|
||||
|
||||
NameHierarchy ret = getParent() ? getParent()->toNameHierarchy(): NameHierarchy();
|
||||
NameHierarchy ret = getParent() ? getParent()->toNameHierarchy(): NameHierarchy(NAME_DELIMITER_CXX);
|
||||
ret.push(std::make_shared<NameElement>(nameString));
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -39,7 +39,7 @@ CxxTypeName::~CxxTypeName()
|
||||
|
||||
NameHierarchy CxxTypeName::toNameHierarchy() const
|
||||
{
|
||||
NameHierarchy ret = getParent() ? getParent()->toNameHierarchy(): NameHierarchy();
|
||||
NameHierarchy ret = getParent() ? getParent()->toNameHierarchy(): NameHierarchy(NAME_DELIMITER_CXX);
|
||||
ret.push(std::make_shared<NameElement>(getTypeNameString()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ bool QtSmartSearchBox::event(QEvent *event)
|
||||
{
|
||||
if (m_highlightedMatch.hasChildren)
|
||||
{
|
||||
setEditText((m_highlightedMatch.getFullName() + NameHierarchy::getDelimiter()).c_str());
|
||||
setEditText((m_highlightedMatch.getFullName() + nameDelimiterTypeToString(m_highlightedMatch.delimiter)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -256,7 +256,8 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::string> names = utility::splitToVector(text().toStdString(), NameHierarchy::getDelimiter());
|
||||
const NameDelimiterType delimiter = detectDelimiterType(text().toStdString());
|
||||
std::vector<std::string> names = utility::splitToVector(text().toStdString(), delimiter);
|
||||
if (names.back() == "")
|
||||
{
|
||||
names.pop_back();
|
||||
@@ -269,7 +270,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event)
|
||||
else
|
||||
{
|
||||
names.back() = "";
|
||||
setEditText(utility::join(names, NameHierarchy::getDelimiter()).c_str());
|
||||
setEditText(utility::join(names, delimiter).c_str());
|
||||
}
|
||||
|
||||
requestAutoCompletions();
|
||||
|
||||
@@ -93,7 +93,7 @@ void QtGraphNodeData::onClick()
|
||||
FilePath path = getFilePath();
|
||||
|
||||
MessageActivateNodes message;
|
||||
message.addNode(m_data->getId(), path.empty() ? m_data->getNameHierarchy() : path.str());
|
||||
message.addNode(m_data->getId(), path.empty() ? m_data->getNameHierarchy() : NameHierarchy(path.str(), NAME_DELIMITER_FILE));
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -120,8 +120,6 @@ void JavaParser::buildIndex(
|
||||
const std::string& classPath,
|
||||
std::shared_ptr<TextAccess> textAccess)
|
||||
{
|
||||
NameHierarchy::setDelimiter(getSymbolNameDelimiterForLanguage(LANGUAGE_JAVA));
|
||||
|
||||
if (m_javaEnvironment)
|
||||
{
|
||||
m_currentFilePath = sourceFilePath;
|
||||
|
||||
@@ -3412,8 +3412,6 @@ public:
|
||||
private:
|
||||
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)
|
||||
{
|
||||
NameHierarchy::setDelimiter("::");
|
||||
|
||||
std::shared_ptr<TestFileRegister> fileRegister = std::make_shared<TestFileRegister>();
|
||||
std::shared_ptr<TestParserClient> parserClient = std::make_shared<TestParserClient>();
|
||||
CxxParser parser(parserClient, fileRegister);
|
||||
|
||||
+29
-29
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
void test_nodes_are_nodes()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
|
||||
TS_ASSERT(a.isNode());
|
||||
TS_ASSERT(!a.isEdge());
|
||||
@@ -100,8 +100,8 @@ public:
|
||||
|
||||
void test_edges_are_edges()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(!e.isNode());
|
||||
@@ -110,27 +110,27 @@ public:
|
||||
|
||||
void test_set_type_of_node_from_constructor()
|
||||
{
|
||||
Node n(1, Node::NODE_FUNCTION, NameHierarchy("A"), false);
|
||||
Node n(1, Node::NODE_FUNCTION, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
TS_ASSERT_EQUALS(Node::NODE_FUNCTION, n.getType());
|
||||
}
|
||||
|
||||
void test_set_type_of_node_from_non_indexed()
|
||||
{
|
||||
Node n(2, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node n(2, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
n.setType(Node::NODE_CLASS);
|
||||
TS_ASSERT_EQUALS(Node::NODE_CLASS, n.getType());
|
||||
}
|
||||
|
||||
void test_can_not_change_type_of_node_after_it_was_set()
|
||||
{
|
||||
Node n(3, Node::NODE_NAMESPACE, NameHierarchy("A"), false);
|
||||
Node n(3, Node::NODE_NAMESPACE, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
n.setType(Node::NODE_CLASS);
|
||||
TS_ASSERT_DIFFERS(Node::NODE_CLASS, n.getType());
|
||||
}
|
||||
|
||||
void test_node_can_be_copied_and_keeps_same_id()
|
||||
{
|
||||
Node n(4, Node::NODE_NAMESPACE, NameHierarchy("A"), false);
|
||||
Node n(4, Node::NODE_NAMESPACE, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node n2(n);
|
||||
|
||||
TS_ASSERT_DIFFERS(&n, &n2);
|
||||
@@ -141,15 +141,15 @@ public:
|
||||
|
||||
void test_node_type_bit_masking()
|
||||
{
|
||||
Node n(1, Node::NODE_NAMESPACE, NameHierarchy("A"), false);
|
||||
Node n(1, Node::NODE_NAMESPACE, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
TS_ASSERT(n.isType(Node::NODE_FUNCTION | Node::NODE_NAMESPACE | Node::NODE_CLASS));
|
||||
TS_ASSERT(!n.isType(Node::NODE_FUNCTION | Node::NODE_METHOD | Node::NODE_CLASS));
|
||||
}
|
||||
|
||||
void test_get_type_of_edges()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT_EQUALS(Edge::EDGE_USAGE, e.getType());
|
||||
@@ -157,8 +157,8 @@ public:
|
||||
|
||||
void test_edge_can_be_copied_and_keeps_same_id()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
Edge e2(e, &a, &b);
|
||||
|
||||
@@ -169,8 +169,8 @@ public:
|
||||
|
||||
void test_edge_type_bit_masking()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Edge e(3, Edge::EDGE_USAGE, &a, &b);
|
||||
|
||||
TS_ASSERT(e.isType(Edge::EDGE_MEMBER | Edge::EDGE_CALL | Edge::EDGE_USAGE));
|
||||
@@ -179,9 +179,9 @@ public:
|
||||
|
||||
void test_node_finds_child_node()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C", NAME_DELIMITER_CXX), false);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -198,9 +198,9 @@ public:
|
||||
|
||||
void test_node_can_not_find_child_node()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C", NAME_DELIMITER_CXX), false);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -216,9 +216,9 @@ public:
|
||||
|
||||
void test_node_visits_child_nodes()
|
||||
{
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C"), false);
|
||||
Node a(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node b(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
Node c(3, Node::NODE_NON_INDEXED, NameHierarchy("C", NAME_DELIMITER_CXX), false);
|
||||
Edge e(4, Edge::EDGE_MEMBER, &a, &b);
|
||||
Edge e2(5, Edge::EDGE_MEMBER, &a, &c);
|
||||
|
||||
@@ -238,8 +238,8 @@ public:
|
||||
void test_graph_saves_nodes()
|
||||
{
|
||||
Graph graph;
|
||||
Node* a = graph.createNode(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
Node* b = graph.createNode(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node* a = graph.createNode(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node* b = graph.createNode(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
|
||||
TS_ASSERT_EQUALS(2, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
|
||||
@@ -257,8 +257,8 @@ public:
|
||||
{
|
||||
Graph graph;
|
||||
|
||||
Node* a = graph.createNode(1, Node::NODE_FUNCTION, NameHierarchy("A"), false);
|
||||
Node* b = graph.createNode(2, Node::NODE_FUNCTION, NameHierarchy("B"), false);
|
||||
Node* a = graph.createNode(1, Node::NODE_FUNCTION, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
Node* b = graph.createNode(2, Node::NODE_FUNCTION, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
|
||||
Edge* e = graph.createEdge(3, Edge::EDGE_CALL, a, b);
|
||||
|
||||
@@ -273,8 +273,8 @@ public:
|
||||
{
|
||||
Graph graph;
|
||||
|
||||
Node* a = graph.createNode(1, Node::NODE_NON_INDEXED, NameHierarchy("A"), false);
|
||||
graph.createNode(2, Node::NODE_NON_INDEXED, NameHierarchy("B"), false);
|
||||
Node* a = graph.createNode(1, Node::NODE_NON_INDEXED, NameHierarchy("A", NAME_DELIMITER_CXX), false);
|
||||
graph.createNode(2, Node::NODE_NON_INDEXED, NameHierarchy("B", NAME_DELIMITER_CXX), false);
|
||||
|
||||
TS_ASSERT_EQUALS(2, graph.getNodeCount());
|
||||
TS_ASSERT_EQUALS(0, graph.getEdgeCount());
|
||||
|
||||
@@ -832,8 +832,6 @@ private:
|
||||
|
||||
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)
|
||||
{
|
||||
NameHierarchy::setDelimiter(".");
|
||||
|
||||
std::shared_ptr<TestParserClient> parserClient = std::make_shared<TestParserClient>();
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromString(code);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/search/SearchIndex.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
class SearchIndexTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void test_search_index_finds_id_of_element_added()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("foo\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfoo\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("oo", 0);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void test_search_index_finds_correct_indices_for_query()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("foo\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfoo\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("oo", 0);
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
void test_search_index_finds_ids_for_ambiguous_query()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("for\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("fos\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfor\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("::\tmfos\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("fo", 0);
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
void test_search_index_does_not_find_anything_after_clear()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("foo\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfoo\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
index.clear();
|
||||
std::vector<SearchResult> results = index.search("oo", 0);
|
||||
@@ -62,8 +62,8 @@ public:
|
||||
void test_search_index_does_not_find_all_results_when_max_amount_is_limited()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("foo1\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("foo2\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfoo1\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("::\tmfoo2\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("oo", 1);
|
||||
|
||||
@@ -73,8 +73,8 @@ public:
|
||||
void test_search_index_query_is_case_insensitive()
|
||||
{
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("foo1\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("FOO2\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmfoo1\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("::\tmFOO2\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("oo", 0);
|
||||
|
||||
@@ -85,8 +85,8 @@ public:
|
||||
{
|
||||
|
||||
SearchIndex index;
|
||||
index.addNode(1, NameHierarchy::deserialize("oaabbcc\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("ocbcabc\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(1, NameHierarchy::deserialize("::\tmoaabbcc\tsvoid\tp() const").getQualifiedName());
|
||||
index.addNode(2, NameHierarchy::deserialize("::\tmocbcabc\tsvoid\tp() const").getQualifiedName());
|
||||
index.finishSetup();
|
||||
std::vector<SearchResult> results = index.search("abc", 0);
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
#include "settings/migration/SettingsMigrationLambda.h"
|
||||
#include "settings/migration/SettingsMigrationMoveKey.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
|
||||
class SettingsMigratorTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "int"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -75,7 +76,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "sub/int"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "sub/int"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("values/value", "vals/value"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("values/value", "vals/value"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -139,7 +140,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("values/value", "values/val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("values/value", "values/val"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -163,8 +164,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -189,8 +190,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -214,8 +215,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -241,8 +242,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "val"));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("element", "ele"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("element", "ele"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -274,10 +275,10 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int/val"));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("element", "ele"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int/val", "int"));
|
||||
migrator.addMigration(3, std::make_shared<MigrationMoveKey>("ele", "elements/element"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("value", "int/val"));
|
||||
migrator.addMigration(1, std::make_shared<SettingsMigrationMoveKey>("element", "ele"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("int/val", "int"));
|
||||
migrator.addMigration(3, std::make_shared<SettingsMigrationMoveKey>("ele", "elements/element"));
|
||||
migrator.migrate(&settingsBefore, 3);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -302,8 +303,8 @@ public:
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(
|
||||
1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
1, std::make_shared<SettingsMigrationLambda>(
|
||||
[](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) * 2);
|
||||
}
|
||||
@@ -332,19 +333,21 @@ public:
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(
|
||||
1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) * 2);
|
||||
}
|
||||
));
|
||||
1, std::make_shared<SettingsMigrationLambda>(
|
||||
[](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) * 2);
|
||||
}
|
||||
)
|
||||
);
|
||||
migrator.addMigration(
|
||||
2, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) - 1);
|
||||
}
|
||||
));
|
||||
2, std::make_shared<SettingsMigrationLambda>(
|
||||
[](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) - 1);
|
||||
}
|
||||
)
|
||||
);
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
std::string filePath = "path/to/test.h";
|
||||
|
||||
std::shared_ptr<IntermediateStorage> intermetiateStorage = std::make_shared<IntermediateStorage>();
|
||||
Id id = intermetiateStorage->addNode(Node::typeToInt(Node::NODE_FILE), NameHierarchy::serialize(NameHierarchy(filePath)));
|
||||
Id id = intermetiateStorage->addNode(Node::typeToInt(Node::NODE_FILE), NameHierarchy::serialize(NameHierarchy(filePath, NAME_DELIMITER_FILE)));
|
||||
intermetiateStorage->addFile(id, filePath, "someTime", true);
|
||||
|
||||
storage.inject(intermetiateStorage.get());
|
||||
@@ -249,8 +249,6 @@ private:
|
||||
|
||||
Id getEdgeId(Edge::EdgeType type, const NameHierarchy& fromName, const NameHierarchy& toName) const
|
||||
{
|
||||
NameHierarchy from;
|
||||
|
||||
return getIdForEdge(type, fromName, toName);
|
||||
}
|
||||
};
|
||||
@@ -271,8 +269,8 @@ private:
|
||||
|
||||
NameHierarchy createNameHierarchy(std::string s) const
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
for (std::string element: utility::splitToVector(s, "::"))
|
||||
NameHierarchy nameHierarchy(NAME_DELIMITER_CXX);
|
||||
for (std::string element: utility::splitToVector(s, nameDelimiterTypeToString(NAME_DELIMITER_CXX)))
|
||||
{
|
||||
nameHierarchy.push(std::make_shared<NameElement>(element, NameElement::Signature()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user