diff --git a/.gitignore b/.gitignore
index d85718ab..0034fba5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,11 @@
/build/
/bin/app/Debug/
-/bin/app/Release/
/bin/app/data/log/
+/bin/app/data/ApplicationSettings.xml
+/bin/app/data/ProjectSettings.xml
+/bin/app/data/window_settings.ini
+/bin/app/Release/
/bin/lib/
@@ -10,9 +13,6 @@
/bin/test/Release/
/bin/test/data/log/
/bin/test/data/temp.xml
-
-/bin/app/data/window_settings.ini
-/bin/app/data/ApplicationSettings.xml
-/bin/app/data/ProjectSettings.xml
+/bin/test/data/TestSettings.xml
.DS_Store
diff --git a/bin/app/data/src/sample/sample.cpp b/bin/app/data/src/sample/sample.cpp
index 5c43ee12..a6ec35cf 100644
--- a/bin/app/data/src/sample/sample.cpp
+++ b/bin/app/data/src/sample/sample.cpp
@@ -3,7 +3,10 @@ public:
void Do() {}
};
-class Base {};
+class Base {
+protected:
+ void Init() {}
+};
class Game : public Base {
public:
@@ -11,12 +14,11 @@ public:
Init();
}
- void Init() {}
-
void Run() {
player.Do();
}
+private:
Player player;
};
diff --git a/bin/app/data/src/tictactoe/player.h b/bin/app/data/src/tictactoe/player.h
index 5d748a6c..f0029566 100644
--- a/bin/app/data/src/tictactoe/player.h
+++ b/bin/app/data/src/tictactoe/player.h
@@ -15,6 +15,17 @@ public:
virtual Field::Move Turn( const Field& field ) const = 0;
+ const Field::Token& getToken() const
+ {
+ return token_;
+ }
+
+ const std::string getName() const
+ {
+ return name_;
+ }
+
+protected:
const Field::Token token_;
const std::string name_;
};
diff --git a/bin/app/data/src/tictactoe/tictactoe.h b/bin/app/data/src/tictactoe/tictactoe.h
index 6c800560..cea41845 100644
--- a/bin/app/data/src/tictactoe/tictactoe.h
+++ b/bin/app/data/src/tictactoe/tictactoe.h
@@ -44,11 +44,11 @@ public:
for ( int i = 0; i < 9; i++ ) {
Player& player = *players_[playerIndex];
- field_.MakeMove( player.Turn( field_ ), player.token_ );
+ field_.MakeMove( player.Turn( field_ ), player.getToken() );
field_.Show();
- if ( field_.SameInRow( player.token_, 3 ) ) {
- std::cout << player.name_ << " won!\n\n";
+ if ( field_.SameInRow( player.getToken(), 3 ) ) {
+ std::cout << player.getName() << " won!\n\n";
return;
}
diff --git a/bin/data/window_settings.ini b/bin/data/window_settings.ini
deleted file mode 100644
index 8a4dcd41..00000000
--- a/bin/data/window_settings.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[MainWindow]
-maximized=false
-size=@Size(600 400)
-position=@Point(200 200)
-
-[General]
-DOCK_LOCATIONS=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x1\0\0\0\x2\0\0\x2X\0\0\x1g\xfc\x1\0\0\0\x3\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0G\0r\0\x61\0p\0h\0V\0i\0\x65\0w\x1\0\0\0\0\0\0\0\x86\0\0\0P\0\xff\xff\xff\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0\x43\0o\0\x64\0\x65\0V\0i\0\x65\0w\x1\0\0\0\x8a\0\0\0\xb3\0\0\0P\0\xff\xff\xff\xfb\0\0\0\"\0\x44\0o\0\x63\0k\0\x43\0o\0m\0p\0o\0s\0i\0t\0\x65\0V\0i\0\x65\0w\x1\0\0\x1\x41\0\0\x1\x17\0\0\x1\x10\0\xff\xff\xff\0\0\x2X\0\0\0\0\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\0)
diff --git a/bin/test/data/TestSettings_template.xml b/bin/test/data/TestSettings_template.xml
new file mode 100644
index 00000000..ab90867b
--- /dev/null
+++ b/bin/test/data/TestSettings_template.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp
index 91beaa45..05403011 100644
--- a/src/lib/data/Storage.cpp
+++ b/src/lib/data/Storage.cpp
@@ -738,7 +738,7 @@ std::vector Storage::getAutocompletionMatches(const std::string& qu
}
Token* token = m_graph.getTokenById(*match.tokenIds.cbegin());
- if(!token->isEdge())
+ if (token->isNode())
{
match.nodeType = dynamic_cast(token)->getType();
}
diff --git a/src/lib/data/parser/Parser.h b/src/lib/data/parser/Parser.h
index 4c72a46e..94364eff 100644
--- a/src/lib/data/parser/Parser.h
+++ b/src/lib/data/parser/Parser.h
@@ -20,7 +20,10 @@ public:
const std::vector& filePaths,
const std::vector& systemHeaderSearchPaths,
const std::vector& headerSearchPaths) = 0;
- virtual void parseFile(std::shared_ptr textAccess) = 0;
+ virtual void parseFile(
+ std::shared_ptr textAccess,
+ const std::vector& systemHeaderSearchPaths,
+ bool logErrors) = 0;
protected:
ParserClient* m_client;
diff --git a/src/lib/data/parser/cxx/CxxParser.cpp b/src/lib/data/parser/cxx/CxxParser.cpp
index 9a145160..859c16d8 100644
--- a/src/lib/data/parser/cxx/CxxParser.cpp
+++ b/src/lib/data/parser/cxx/CxxParser.cpp
@@ -63,36 +63,9 @@ void CxxParser::parseFiles(
const std::vector& systemHeaderSearchPaths,
const std::vector& headerSearchPaths
){
- // Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
- std::vector args;
- args.push_back("app");
- args.push_back("--");
-
- // verbose
- // args.push_back("-v");
-
- // The option -fno-delayed-template-parsing signals that templates that there should
- // be AST elements for unused template functions as well.
- args.push_back("-fno-delayed-template-parsing");
-
- // The option -c signals that no executable is built.
- args.push_back("-c");
-
- // The option '-x c++' treats subsequent input files as C++.
- args.push_back("-x");
- args.push_back("c++");
-
- args.push_back("-std=c++11");
-
- for (const std::string& path : systemHeaderSearchPaths)
- {
- args.push_back("-isystem" + path);
- }
-
- for (const std::string& path : headerSearchPaths)
- {
- args.push_back("-I" + path);
- }
+ std::vector args = getArgs(systemHeaderSearchPaths, headerSearchPaths);
+ args.insert(args.begin(), "app");
+ args.insert(args.begin() + 1, "--");
int argc = args.size();
const char** argv = new const char*[argc];
@@ -129,16 +102,51 @@ void CxxParser::parseFiles(
tool.run(&actionFactory);
}
-void CxxParser::parseFile(std::shared_ptr textAccess)
-{
- std::vector args;
- args.push_back("-fno-delayed-template-parsing");
+void CxxParser::parseFile(
+ std::shared_ptr textAccess, const std::vector& systemHeaderSearchPaths, bool logErrors
+){
+ std::vector args = getArgs(systemHeaderSearchPaths, std::vector());
llvm::IntrusiveRefCntPtr options = new clang::DiagnosticOptions();
- CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, false);
+ CxxDiagnosticConsumer reporter(llvm::errs(), &*options, m_client, logErrors);
FileRegister fileRegister(m_fileManager, std::vector());
ASTActionFactory actionFactory(m_client, &fileRegister);
runToolOnCodeWithArgs(&reporter, actionFactory.create(), textAccess->getText(), args);
}
+
+std::vector CxxParser::getArgs(
+ const std::vector& systemHeaderSearchPaths, const std::vector& headerSearchPaths
+) const {
+ // Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
+ std::vector args;
+
+ // verbose
+ // args.push_back("-v");
+
+ // The option -fno-delayed-template-parsing signals that templates that there should
+ // be AST elements for unused template functions as well.
+ args.push_back("-fno-delayed-template-parsing");
+
+ // The option -c signals that no executable is built.
+ args.push_back("-c");
+
+ // The option '-x c++' treats subsequent input files as C++.
+ args.push_back("-x");
+ args.push_back("c++");
+
+ args.push_back("-std=c++11");
+
+ for (const std::string& path : systemHeaderSearchPaths)
+ {
+ args.push_back("-isystem" + path);
+ }
+
+ for (const std::string& path : headerSearchPaths)
+ {
+ args.push_back("-I" + path);
+ }
+
+ return args;
+}
diff --git a/src/lib/data/parser/cxx/CxxParser.h b/src/lib/data/parser/cxx/CxxParser.h
index c88582fb..ee47439c 100644
--- a/src/lib/data/parser/cxx/CxxParser.h
+++ b/src/lib/data/parser/cxx/CxxParser.h
@@ -14,9 +14,16 @@ public:
const std::vector& filePaths,
const std::vector& systemHeaderSearchPaths,
const std::vector& headerSearchPaths);
- virtual void parseFile(std::shared_ptr textAccess);
+ virtual void parseFile(
+ std::shared_ptr textAccess,
+ const std::vector& systemHeaderSearchPaths,
+ bool logErrors);
private:
+ std::vector getArgs(
+ const std::vector& systemHeaderSearchPaths,
+ const std::vector& headerSearchPaths) const;
+
const FileManager* m_fileManager;
};
diff --git a/src/lib/data/search/SearchMatch.cpp b/src/lib/data/search/SearchMatch.cpp
index 2fdadf85..be9d6ace 100644
--- a/src/lib/data/search/SearchMatch.cpp
+++ b/src/lib/data/search/SearchMatch.cpp
@@ -61,7 +61,6 @@ std::string SearchMatch::encodeForQuery() const
{
std::stringstream ss;
ss << QueryToken::BOUNDARY << fullName;
- ss << QueryToken::DELIMITER << nodeType;
for (Id tokenId : tokenIds)
{
ss << QueryToken::DELIMITER << tokenId;
@@ -103,17 +102,15 @@ void SearchMatch::decodeFromQuery(std::string query)
fullName = queryParts[0];
- if(queryParts.size() > 1)
+ if (queryParts.size() > 1)
{
- for(int i = 2; i < queryParts.size(); ++i)
+ for (size_t i = 2; i < queryParts.size(); ++i)
{
tokenIds.insert(std::strtoul(queryParts[i].c_str(),nullptr,0));
}
}
-
}
-
std::deque SearchMatch::stringDequeToSearchMatchDeque(const std::deque& stringDeque)
{
std::deque matchDeque;
diff --git a/src/lib/data/search/SearchResult.cpp b/src/lib/data/search/SearchResult.cpp
index 5dc5492f..1e38deec 100644
--- a/src/lib/data/search/SearchResult.cpp
+++ b/src/lib/data/search/SearchResult.cpp
@@ -23,5 +23,12 @@ bool SearchResult::operator()(const SearchResult& lhs, const SearchResult& rhs)
return lhs.weight > rhs.weight;
}
- return utility::toLowerCase(lhs.node->getFullName()) < utility::toLowerCase(rhs.node->getFullName());
+ std::string lhsLow = utility::toLowerCase(lhs.node->getFullName());
+ std::string rhsLow = utility::toLowerCase(rhs.node->getFullName());
+ if (lhsLow != rhsLow)
+ {
+ return lhsLow < rhsLow;
+ }
+
+ return lhs.node->getFirstTokenId() < rhs.node->getFirstTokenId();
}
diff --git a/src/test/CxxParserTestSuite.h b/src/test/CxxParserTestSuite.h
index 2d7fb997..fd2f83ec 100644
--- a/src/test/CxxParserTestSuite.h
+++ b/src/test/CxxParserTestSuite.h
@@ -1,5 +1,6 @@
#include "cxxtest/TestSuite.h"
+#include "ApplicationSettings.h"
#include "data/parser/cxx/CxxParser.h"
#include "data/parser/ParseFunction.h"
#include "data/parser/ParseLocation.h"
@@ -669,7 +670,8 @@ public:
"};\n"
"class B : public A {\n"
" int foo();\n"
- "};\n"
+ "};\n",
+ false
);
TS_ASSERT_EQUALS(client->overrides.size(), 1);
@@ -2017,7 +2019,8 @@ public:
void test_cxx_parser_catches_error()
{
std::shared_ptr client = parseCode(
- "int a = b;\n"
+ "int a = b;\n",
+ false
);
TS_ASSERT_EQUALS(client->errors.size(), 1);
@@ -2316,12 +2319,21 @@ private:
}
};
- std::shared_ptr parseCode(std::string code) const
+ std::shared_ptr parseCode(std::string code, bool logErrors = true)
{
+ if (!m_systemHeaderSearchPaths.size())
+ {
+ std::shared_ptr settings = ApplicationSettings::getInstance();
+ settings->load("data/TestSettings.xml");
+ m_systemHeaderSearchPaths = settings->getHeaderSearchPaths();
+ }
+
TestFileManager fm;
std::shared_ptr client = std::make_shared();
CxxParser parser(client.get(), &fm);
- parser.parseFile(TextAccess::createFromString(code));
+ parser.parseFile(TextAccess::createFromString(code), m_systemHeaderSearchPaths, logErrors);
return client;
}
+
+ std::vector m_systemHeaderSearchPaths;
};
diff --git a/src/test/helper/TestStorage.cpp b/src/test/helper/TestStorage.cpp
index f6c25678..68fab477 100644
--- a/src/test/helper/TestStorage.cpp
+++ b/src/test/helper/TestStorage.cpp
@@ -9,7 +9,7 @@ void TestStorage::parseCxxCode(std::string code)
clear();
TestFileManager fm;
CxxParser parser(this, &fm);
- parser.parseFile(TextAccess::createFromString(code));
+ parser.parseFile(TextAccess::createFromString(code), std::vector(), true);
}
const Graph& TestStorage::getGraph() const