forked from qt-creator/qt-creator
CppEditor: Add second "Find References" Action
This one includes access type categorization, while the "normal" one does not. We need this now, because with clangd, the categorization is too slow to enable it by default. Change-Id: I2eb4608630d34452ae28f0836befd5d9053f42bf Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -45,13 +45,15 @@
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
FindUsages::FindUsages(const QByteArray &originalSource, Document::Ptr doc, const Snapshot &snapshot)
|
||||
FindUsages::FindUsages(const QByteArray &originalSource, Document::Ptr doc,
|
||||
const Snapshot &snapshot, bool categorize)
|
||||
: ASTVisitor(doc->translationUnit()),
|
||||
_doc(doc),
|
||||
_snapshot(snapshot),
|
||||
_context(doc, snapshot),
|
||||
_originalSource(originalSource),
|
||||
_source(_doc->utf8Source())
|
||||
_source(_doc->utf8Source()),
|
||||
_categorize(categorize)
|
||||
{
|
||||
_snapshot.insert(_doc);
|
||||
typeofExpression.init(_doc, _snapshot, _context.bindings());
|
||||
@@ -465,6 +467,8 @@ private:
|
||||
|
||||
Usage::Type FindUsages::getType(int line, int column, int tokenIndex)
|
||||
{
|
||||
if (!_categorize)
|
||||
return Usage::Type::Other;
|
||||
return GetUsageType(this, ASTPath(_doc)(line, column), tokenIndex).getUsageType();
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,8 @@ public:
|
||||
class CPLUSPLUS_EXPORT FindUsages: protected ASTVisitor
|
||||
{
|
||||
public:
|
||||
FindUsages(const QByteArray &originalSource, Document::Ptr doc, const Snapshot &snapshot);
|
||||
FindUsages(const QByteArray &originalSource, Document::Ptr doc, const Snapshot &snapshot,
|
||||
bool categorize);
|
||||
FindUsages(const LookupContext &context);
|
||||
|
||||
void operator()(Symbol *symbol);
|
||||
@@ -302,6 +303,7 @@ private:
|
||||
QSet<unsigned> _processed;
|
||||
TypeOfExpression typeofExpression;
|
||||
Scope *_currentScope = nullptr;
|
||||
const bool _categorize = false;
|
||||
class GetUsageType;
|
||||
};
|
||||
|
||||
|
@@ -386,6 +386,7 @@ public:
|
||||
Utils::optional<ReplacementData> replacementData;
|
||||
quint64 key;
|
||||
bool canceled = false;
|
||||
bool categorize = CppTools::codeModelSettings()->categorizeFindReferences();
|
||||
};
|
||||
|
||||
using SymbolData = QPair<QString, Utils::Link>;
|
||||
@@ -594,7 +595,8 @@ void ClangdClient::findUsages(TextEditor::TextDocument *document, const QTextCur
|
||||
replacement ? SearchResultWindow::SearchAndReplace : SearchResultWindow::SearchOnly,
|
||||
SearchResultWindow::PreserveCaseDisabled,
|
||||
"CppEditor");
|
||||
refData.search->setFilter(new CppTools::CppSearchResultFilter);
|
||||
if (refData.categorize)
|
||||
refData.search->setFilter(new CppTools::CppSearchResultFilter);
|
||||
if (refData.replacementData) {
|
||||
refData.search->setTextToReplace(refData.replacementData->newSymbolName);
|
||||
const auto renameFilesCheckBox = new QCheckBox;
|
||||
@@ -699,7 +701,7 @@ void ClangdClient::Private::handleFindUsagesResult(quint64 key, const QList<Loca
|
||||
|
||||
qCDebug(clangdLog) << "document count is" << refData->fileData.size();
|
||||
if (refData->replacementData || q->versionNumber() < QVersionNumber(13)
|
||||
|| refData->fileData.size() > 15) { // TODO: If we need to keep this, make it configurable.
|
||||
|| !refData->categorize) {
|
||||
qCDebug(clangdLog) << "skipping AST retrieval";
|
||||
reportAllSearchResultsAndFinish(*refData);
|
||||
return;
|
||||
|
@@ -147,6 +147,7 @@ ClangdTestFindReferences::ClangdTestFindReferences()
|
||||
void ClangdTestFindReferences::initTestCase()
|
||||
{
|
||||
ClangdTest::initTestCase();
|
||||
CppTools::codeModelSettings()->setCategorizeFindReferences(true);
|
||||
connect(client(), &ClangdClient::foundReferences, this,
|
||||
[this](const QList<SearchResultItem> &results) {
|
||||
if (results.isEmpty())
|
||||
|
@@ -56,8 +56,10 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/navigationwidget.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <cpptools/cppcodemodelsettings.h>
|
||||
#include <cpptools/cpphoverhandler.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <texteditor/colorpreviewhoverhandler.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
@@ -81,6 +83,13 @@ namespace Internal {
|
||||
|
||||
enum { QUICKFIX_INTERVAL = 20 };
|
||||
|
||||
static CppEditorWidget *currentCppEditorWidget()
|
||||
{
|
||||
if (IEditor *currentEditor = EditorManager::currentEditor())
|
||||
return qobject_cast<CppEditorWidget*>(currentEditor->widget());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//////////////////////////// CppEditorFactory /////////////////////////////
|
||||
|
||||
class CppEditorFactory : public TextEditorFactory
|
||||
@@ -123,6 +132,7 @@ public:
|
||||
void inspectCppCodeModel();
|
||||
|
||||
QAction *m_reparseExternallyChangedFiles = nullptr;
|
||||
QAction *m_findRefsCategorizedAction = nullptr;
|
||||
QAction *m_openTypeHierarchyAction = nullptr;
|
||||
QAction *m_openIncludeHierarchyAction = nullptr;
|
||||
|
||||
@@ -241,6 +251,19 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
|
||||
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
|
||||
cppToolsMenu->addAction(cmd);
|
||||
|
||||
d->m_findRefsCategorizedAction = new QAction(tr("Find References With Access Type"), this);
|
||||
cmd = ActionManager::registerAction(d->m_findRefsCategorizedAction,
|
||||
"CppEditor.FindRefsCategorized", context);
|
||||
connect(d->m_findRefsCategorizedAction, &QAction::triggered, this, [] {
|
||||
if (const auto w = currentCppEditorWidget()) {
|
||||
codeModelSettings()->setCategorizeFindReferences(true);
|
||||
w->findUsages();
|
||||
codeModelSettings()->setCategorizeFindReferences(false);
|
||||
}
|
||||
});
|
||||
contextMenu->addAction(cmd, Constants::G_CONTEXT_FIRST);
|
||||
cppToolsMenu->addAction(cmd);
|
||||
|
||||
d->m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this);
|
||||
cmd = ActionManager::registerAction(d->m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context);
|
||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+T") : tr("Ctrl+Shift+T")));
|
||||
@@ -313,13 +336,6 @@ void CppEditorPlugin::extensionsInitialized()
|
||||
}
|
||||
}
|
||||
|
||||
static CppEditorWidget *currentCppEditorWidget()
|
||||
{
|
||||
if (IEditor *currentEditor = EditorManager::currentEditor())
|
||||
return qobject_cast<CppEditorWidget*>(currentEditor->widget());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CppEditorPlugin::switchDeclarationDefinition()
|
||||
{
|
||||
if (CppEditorWidget *editorWidget = currentCppEditorWidget())
|
||||
|
@@ -85,6 +85,9 @@ public:
|
||||
void setClangdFilePath(const Utils::FilePath &filePath) { m_clangdFilePath = filePath; }
|
||||
Utils::FilePath clangdFilePath() const;
|
||||
|
||||
void setCategorizeFindReferences(bool categorize) { m_categorizeFindReferences = categorize; }
|
||||
bool categorizeFindReferences() const { return m_categorizeFindReferences; }
|
||||
|
||||
signals:
|
||||
void clangDiagnosticConfigsInvalidated(const QVector<Utils::Id> &configId);
|
||||
void changed();
|
||||
@@ -99,6 +102,7 @@ private:
|
||||
bool m_enableLowerClazyLevels = true; // For UI behavior only
|
||||
Utils::FilePath m_clangdFilePath;
|
||||
bool m_useClangd = false;
|
||||
bool m_categorizeFindReferences = false; // Ephemeral!
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
@@ -25,9 +25,11 @@
|
||||
|
||||
#include "cppfindreferences.h"
|
||||
|
||||
#include "cppcodemodelsettings.h"
|
||||
#include "cppfilesettingspage.h"
|
||||
#include "cpptoolsconstants.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "cppworkingcopy.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -295,6 +297,7 @@ class ProcessFile
|
||||
CPlusPlus::Document::Ptr symbolDocument;
|
||||
CPlusPlus::Symbol *symbol;
|
||||
QFutureInterface<CPlusPlus::Usage> *future;
|
||||
const bool categorize;
|
||||
|
||||
public:
|
||||
// needed by QtConcurrent
|
||||
@@ -305,12 +308,14 @@ public:
|
||||
const CPlusPlus::Snapshot snapshot,
|
||||
CPlusPlus::Document::Ptr symbolDocument,
|
||||
CPlusPlus::Symbol *symbol,
|
||||
QFutureInterface<CPlusPlus::Usage> *future)
|
||||
QFutureInterface<CPlusPlus::Usage> *future,
|
||||
bool categorize)
|
||||
: workingCopy(workingCopy),
|
||||
snapshot(snapshot),
|
||||
symbolDocument(symbolDocument),
|
||||
symbol(symbol),
|
||||
future(future)
|
||||
future(future),
|
||||
categorize(categorize)
|
||||
{ }
|
||||
|
||||
QList<CPlusPlus::Usage> operator()(const Utils::FilePath &fileName)
|
||||
@@ -342,7 +347,7 @@ public:
|
||||
if (doc != symbolDocument)
|
||||
doc->check();
|
||||
|
||||
CPlusPlus::FindUsages process(unpreprocessedSource, doc, snapshot);
|
||||
CPlusPlus::FindUsages process(unpreprocessedSource, doc, snapshot, categorize);
|
||||
process(symbol);
|
||||
|
||||
usages = process.usages();
|
||||
@@ -395,7 +400,8 @@ QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
|
||||
static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
|
||||
const WorkingCopy workingCopy,
|
||||
const CPlusPlus::LookupContext &context,
|
||||
CPlusPlus::Symbol *symbol)
|
||||
CPlusPlus::Symbol *symbol,
|
||||
bool categorize)
|
||||
{
|
||||
const CPlusPlus::Identifier *symbolId = symbol->identifier();
|
||||
QTC_ASSERT(symbolId != nullptr, return);
|
||||
@@ -428,7 +434,7 @@ static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
|
||||
|
||||
future.setProgressRange(0, files.size());
|
||||
|
||||
ProcessFile process(workingCopy, snapshot, context.thisDocument(), symbol, &future);
|
||||
ProcessFile process(workingCopy, snapshot, context.thisDocument(), symbol, &future, categorize);
|
||||
UpdateUI reduce(&future);
|
||||
// This thread waits for blockingMappedReduced to finish, so reduce the pool's used thread count
|
||||
// so the blockingMappedReduced can use one more thread, and increase it again afterwards.
|
||||
@@ -458,7 +464,8 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
||||
SearchResultWindow::PreserveCaseDisabled,
|
||||
QLatin1String("CppEditor"));
|
||||
search->setTextToReplace(replacement);
|
||||
search->setFilter(new CppSearchResultFilter);
|
||||
if (codeModelSettings()->categorizeFindReferences())
|
||||
search->setFilter(new CppSearchResultFilter);
|
||||
auto renameFilesCheckBox = new QCheckBox();
|
||||
renameFilesCheckBox->setVisible(false);
|
||||
search->setAdditionalReplaceWidget(renameFilesCheckBox);
|
||||
@@ -469,6 +476,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
||||
CppFindReferencesParameters parameters;
|
||||
parameters.symbolId = fullIdForSymbol(symbol);
|
||||
parameters.symbolFileName = QByteArray(symbol->fileName());
|
||||
parameters.categorize = codeModelSettings()->categorizeFindReferences();
|
||||
|
||||
if (symbol->isClass() || symbol->isForwardClassDeclaration()) {
|
||||
CPlusPlus::Overview overview;
|
||||
@@ -477,7 +485,7 @@ void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol,
|
||||
}
|
||||
|
||||
search->setUserData(QVariant::fromValue(parameters));
|
||||
findAll_helper(search, symbol, context);
|
||||
findAll_helper(search, symbol, context, codeModelSettings()->categorizeFindReferences());
|
||||
}
|
||||
|
||||
void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol,
|
||||
@@ -492,7 +500,7 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol,
|
||||
}
|
||||
|
||||
void CppFindReferences::findAll_helper(SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
const CPlusPlus::LookupContext &context)
|
||||
const CPlusPlus::LookupContext &context, bool categorize)
|
||||
{
|
||||
if (!(symbol && symbol->identifier())) {
|
||||
search->finishSearch(false);
|
||||
@@ -507,7 +515,7 @@ void CppFindReferences::findAll_helper(SearchResult *search, CPlusPlus::Symbol *
|
||||
const WorkingCopy workingCopy = m_modelManager->workingCopy();
|
||||
QFuture<CPlusPlus::Usage> result;
|
||||
result = Utils::runAsync(m_modelManager->sharedThreadPool(), find_helper,
|
||||
workingCopy, context, symbol);
|
||||
workingCopy, context, symbol, categorize);
|
||||
createWatcher(result, search);
|
||||
|
||||
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching for Usages"),
|
||||
@@ -553,7 +561,7 @@ void CppFindReferences::searchAgain()
|
||||
search->finishSearch(false);
|
||||
return;
|
||||
}
|
||||
findAll_helper(search, symbol, context);
|
||||
findAll_helper(search, symbol, context, parameters.categorize);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@@ -75,6 +75,7 @@ public:
|
||||
QByteArray symbolFileName;
|
||||
QString prettySymbolName;
|
||||
QVector<ProjectExplorer::Node *> filesToRename;
|
||||
bool categorize = false;
|
||||
};
|
||||
|
||||
class CppFindReferences: public QObject
|
||||
@@ -104,7 +105,7 @@ private:
|
||||
void findMacroUses(const CPlusPlus::Macro ¯o, const QString &replacement,
|
||||
bool replace);
|
||||
void findAll_helper(Core::SearchResult *search, CPlusPlus::Symbol *symbol,
|
||||
const CPlusPlus::LookupContext &context);
|
||||
const CPlusPlus::LookupContext &context, bool categorize);
|
||||
void createWatcher(const QFuture<CPlusPlus::Usage> &future, Core::SearchResult *search);
|
||||
CPlusPlus::Symbol *findSymbol(const CppFindReferencesParameters ¶meters,
|
||||
const CPlusPlus::Snapshot &snapshot, CPlusPlus::LookupContext *context);
|
||||
|
@@ -175,7 +175,7 @@ void tst_FindUsages::inlineMethod()
|
||||
QVERIFY(arg);
|
||||
QCOMPARE(arg->identifier()->chars(), "arg");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(arg);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -210,7 +210,7 @@ void tst_FindUsages::lambdaCaptureByValue()
|
||||
QVERIFY(d);
|
||||
QCOMPARE(d->name()->identifier()->chars(), "test");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -245,7 +245,7 @@ void tst_FindUsages::lambdaCaptureByReference()
|
||||
QVERIFY(d);
|
||||
QCOMPARE(d->name()->identifier()->chars(), "test");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -279,7 +279,7 @@ void tst_FindUsages::shadowedNames_1()
|
||||
QVERIFY(d);
|
||||
QCOMPARE(d->name()->identifier()->chars(), "a");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -314,7 +314,7 @@ void tst_FindUsages::shadowedNames_2()
|
||||
QVERIFY(d);
|
||||
QCOMPARE(d->name()->identifier()->chars(), "a");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -363,7 +363,7 @@ void tst_FindUsages::staticVariables()
|
||||
QVERIFY(d);
|
||||
QCOMPARE(d->name()->identifier()->chars(), "Foo");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(d);
|
||||
QCOMPARE(findUsages.usages().size(), 5);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -398,7 +398,7 @@ void foo2(int b=bar()){} // 3rd result
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(s);
|
||||
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
@@ -465,7 +465,7 @@ struct Struct{
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
|
||||
find(memberFunctionFoo);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
@@ -539,7 +539,7 @@ int main() {
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 7);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -598,7 +598,7 @@ int main()
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 7);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -663,7 +663,7 @@ void tst_FindUsages::objc_args()
|
||||
Argument *arg = methodImpl->argumentAt(0)->asArgument();
|
||||
QCOMPARE(arg->identifier()->chars(), "arg");
|
||||
|
||||
FindUsages findUsages(objcSource, doc, snapshot);
|
||||
FindUsages findUsages(objcSource, doc, snapshot, true);
|
||||
findUsages(arg);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.references().size(), 2);
|
||||
@@ -701,7 +701,7 @@ void tst_FindUsages::qproperty_1()
|
||||
QCOMPARE(setX_method->identifier()->chars(), "setX");
|
||||
QCOMPARE(setX_method->argumentCount(), 1);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(setX_method);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Other);
|
||||
@@ -747,7 +747,7 @@ void tst_FindUsages::instantiateTemplateWithNestedClass()
|
||||
QVERIFY(barDeclaration);
|
||||
QCOMPARE(barDeclaration->name()->identifier()->chars(), "bar");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(barDeclaration);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -793,7 +793,7 @@ void tst_FindUsages::operatorAsteriskOfNestedClassOfTemplateClass_QTCREATORBUG90
|
||||
QVERIFY(fooDeclaration);
|
||||
QCOMPARE(fooDeclaration->name()->identifier()->chars(), "foo");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(fooDeclaration);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
@@ -838,7 +838,7 @@ void tst_FindUsages::anonymousClass_QTCREATORBUG8963()
|
||||
QVERIFY(isNotIntDeclaration);
|
||||
QCOMPARE(isNotIntDeclaration->name()->identifier()->chars(), "isNotInt");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(isNotIntDeclaration);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
@@ -881,7 +881,7 @@ void tst_FindUsages::anonymousClass_QTCREATORBUG11859()
|
||||
QVERIFY(fooAsMemberOfAnonymousStruct);
|
||||
QCOMPARE(fooAsMemberOfAnonymousStruct->name()->identifier()->chars(), "Foo");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(fooAsStruct);
|
||||
QCOMPARE(findUsages.references().size(), 1);
|
||||
QCOMPARE(findUsages.usages().size(), 1);
|
||||
@@ -927,7 +927,7 @@ void tst_FindUsages::using_insideGlobalNamespace()
|
||||
Class *structSymbol = nsSymbol->memberAt(0)->asClass();
|
||||
QVERIFY(structSymbol);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
@@ -973,7 +973,7 @@ void tst_FindUsages::using_insideNamespace()
|
||||
Class *structSymbol = nsSymbol->memberAt(0)->asClass();
|
||||
QVERIFY(structSymbol);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
@@ -1016,7 +1016,7 @@ void tst_FindUsages::using_insideFunction()
|
||||
Class *structSymbol = nsSymbol->memberAt(0)->asClass();
|
||||
QVERIFY(structSymbol);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(structSymbol);
|
||||
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
@@ -1064,7 +1064,7 @@ void tst_FindUsages::operatorArrowOfNestedClassOfTemplateClass_QTCREATORBUG9005(
|
||||
QVERIFY(fooDeclaration);
|
||||
QCOMPARE(fooDeclaration->name()->identifier()->chars(), "foo");
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(fooDeclaration);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1101,7 +1101,7 @@ void tst_FindUsages::templateClassParameters()
|
||||
TypenameArgument *templArgument = templateClassTS->templateParameterAt(0)->asTypenameArgument();
|
||||
QVERIFY(templArgument);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templArgument);
|
||||
QCOMPARE(findUsages.usages().size(), 5);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1147,7 +1147,7 @@ void tst_FindUsages::templateClass_className()
|
||||
QVERIFY(classTS);
|
||||
QCOMPARE(classTS->memberCount(), 2);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(classTS);
|
||||
QCOMPARE(findUsages.usages().size(), 7);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1187,7 +1187,7 @@ void tst_FindUsages::templateFunctionParameters()
|
||||
TypenameArgument *templArgument = templateFunctionTS->templateParameterAt(0)->asTypenameArgument();
|
||||
QVERIFY(templArgument);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templArgument);
|
||||
QCOMPARE(findUsages.usages().size(), 4);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1221,7 +1221,7 @@ void tst_FindUsages::templatedFunction_QTCREATORBUG9749()
|
||||
QCOMPARE(funcTempl->memberCount(), 2);
|
||||
Function *func = funcTempl->memberAt(1)->asFunction();
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(func);
|
||||
QCOMPARE(findUsages.usages().size(), 2);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1262,7 +1262,7 @@ void tst_FindUsages::usingInDifferentNamespace_QTCREATORBUG7978()
|
||||
QCOMPARE(ns->memberCount(), 1);
|
||||
Template *templateClass = ns->memberAt(0)->asTemplate();
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(templateClass);
|
||||
QCOMPARE(findUsages.usages().size(), 3);
|
||||
QCOMPARE(findUsages.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1291,7 +1291,7 @@ void tst_FindUsages::unicodeIdentifier()
|
||||
Declaration *declaration = doc->globalSymbolAt(0)->asDeclaration();
|
||||
QVERIFY(declaration);
|
||||
|
||||
FindUsages findUsages(src, doc, snapshot);
|
||||
FindUsages findUsages(src, doc, snapshot, true);
|
||||
findUsages(declaration);
|
||||
const QList<Usage> usages = findUsages.usages();
|
||||
QCOMPARE(usages.size(), 2);
|
||||
@@ -1323,7 +1323,7 @@ void tst_FindUsages::inAlignas()
|
||||
QVERIFY(c);
|
||||
QCOMPARE(c->name()->identifier()->chars(), "One");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(c);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
@@ -1366,7 +1366,7 @@ void tst_FindUsages::memberAccessAsTemplate()
|
||||
QVERIFY(c);
|
||||
QCOMPARE(c->name()->identifier()->chars(), "Foo");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(c);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
@@ -1387,7 +1387,7 @@ void tst_FindUsages::memberAccessAsTemplate()
|
||||
QVERIFY(f);
|
||||
QCOMPARE(f->name()->identifier()->chars(), "templateFunc");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(f);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages()[0].type, Usage::Type::Declaration);
|
||||
@@ -1430,7 +1430,7 @@ void tst_FindUsages::variadicFunctionTemplate()
|
||||
QVERIFY(v);
|
||||
QCOMPARE(v->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(v);
|
||||
QCOMPARE(find.usages().size(), 4);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1481,7 +1481,7 @@ void tst_FindUsages::typeTemplateParameterWithDefault()
|
||||
QVERIFY(sv);
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(xv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1525,7 +1525,7 @@ void tst_FindUsages::resolveOrder_for_templateFunction_vs_function()
|
||||
QVERIFY(xv);
|
||||
QCOMPARE(xv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(xv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1567,7 +1567,7 @@ void tst_FindUsages::templateArrowOperator_with_defaultType()
|
||||
QVERIFY(sv);
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 3);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -1639,7 +1639,7 @@ void tst_FindUsages::templateSpecialization_with_IntArgument()
|
||||
QCOMPARE(sv[1]->name()->identifier()->chars(), "value");
|
||||
QCOMPARE(sv[2]->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
@@ -1726,7 +1726,7 @@ void tst_FindUsages::templateSpecialization_with_BoolArgument()
|
||||
QCOMPARE(sv[0]->name()->identifier()->chars(), "value");
|
||||
QCOMPARE(sv[1]->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
@@ -1802,7 +1802,7 @@ void tst_FindUsages::templatePartialSpecialization()
|
||||
QCOMPARE(sv[0]->name()->identifier()->chars(), "value");
|
||||
QCOMPARE(sv[1]->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
|
||||
find(sv[0]);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
@@ -1858,7 +1858,7 @@ int main()
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
|
||||
Class *s[3];
|
||||
Declaration *sv[3];
|
||||
@@ -1923,7 +1923,7 @@ int main(){
|
||||
QVERIFY(sv);
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Initialization);
|
||||
@@ -1968,7 +1968,7 @@ int main(){
|
||||
QVERIFY(sv);
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -2008,7 +2008,7 @@ int main(){}
|
||||
QVERIFY(sv);
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 2);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Declaration);
|
||||
@@ -2121,7 +2121,7 @@ int main()
|
||||
QCOMPARE(sv->name()->identifier()->chars(), "value");
|
||||
|
||||
// Access to struct member
|
||||
FindUsages find(src, doc, snapshot);
|
||||
FindUsages find(src, doc, snapshot, true);
|
||||
find(sv);
|
||||
QCOMPARE(find.usages().size(), 31);
|
||||
QCOMPARE(find.usages().at(0).type, Usage::Type::Read);
|
||||
|
Reference in New Issue
Block a user