forked from qt-creator/qt-creator
Clang: Add usage functions to symbol query
Change-Id: If68a5119c863e616fea40275136d028abcf441f3 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -44,6 +44,11 @@ public:
|
||||
" (SELECT symbolId FROM locations WHERE sourceId=? AND line=? AND column=?) "
|
||||
"ORDER BY sourceId, line, column",
|
||||
database};
|
||||
ReadStatement selectSourceUsagesForSymbolLocation{
|
||||
"SELECT directoryPath || '/' || sourceName, line, column "
|
||||
"FROM locations NATURAL JOIN sources NATURAL JOIN directories "
|
||||
"WHERE symbolId = (SELECT symbolId FROM locations WHERE sourceId=? AND line=? AND column=?)",
|
||||
database};
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
||||
@@ -43,6 +43,14 @@ public:
|
||||
: filePathId{directoryId, sourceId}, line(line), column(column)
|
||||
{}
|
||||
|
||||
friend bool operator==(SourceLocation first, SourceLocation second)
|
||||
{
|
||||
return first.filePathId == second.filePathId
|
||||
&& first.line == second.line
|
||||
&& first.column == second.column;
|
||||
}
|
||||
|
||||
public:
|
||||
ClangBackEnd::FilePathId filePathId;
|
||||
int line;
|
||||
int column;
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <filepathid.h>
|
||||
#include <sourcelocations.h>
|
||||
|
||||
#include <cpptools/usages.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace ClangRefactoring {
|
||||
@@ -56,6 +58,18 @@ public:
|
||||
utf8Column);
|
||||
}
|
||||
|
||||
CppTools::Usages sourceUsagesAt(ClangBackEnd::FilePathId filePathId, int line, int utf8Column)
|
||||
{
|
||||
ReadStatement &locationsStatement = m_statementFactory.selectSourceUsagesForSymbolLocation;
|
||||
|
||||
const std::size_t reserveSize = 128;
|
||||
|
||||
return locationsStatement.template values<CppTools::Usage, 3>(reserveSize,
|
||||
filePathId.fileNameId,
|
||||
line,
|
||||
utf8Column);
|
||||
}
|
||||
|
||||
private:
|
||||
StatementFactory &m_statementFactory;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user