forked from qt-creator/qt-creator
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:
@@ -25,6 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangtool.h"
|
||||
#include "findusrforcursoraction.h"
|
||||
#include "symbollocationfinderaction.h"
|
||||
#include "sourcefilecallbacks.h"
|
||||
@@ -42,42 +43,13 @@
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
struct FileContent
|
||||
{
|
||||
FileContent(const std::string &directory,
|
||||
const std::string &fileName,
|
||||
const std::string &content,
|
||||
const std::vector<std::string> &commandLine)
|
||||
: directory(directory),
|
||||
fileName(fileName),
|
||||
filePath(directory + nativeSeperator + fileName),
|
||||
content(content),
|
||||
commandLine(commandLine)
|
||||
{}
|
||||
|
||||
std::string directory;
|
||||
std::string fileName;
|
||||
std::string filePath;
|
||||
std::string content;
|
||||
std::vector<std::string> commandLine;
|
||||
};
|
||||
|
||||
class SymbolFinder
|
||||
class SymbolFinder : public ClangTool
|
||||
{
|
||||
public:
|
||||
SymbolFinder(uint line, uint column);
|
||||
|
||||
void addFile(std::string &&directory,
|
||||
std::string &&fileName,
|
||||
std::string &&content,
|
||||
std::vector<std::string> &&commandLine);
|
||||
|
||||
|
||||
void findSymbol();
|
||||
|
||||
Utils::SmallString takeSymbolName();
|
||||
@@ -90,7 +62,7 @@ private:
|
||||
USRFindingAction usrFindingAction;
|
||||
SymbolLocationFinderAction symbolLocationFinderAction;
|
||||
SourceFileCallbacks sourceFileCallbacks;
|
||||
std::vector<FileContent> fileContents;
|
||||
|
||||
ClangBackEnd::SourceLocationsContainer sourceLocations_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user