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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user