- enhancement: show parameter tips for class constructors
- enhancement: when there are tips showing, don't show mouse tips
This commit is contained in:
parent
922a870724
commit
894e587f7d
2
NEWS.md
2
NEWS.md
|
@ -5,6 +5,8 @@ Red Panda C++ Version 0.13.4
|
|||
- fix: can't show private & protected members of 'this'
|
||||
- fix: function name like 'A::B' is not correctly parsed
|
||||
- fix: static members are not correct shown after Classname + '::'
|
||||
- enhancement: show parameter tips for class constructors
|
||||
- enhancement: when there are tips showing, don't show mouse tips
|
||||
|
||||
Red Panda C++ Version 0.13.3
|
||||
- enhancement: restore editor position after rename symbol
|
||||
|
|
|
@ -957,7 +957,9 @@ bool Editor::event(QEvent *event)
|
|||
{
|
||||
if ((event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverMove)
|
||||
&& pSettings->editor().enableTooltips()
|
||||
) {
|
||||
&& !pMainWindow->completionPopup()->isVisible()
|
||||
&& !pMainWindow->functionTip()->isVisible()
|
||||
&& !pMainWindow->headerCompletionPopup()->isVisible()) {
|
||||
QHoverEvent *helpEvent = static_cast<QHoverEvent *>(event);
|
||||
BufferCoord p;
|
||||
TipType reason = getTipType(helpEvent->pos(),p);
|
||||
|
@ -3366,6 +3368,39 @@ void Editor::updateFunctionTip()
|
|||
|
||||
QString s = getWordAtPosition(this, functionNamePos, pWordBegin,pWordEnd, WordPurpose::wpInformation);
|
||||
|
||||
int x = pWordBegin.Char-1-1;
|
||||
QString line = lines()->getString(pWordBegin.Line-1);
|
||||
bool hasPreviousWord=false;
|
||||
while (x>=0) {
|
||||
QChar ch=line[x];
|
||||
if (ch == ' ' || ch == '\t')
|
||||
continue;
|
||||
if (isIdentChar(ch)) {
|
||||
hasPreviousWord = true;
|
||||
break;
|
||||
}
|
||||
hasPreviousWord = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (x >= 0 && hasPreviousWord) {
|
||||
BufferCoord pos = pWordBegin;
|
||||
pos.Char = x+1;
|
||||
QString previousWord = getPreviousWordAtPositionForSuggestion(pos);
|
||||
|
||||
PStatement statement = mParser->findStatementOf(
|
||||
mFilename,
|
||||
previousWord,
|
||||
pos.Line);
|
||||
if (statement) {
|
||||
PStatement typeStatement = mParser->findTypeDef(statement,mFilename);
|
||||
if (typeStatement && typeStatement->kind == StatementKind::skClass) {
|
||||
s = previousWord;
|
||||
functionNamePos = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// qDebug()<<QString("find word at %1:%2 - '%3'")
|
||||
// .arg(FuncStartXY.Line)
|
||||
// .arg(FuncStartXY.Char)
|
||||
|
|
|
@ -5406,7 +5406,7 @@ void MainWindow::on_actionRename_Symbol_triggered()
|
|||
// return;
|
||||
// }
|
||||
|
||||
if (isKeyword(word)) {
|
||||
if (isCppKeyword(word)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,11 @@ QList<PStatement> CppParser::getListOfFunctions(const QString &fileName, const Q
|
|||
PStatement statement = findStatementOf(fileName,phrase, line);
|
||||
if (!statement)
|
||||
return result;
|
||||
PStatement parentScope = statement->parentScope.lock();
|
||||
PStatement parentScope;
|
||||
if (statement->kind == StatementKind::skClass) {
|
||||
parentScope = statement;
|
||||
} else
|
||||
parentScope = statement->parentScope.lock();
|
||||
if (parentScope && parentScope->kind == StatementKind::skNamespace) {
|
||||
PStatementList namespaceStatementsList = findNamespace(parentScope->command);
|
||||
if (namespaceStatementsList) {
|
||||
|
@ -545,6 +549,15 @@ PStatement CppParser::findTypeDefinitionOf(const QString &fileName, const QStrin
|
|||
return getTypeDef(statement,fileName,aType);
|
||||
}
|
||||
|
||||
PStatement CppParser::findTypeDef(const PStatement &statement, const QString &fileName)
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
|
||||
if (mParsing)
|
||||
return PStatement();
|
||||
return getTypeDef(statement, fileName, "");
|
||||
}
|
||||
|
||||
bool CppParser::freeze()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
|
@ -3323,12 +3336,12 @@ QList<PStatement> CppParser::getListOfFunctions(const QString &fileName, int lin
|
|||
QList<PStatement> result;
|
||||
StatementMap children = mStatementList.childrenStatements(scopeStatement);
|
||||
for (const PStatement& child:children) {
|
||||
if ((statement->command == child->command)
|
||||
if (( (statement->command == child->command)
|
||||
#ifdef Q_OS_WIN
|
||||
|| (statement->command +'A' == child->command)
|
||||
|| (statement->command +'W' == child->command)
|
||||
#endif
|
||||
) {
|
||||
) ) {
|
||||
if (line < child->line && (child->fileName == fileName))
|
||||
continue;
|
||||
result.append(child);
|
||||
|
@ -4473,7 +4486,7 @@ QString CppParser::removeArgNames(const QString &args)
|
|||
if (!typeGetted) {
|
||||
currentArg += ' ' + word;
|
||||
} else {
|
||||
if (isKeyword(word)) {
|
||||
if (isCppKeyword(word)) {
|
||||
currentArg += ' ' + word;
|
||||
}
|
||||
}
|
||||
|
@ -4502,10 +4515,10 @@ QString CppParser::removeArgNames(const QString &args)
|
|||
} else if (!word.trimmed().isEmpty()) {
|
||||
if (!typeGetted) {
|
||||
currentArg += ' ' + word;
|
||||
if (mCppTypeKeywords.contains(word) || !isKeyword(word))
|
||||
if (mCppTypeKeywords.contains(word) || !isCppKeyword(word))
|
||||
typeGetted = true;
|
||||
} else {
|
||||
if (isKeyword(word))
|
||||
if (isCppKeyword(word))
|
||||
currentArg += ' ' + word;
|
||||
}
|
||||
word = "";
|
||||
|
@ -4520,7 +4533,7 @@ QString CppParser::removeArgNames(const QString &args)
|
|||
if (!typeGetted) {
|
||||
currentArg += ' ' + word;
|
||||
} else {
|
||||
if (isKeyword(word)) {
|
||||
if (isCppKeyword(word)) {
|
||||
currentArg += ' ' + word;
|
||||
}
|
||||
}
|
||||
|
@ -4650,7 +4663,7 @@ bool CppParser::isNotFuncArgs(const QString &args)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (isKeyword(word)) {
|
||||
if (isCppKeyword(word)) {
|
||||
return word == "true" || word == "false" || word == "nullptr";
|
||||
}
|
||||
PStatement statement =findStatementOf(mCurrentFile,word,getCurrentScope(),true);
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
PStatement findTypeDefinitionOf(const QString& fileName,
|
||||
const QString& aType,
|
||||
const PStatement& currentClass);
|
||||
PStatement findTypeDef(const PStatement& statement,
|
||||
const QString& fileName);
|
||||
bool freeze(); // Freeze/Lock (stop reparse while searching)
|
||||
bool freeze(const QString& serialId); // Freeze/Lock (stop reparse while searching)
|
||||
QStringList getClassesList();
|
||||
|
|
|
@ -413,7 +413,7 @@ bool isSystemHeaderFile(const QString &fileName, const QSet<QString> &includePat
|
|||
return false;
|
||||
}
|
||||
|
||||
bool isKeyword(const QString &word)
|
||||
bool isCppKeyword(const QString &word)
|
||||
{
|
||||
return CppKeywords.contains(word);
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ QString getSystemHeaderFilename(const QString& fileName, const QStringList& incl
|
|||
bool isSystemHeaderFile(const QString& fileName, const QSet<QString>& includePaths);
|
||||
bool isHfile(const QString& filename);
|
||||
bool isCfile(const QString& filename);
|
||||
bool isKeyword(const QString& word);
|
||||
bool isCppKeyword(const QString& word);
|
||||
bool isScopeTypeKind(StatementKind kind);
|
||||
MemberOperatorType getOperatorType(const QString& phrase, int index);
|
||||
QStringList getOwnerExpressionAndMember(
|
||||
|
|
Loading…
Reference in New Issue