forked from qt-creator/qt-creator
CppTools: Remove processEvents call from follow symbol
processEvents is a bad way of dealing with asynchronous requests. Use QFutureWatcher for that purpose. Change-Id: I3839cb9db80a6d391f6af1178e96986a325b7b99 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -480,8 +480,9 @@ static int skipMatchingParentheses(const Tokens &tokens, int idx, int initialDep
|
||||
return j;
|
||||
}
|
||||
|
||||
Link FollowSymbolUnderCursor::findLink(
|
||||
void FollowSymbolUnderCursor::findLink(
|
||||
const CppTools::CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
bool resolveTarget,
|
||||
const Snapshot &theSnapshot,
|
||||
const Document::Ptr &documentFromSemanticInfo,
|
||||
@@ -518,7 +519,7 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link = attemptFuncDeclDef(cursor, snapshot, documentFromSemanticInfo,
|
||||
symbolFinder);
|
||||
if (link.hasValidLinkText())
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +591,7 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link = attemptFuncDeclDef(cursor, theSnapshot,
|
||||
documentFromSemanticInfo, symbolFinder);
|
||||
if (link.hasValidLinkText())
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
} else if (tk.isOperator() && i > 0 && tokens.at(i - 1).is(T_OPERATOR)) {
|
||||
QTextCursor c = cursor;
|
||||
c.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor,
|
||||
@@ -598,7 +599,7 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link = attemptFuncDeclDef(c, theSnapshot, documentFromSemanticInfo,
|
||||
symbolFinder);
|
||||
if (link.hasValidLinkText())
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
}
|
||||
} else if (cursorRegionReached) {
|
||||
break;
|
||||
@@ -608,13 +609,14 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
|
||||
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||
if (!editorWidget)
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
|
||||
// Now we prefer the doc from the snapshot with macros expanded.
|
||||
Document::Ptr doc = snapshot.document(data.filePath());
|
||||
if (!doc) {
|
||||
doc = documentFromSemanticInfo;
|
||||
if (!doc)
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
}
|
||||
|
||||
if (!recognizedQtMethod) {
|
||||
@@ -638,13 +640,14 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link.targetFileName = incl.resolvedFileName();
|
||||
link.linkTextStart = beginOfToken + 1;
|
||||
link.linkTextEnd = endOfToken - 1;
|
||||
return link;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tk.isNot(T_IDENTIFIER) && !tk.isQtKeyword())
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
|
||||
tc.setPosition(endOfToken);
|
||||
}
|
||||
@@ -655,7 +658,7 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
QTextCursor macroCursor = cursor;
|
||||
const QByteArray name = CppTools::identifierUnderCursor(¯oCursor).toUtf8();
|
||||
if (macro->name() == name)
|
||||
return link; //already on definition!
|
||||
return processLinkCallback(link); //already on definition!
|
||||
} else if (const Document::MacroUse *use = doc->findMacroUseAt(endOfToken - 1)) {
|
||||
const QString fileName = use->macro().fileName();
|
||||
if (fileName == CppModelManager::editorConfigurationFileName()) {
|
||||
@@ -667,13 +670,14 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link.linkTextStart = use->utf16charsBegin();
|
||||
link.linkTextEnd = use->utf16charsEnd();
|
||||
}
|
||||
return link;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the last symbol up to the cursor position
|
||||
Scope *scope = doc->scopeAt(line, column);
|
||||
if (!scope)
|
||||
return link;
|
||||
return processLinkCallback(link);
|
||||
|
||||
// Evaluate the type of the expression under the cursor
|
||||
QTC_CHECK(document == tc.document());
|
||||
@@ -741,7 +745,8 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
Link link;
|
||||
link.linkTextStart = beginOfToken;
|
||||
link.linkTextEnd = endOfToken;
|
||||
return link;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
|
||||
Symbol *lastVisibleSymbol = doc->lastVisibleSymbolAt(line, column);
|
||||
@@ -765,7 +770,8 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
link = (def ? def : symbol)->toLink();
|
||||
link.linkTextStart = beginOfToken;
|
||||
link.linkTextEnd = endOfToken;
|
||||
return link;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,10 +782,11 @@ Link FollowSymbolUnderCursor::findLink(
|
||||
if (link.hasValidTarget()) {
|
||||
link.linkTextStart = macroCursor.selectionStart();
|
||||
link.linkTextEnd = macroCursor.selectionEnd();
|
||||
return link;
|
||||
processLinkCallback(link);
|
||||
return;
|
||||
}
|
||||
|
||||
return Link();
|
||||
processLinkCallback(Link());
|
||||
}
|
||||
|
||||
QSharedPointer<VirtualFunctionAssistProvider> FollowSymbolUnderCursor::virtualFunctionAssistProvider()
|
||||
|
||||
@@ -36,7 +36,8 @@ class CPPTOOLS_EXPORT FollowSymbolUnderCursor : public CppTools::FollowSymbolInt
|
||||
public:
|
||||
FollowSymbolUnderCursor();
|
||||
|
||||
Link findLink(const CppTools::CursorInEditor &data,
|
||||
void findLink(const CppTools::CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
bool resolveTarget,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
|
||||
@@ -327,17 +327,18 @@ void CppModelManager::findUsages(const CppTools::CursorInEditor &data,
|
||||
engine->findUsages(data, std::move(showUsagesCallback));
|
||||
}
|
||||
|
||||
CppModelManager::Link CppModelManager::globalFollowSymbol(
|
||||
void CppModelManager::globalFollowSymbol(
|
||||
const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
SymbolFinder *symbolFinder,
|
||||
bool inNextSplit) const
|
||||
{
|
||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
||||
QTC_ASSERT(engine, return Link(););
|
||||
return engine->globalFollowSymbol(data, snapshot, documentFromSemanticInfo,
|
||||
symbolFinder, inNextSplit);
|
||||
QTC_ASSERT(engine, return;);
|
||||
engine->globalFollowSymbol(data, std::move(processLinkCallback), snapshot, documentFromSemanticInfo,
|
||||
symbolFinder, inNextSplit);
|
||||
}
|
||||
|
||||
void CppModelManager::addRefactoringEngine(RefactoringEngineType type,
|
||||
|
||||
@@ -163,7 +163,8 @@ public:
|
||||
const QString &replacement) final;
|
||||
void findUsages(const CppTools::CursorInEditor &data,
|
||||
UsagesCallback &&showUsagesCallback) const final;
|
||||
Link globalFollowSymbol(const CursorInEditor &data,
|
||||
void globalFollowSymbol(const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
SymbolFinder *symbolFinder,
|
||||
|
||||
@@ -100,16 +100,17 @@ void CppRefactoringEngine::findUsages(const CursorInEditor &data,
|
||||
}
|
||||
}
|
||||
|
||||
CppRefactoringEngine::Link CppRefactoringEngine::globalFollowSymbol(
|
||||
void CppRefactoringEngine::globalFollowSymbol(
|
||||
const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
SymbolFinder *symbolFinder,
|
||||
bool inNextSplit) const
|
||||
{
|
||||
FollowSymbolUnderCursor followSymbol;
|
||||
return followSymbol.findLink(data, true, snapshot, documentFromSemanticInfo,
|
||||
symbolFinder, inNextSplit);
|
||||
return followSymbol.findLink(data, std::move(processLinkCallback), true, snapshot,
|
||||
documentFromSemanticInfo, symbolFinder, inNextSplit);
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
|
||||
@@ -38,7 +38,8 @@ public:
|
||||
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
||||
const QString &replacement) override;
|
||||
void findUsages(const CursorInEditor &data, UsagesCallback &&) const override;
|
||||
Link globalFollowSymbol(const CursorInEditor &data,
|
||||
void globalFollowSymbol(const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
SymbolFinder *symbolFinder,
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
using Link = Utils::Link;
|
||||
|
||||
virtual ~FollowSymbolInterface() {}
|
||||
virtual Link findLink(const CursorInEditor &data,
|
||||
virtual void findLink(const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
bool resolveTarget,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
|
||||
@@ -69,7 +69,8 @@ public:
|
||||
const QString &replacement) = 0;
|
||||
virtual void findUsages(const CppTools::CursorInEditor &data,
|
||||
UsagesCallback &&showUsagesCallback) const = 0;
|
||||
virtual Link globalFollowSymbol(const CursorInEditor &data,
|
||||
virtual void globalFollowSymbol(const CursorInEditor &data,
|
||||
Utils::ProcessLinkCallback &&processLinkCallback,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
|
||||
SymbolFinder *symbolFinder,
|
||||
|
||||
Reference in New Issue
Block a user