build: bug fixes for release version
* fixed search activating 2 nodes, because of NodeType in query * fixed search results didn't contain results with same name * added protected contents to sample and tictactoe code * fixed CxxParserTests not logging errors, disabled logging for tests with errors * fixed CxxParserTests not finding system headers, added TestSettings.xml and pass headers to Parser::parseFile()
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- INTEGER: int e.g 123 -->
|
||||
<!-- DECIMAL: float e.g 123.456 -->
|
||||
<!-- STRING: string e.g hello -->
|
||||
<!-- COLOR: int int int int - rgba e.g. 125 125 125 255 -->
|
||||
|
||||
<config>
|
||||
<source>
|
||||
<HeaderSearchPaths>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPaht element--></HeaderSearchPath>
|
||||
</HeaderSearchPaths>
|
||||
</source>
|
||||
</config>
|
||||
@@ -738,7 +738,7 @@ std::vector<SearchMatch> Storage::getAutocompletionMatches(const std::string& qu
|
||||
}
|
||||
|
||||
Token* token = m_graph.getTokenById(*match.tokenIds.cbegin());
|
||||
if(!token->isEdge())
|
||||
if (token->isNode())
|
||||
{
|
||||
match.nodeType = dynamic_cast<Node*>(token)->getType();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ public:
|
||||
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) = 0;
|
||||
virtual void parseFile(
|
||||
std::shared_ptr<TextAccess> textAccess,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
bool logErrors) = 0;
|
||||
|
||||
protected:
|
||||
ParserClient* m_client;
|
||||
|
||||
@@ -63,36 +63,9 @@ void CxxParser::parseFiles(
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths
|
||||
){
|
||||
// Commandline flags passed to the programm. Everything after '--' will be interpreted by the ClangTool.
|
||||
std::vector<std::string> 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<std::string> 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> textAccess)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
args.push_back("-fno-delayed-template-parsing");
|
||||
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>());
|
||||
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> 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<FilePath>());
|
||||
|
||||
ASTActionFactory actionFactory(m_client, &fileRegister);
|
||||
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> 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;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,16 @@ public:
|
||||
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);
|
||||
virtual void parseFile(
|
||||
std::shared_ptr<TextAccess> textAccess,
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
bool logErrors);
|
||||
|
||||
private:
|
||||
std::vector<std::string> getArgs(
|
||||
const std::vector<std::string>& systemHeaderSearchPaths,
|
||||
const std::vector<std::string>& headerSearchPaths) const;
|
||||
|
||||
const FileManager* m_fileManager;
|
||||
};
|
||||
|
||||
|
||||
@@ -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> SearchMatch::stringDequeToSearchMatchDeque(const std::deque<std::string>& stringDeque)
|
||||
{
|
||||
std::deque<SearchMatch> matchDeque;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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<TestParserClient> 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<TestParserClient> parseCode(std::string code) const
|
||||
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)
|
||||
{
|
||||
if (!m_systemHeaderSearchPaths.size())
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load("data/TestSettings.xml");
|
||||
m_systemHeaderSearchPaths = settings->getHeaderSearchPaths();
|
||||
}
|
||||
|
||||
TestFileManager fm;
|
||||
std::shared_ptr<TestParserClient> client = std::make_shared<TestParserClient>();
|
||||
CxxParser parser(client.get(), &fm);
|
||||
parser.parseFile(TextAccess::createFromString(code));
|
||||
parser.parseFile(TextAccess::createFromString(code), m_systemHeaderSearchPaths, logErrors);
|
||||
return client;
|
||||
}
|
||||
|
||||
std::vector<std::string> m_systemHeaderSearchPaths;
|
||||
};
|
||||
|
||||
@@ -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<std::string>(), true);
|
||||
}
|
||||
|
||||
const Graph& TestStorage::getGraph() const
|
||||
|
||||
Reference in New Issue
Block a user