logic: Refreshing reloads the source code and resets the Token ids to start from 1
This commit is contained in:
@@ -13,7 +13,7 @@ y fooy();
|
||||
z fooz();
|
||||
*/
|
||||
|
||||
const bool *ab(int a, int b);
|
||||
const bool *ab(int abc, int bca);
|
||||
|
||||
bool const *abc(int a, int b);
|
||||
|
||||
|
||||
+15
-4
@@ -45,8 +45,7 @@ void Application::loadProject(const std::string& projectSettingsFilePath)
|
||||
m_project->loadProjectSettings(projectSettingsFilePath);
|
||||
m_project->parseCode();
|
||||
|
||||
MessageActivateToken message(1);
|
||||
message.dispatch();
|
||||
MessageActivateToken(1).dispatch();
|
||||
}
|
||||
|
||||
void Application::loadSource(const std::string& sourceDirectoryPath)
|
||||
@@ -57,8 +56,15 @@ void Application::loadSource(const std::string& sourceDirectoryPath)
|
||||
m_project->setSourceDirectoryPath(sourceDirectoryPath);
|
||||
m_project->parseCode();
|
||||
|
||||
MessageActivateToken message(1);
|
||||
message.dispatch();
|
||||
MessageActivateToken(1).dispatch();
|
||||
}
|
||||
|
||||
void Application::reloadProject()
|
||||
{
|
||||
m_project->clearStorage();
|
||||
m_project->parseCode();
|
||||
|
||||
MessageActivateToken(1).dispatch();
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageLoadProject* message)
|
||||
@@ -70,3 +76,8 @@ void Application::handleMessage(MessageLoadSource* message)
|
||||
{
|
||||
loadSource(message->sourceDirectoryPath);
|
||||
}
|
||||
|
||||
void Application::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
reloadProject();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageLoadSource.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
class ViewFactory;
|
||||
class MainView;
|
||||
@@ -17,6 +18,7 @@ class LocationAccessProxy;
|
||||
class Application
|
||||
: public MessageListener<MessageLoadProject>
|
||||
, public MessageListener<MessageLoadSource>
|
||||
, public MessageListener<MessageRefresh>
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<Application> create(ViewFactory* viewFactory);
|
||||
@@ -25,12 +27,14 @@ public:
|
||||
|
||||
void loadProject(const std::string& projectSettingsFilePath);
|
||||
void loadSource(const std::string& sourceDirectoryPath);
|
||||
void reloadProject();
|
||||
|
||||
private:
|
||||
Application();
|
||||
|
||||
virtual void handleMessage(MessageLoadProject* message);
|
||||
virtual void handleMessage(MessageLoadSource* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
|
||||
std::shared_ptr<Project> m_project;
|
||||
std::shared_ptr<GraphAccessProxy> m_graphAccessProxy;
|
||||
|
||||
+14
-5
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "data/access/GraphAccessProxy.h"
|
||||
#include "data/access/LocationAccessProxy.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "utility/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
@@ -13,11 +14,7 @@
|
||||
std::shared_ptr<Project> Project::create(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy)
|
||||
{
|
||||
std::shared_ptr<Project> ptr(new Project(graphAccessProxy, locationAccessProxy));
|
||||
ptr->m_storage = std::make_shared<Storage>();
|
||||
|
||||
graphAccessProxy->setSubject(ptr->m_storage.get());
|
||||
locationAccessProxy->setSubject(ptr->m_storage.get());
|
||||
|
||||
ptr->clearStorage();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -40,13 +37,25 @@ bool Project::setSourceDirectoryPath(const std::string& sourceDirectoryPath)
|
||||
return ProjectSettings::getInstance()->setSourcePath(sourceDirectoryPath);
|
||||
}
|
||||
|
||||
void Project::clearStorage()
|
||||
{
|
||||
m_storage = std::make_shared<Storage>();
|
||||
|
||||
m_graphAccessProxy->setSubject(m_storage.get());
|
||||
m_locationAccessProxy->setSubject(m_storage.get());
|
||||
|
||||
Token::resetNextId();
|
||||
}
|
||||
|
||||
void Project::parseCode()
|
||||
{
|
||||
if (ProjectSettings::getInstance()->getSourcePath() != "")
|
||||
{
|
||||
std::vector<std::string> extensions;
|
||||
extensions.push_back(".cpp");
|
||||
extensions.push_back(".cc");
|
||||
extensions.push_back(".h");
|
||||
extensions.push_back(".hpp");
|
||||
|
||||
CxxParser parser(m_storage);
|
||||
parser.parseFiles(
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
|
||||
bool setSourceDirectoryPath(const std::string& sourceDirectoryPath);
|
||||
|
||||
void clearStorage();
|
||||
void parseCode();
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
void Token::resetNextId()
|
||||
{
|
||||
s_nextId = 1;
|
||||
}
|
||||
|
||||
Token::Token()
|
||||
: m_id(s_nextId++)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
class Token
|
||||
{
|
||||
public:
|
||||
static void resetNextId();
|
||||
|
||||
Token();
|
||||
virtual ~Token();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user