minor refactor

This commit is contained in:
Roy Qu 2021-12-04 14:53:21 +08:00
parent 202b293c9e
commit 8a2d40f6d7
1 changed files with 9 additions and 10 deletions

View File

@ -79,17 +79,17 @@ void CodeCompletionPopup::prepareSearch(
mIncludedFiles = mParser->getFileIncludes(filename); mIncludedFiles = mParser->getFileIncludes(filename);
getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line); getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line);
} else { } else {
getFullCompletionListFor(preWord); getCompletionListForPreWord(preWord);
} }
setCursor(oldCursor); setCursor(oldCursor);
} }
bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleResult) bool CodeCompletionPopup::search(const QString &memberPhrase, bool autoHideOnSingleResult)
{ {
QMutexLocker locker(&mMutex); QMutexLocker locker(&mMutex);
mMemberPhrase = phrase; mMemberPhrase = memberPhrase;
if (!isEnabled()) { if (!isEnabled()) {
hide(); hide();
@ -99,9 +99,8 @@ bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleRes
QCursor oldCursor = cursor(); QCursor oldCursor = cursor();
setCursor(Qt::CursorShape::WaitCursor); setCursor(Qt::CursorShape::WaitCursor);
QString symbol = phrase;
// filter fFullCompletionStatementList to fCompletionStatementList // filter fFullCompletionStatementList to fCompletionStatementList
filterList(symbol); filterList(memberPhrase);
//if can't find a destructor, maybe '~' is only an operator //if can't find a destructor, maybe '~' is only an operator
// if (mCompletionStatementList.isEmpty() && phrase.startsWith('~')) { // if (mCompletionStatementList.isEmpty() && phrase.startsWith('~')) {
@ -118,7 +117,7 @@ bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleRes
// if only one suggestion and auto hide , don't show the frame // if only one suggestion and auto hide , don't show the frame
if(mCompletionStatementList.count() == 1) if(mCompletionStatementList.count() == 1)
if (autoHideOnSingleResult if (autoHideOnSingleResult
|| (symbol == mCompletionStatementList.front()->command)) { || (memberPhrase == mCompletionStatementList.front()->command)) {
return true; return true;
} }
} else { } else {
@ -552,9 +551,9 @@ void CodeCompletionPopup::getCompletionFor(
scopeName, scopeName,
mCurrentStatement, mCurrentStatement,
parentTypeStatement); parentTypeStatement);
qDebug()<<scopeName; // qDebug()<<scopeName;
qDebug()<<memberOperator; // qDebug()<<memberOperator;
qDebug()<<memberExpression; // qDebug()<<memberExpression;
if(!ownerStatement ) { if(!ownerStatement ) {
// qDebug()<<"not found!"; // qDebug()<<"not found!";
return; return;
@ -729,7 +728,7 @@ void CodeCompletionPopup::getCompletionFor(
} }
} }
void CodeCompletionPopup::getFullCompletionListFor(const QString &preWord) void CodeCompletionPopup::getCompletionListForPreWord(const QString &preWord)
{ {
mFullCompletionStatementList.clear(); mFullCompletionStatementList.clear();
if (preWord == "long") { if (preWord == "long") {