src: code cleanup
* removed unused code: ParseFunction, ParseVariable and ParseTypeUsage. All this is handled using NameHierarchies now. * Moved the getErrorCount method from ParserClient to the StorageAccess * MessageFinishedParsing doesn't know the error count anymore. * StatusBarController now has a StorageAccess to fetch the error count when needed.
This commit is contained in:
@@ -123,18 +123,12 @@ add_files(
|
||||
|
||||
data/parser/cxx/TaskParseCxx.h
|
||||
|
||||
data/parser/ParseFunction.cpp
|
||||
data/parser/ParseFunction.h
|
||||
data/parser/ParseLocation.cpp
|
||||
data/parser/ParseLocation.h
|
||||
data/parser/Parser.cpp
|
||||
data/parser/Parser.h
|
||||
data/parser/ParserClient.cpp
|
||||
data/parser/ParserClient.h
|
||||
data/parser/ParseTypeUsage.cpp
|
||||
data/parser/ParseTypeUsage.h
|
||||
data/parser/ParseVariable.cpp
|
||||
data/parser/ParseVariable.h
|
||||
|
||||
data/search/SearchIndex.cpp
|
||||
data/search/SearchIndex.h
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ bool Project::load(const FilePath& projectSettingsFile)
|
||||
{
|
||||
m_storage->startParsing();
|
||||
m_storage->finishParsing();
|
||||
MessageFinishedParsing(0, 0, 0, m_storage->getErrorCount()).dispatch();
|
||||
MessageFinishedParsing(0, 0, 0).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ std::shared_ptr<Component> ComponentFactory::createUndoRedoComponent(ViewLayout*
|
||||
std::shared_ptr<Component> ComponentFactory::createStatusBarComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<StatusBarView> view = m_viewFactory->createStatusBarView(viewLayout);
|
||||
std::shared_ptr<StatusBarController> controller = std::make_shared<StatusBarController>();
|
||||
std::shared_ptr<StatusBarController> controller = std::make_shared<StatusBarController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "component/controller/StatusBarController.h"
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
#include "data/access/StorageAccess.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
|
||||
StatusBarController::StatusBarController()
|
||||
StatusBarController::StatusBarController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,7 +25,17 @@ void StatusBarController::handleMessage(MessageClearErrorCount* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
getView()->setErrorCount(message->errorCount);
|
||||
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
|
||||
getView()->setErrorCount(errorCount);
|
||||
|
||||
std::string status = message->getStatusStr();
|
||||
status += " " + std::to_string(errorCount.total) + " error" + (errorCount.total > 1 ? "s" : "");
|
||||
if (errorCount.fatal > 0)
|
||||
{
|
||||
status += " (" + std::to_string(errorCount.fatal) + " fatal)";
|
||||
}
|
||||
|
||||
MessageStatus(status, errorCount.total > 0).dispatch();
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
class StatusBarView;
|
||||
class StorageAccess;
|
||||
|
||||
class StatusBarController
|
||||
: public Controller
|
||||
@@ -21,7 +22,7 @@ class StatusBarController
|
||||
, public MessageListener<MessageStatus>
|
||||
{
|
||||
public:
|
||||
StatusBarController(void);
|
||||
StatusBarController(StorageAccess* storageAccess);
|
||||
virtual ~StatusBarController(void);
|
||||
|
||||
StatusBarView* getView();
|
||||
@@ -33,6 +34,8 @@ private:
|
||||
virtual void handleMessage(MessageStatus* message);
|
||||
|
||||
void setStatus(const std::string& status, bool isError, bool showLoader);
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // STATUS_BAR_CONTROLLER_H
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "data/location/TokenLocationLine.h"
|
||||
#include "data/parser/ParseFunction.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
@@ -209,11 +206,6 @@ void Storage::onError(const ParseLocation& location, const std::string& message,
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCountInfo Storage::getErrorCount() const
|
||||
{
|
||||
return ErrorCountInfo(m_sqliteStorage.getAllErrors().size(), m_sqliteStorage.getFatalErrors().size());
|
||||
}
|
||||
|
||||
Id Storage::onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access
|
||||
){
|
||||
@@ -1091,6 +1083,11 @@ TimePoint Storage::getFileModificationTime(const FilePath& filePath) const
|
||||
return TimePoint(m_sqliteStorage.getFileByPath(filePath.str()).modificationTime);
|
||||
}
|
||||
|
||||
ErrorCountInfo Storage::getErrorCount() const
|
||||
{
|
||||
return ErrorCountInfo(m_sqliteStorage.getAllErrors().size(), m_sqliteStorage.getFatalErrors().size());
|
||||
}
|
||||
|
||||
StorageStats Storage::getStorageStats() const
|
||||
{
|
||||
StorageStats stats;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
const ParseLocation& location, const NameHierarchy& argumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateNameHierarchy);
|
||||
virtual Id onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateParameterNameHierarchy);
|
||||
virtual Id onTemplateParameterTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& templateParameterTypeNameHierarchy);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/search/SearchMatch.h"
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "data/StorageStats.h"
|
||||
|
||||
struct FileInfo;
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const = 0;
|
||||
virtual TimePoint getFileModificationTime(const FilePath& filePath) const = 0;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
virtual StorageStats getStorageStats() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -275,6 +275,16 @@ TimePoint StorageAccessProxy::getFileModificationTime(const FilePath& filePath)
|
||||
return TimePoint(boost::posix_time::not_a_date_time);
|
||||
}
|
||||
|
||||
ErrorCountInfo StorageAccessProxy::getErrorCount() const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getErrorCount();
|
||||
}
|
||||
|
||||
return ErrorCountInfo();
|
||||
}
|
||||
|
||||
StorageStats StorageAccessProxy::getStorageStats() const
|
||||
{
|
||||
if (hasSubject())
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
virtual std::shared_ptr<TextAccess> getFileContent(const FilePath& filePath) const;
|
||||
virtual TimePoint getFileModificationTime(const FilePath& filePath) const;
|
||||
|
||||
virtual ErrorCountInfo getErrorCount() const;
|
||||
virtual StorageStats getStorageStats() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#include "data/parser/ParseFunction.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
ParseFunction::ParseFunction(
|
||||
const ParseTypeUsage& returnType,
|
||||
const NameHierarchy& nameHierarchy,
|
||||
const std::vector<ParseTypeUsage>& parameters,
|
||||
bool isStatic,
|
||||
bool isConst
|
||||
)
|
||||
: returnType(returnType)
|
||||
, nameHierarchy(nameHierarchy)
|
||||
, parameters(parameters)
|
||||
, isStatic(isStatic)
|
||||
, isConst(isConst)
|
||||
{
|
||||
}
|
||||
|
||||
std::string ParseFunction::getFullName() const
|
||||
{
|
||||
return nameHierarchy.getQualifiedNameWithSignature();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef PARSE_FUNCTION_H
|
||||
#define PARSE_FUNCTION_H
|
||||
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
|
||||
struct ParseFunction
|
||||
{
|
||||
ParseFunction(
|
||||
const ParseTypeUsage& returnType,
|
||||
const NameHierarchy& nameHierarchy,
|
||||
const std::vector<ParseTypeUsage>& parameters,
|
||||
bool isStatic = false,
|
||||
bool isConst = false
|
||||
);
|
||||
|
||||
std::string getFullName() const;
|
||||
|
||||
const ParseTypeUsage returnType;
|
||||
const NameHierarchy nameHierarchy;
|
||||
const std::vector<ParseTypeUsage> parameters;
|
||||
const bool isStatic;
|
||||
const bool isConst;
|
||||
};
|
||||
|
||||
#endif // PARSE_FUNCTION_H
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
|
||||
ParseTypeUsage::ParseTypeUsage(const ParseLocation& location, const std::shared_ptr<DataType> dataType)
|
||||
: location(location)
|
||||
, dataType(dataType)
|
||||
{
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef PARSE_TYPE_USAGE_H
|
||||
#define PARSE_TYPE_USAGE_H
|
||||
|
||||
#include <memory>
|
||||
#include "data/type/DataType.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
|
||||
struct ParseTypeUsage
|
||||
{
|
||||
ParseTypeUsage(const ParseLocation& location, const std::shared_ptr<DataType> dataType);
|
||||
|
||||
const ParseLocation location;
|
||||
const std::shared_ptr<DataType> dataType;
|
||||
};
|
||||
|
||||
#endif // PARSE_TYPE_USAGE_H
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "data/parser/ParseVariable.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
ParseVariable::ParseVariable(const ParseTypeUsage& type, const NameHierarchy& nameHierarchy, bool isStatic)
|
||||
: type(type)
|
||||
, nameHierarchy(nameHierarchy)
|
||||
, isStatic(isStatic)
|
||||
{
|
||||
}
|
||||
|
||||
std::string ParseVariable::getFullName() const
|
||||
{
|
||||
return nameHierarchy.getQualifiedNameWithSignature();
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef PARSE_VARIABLE_H
|
||||
#define PARSE_VARIABLE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
|
||||
struct ParseVariable
|
||||
{
|
||||
ParseVariable(const ParseTypeUsage& type, const NameHierarchy& nameHierarchy, bool isStatic);
|
||||
|
||||
std::string getFullName() const;
|
||||
|
||||
const ParseTypeUsage type;
|
||||
const NameHierarchy nameHierarchy;
|
||||
const bool isStatic;
|
||||
};
|
||||
|
||||
#endif // PARSE_VARIABLE_H
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "data/parser/ParseFunction.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "data/type/DataType.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
@@ -85,34 +82,6 @@ std::string ParserClient::addLocationSuffix(
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string ParserClient::variableStr(const ParseVariable& variable)
|
||||
{
|
||||
std::string str = variable.type.dataType->getFullTypeName() + " " + variable.getFullName();
|
||||
return addStaticPrefix(str, variable.isStatic);
|
||||
}
|
||||
|
||||
std::string ParserClient::parameterStr(const std::vector<ParseTypeUsage> parameters)
|
||||
{
|
||||
std::string str = "(";
|
||||
for (size_t i = 0; i < parameters.size(); i++)
|
||||
{
|
||||
str += parameters[i].dataType->getFullTypeName();
|
||||
if (i < parameters.size() - 1)
|
||||
{
|
||||
str += ", ";
|
||||
}
|
||||
}
|
||||
return str + ")";
|
||||
}
|
||||
|
||||
std::string ParserClient::functionStr(const ParseFunction& function)
|
||||
{
|
||||
/*std::string str =
|
||||
function.returnType.dataType->getFullTypeName() + " " + function.getFullName() + parameterStr(function.parameters);
|
||||
return addConstPrefix(addStaticPrefix(str, function.isStatic), function.isConst, false);*/
|
||||
return function.nameHierarchy.getQualifiedNameWithSignature();
|
||||
}
|
||||
|
||||
ParserClient::ParserClient()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,17 +6,10 @@
|
||||
|
||||
#include "utility/types.h"
|
||||
#include "data/name/NameHierarchy.h"
|
||||
#include "data/ErrorCountInfo.h"
|
||||
|
||||
#include "utility/file/FileInfo.h"
|
||||
|
||||
#include "ParseLocation.h"
|
||||
|
||||
|
||||
struct ParseFunction;
|
||||
struct ParseLocation;
|
||||
struct ParseTypeUsage;
|
||||
struct ParseVariable;
|
||||
class DataType;
|
||||
|
||||
class ParserClient
|
||||
@@ -48,10 +41,6 @@ public:
|
||||
static std::string addLocationSuffix(
|
||||
const std::string& str, const ParseLocation& location, const ParseLocation& scopeLocation);
|
||||
|
||||
static std::string variableStr(const ParseVariable& variable);
|
||||
static std::string parameterStr(const std::vector<ParseTypeUsage> parameters);
|
||||
static std::string functionStr(const ParseFunction& function);
|
||||
static std::string functionSignatureStr(const ParseFunction& function); // should this be in here? consider languages other than c++.
|
||||
|
||||
ParserClient();
|
||||
virtual ~ParserClient();
|
||||
@@ -63,7 +52,6 @@ public:
|
||||
virtual void finishParsingFile(const FilePath& filePath) = 0;
|
||||
|
||||
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) = 0;
|
||||
virtual ErrorCountInfo getErrorCount() const = 0;
|
||||
|
||||
virtual Id onTypedefParsed(
|
||||
const ParseLocation& location, const NameHierarchy& typedefName, AccessType access) = 0;
|
||||
@@ -107,7 +95,7 @@ public:
|
||||
const ParseLocation& location, const NameHierarchy& argumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateNameHierarchy) = 0;
|
||||
virtual Id onTemplateDefaultArgumentTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const ParseLocation& location, const NameHierarchy& defaultArgumentTypeNameHierarchy,
|
||||
const NameHierarchy& templateArgumentTypeNameHierarchy) = 0;
|
||||
virtual Id onTemplateParameterTypeParsed(
|
||||
const ParseLocation& location, const NameHierarchy& templateParameterTypeNameHierarchy) = 0;
|
||||
@@ -121,7 +109,6 @@ public:
|
||||
virtual Id onFileIncludeParsed(
|
||||
const ParseLocation& location, const FileInfo& fileInfo, const FileInfo& includedFileInfo) = 0;
|
||||
|
||||
|
||||
virtual Id onMacroDefineParsed(
|
||||
const ParseLocation& location, const NameHierarchy& macroNameHierarchy, const ParseLocation& scopeLocation) = 0;
|
||||
virtual Id onMacroExpandParsed(
|
||||
|
||||
@@ -12,11 +12,10 @@ class MessageFinishedParsing
|
||||
: public Message<MessageFinishedParsing>
|
||||
{
|
||||
public:
|
||||
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, ErrorCountInfo errorCount)
|
||||
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime)
|
||||
: fileCount(fileCount)
|
||||
, totalFileCount(totalFileCount)
|
||||
, parseTime(parseTime)
|
||||
, errorCount(errorCount)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,8 +26,6 @@ public:
|
||||
|
||||
virtual void dispatch()
|
||||
{
|
||||
MessageStatus(getStatusStr(), errorCount.total > 0).dispatch();
|
||||
|
||||
Message<MessageFinishedParsing>::dispatch();
|
||||
}
|
||||
|
||||
@@ -37,12 +34,7 @@ public:
|
||||
std::stringstream ss;
|
||||
ss << "Finished analysis: ";
|
||||
ss << fileCount << "/" << totalFileCount << " files, ";
|
||||
ss << std::setprecision(2) << std::fixed << parseTime << " seconds, ";
|
||||
ss << errorCount.total << " error" << (errorCount.total > 1 ? "s" : "");
|
||||
if (errorCount.fatal > 0)
|
||||
{
|
||||
ss << " (" << errorCount.fatal << " fatal)";
|
||||
}
|
||||
ss << std::setprecision(2) << std::fixed << parseTime << " seconds.";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -54,7 +46,6 @@ public:
|
||||
size_t fileCount;
|
||||
size_t totalFileCount;
|
||||
float parseTime;
|
||||
ErrorCountInfo errorCount;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FINISHED_PARSING_H
|
||||
|
||||
Reference in New Issue
Block a user