Clang: Add clang query

Clang query is mechanism to use AST matcher to search for code. Think
about regular expression but in the context of AST. So you get a semantic
search tool for C++.

Change-Id: I72e882c5b53a0c52f352a3664847c4c3e4f6fc2e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenssen
2016-11-15 15:38:12 +01:00
parent 96187594b5
commit 9c7ff5199f
99 changed files with 4603 additions and 246 deletions

View File

@@ -32,7 +32,9 @@
#include <refactoringengine.h>
#include <requestsourcelocationforrenamingmessage.h>
#include <requestsourcerangesanddiagnosticsforquerymessage.h>
#include <sourcelocationsforrenamingmessage.h>
#include <sourcerangesanddiagnosticsforquerymessage.h>
#include <cpptools/projectpart.h>
@@ -66,7 +68,7 @@ protected:
QTextCursor cursor{&textDocument};
QString qStringFilePath{QStringLiteral("/home/user/file.cpp")};
Utils::FileName filePath{Utils::FileName::fromString(qStringFilePath)};
ClangBackEnd::FilePath clangBackEndFilePath{"/home/user", "file.cpp"};
ClangBackEnd::FilePath clangBackEndFilePath{qStringFilePath};
SmallStringVector commandLine;
CppTools::ProjectPart::Ptr projectPart;
CppTools::ProjectFile projectFile{qStringFilePath, CppTools::ProjectFile::CXXSource};
@@ -97,6 +99,25 @@ TEST_F(RefactoringEngine, AfterSendRequestSourceLocationsForRenamingMessageIsUnu
ASSERT_FALSE(engine.isUsable());
}
TEST_F(RefactoringEngine, EngineIsNotUsableForUnusableServer)
{
ASSERT_FALSE(engine.isUsable());
}
TEST_F(RefactoringEngine, EngineIsUsableForUsableServer)
{
mockRefactoringServer.setUsable(true);
ASSERT_TRUE(engine.isUsable());
}
TEST_F(RefactoringEngine, ServerIsUsableForUsableEngine)
{
engine.setUsable(true);
ASSERT_TRUE(mockRefactoringServer.isUsable());
}
RefactoringEngine::RefactoringEngine()
: engine(mockRefactoringServer, mockRefactoringClient)
{