logic: multiple fixes and improvements
* showing project name in main window title * keep reference count visible when maximizing code file * show first node in db when no main function is available * log Storage stats after parse * fixed macro locations saved multiply * using NameHierarchy when retrieving ids
This commit is contained in:
@@ -136,7 +136,7 @@ void QtCodeFile::addCodeSnippet(
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount
|
||||
int refCount
|
||||
){
|
||||
m_locationFile.reset();
|
||||
|
||||
@@ -153,7 +153,10 @@ void QtCodeFile::addCodeSnippet(
|
||||
m_fileSnippet = snippet;
|
||||
|
||||
clickedMaximizeButton();
|
||||
updateRefCount(0);
|
||||
if (refCount != -1)
|
||||
{
|
||||
updateRefCount(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ QWidget* QtCodeFile::insertCodeSnippet(
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount
|
||||
int refCount
|
||||
){
|
||||
m_locationFile.reset();
|
||||
|
||||
@@ -271,7 +274,7 @@ void QtCodeFile::updateContent()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFile::setLocationFile(std::shared_ptr<TokenLocationFile> locationFile, uint refCount)
|
||||
void QtCodeFile::setLocationFile(std::shared_ptr<TokenLocationFile> locationFile, int refCount)
|
||||
{
|
||||
m_locationFile = locationFile;
|
||||
clickedMinimizeButton();
|
||||
@@ -395,7 +398,7 @@ void QtCodeFile::updateSnippets()
|
||||
clickedSnippetButton();
|
||||
}
|
||||
|
||||
void QtCodeFile::updateRefCount(uint refCount)
|
||||
void QtCodeFile::updateRefCount(int refCount)
|
||||
{
|
||||
if (refCount > 0)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount
|
||||
int refCount
|
||||
);
|
||||
|
||||
QWidget* insertCodeSnippet(
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount
|
||||
int refCount
|
||||
);
|
||||
|
||||
QWidget* findFirstActiveSnippet() const;
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
void updateContent();
|
||||
|
||||
void setLocationFile(std::shared_ptr<TokenLocationFile> locationFile, uint refCount);
|
||||
void setLocationFile(std::shared_ptr<TokenLocationFile> locationFile, int refCount);
|
||||
|
||||
public slots:
|
||||
void clickedSnippetButton();
|
||||
@@ -68,7 +68,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void updateSnippets();
|
||||
void updateRefCount(uint refCount);
|
||||
void updateRefCount(int refCount);
|
||||
|
||||
QtCodeFileList* m_parent;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void QtCodeFileList::addCodeSnippet(
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount,
|
||||
int refCount,
|
||||
bool insert
|
||||
){
|
||||
QtCodeFile* file = getFile(locationFile);
|
||||
@@ -62,7 +62,7 @@ void QtCodeFileList::addCodeSnippet(
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileList::addFile(std::shared_ptr<TokenLocationFile> locationFile, uint refCount)
|
||||
void QtCodeFileList::addFile(std::shared_ptr<TokenLocationFile> locationFile, int refCount)
|
||||
{
|
||||
QtCodeFile* file = getFile(locationFile);
|
||||
file->setLocationFile(locationFile, refCount);
|
||||
|
||||
@@ -32,11 +32,11 @@ public:
|
||||
Id titleId,
|
||||
const std::string& code,
|
||||
std::shared_ptr<TokenLocationFile> locationFile,
|
||||
uint refCount,
|
||||
int refCount,
|
||||
bool insert = false
|
||||
);
|
||||
|
||||
void addFile(std::shared_ptr<TokenLocationFile> locationFile, uint refCount);
|
||||
void addFile(std::shared_ptr<TokenLocationFile> locationFile, int refCount);
|
||||
|
||||
void clearCodeSnippets();
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ void QtCodeView::doAddCodeSnippets(const std::vector<CodeSnippetParams>& snippet
|
||||
|
||||
void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
{
|
||||
m_widget->addCodeSnippet(1, params.title, 0, params.code, params.locationFile, params.refCount);
|
||||
m_widget->addCodeSnippet(1, params.title, 0, params.code, params.locationFile, -1);
|
||||
}
|
||||
|
||||
void QtCodeView::doShowFirstActiveSnippet()
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
|
||||
QtMainView::QtMainView()
|
||||
: m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1))
|
||||
{
|
||||
m_window = std::make_shared<QtMainWindow>();
|
||||
m_window->show();
|
||||
@@ -67,3 +68,13 @@ void QtMainView::showStartScreen()
|
||||
{
|
||||
m_window->showStartScreen();
|
||||
}
|
||||
|
||||
void QtMainView::setTitle(const std::string& title)
|
||||
{
|
||||
m_setTitleFunctor(title);
|
||||
}
|
||||
|
||||
void QtMainView::doSetTitle(const std::string& title)
|
||||
{
|
||||
m_window->setWindowTitle(QString::fromStdString(title));
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@
|
||||
#include <vector>
|
||||
|
||||
#include <QStatusBar>
|
||||
|
||||
#include "component/view/MainView.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QtMainWindow;
|
||||
class View;
|
||||
|
||||
class QtMainView: public MainView
|
||||
class QtMainView
|
||||
: public MainView
|
||||
{
|
||||
public:
|
||||
QtMainView();
|
||||
@@ -31,10 +34,15 @@ public:
|
||||
|
||||
// MainView implementation
|
||||
virtual void showStartScreen();
|
||||
virtual void setTitle(const std::string& title);
|
||||
|
||||
private:
|
||||
void doSetTitle(const std::string& title);
|
||||
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
QtThreadedFunctor<const std::string&> m_setTitleFunctor;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_VIEW_H
|
||||
|
||||
+11
-7
@@ -24,6 +24,8 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
ptr->m_componentManager = ComponentManager::create(viewFactory, ptr->m_storageCache.get());
|
||||
|
||||
ptr->m_mainView = viewFactory->createMainView();
|
||||
ptr->m_mainView->setTitle("Coati");
|
||||
|
||||
ptr->m_componentManager->setup(ptr->m_mainView.get());
|
||||
ptr->m_mainView->loadLayout();
|
||||
|
||||
@@ -71,6 +73,8 @@ void Application::loadProject(const FilePath& projectSettingsFilePath)
|
||||
|
||||
updateRecentProjects(projectSettingsFilePath);
|
||||
|
||||
m_mainView->setTitle(projectSettingsFilePath.fileName());
|
||||
|
||||
m_storageCache->clear();
|
||||
m_componentManager->refreshViews();
|
||||
|
||||
@@ -109,20 +113,20 @@ void Application::handleMessage(MessageFinishedParsing* message)
|
||||
|
||||
m_isInitialParse = false;
|
||||
|
||||
Id mainId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main"));
|
||||
Id nodeId = m_storageCache->getIdForNodeWithNameHierarchy(NameHierarchy("main"));
|
||||
|
||||
if (!mainId)
|
||||
if (!nodeId)
|
||||
{
|
||||
mainId = 1;
|
||||
nodeId = m_storageCache->getIdForFirstNode();
|
||||
}
|
||||
|
||||
if (mainId)
|
||||
if (nodeId)
|
||||
{
|
||||
MessageActivateNodes message;
|
||||
message.addNode(
|
||||
mainId,
|
||||
m_storageCache->getNodeTypeForNodeWithId(mainId),
|
||||
m_storageCache->getNameHierarchyForNodeWithId(mainId)
|
||||
nodeId,
|
||||
m_storageCache->getNodeTypeForNodeWithId(nodeId),
|
||||
m_storageCache->getNameHierarchyForNodeWithId(nodeId)
|
||||
);
|
||||
message.isFromSystem = true;
|
||||
message.dispatch();
|
||||
|
||||
@@ -131,8 +131,6 @@ void Project::parseCode()
|
||||
|
||||
void Project::logStats() const
|
||||
{
|
||||
// m_storage->logGraph();
|
||||
// m_storage->logLocations();
|
||||
m_storage->logStats();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
std::shared_ptr<TokenLocationFile> locationFile;
|
||||
|
||||
uint refCount;
|
||||
int refCount;
|
||||
|
||||
bool isActive;
|
||||
bool isDeclaration;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MAIN_VIEW_H
|
||||
#define MAIN_VIEW_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
class MainView: public ViewLayout
|
||||
@@ -10,6 +12,7 @@ public:
|
||||
virtual ~MainView();
|
||||
|
||||
virtual void showStartScreen() = 0;
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
};
|
||||
|
||||
#endif // MAIN_VIEW_H
|
||||
|
||||
@@ -188,6 +188,17 @@ void SqliteStorage::removeUnusedNameHierarchyElements()
|
||||
);
|
||||
}
|
||||
|
||||
StorageNode SqliteStorage::getFirstNode() const
|
||||
{
|
||||
std::vector<StorageNode> nodes = getAllNodes("LIMIT 1");
|
||||
if (nodes.size())
|
||||
{
|
||||
return nodes[0];
|
||||
}
|
||||
|
||||
return StorageNode(0, 0, 0);
|
||||
}
|
||||
|
||||
std::vector<StorageNode> SqliteStorage::getAllNodes() const
|
||||
{
|
||||
std::vector<StorageNode> nodes;
|
||||
@@ -680,17 +691,27 @@ Id SqliteStorage::getNodeIdBySignature(const std::string& signature) const
|
||||
|
||||
int SqliteStorage::getNodeCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) from node;");
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM node;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getEdgeCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) from edge;");
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM edge;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getFileCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM file;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getNameHierarchyElementCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) from name_hierarchy_element;");
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM name_hierarchy_element;");
|
||||
}
|
||||
|
||||
int SqliteStorage::getSourceLocationCount() const
|
||||
{
|
||||
return m_database.execScalar("SELECT COUNT(*) FROM source_location;");
|
||||
}
|
||||
|
||||
void SqliteStorage::clearTables()
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
void removeFile(Id id);
|
||||
void removeUnusedNameHierarchyElements();
|
||||
|
||||
StorageNode getFirstNode() const;
|
||||
std::vector<StorageNode> getAllNodes() const;
|
||||
|
||||
bool isEdge(Id elementId) const;
|
||||
@@ -97,7 +98,9 @@ public:
|
||||
|
||||
int getNodeCount() const;
|
||||
int getEdgeCount() const;
|
||||
int getFileCount() const;
|
||||
int getNameHierarchyElementCount() const;
|
||||
int getSourceLocationCount() const;
|
||||
|
||||
private:
|
||||
void clearTables();
|
||||
|
||||
+40
-30
@@ -93,20 +93,51 @@ void Storage::removeUnusedNames()
|
||||
clearCaches();
|
||||
}
|
||||
|
||||
void Storage::logGraph() const
|
||||
std::vector<FileInfo> Storage::getInfoOnAllFiles() const
|
||||
{
|
||||
std::vector<FileInfo> fileInfos;
|
||||
|
||||
std::vector<StorageFile> storageFiles = m_sqliteStorage.getAllFiles();
|
||||
for (size_t i = 0; i < storageFiles.size(); i++)
|
||||
{
|
||||
boost::posix_time::ptime modificationTime = boost::posix_time::not_a_date_time;
|
||||
if (storageFiles[i].modificationTime != "not-a-date-time")
|
||||
{
|
||||
modificationTime = boost::posix_time::time_from_string(storageFiles[i].modificationTime);
|
||||
}
|
||||
fileInfos.push_back(FileInfo(
|
||||
FilePath(storageFiles[i].filePath),
|
||||
modificationTime
|
||||
));
|
||||
}
|
||||
|
||||
return fileInfos;
|
||||
}
|
||||
|
||||
void Storage::logLocations() const
|
||||
{
|
||||
}
|
||||
|
||||
void Storage::logIndex() const
|
||||
const SearchIndex& Storage::getSearchIndex() const
|
||||
{
|
||||
return m_tokenIndex;
|
||||
}
|
||||
|
||||
void Storage::logStats() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "\nGraph:\n";
|
||||
ss << "\t" << m_sqliteStorage.getNodeCount() << " Nodes\n";
|
||||
ss << "\t" << m_sqliteStorage.getEdgeCount() << " Edges\n";
|
||||
|
||||
ss << "\nSearch:\n";
|
||||
ss << "\t" << m_tokenIndex.getCharCount() << " Characters\n";
|
||||
ss << "\t" << m_tokenIndex.getWordCount() << " Words\n";
|
||||
ss << "\t" << m_tokenIndex.getNodeCount() << " SearchNodes\n";
|
||||
ss << "\t" << m_sqliteStorage.getNameHierarchyElementCount() << " NameHierarchyElements\n";
|
||||
|
||||
ss << "\nCode:\n";
|
||||
ss << "\t" << m_sqliteStorage.getFileCount() << " Files\n";
|
||||
ss << "\t" << m_sqliteStorage.getSourceLocationCount() << " Source Locations\n";
|
||||
|
||||
LOG_WARNING(ss.str());
|
||||
}
|
||||
|
||||
void Storage::startParsing()
|
||||
@@ -704,25 +735,9 @@ Id Storage::getIdForEdge(
|
||||
return m_sqliteStorage.getEdgeBySourceTargetType(sourceId, targetId, type).id;
|
||||
}
|
||||
|
||||
std::vector<FileInfo> Storage::getInfoOnAllFiles() const
|
||||
Id Storage::getIdForFirstNode() const
|
||||
{
|
||||
std::vector<FileInfo> fileInfos;
|
||||
|
||||
std::vector<StorageFile> storageFiles = m_sqliteStorage.getAllFiles();
|
||||
for (size_t i = 0; i < storageFiles.size(); i++)
|
||||
{
|
||||
boost::posix_time::ptime modificationTime = boost::posix_time::not_a_date_time;
|
||||
if (storageFiles[i].modificationTime != "not-a-date-time")
|
||||
{
|
||||
modificationTime = boost::posix_time::time_from_string(storageFiles[i].modificationTime);
|
||||
}
|
||||
fileInfos.push_back(FileInfo(
|
||||
FilePath(storageFiles[i].filePath),
|
||||
modificationTime
|
||||
));
|
||||
}
|
||||
|
||||
return fileInfos;
|
||||
return m_sqliteStorage.getFirstNode().id;
|
||||
}
|
||||
|
||||
NameHierarchy Storage::getNameHierarchyForNodeWithId(Id nodeId) const
|
||||
@@ -796,7 +811,7 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
|
||||
|
||||
addAggregationEdgesToGraph(elementId, graph);
|
||||
}
|
||||
else
|
||||
else if (m_sqliteStorage.isEdge(elementId))
|
||||
{
|
||||
addEdgeAndAllChildrenToGraph(elementId, graph);
|
||||
}
|
||||
@@ -1129,11 +1144,6 @@ std::shared_ptr<TextAccess> Storage::getFileContent(const FilePath& filePath) co
|
||||
return m_sqliteStorage.getFileContentByPath(filePath.str());
|
||||
}
|
||||
|
||||
const SearchIndex& Storage::getSearchIndex() const
|
||||
{
|
||||
return m_tokenIndex;
|
||||
}
|
||||
|
||||
Id Storage::addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct)
|
||||
{
|
||||
addNameHierarchyElements(nameHierarchy);
|
||||
|
||||
@@ -32,9 +32,9 @@ public:
|
||||
void clearFileElement(const FilePath& filePath);
|
||||
void removeUnusedNames();
|
||||
|
||||
void logGraph() const;
|
||||
void logLocations() const;
|
||||
void logIndex() const;
|
||||
std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
const SearchIndex& getSearchIndex() const;
|
||||
|
||||
void logStats() const;
|
||||
|
||||
// ParserClient implementation
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
virtual Id getIdForFirstNode() const;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id nodeId) const;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const;
|
||||
@@ -156,8 +156,6 @@ public:
|
||||
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
|
||||
|
||||
const SearchIndex& getSearchIndex() const;
|
||||
|
||||
private:
|
||||
Id addNodeHierarchy(Node::NodeType nodeType, NameHierarchy nameHierarchy, bool distinct = false);
|
||||
Id addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const = 0;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const = 0;
|
||||
virtual Id getIdForFirstNode() const = 0;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const = 0;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0;
|
||||
|
||||
@@ -53,19 +53,19 @@ Id StorageAccessProxy::getIdForEdge(
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<FileInfo> StorageAccessProxy::getInfoOnAllFiles() const
|
||||
Id StorageAccessProxy::getIdForFirstNode() const
|
||||
{
|
||||
std::vector<FileInfo> fileInfos;
|
||||
if (hasSubject())
|
||||
{
|
||||
fileInfos = m_subject->getInfoOnAllFiles();
|
||||
return m_subject->getIdForFirstNode();
|
||||
}
|
||||
return fileInfos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node::NodeType StorageAccessProxy::getNodeTypeForNodeWithId(Id id) const
|
||||
{
|
||||
if(hasSubject())
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNodeTypeForNodeWithId(id);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
virtual Id getIdForEdge(
|
||||
Edge::EdgeType type, const NameHierarchy& fromNameHierarchy, const NameHierarchy& toNameHierarchy) const;
|
||||
|
||||
virtual std::vector<FileInfo> getInfoOnAllFiles() const;
|
||||
virtual Id getIdForFirstNode() const;
|
||||
|
||||
virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const;
|
||||
virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const;
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual ~Parser();
|
||||
|
||||
virtual void parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments) = 0;
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments) = 0;
|
||||
virtual void parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments) = 0;
|
||||
|
||||
protected:
|
||||
ParserClient* m_client;
|
||||
|
||||
@@ -83,8 +83,10 @@ void CxxParser::parseFiles(const std::vector<FilePath>& filePaths, const Argumen
|
||||
}
|
||||
}
|
||||
|
||||
void CxxParser::parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
|
||||
void CxxParser::parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
|
||||
{
|
||||
setupParsing(std::vector<FilePath>(1, filePath), arguments);
|
||||
|
||||
std::vector<std::string> args = getCommandlineArguments(arguments);
|
||||
std::shared_ptr<CxxDiagnosticConsumer> diagnostics = getDiagnostics(arguments);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
|
||||
// ParserClient implementation
|
||||
virtual void parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments);
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments);
|
||||
virtual void parseFile(const FilePath& filePath, std::shared_ptr<TextAccess> textAccess, const Arguments& arguments);
|
||||
|
||||
private:
|
||||
std::vector<std::string> getCommandlineArguments(const Arguments& arguments) const;
|
||||
|
||||
@@ -57,7 +57,7 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
|
||||
const FileManager* fileManager = m_fileRegister->getFileManager();
|
||||
if (fileManager->hasFilePath(baseFilePath) && fileManager->hasFilePath(includedFilePath) &&
|
||||
!m_fileRegister->includeFileIsParsed(baseFilePath))
|
||||
!m_fileRegister->fileIsParsed(baseFilePath))
|
||||
{
|
||||
m_client->onFileIncludeParsed(
|
||||
getParseLocation(fileNameRange.getAsRange()),
|
||||
@@ -77,7 +77,7 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con
|
||||
}
|
||||
|
||||
FilePath filePath = FilePath(fileStr);
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath))
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
{
|
||||
// ignore builtin macros
|
||||
if (m_sourceManager.getSpellingLoc(macroNameToken.getLocation()).printToString(m_sourceManager)[0] == '<')
|
||||
@@ -103,7 +103,7 @@ void PreprocessorCallbacks::MacroExpands(
|
||||
}
|
||||
|
||||
FilePath filePath = FilePath(fileStr);
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath))
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
nameHierarchy.push(std::make_shared<NameElement>(macroNameToken.getIdentifierInfo()->getName().str()));
|
||||
|
||||
@@ -18,8 +18,10 @@ void FileRegister::setFilePaths(const std::vector<FilePath>& filePaths)
|
||||
m_sourceFilePaths.clear();
|
||||
m_includeFilePaths.clear();
|
||||
|
||||
for (const FilePath& path : filePaths)
|
||||
for (const FilePath& p : filePaths)
|
||||
{
|
||||
FilePath path = p.exists() ? p.absolute() : p;
|
||||
|
||||
if (m_fileManager->hasSourceExtension(path))
|
||||
{
|
||||
m_sourceFilePaths.emplace(path, STATE_UNPARSED);
|
||||
@@ -41,6 +43,23 @@ std::vector<FilePath> FileRegister::getUnparsedIncludeFilePaths() const
|
||||
return getUnparsedFilePaths(m_includeFilePaths);
|
||||
}
|
||||
|
||||
bool FileRegister::fileIsParsed(const FilePath& filePath) const
|
||||
{
|
||||
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
|
||||
if (it != m_includeFilePaths.end())
|
||||
{
|
||||
return it->second == STATE_PARSED;
|
||||
}
|
||||
|
||||
it = m_sourceFilePaths.find(filePath);
|
||||
if (it != m_sourceFilePaths.end())
|
||||
{
|
||||
return it->second == STATE_PARSED;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileRegister::includeFileIsParsing(const FilePath& filePath) const
|
||||
{
|
||||
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
|
||||
|
||||
@@ -21,6 +21,8 @@ public:
|
||||
std::vector<FilePath> getUnparsedSourceFilePaths() const;
|
||||
std::vector<FilePath> getUnparsedIncludeFilePaths() const;
|
||||
|
||||
bool fileIsParsed(const FilePath& filePath) const;
|
||||
|
||||
bool includeFileIsParsing(const FilePath& filePath) const;
|
||||
bool includeFileIsParsed(const FilePath& filePath) const;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
@@ -2641,13 +2642,6 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onFieldUsageParsed(
|
||||
const ParseLocation& location, const ParseVariable& user, const NameHierarchy& usedNameHierarchy)
|
||||
{
|
||||
usages.push_back(addLocationSuffix(variableStr(user) + " -> " + usedNameHierarchy.getFullName(), location));
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual Id onGlobalVariableUsageParsed(
|
||||
const ParseLocation& location, const ParseFunction& user, const NameHierarchy& usedNameHierarchy)
|
||||
{
|
||||
@@ -2835,7 +2829,7 @@ private:
|
||||
TestFileManager fm;
|
||||
std::shared_ptr<TestParserClient> client = std::make_shared<TestParserClient>();
|
||||
CxxParser parser(client.get(), &fm);
|
||||
parser.parseFile(TextAccess::createFromString(code), m_args);
|
||||
parser.parseFile("input.cc", TextAccess::createFromString(code), m_args);
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
+55
-37
@@ -27,10 +27,10 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onTypedefParsed(validLocation(1), createNameHierarchy("type"), typeUsage("int"), ParserClient::ACCESS_NONE);
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "type");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "type");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_TYPEDEF);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPEDEF_OF) + ":type->int") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPEDEF_OF, "type", "int") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onClassParsed(validLocation(1), createNameHierarchy("Class"), ParserClient::ACCESS_NONE, validLocation(2));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Class");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Class");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_CLASS);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onStructParsed(validLocation(1), createNameHierarchy("Struct"), ParserClient::ACCESS_NONE, validLocation(2));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Struct");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Struct");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_STRUCT);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
@@ -67,12 +67,12 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(42), ParseVariable(typeUsage("char"), createNameHierarchy("Global"), false));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Global");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Global");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_GLOBAL_VARIABLE);
|
||||
|
||||
//TS_ASSERT(!node->getComponent<TokenComponentStatic>());
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":Global->char") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "Global", "char") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onGlobalVariableParsed(validLocation(7), ParseVariable(typeUsage("char"), createNameHierarchy("Global"), true));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Global");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Global");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_GLOBAL_VARIABLE);
|
||||
|
||||
//TS_ASSERT(node->getComponent<TokenComponentStatic>());
|
||||
@@ -99,10 +99,10 @@ public:
|
||||
validLocation(3), ParseVariable(typeUsage("bool"), createNameHierarchy("m_field"), false), ParserClient::ACCESS_NONE
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "m_field");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "m_field");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FIELD);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":m_field->bool") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "m_field", "bool") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -115,17 +115,17 @@ public:
|
||||
validLocation(11), ParseVariable(typeUsage("bool"), createNameHierarchy("Struct::m_field"), false), ParserClient::ACCESS_PUBLIC
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Struct::m_field");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Struct::m_field");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FIELD);
|
||||
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Struct->Struct::m_field") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Struct", "Struct::m_field") != 0);
|
||||
//TS_ASSERT(memberEdge->getComponent<TokenComponentAccess>());
|
||||
//TS_ASSERT_EQUALS(
|
||||
// memberEdge->getComponent<TokenComponentAccess>()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC
|
||||
//);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_OF) + ":Struct::m_field->bool") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_OF, "Struct::m_field", "bool") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -138,13 +138,13 @@ public:
|
||||
validLocation(14), ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char")), validLocation(41)
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "isTrue");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "isTrue");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FUNCTION);
|
||||
|
||||
// TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_RETURN_TYPE_OF) + ":isTrue->bool") != 0);
|
||||
// TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_PARAMETER_TYPE_OF) + ":isTrue->char") != 0);
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->bool") != 0);
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->char") != 0);
|
||||
// TS_ASSERT(storage.getEdgeId(Edge::EDGE_RETURN_TYPE_OF, "isTrue", "bool") != 0);
|
||||
// TS_ASSERT(storage.getEdgeId(Edge::EDGE_PARAMETER_TYPE_OF, "isTrue", "char") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "bool") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "char") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 2);
|
||||
@@ -161,13 +161,13 @@ public:
|
||||
validLocation(4)
|
||||
);
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "isMethod");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "isMethod");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_METHOD);
|
||||
|
||||
// TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_RETURN_TYPE_OF) + ":isMethod->void") != 0);
|
||||
// TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_PARAMETER_TYPE_OF) + ":isMethod->bool") != 0);
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isMethod->void") != 0);
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isMethod->bool") != 0);
|
||||
// TS_ASSERT(storage.getEdgeId(Edge::EDGE_RETURN_TYPE_OF, "isMethod", "void") != 0);
|
||||
// TS_ASSERT(storage.getEdgeId(Edge::EDGE_PARAMETER_TYPE_OF, "isMethod", "bool") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isMethod", "void") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isMethod", "bool") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 2);
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
// TokenComponentAbstraction::ABSTRACTION_VIRTUAL
|
||||
//);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Class->Class::isMethod") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Class", "Class::isMethod") != 0);
|
||||
//TS_ASSERT(memberEdge->getComponent<TokenComponentAccess>());
|
||||
//TS_ASSERT_EQUALS(
|
||||
// memberEdge->getComponent<TokenComponentAccess>()->getAccess(), TokenComponentAccess::ACCESS_PROTECTED
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onNamespaceParsed(validLocation(1), createNameHierarchy("utility"), validLocation(2));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "utility");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "utility");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_NAMESPACE);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onEnumParsed(validLocation(17), createNameHierarchy("Category"), ParserClient::ACCESS_NONE, validLocation(23));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "Category");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "Category");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_ENUM);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
ParserClient::ACCESS_PRIVATE, validLocation(2)
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_MEMBER) + ":Class->Class::Category") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_MEMBER, "Class", "Class::Category") != 0);
|
||||
|
||||
//TS_ASSERT(memberEdge->getComponent<TokenComponentAccess>());
|
||||
//TS_ASSERT_EQUALS(
|
||||
@@ -262,7 +262,7 @@ public:
|
||||
TestStorage storage;
|
||||
Id id = storage.onEnumConstantParsed(validLocation(1), createNameHierarchy("VALUE"));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "VALUE");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "VALUE");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_ENUM_CONSTANT);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
createNameHierarchy("ClassA"), ParserClient::ACCESS_PUBLIC
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INHERITANCE) + ":ClassB->ClassA") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_INHERITANCE, "ClassB", "ClassA") != 0);
|
||||
//TS_ASSERT(edge->getComponent<TokenComponentAccess>());
|
||||
//TS_ASSERT_EQUALS(edge->getComponent<TokenComponentAccess>()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC);
|
||||
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
createNameHierarchy("StructA"), ParserClient::ACCESS_PUBLIC
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INHERITANCE) + ":StructB->StructA") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_INHERITANCE, "StructB", "StructA") != 0);
|
||||
|
||||
//TS_ASSERT(edge->getComponent<TokenComponentAccess>());
|
||||
//TS_ASSERT_EQUALS(edge->getComponent<TokenComponentAccess>()->getAccess(), TokenComponentAccess::ACCESS_PUBLIC);
|
||||
@@ -318,7 +318,7 @@ public:
|
||||
|
||||
storage.onMethodOverrideParsed(validLocation(4), a, b);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_OVERRIDE) + ":B::isMethod->A::isMethod") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_OVERRIDE, "B::isMethod", "A::isMethod") != 0);
|
||||
}
|
||||
|
||||
void test_storage_saves_call()
|
||||
@@ -336,7 +336,7 @@ public:
|
||||
ParseFunction(typeUsage("void"), createNameHierarchy("func"), parameters("bool"))
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_CALL) + ":isTrue->func") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_CALL, "isTrue", "func") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -356,7 +356,7 @@ public:
|
||||
ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char"))
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_CALL) + ":global->isTrue") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_CALL, "global", "isTrue") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -378,7 +378,7 @@ public:
|
||||
createNameHierarchy("Foo::m_field")
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_USAGE) + ":isTrue->Foo::m_field") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_USAGE, "isTrue", "Foo::m_field") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
createNameHierarchy("global")
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_USAGE) + ":isTrue->global") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_USAGE, "isTrue", "global") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -419,7 +419,7 @@ public:
|
||||
ParseFunction(typeUsage("bool"), createNameHierarchy("isTrue"), parameters("char"))
|
||||
);
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_TYPE_USAGE) + ":isTrue->Struct") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_TYPE_USAGE, "isTrue", "Struct") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -548,7 +548,7 @@ public:
|
||||
|
||||
Id id = storage.onFileParsed(FileInfo("file.h"));
|
||||
|
||||
TS_ASSERT_EQUALS(storage.getNameForNodeWithId(id), "file.h");
|
||||
TS_ASSERT_EQUALS(storage.getNameHierarchyForNodeWithId(id).getFullName(), "file.h");
|
||||
TS_ASSERT_EQUALS(storage.getNodeTypeForNodeWithId(id), Node::NODE_FILE);
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ public:
|
||||
storage.onFileParsed(FileInfo("file.cpp"));
|
||||
Id id = storage.onFileIncludeParsed(validLocation(7), FileInfo("file.cpp"), FileInfo("file.h"));
|
||||
|
||||
TS_ASSERT(storage.getIdForEdgeWithName(Edge::getTypeString(Edge::EDGE_INCLUDE) + ":file.cpp->file.h") != 0);
|
||||
TS_ASSERT(storage.getEdgeId(Edge::EDGE_INCLUDE, "file.cpp", "file.h") != 0);
|
||||
|
||||
std::shared_ptr<TokenLocationCollection> tlc = storage.getLocationCollectionForTokenId(id);
|
||||
TS_ASSERT_EQUALS(tlc->getTokenLocationCount(), 1);
|
||||
@@ -631,6 +631,24 @@ private:
|
||||
{
|
||||
return getSearchIndex();
|
||||
}
|
||||
|
||||
NameHierarchy nameHierarchyFromString(const std::string& str) const
|
||||
{
|
||||
NameHierarchy result;
|
||||
std::vector<std::string> names = utility::splitToVector(str, "::");
|
||||
for (const std::string& name : names)
|
||||
{
|
||||
result.push(std::make_shared<NameElement>(name));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Id getEdgeId(Edge::EdgeType type, const std::string& fromName, const std::string& toName) const
|
||||
{
|
||||
NameHierarchy from;
|
||||
|
||||
return getIdForEdge(type, nameHierarchyFromString(fromName), nameHierarchyFromString(toName));
|
||||
}
|
||||
};
|
||||
|
||||
ParseLocation validLocation(Id locationId = 0) const // id is not used as id ..... who programs this? ebsi? :P
|
||||
|
||||
@@ -15,5 +15,5 @@ void TestStorage::parseCxxCode(std::string code)
|
||||
|
||||
TestFileManager fm;
|
||||
CxxParser parser(this, &fm);
|
||||
parser.parseFile(TextAccess::createFromString(code), Parser::Arguments());
|
||||
parser.parseFile("input.cc", TextAccess::createFromString(code), Parser::Arguments());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user