data: Fixes and features for loading Coati into Coati
This change facilitates loading Coati into Coati: * removed error logs for TokenComponent setting * fixed edge checks regarding template stuff * separated CommonSettings to be inherited by Project- and ApplicationSettings for common settings * pluralized SourcePaths setting in xml to allow for loading multiple directories and single files * added CompilerFlags section to settings * passing Compiler arguments to Parser via struct Parser::Arguments * setting -isystem for all header search paths to avoid distinction between "" and <> headers * parsing all headers from the SourcePaths, even the ones that are not included * fixed parsing time measurement and display * added utility.h file for general utility functionality
This commit is contained in:
@@ -7,9 +7,18 @@
|
||||
|
||||
<config>
|
||||
<source>
|
||||
<CompilerFlags>
|
||||
<CompilerFlag><!-- STRING: compiler flag, including the dash e.g. -v --></CompilerFlag>
|
||||
</CompilerFlags>
|
||||
|
||||
<HeaderSearchPaths>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPaht element--></HeaderSearchPath>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPath element --></HeaderSearchPath>
|
||||
</HeaderSearchPaths>
|
||||
|
||||
<!-- MAC ONLY -->
|
||||
<FrameworkSearchPaths>
|
||||
<FrameworkSearchPath><!-- STRING: framework search path --></FrameworkSearchPath>
|
||||
</FrameworkSearchPaths>
|
||||
</source>
|
||||
|
||||
<code>
|
||||
@@ -23,7 +32,6 @@
|
||||
<ActiveLinkColor><!-- COLOR: color of active elements or scopes in the source view --></ActiveLinkColor>
|
||||
</code>
|
||||
|
||||
|
||||
<colors>
|
||||
<!-- QueryNodeType -->
|
||||
<command>
|
||||
|
||||
@@ -7,9 +7,21 @@
|
||||
|
||||
<config>
|
||||
<source>
|
||||
<SourcePath><!-- STRING: root folder for source code parsing, also used as header search path --></SourcePath>
|
||||
<SourcePaths>
|
||||
<SourcePath><!-- STRING: path to source file or directory, also used as header search path --></SourcePath>
|
||||
</SourcePaths>
|
||||
|
||||
<CompilerFlags>
|
||||
<CompilerFlag><!-- STRING: compiler flag, including the dash e.g. -v --></CompilerFlag>
|
||||
</CompilerFlags>
|
||||
|
||||
<HeaderSearchPaths>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPaht element--></HeaderSearchPath>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPath element --></HeaderSearchPath>
|
||||
</HeaderSearchPaths>
|
||||
|
||||
<!-- MAC ONLY -->
|
||||
<FrameworkSearchPaths>
|
||||
<FrameworkSearchPath><!-- STRING: framework search path --></FrameworkSearchPath>
|
||||
</FrameworkSearchPaths>
|
||||
</source>
|
||||
</config>
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
<String>Hello World!</String>
|
||||
|
||||
<source>
|
||||
<SourcePath>data</SourcePath>
|
||||
<SourcePaths>
|
||||
<SourcePath>data</SourcePath>
|
||||
</SourcePaths>
|
||||
<HeaderSearchPaths>
|
||||
<HeaderSearchPath>data/</HeaderSearchPath>
|
||||
<HeaderSearchPath>src/</HeaderSearchPath>
|
||||
</HeaderSearchPaths>
|
||||
|
||||
|
||||
</source>
|
||||
</config>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define INCLUDES_MAC_H
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
void setup(int argc, char *argv[])
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
QtAutocompletionModel::QtAutocompletionModel(QObject* parent)
|
||||
: QAbstractTableModel(parent)
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#include <QPushButton>
|
||||
#include <QToolTip>
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "qt/element/QtCodeFile.h"
|
||||
#include "qt/utility/QtHighlighter.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
QtCodeSnippet::LineNumberArea::LineNumberArea(QtCodeSnippet *codeSnippet)
|
||||
: QWidget(codeSnippet)
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <QClipboard>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageSearchAutocomplete.h"
|
||||
@@ -16,8 +14,7 @@
|
||||
|
||||
#include "data/query/QueryTree.h"
|
||||
#include "qt/element/QtAutocompletionList.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
QtQueryElement::QtQueryElement(const QString& text, QWidget* parent)
|
||||
: QPushButton(text, parent)
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <QGraphicsSceneEvent>
|
||||
#include <QPen>
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
|
||||
@@ -13,6 +11,7 @@
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
|
||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
void QtGraphNode::blendIn()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#include "Application.h"
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
|
||||
#include "component/view/MainView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "data/access/GraphAccessProxy.h"
|
||||
#include "data/access/LocationAccessProxy.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
{
|
||||
|
||||
@@ -190,6 +190,15 @@ add_files(
|
||||
data/Storage.cpp
|
||||
data/Storage.h
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
settings/ApplicationSettings.h
|
||||
settings/CommonSettings.cpp
|
||||
settings/CommonSettings.h
|
||||
settings/ProjectSettings.cpp
|
||||
settings/ProjectSettings.h
|
||||
settings/Settings.cpp
|
||||
settings/Settings.h
|
||||
|
||||
utility/file/FileInfo.cpp
|
||||
utility/file/FileInfo.h
|
||||
utility/file/FileManager.cpp
|
||||
@@ -265,12 +274,6 @@ add_files(
|
||||
|
||||
Application.cpp
|
||||
Application.h
|
||||
ApplicationSettings.cpp
|
||||
ApplicationSettings.h
|
||||
Project.cpp
|
||||
Project.h
|
||||
ProjectSettings.cpp
|
||||
ProjectSettings.h
|
||||
Settings.cpp
|
||||
Settings.h
|
||||
)
|
||||
|
||||
+76
-88
@@ -1,19 +1,15 @@
|
||||
#include "Project.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
#include "data/access/GraphAccessProxy.h"
|
||||
#include "data/access/LocationAccessProxy.h"
|
||||
#include "data/graph/Token.h"
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
std::shared_ptr<Project> Project::create(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy)
|
||||
{
|
||||
@@ -64,7 +60,7 @@ void Project::clearProjectSettings()
|
||||
bool Project::setSourceDirectoryPath(const std::string& sourceDirectoryPath)
|
||||
{
|
||||
m_projectSettingsFilepath = sourceDirectoryPath + "/ProjectSettings.xml";
|
||||
return ProjectSettings::getInstance()->setSourcePath(sourceDirectoryPath);
|
||||
return ProjectSettings::getInstance()->setSourcePaths(std::vector<std::string>(1, sourceDirectoryPath));
|
||||
}
|
||||
|
||||
void Project::clearStorage()
|
||||
@@ -79,86 +75,78 @@ void Project::clearStorage()
|
||||
|
||||
void Project::parseCode()
|
||||
{
|
||||
std::string sourcePath = ProjectSettings::getInstance()->getSourcePath();
|
||||
if (sourcePath.size())
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
std::vector<std::string> sourcePaths = projSettings->getSourcePaths();
|
||||
if (!sourcePaths.size())
|
||||
{
|
||||
std::vector<std::string> includePaths;
|
||||
includePaths.push_back(sourcePath);
|
||||
|
||||
// TODO: move this creation to another place (after projectsettings have been loaded)
|
||||
if (!m_fileManager)
|
||||
{
|
||||
std::vector<std::string> sourcePaths;
|
||||
sourcePaths.push_back(sourcePath);
|
||||
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".cc");
|
||||
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".h");
|
||||
includeExtensions.push_back(".hpp");
|
||||
|
||||
m_fileManager = std::make_shared<FileManager>(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
}
|
||||
|
||||
m_fileManager->fetchFilePaths();
|
||||
std::set<FilePath> addedFilePaths = m_fileManager->getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager->getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager->getRemovedFilePaths();
|
||||
|
||||
std::set<FilePath> dependingFilePaths;
|
||||
dependingFilePaths = m_storage->getDependingFilePathsAndRemoveFileNodes(updatedFilePaths);
|
||||
updatedFilePaths.insert(dependingFilePaths.begin(), dependingFilePaths.end());
|
||||
|
||||
dependingFilePaths = m_storage->getDependingFilePathsAndRemoveFileNodes(removedFilePaths);
|
||||
updatedFilePaths.insert(dependingFilePaths.begin(), dependingFilePaths.end());
|
||||
|
||||
m_storage->clearFileData(updatedFilePaths);
|
||||
m_storage->clearFileData(removedFilePaths);
|
||||
|
||||
std::vector<FilePath> filesToParse;
|
||||
filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end());
|
||||
filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end());
|
||||
|
||||
if (filesToParse.size() == 0)
|
||||
{
|
||||
MessageFinishedParsing(0, 0, m_storage->getErrorCount()).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the SourcePaths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
std::vector<std::string> headerSearchPaths = ProjectSettings::getInstance()->getHeaderSearchPaths();
|
||||
for (size_t i = 0; i < includePaths.size(); i++)
|
||||
{
|
||||
headerSearchPaths.push_back(includePaths[i]);
|
||||
}
|
||||
|
||||
// std::cout << "parse files" << std::endl;
|
||||
// for (const FilePath& path : filesToParse)
|
||||
// {
|
||||
// std::cout << path.absoluteStr() << std::endl;
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
|
||||
CxxParser parser(m_storage.get(), m_fileManager.get());
|
||||
clock_t time = clock();
|
||||
parser.parseFiles(
|
||||
filesToParse,
|
||||
ApplicationSettings::getInstance()->getHeaderSearchPaths(),
|
||||
headerSearchPaths
|
||||
);
|
||||
time = clock() - time;
|
||||
|
||||
// m_storage->logGraph();
|
||||
// m_storage->logLocations();
|
||||
|
||||
double parseTime = (double)(time) / CLOCKS_PER_SEC;
|
||||
LOG_INFO_STREAM(<< "parse time: " << parseTime);
|
||||
|
||||
MessageFinishedParsing(filesToParse.size(), parseTime, m_storage->getErrorCount()).dispatch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> includePaths(sourcePaths);
|
||||
|
||||
// TODO: move this creation to another place (after projectsettings have been loaded)
|
||||
if (!m_fileManager)
|
||||
{
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".cc");
|
||||
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".h");
|
||||
includeExtensions.push_back(".hpp");
|
||||
|
||||
m_fileManager = std::make_shared<FileManager>(sourcePaths, includePaths, sourceExtensions, includeExtensions);
|
||||
}
|
||||
|
||||
m_fileManager->fetchFilePaths();
|
||||
std::set<FilePath> addedFilePaths = m_fileManager->getAddedFilePaths();
|
||||
std::set<FilePath> updatedFilePaths = m_fileManager->getUpdatedFilePaths();
|
||||
std::set<FilePath> removedFilePaths = m_fileManager->getRemovedFilePaths();
|
||||
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePathsAndRemoveFileNodes(updatedFilePaths));
|
||||
utility::append(updatedFilePaths, m_storage->getDependingFilePathsAndRemoveFileNodes(removedFilePaths));
|
||||
|
||||
m_storage->clearFileData(updatedFilePaths);
|
||||
m_storage->clearFileData(removedFilePaths);
|
||||
|
||||
std::vector<FilePath> filesToParse;
|
||||
filesToParse.insert(filesToParse.end(), addedFilePaths.begin(), addedFilePaths.end());
|
||||
filesToParse.insert(filesToParse.end(), updatedFilePaths.begin(), updatedFilePaths.end());
|
||||
|
||||
if (filesToParse.size() == 0)
|
||||
{
|
||||
MessageFinishedParsing(0, 0, m_storage->getErrorCount()).dispatch();
|
||||
return;
|
||||
}
|
||||
|
||||
Parser::Arguments args;
|
||||
|
||||
utility::append(args.compilerFlags, projSettings->getCompilerFlags());
|
||||
utility::append(args.compilerFlags, appSettings->getCompilerFlags());
|
||||
|
||||
// Add the include paths as HeaderSearchPaths as well, so clang will also look here when searching include files.
|
||||
utility::append(args.systemHeaderSearchPaths, includePaths);
|
||||
utility::append(args.systemHeaderSearchPaths, projSettings->getHeaderSearchPaths());
|
||||
utility::append(args.systemHeaderSearchPaths, appSettings->getHeaderSearchPaths());
|
||||
|
||||
utility::append(args.frameworkSearchPaths, projSettings->getFrameworkSearchPaths());
|
||||
utility::append(args.frameworkSearchPaths, appSettings->getFrameworkSearchPaths());
|
||||
|
||||
CxxParser parser(m_storage.get(), m_fileManager.get());
|
||||
|
||||
float duration = utility::duration(
|
||||
[&]()
|
||||
{
|
||||
parser.parseFiles(filesToParse, args);
|
||||
}
|
||||
);
|
||||
|
||||
// m_storage->logGraph();
|
||||
// m_storage->logLocations();
|
||||
|
||||
MessageFinishedParsing(filesToParse.size(), duration, m_storage->getErrorCount()).dispatch();
|
||||
}
|
||||
|
||||
Project::Project(GraphAccessProxy* graphAccessProxy, LocationAccessProxy* locationAccessProxy)
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "data/Storage.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "ProjectSettings.h"
|
||||
|
||||
#include "data/Storage.h"
|
||||
|
||||
class GraphAccessProxy;
|
||||
class LocationAccessProxy;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#include "ProjectSettings.h"
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ProjectSettings>(new ProjectSettings());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ProjectSettings::getSourcePath() const
|
||||
{
|
||||
return getValue<std::string>("source/SourcePath", "");
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourcePath(const std::string& sourcePath)
|
||||
{
|
||||
return setValue<std::string>("source/SourcePath", sourcePath);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
//TODO defaultvalues?
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues);
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "component/controller/StatusBarController.h"
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
|
||||
StatusBarController::StatusBarController()
|
||||
: MessageListener<MessageError>(true)
|
||||
, MessageListener<MessageFinishedParsing>(true)
|
||||
@@ -29,7 +31,7 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
std::stringstream ss;
|
||||
ss << "Parsing Finished: ";
|
||||
ss << message->fileCount << " files, ";
|
||||
ss << std::setprecision(2) << message->parseTime << " seconds, ";
|
||||
ss << std::setprecision(2) << std::fixed << message->parseTime << " seconds, ";
|
||||
ss << message->errorCount << " error(s)";
|
||||
|
||||
bool hasErrors = message->errorCount > 0;
|
||||
@@ -66,6 +68,8 @@ void StatusBarController::setStatus(const std::string& status, bool isError)
|
||||
{
|
||||
if (!status.empty())
|
||||
{
|
||||
LOG_INFO_STREAM(<< "STATUS " << status);
|
||||
|
||||
getView()->showMessage(status, isError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ void Edge::addComponentAccess(std::shared_ptr<TokenComponentAccess> component)
|
||||
{
|
||||
if (getComponent<TokenComponentAccess>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentAccess has been set before!");
|
||||
// LOG_ERROR("TokenComponentAccess has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (m_type != EDGE_MEMBER && m_type != EDGE_INHERITANCE)
|
||||
{
|
||||
@@ -182,7 +183,7 @@ std::ostream& operator<<(std::ostream& ostream, const Edge& edge)
|
||||
|
||||
bool Edge::checkType() const
|
||||
{
|
||||
Node::NodeTypeMask complexTypeMask = Node::NODE_UNDEFINED_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT;
|
||||
Node::NodeTypeMask complexTypeMask = Node::NODE_UNDEFINED_TYPE | Node::NODE_CLASS | Node::NODE_STRUCT | Node:: NODE_TEMPLATE_PARAMETER_TYPE;
|
||||
Node::NodeTypeMask typeMask = Node::NODE_UNDEFINED | Node::NODE_ENUM | Node::NODE_TYPEDEF | complexTypeMask;
|
||||
Node::NodeTypeMask variableMask = Node::NODE_UNDEFINED | Node::NODE_UNDEFINED_VARIABLE | Node::NODE_GLOBAL_VARIABLE | Node::NODE_FIELD;
|
||||
Node::NodeTypeMask functionMask = Node::NODE_UNDEFINED_FUNCTION | Node::NODE_FUNCTION | Node::NODE_METHOD;
|
||||
@@ -190,9 +191,10 @@ bool Edge::checkType() const
|
||||
switch (m_type)
|
||||
{
|
||||
case EDGE_MEMBER:
|
||||
if (!m_from->isType(typeMask | Node::NODE_NAMESPACE) ||
|
||||
if (!m_from->isType(typeMask | Node::NODE_NAMESPACE | functionMask) ||
|
||||
(!m_from->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE) && m_to->isType(Node::NODE_NAMESPACE)) ||
|
||||
(m_from->isType(Node::NODE_ENUM) && !m_to->isType(Node::NODE_ENUM_CONSTANT)))
|
||||
(m_from->isType(Node::NODE_ENUM) && !m_to->isType(Node::NODE_ENUM_CONSTANT)) ||
|
||||
(m_from->isType(functionMask) && !m_to->isType(Node::NODE_TEMPLATE_PARAMETER_TYPE)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -259,7 +261,7 @@ bool Edge::checkType() const
|
||||
|
||||
case EDGE_TEMPLATE_ARGUMENT_OF:
|
||||
case EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF:
|
||||
if (!m_from->isType(typeMask) || !m_to->isType(typeMask))
|
||||
if (!m_from->isType(typeMask) || !m_to->isType(typeMask | functionMask))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,8 @@ void Node::addComponentAbstraction(std::shared_ptr<TokenComponentAbstraction> co
|
||||
{
|
||||
if (getComponent<TokenComponentAbstraction>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentAbstraction has been set before!");
|
||||
// LOG_ERROR("TokenComponentAbstraction has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (!isType(NODE_METHOD))
|
||||
{
|
||||
@@ -267,7 +268,8 @@ void Node::addComponentConst(std::shared_ptr<TokenComponentConst> component)
|
||||
{
|
||||
if (getComponent<TokenComponentConst>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentConst has been set before!");
|
||||
// LOG_ERROR("TokenComponentConst has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (!isType(NODE_METHOD))
|
||||
{
|
||||
@@ -283,7 +285,8 @@ void Node::addComponentStatic(std::shared_ptr<TokenComponentStatic> component)
|
||||
{
|
||||
if (getComponent<TokenComponentStatic>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentStatic has been set before!");
|
||||
// LOG_ERROR("TokenComponentStatic has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (!isType(NODE_GLOBAL_VARIABLE | NODE_FIELD | NODE_FUNCTION | NODE_METHOD))
|
||||
{
|
||||
@@ -315,11 +318,12 @@ void Node::addComponentFilePath(std::shared_ptr<TokenComponentFilePath> componen
|
||||
{
|
||||
if (getComponent<TokenComponentFilePath>())
|
||||
{
|
||||
LOG_ERROR("TokenComponentFilePath has been set before!");
|
||||
// LOG_ERROR("TokenComponentFilePath has been set before!");
|
||||
return;
|
||||
}
|
||||
else if (!isType(NODE_FILE))
|
||||
{
|
||||
LOG_ERROR("TokenComponentSignature can't be set on node of type: " + getTypeString());
|
||||
LOG_ERROR("TokenComponentFilePath can't be set on node of type: " + getTypeString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -24,9 +24,9 @@ public:
|
||||
enum NodeType : NodeTypeMask
|
||||
{
|
||||
NODE_UNDEFINED = 0x1,
|
||||
NODE_UNDEFINED_FUNCTION = 0x2,
|
||||
NODE_UNDEFINED_TYPE = 0x2,
|
||||
NODE_UNDEFINED_VARIABLE = 0x4,
|
||||
NODE_UNDEFINED_TYPE = 0x8,
|
||||
NODE_UNDEFINED_FUNCTION = 0x8,
|
||||
|
||||
NODE_STRUCT = 0x10,
|
||||
NODE_CLASS = 0x20,
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "data/parser/Parser.h"
|
||||
|
||||
Parser::Arguments::Arguments()
|
||||
: logErrors(true)
|
||||
{
|
||||
}
|
||||
|
||||
Parser::Parser(ParserClient* client)
|
||||
: m_client(client)
|
||||
{
|
||||
|
||||
@@ -13,17 +13,22 @@ class TextAccess;
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
struct Arguments
|
||||
{
|
||||
Arguments();
|
||||
|
||||
std::vector<std::string> headerSearchPaths;
|
||||
std::vector<std::string> systemHeaderSearchPaths;
|
||||
std::vector<std::string> frameworkSearchPaths;
|
||||
std::vector<std::string> compilerFlags;
|
||||
bool logErrors;
|
||||
};
|
||||
|
||||
Parser(ParserClient* client);
|
||||
virtual ~Parser();
|
||||
|
||||
virtual void parseFiles(
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths) = 0;
|
||||
virtual void parseFile(
|
||||
std::shared_ptr<TextAccess> textAccess,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
bool logErrors) = 0;
|
||||
virtual void parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments) = 0;
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments) = 0;
|
||||
|
||||
protected:
|
||||
ParserClient* m_client;
|
||||
|
||||
@@ -703,7 +703,7 @@ bool ASTVisitor::isLocatedInUnparsedProjectFile(const clang::Decl* declaration)
|
||||
return true;
|
||||
}
|
||||
|
||||
return m_fileRegister->includeFileIsParsing(m_context->getSourceManager().getFilename(location));
|
||||
return m_fileRegister->includeFileIsParsing(FilePath(m_context->getSourceManager().getFilename(location)));
|
||||
}
|
||||
|
||||
bool ASTVisitor::isLocatedInProjectFile(const clang::Decl* declaration) const
|
||||
|
||||
@@ -58,12 +58,10 @@ CxxParser::~CxxParser()
|
||||
{
|
||||
}
|
||||
|
||||
void CxxParser::parseFiles(
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths
|
||||
){
|
||||
std::vector<std::string> args = getArgs(systemHeaderSearchPaths, headerSearchPaths);
|
||||
void CxxParser::parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments)
|
||||
{
|
||||
// Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
|
||||
std::vector<std::string> args = getCommandlineArguments(arguments);
|
||||
args.insert(args.begin(), "app");
|
||||
args.insert(args.begin() + 1, "--");
|
||||
|
||||
@@ -93,22 +91,34 @@ void CxxParser::parseFiles(
|
||||
}
|
||||
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client);
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, arguments.logErrors);
|
||||
|
||||
ASTActionFactory actionFactory(m_client, &fileRegister);
|
||||
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, sourcePaths);
|
||||
tool.setDiagnosticConsumer(&reporter);
|
||||
tool.run(&actionFactory);
|
||||
|
||||
std::vector<FilePath> unparsedHeaders = fileRegister.getUnparsedIncludeFilePaths();
|
||||
for (const FilePath& path : unparsedHeaders)
|
||||
{
|
||||
if (!fileRegister.includeFileIsParsed(path))
|
||||
{
|
||||
clang::tooling::ClangTool tool(*compilationDatabase, std::vector<std::string>(1, path.str()));
|
||||
tool.setDiagnosticConsumer(&reporter);
|
||||
tool.run(&actionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
delete argv;
|
||||
}
|
||||
|
||||
void CxxParser::parseFile(
|
||||
std::shared_ptr<TextAccess> textAccess, const std::vector<std::string>& systemHeaderSearchPaths, bool logErrors
|
||||
){
|
||||
std::vector<std::string> args = getArgs(systemHeaderSearchPaths, std::vector<std::string>());
|
||||
void CxxParser::parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments)
|
||||
{
|
||||
std::vector<std::string> args = getCommandlineArguments(arguments);
|
||||
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, logErrors);
|
||||
CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, arguments.logErrors);
|
||||
|
||||
FileRegister fileRegister(m_fileManager, std::vector<FilePath>());
|
||||
|
||||
@@ -116,10 +126,8 @@ void CxxParser::parseFile(
|
||||
runToolOnCodeWithArgs(&reporter, actionFactory.create(), textAccess->getText(), args);
|
||||
}
|
||||
|
||||
std::vector<std::string> CxxParser::getArgs(
|
||||
const std::vector<std::string>& systemHeaderSearchPaths, const std::vector<std::string>& headerSearchPaths
|
||||
) const {
|
||||
// Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
|
||||
std::vector<std::string> CxxParser::getCommandlineArguments(const Arguments& arguments) const
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
|
||||
// verbose
|
||||
@@ -138,15 +146,22 @@ std::vector<std::string> CxxParser::getArgs(
|
||||
|
||||
args.push_back("-std=c++11");
|
||||
|
||||
for (const std::string& path : systemHeaderSearchPaths)
|
||||
{
|
||||
args.push_back("-isystem" + path);
|
||||
}
|
||||
args.insert(args.begin(), arguments.compilerFlags.begin(), arguments.compilerFlags.end());
|
||||
|
||||
for (const std::string& path : headerSearchPaths)
|
||||
for (const std::string& path : arguments.headerSearchPaths)
|
||||
{
|
||||
args.push_back("-I" + path);
|
||||
}
|
||||
|
||||
for (const std::string& path : arguments.systemHeaderSearchPaths)
|
||||
{
|
||||
args.push_back("-isystem" + path);
|
||||
}
|
||||
|
||||
for (const std::string& path : arguments.frameworkSearchPaths)
|
||||
{
|
||||
args.push_back("-iframework" + path);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
@@ -10,19 +10,11 @@ public:
|
||||
CxxParser(ParserClient* client, const FileManager* fileManager);
|
||||
~CxxParser();
|
||||
|
||||
virtual void parseFiles(
|
||||
const std::vector<FilePath>& filePaths,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths);
|
||||
virtual void parseFile(
|
||||
std::shared_ptr<TextAccess> textAccess,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
bool logErrors);
|
||||
virtual void parseFiles(const std::vector<FilePath>& filePaths, const Arguments& arguments);
|
||||
virtual void parseFile(std::shared_ptr<TextAccess> textAccess, const Arguments& arguments);
|
||||
|
||||
private:
|
||||
std::vector<std::string> getArgs(
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths) const;
|
||||
std::vector<std::string> getCommandlineArguments(const Arguments& arguments) const;
|
||||
|
||||
const FileManager* m_fileManager;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ApplicationSettings.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
std::shared_ptr<ApplicationSettings> ApplicationSettings::s_instance;
|
||||
|
||||
@@ -16,13 +16,6 @@ ApplicationSettings::~ApplicationSettings()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::string> ApplicationSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
//TODO: defaultValues?
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
{
|
||||
return getValue<int>("code/TabWidth", 4);
|
||||
@@ -3,20 +3,19 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Settings.h"
|
||||
#include "utility/math/Color.h"
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/query/QueryNode.h"
|
||||
#include "settings/CommonSettings.h"
|
||||
|
||||
class ApplicationSettings: public Settings
|
||||
class ApplicationSettings
|
||||
: public CommonSettings
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ApplicationSettings> getInstance();
|
||||
~ApplicationSettings();
|
||||
|
||||
// source
|
||||
std::vector<std::string> getHeaderSearchPaths() const;
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
void setCodeTabWidth(int codeTabWidth);
|
||||
@@ -36,6 +35,7 @@ public:
|
||||
Colori getCodeActiveLinkColor() const;
|
||||
void setCodeActiveLinkColor(Colori color);
|
||||
|
||||
// colors
|
||||
std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const;
|
||||
void setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state = "normal");
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "settings/CommonSettings.h"
|
||||
|
||||
CommonSettings::~CommonSettings()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::string> CommonSettings::getHeaderSearchPaths() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/HeaderSearchPaths/HeaderSearchPath", defaultValues);
|
||||
}
|
||||
|
||||
std::vector<std::string> CommonSettings::getFrameworkSearchPaths() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/FrameworkSearchPaths/FrameworkSearchPath", defaultValues);
|
||||
}
|
||||
|
||||
std::vector<std::string> CommonSettings::getCompilerFlags() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/CompilerFlags/CompilerFlag", defaultValues);
|
||||
}
|
||||
|
||||
CommonSettings::CommonSettings()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef COMMON_SETTINGS_H
|
||||
#define COMMON_SETTINGS_H
|
||||
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class CommonSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
virtual ~CommonSettings();
|
||||
|
||||
// source
|
||||
std::vector<std::string> getHeaderSearchPaths() const;
|
||||
std::vector<std::string> getFrameworkSearchPaths() const;
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
|
||||
protected:
|
||||
CommonSettings();
|
||||
};
|
||||
|
||||
#endif // COMMON_SETTINGS_H
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::s_instance;
|
||||
|
||||
std::shared_ptr<ProjectSettings> ProjectSettings::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ProjectSettings>(new ProjectSettings());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
ProjectSettings::ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
ProjectSettings::~ProjectSettings()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourcePaths() const
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
return getValues("source/SourcePaths/SourcePath", defaultValues);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourcePaths(const std::vector<std::string>& sourcePaths)
|
||||
{
|
||||
return setValues("source/SourcePaths/SourcePath", sourcePaths);
|
||||
}
|
||||
@@ -4,19 +4,18 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "Settings.h"
|
||||
#include "settings/CommonSettings.h"
|
||||
|
||||
class ProjectSettings: public Settings
|
||||
class ProjectSettings
|
||||
: public CommonSettings
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ProjectSettings> getInstance();
|
||||
~ProjectSettings();
|
||||
|
||||
// source
|
||||
std::string getSourcePath() const;
|
||||
bool setSourcePath(const std::string& sourcePath);
|
||||
|
||||
std::vector<std::string> getHeaderSearchPaths() const;
|
||||
std::vector<std::string> getSourcePaths() const;
|
||||
bool setSourcePaths(const std::vector<std::string>& sourcePaths);
|
||||
|
||||
private:
|
||||
ProjectSettings();
|
||||
@@ -1,15 +1,10 @@
|
||||
#include "Settings.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
Settings::Settings()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
}
|
||||
@@ -45,3 +40,8 @@ void Settings::clear()
|
||||
{
|
||||
m_config = ConfigManager::createEmpty();
|
||||
}
|
||||
|
||||
Settings::Settings()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
Settings();
|
||||
virtual ~Settings();
|
||||
|
||||
bool load(const std::string& filePath);
|
||||
@@ -18,6 +17,8 @@ public:
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
Settings();
|
||||
|
||||
template<typename T>
|
||||
T getValue(const std::string& key, T defaultValue) const;
|
||||
|
||||
@@ -27,6 +28,9 @@ protected:
|
||||
template<typename T>
|
||||
bool setValue(const std::string& key, T value);
|
||||
|
||||
template<typename T>
|
||||
bool setValues(const std::string& key, std::vector<T> values);
|
||||
|
||||
private:
|
||||
std::shared_ptr<ConfigManager> m_config;
|
||||
};
|
||||
@@ -70,4 +74,15 @@ bool Settings::setValue(const std::string& key, T value)
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool Settings::setValues(const std::string& key, std::vector<T> values)
|
||||
{
|
||||
if (m_config)
|
||||
{
|
||||
m_config->setValues(key, values);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // SETTINGS_H
|
||||
@@ -75,7 +75,7 @@ bool ConfigManager::getValues(const std::string& key, std::vector<std::string>&
|
||||
|
||||
if (ret.first != m_values.end())
|
||||
{
|
||||
std::multimap<std::string, std::string>::const_iterator cit = ret.first;
|
||||
std::multimap<std::string, std::string>::const_iterator cit = ret.first;
|
||||
for(;cit!=ret.second;++cit)
|
||||
{
|
||||
values.push_back(cit->second);
|
||||
@@ -256,10 +256,10 @@ bool ConfigManager::createXmlDocument(bool saveAsFile, const std::string filepat
|
||||
{
|
||||
child = new TiXmlElement(tokens.front().c_str());
|
||||
element->LinkEndChild(child);
|
||||
}
|
||||
}
|
||||
tokens.erase(tokens.begin());
|
||||
element = child;
|
||||
}
|
||||
}
|
||||
|
||||
child = new TiXmlElement(tokens.front().c_str());
|
||||
element->LinkEndChild(child);
|
||||
|
||||
@@ -29,9 +29,24 @@ const std::vector<FilePath>& FileRegister::getSourceFilePaths() const
|
||||
return m_sourceFilePaths;
|
||||
}
|
||||
|
||||
bool FileRegister::includeFileIsParsing(const std::string& filePath) const
|
||||
std::vector<FilePath> FileRegister::getUnparsedIncludeFilePaths() const
|
||||
{
|
||||
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(FilePath(filePath));
|
||||
std::vector<FilePath> filePaths;
|
||||
|
||||
for (std::pair<FilePath, ParseState>&& p : m_includeFilePaths)
|
||||
{
|
||||
if (p.second == STATE_UNPARSED)
|
||||
{
|
||||
filePaths.push_back(p.first);
|
||||
}
|
||||
}
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
bool FileRegister::includeFileIsParsing(const FilePath& filePath) const
|
||||
{
|
||||
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
|
||||
if (it == m_includeFilePaths.end())
|
||||
{
|
||||
return false;
|
||||
@@ -40,6 +55,17 @@ bool FileRegister::includeFileIsParsing(const std::string& filePath) const
|
||||
return it->second == STATE_PARSING;
|
||||
}
|
||||
|
||||
bool FileRegister::includeFileIsParsed(const FilePath& filePath) const
|
||||
{
|
||||
std::map<FilePath, ParseState>::const_iterator it = m_includeFilePaths.find(filePath);
|
||||
if (it == m_includeFilePaths.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return it->second == STATE_PARSED;
|
||||
}
|
||||
|
||||
void FileRegister::markIncludeFileParsing(const std::string& filePath)
|
||||
{
|
||||
std::map<FilePath, ParseState>::iterator it = m_includeFilePaths.find(FilePath(filePath));
|
||||
|
||||
@@ -17,8 +17,10 @@ public:
|
||||
const FileManager* getFileManager() const;
|
||||
|
||||
const std::vector<FilePath>& getSourceFilePaths() const;
|
||||
std::vector<FilePath> getUnparsedIncludeFilePaths() const;
|
||||
|
||||
bool includeFileIsParsing(const std::string& filePath) const;
|
||||
bool includeFileIsParsing(const FilePath& filePath) const;
|
||||
bool includeFileIsParsed(const FilePath& filePath) const;
|
||||
|
||||
void markIncludeFileParsing(const std::string& filePath);
|
||||
void markParsingIncludeFilesParsed();
|
||||
|
||||
@@ -59,9 +59,10 @@ std::vector<FileInfo> FileSystem::getFileInfosFromDirectoryPaths(
|
||||
std::vector<FileInfo> files;
|
||||
for (const std::string& directoryPath: directoryPaths)
|
||||
{
|
||||
if (boost::filesystem::is_directory(directoryPath))
|
||||
boost::filesystem::path path(directoryPath);
|
||||
if (boost::filesystem::is_directory(path))
|
||||
{
|
||||
boost::filesystem::recursive_directory_iterator it(directoryPath);
|
||||
boost::filesystem::recursive_directory_iterator it(path);
|
||||
boost::filesystem::recursive_directory_iterator endit;
|
||||
while (it != endit)
|
||||
{
|
||||
@@ -74,6 +75,12 @@ std::vector<FileInfo> FileSystem::getFileInfosFromDirectoryPaths(
|
||||
++it;
|
||||
}
|
||||
}
|
||||
else if (boost::filesystem::exists(path) && hasExtension(path.string(), fileExtensions))
|
||||
{
|
||||
std::time_t t = boost::filesystem::last_write_time(path);
|
||||
boost::posix_time::ptime lastWriteTime = boost::posix_time::from_time_t(t);
|
||||
files.push_back(FileInfo(path, lastWriteTime));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef UTILITY_H
|
||||
#define UTILITY_H
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
float duration(std::function<void()> func)
|
||||
{
|
||||
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now();
|
||||
|
||||
func();
|
||||
|
||||
std::chrono::duration<float> duration =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
|
||||
return duration.count();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b)
|
||||
{
|
||||
std::vector<T> r(a.size() + b.size());
|
||||
append(r, a);
|
||||
append(r, b);
|
||||
return r;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void append(std::vector<T>& a, const std::vector<T>& b)
|
||||
{
|
||||
a.insert(a.begin(), b.begin(), b.end());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void append(std::set<T>& a, const std::set<T>& b)
|
||||
{
|
||||
a.insert(b.begin(), b.end());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // UTILITY_H
|
||||
@@ -1,14 +1,15 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "ApplicationSettings.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/parser/cxx/CxxParser.h"
|
||||
#include "data/parser/ParseFunction.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "data/parser/ParseTypeUsage.h"
|
||||
#include "data/parser/ParseVariable.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
#include "helper/TestFileManager.h"
|
||||
|
||||
@@ -2247,7 +2248,7 @@ public:
|
||||
std::vector<FilePath> filePaths;
|
||||
filePaths.push_back(FilePath("data/CxxParserTestSuite/header.h"));
|
||||
filePaths.push_back(FilePath("data/CxxParserTestSuite/code.cpp"));
|
||||
parser.parseFiles(filePaths, std::vector<std::string>(), std::vector<std::string>());
|
||||
parser.parseFiles(filePaths, Parser::Arguments());
|
||||
|
||||
TS_ASSERT_EQUALS(client.errors.size(), 0);
|
||||
|
||||
@@ -2576,19 +2577,21 @@ private:
|
||||
|
||||
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)
|
||||
{
|
||||
if (!m_systemHeaderSearchPaths.size())
|
||||
if (!m_args.headerSearchPaths.size())
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load("data/TestSettings.xml");
|
||||
m_systemHeaderSearchPaths = settings->getHeaderSearchPaths();
|
||||
m_args.headerSearchPaths = settings->getHeaderSearchPaths();
|
||||
}
|
||||
|
||||
m_args.logErrors = logErrors;
|
||||
|
||||
TestFileManager fm;
|
||||
std::shared_ptr<TestParserClient> client = std::make_shared<TestParserClient>();
|
||||
CxxParser parser(client.get(), &fm);
|
||||
parser.parseFile(TextAccess::createFromString(code), m_systemHeaderSearchPaths, logErrors);
|
||||
parser.parseFile(TextAccess::createFromString(code), m_args);
|
||||
return client;
|
||||
}
|
||||
|
||||
std::vector<std::string> m_systemHeaderSearchPaths;
|
||||
Parser::Arguments m_args;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/type/DataType.h"
|
||||
#include "data/type/modifier/DataTypeModifierArray.h"
|
||||
#include "data/type/modifier/DataTypeModifierPointer.h"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/graph/Graph.h"
|
||||
#include "data/graph/token_component/TokenComponentName.h"
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "data/search/SearchIndex.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/search/SearchIndex.h"
|
||||
#include "data/search/SearchMatch.h"
|
||||
|
||||
class SearchIndexTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "ProjectSettings.h"
|
||||
#include "Settings.h"
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class SettingsTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_settings_get_loaded_from_file()
|
||||
{
|
||||
Settings settings;
|
||||
TestSettings settings;
|
||||
TS_ASSERT(settings.load("data/SettingsTestSuite/settings.xml"));
|
||||
}
|
||||
|
||||
void test_settings_get_not_loaded_from_file()
|
||||
{
|
||||
Settings settings;
|
||||
TestSettings settings;
|
||||
TS_ASSERT(!settings.load("data/SettingsTestSuite/wrong_settings.xml"));
|
||||
}
|
||||
|
||||
@@ -114,7 +114,10 @@ public:
|
||||
void test_load_source_path_from_file()
|
||||
{
|
||||
ProjectSettings::getInstance()->load("data/SettingsTestSuite/settings.xml");
|
||||
TS_ASSERT_EQUALS(ProjectSettings::getInstance()->getSourcePath(), "data");
|
||||
std::vector<std::string> paths = ProjectSettings::getInstance()->getSourcePaths();
|
||||
|
||||
TS_ASSERT_EQUALS(paths.size(), 1);
|
||||
TS_ASSERT_EQUALS(paths[0], "data");
|
||||
}
|
||||
|
||||
void test_load_header_search_paths_from_file()
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/graph/StorageGraph.h"
|
||||
#include "data/graph/token_component/TokenComponentAggregation.h"
|
||||
#include "data/search/SearchIndex.h"
|
||||
|
||||
class StorageGraphTestSuite : public CxxTest::TestSuite
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
#include "data/graph/token_component/TokenComponentAbstraction.h"
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
#include "data/graph/token_component/TokenComponentSignature.h"
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
void TestStorage::parseCxxCode(std::string code)
|
||||
{
|
||||
clear();
|
||||
|
||||
TestFileManager fm;
|
||||
CxxParser parser(this, &fm);
|
||||
parser.parseFile(TextAccess::createFromString(code), std::vector<std::string>(), true);
|
||||
parser.parseFile(TextAccess::createFromString(code), Parser::Arguments());
|
||||
}
|
||||
|
||||
const Graph& TestStorage::getGraph() const
|
||||
|
||||
Reference in New Issue
Block a user