- fix: Goto definition/declaration may choose wrong symbol is multiple files are opened and symbols have the same name.
This commit is contained in:
parent
9076fb6ab9
commit
d3a8a57cf5
1
NEWS.md
1
NEWS.md
|
@ -4,6 +4,7 @@ Red Panda C++ Version 2.24
|
|||
- fix: memory view's cell size is too wide in linux.
|
||||
- fix: Code completion doesn't work if "min id length to show completion" is not 1.
|
||||
- fix: english typos. (thanks for sangiye0@github)
|
||||
- fix: Goto definition/declaration may choose wrong symbol is multiple files are opened and symbols have the same name.
|
||||
|
||||
Red Panda C++ Version 2.23
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ PStatement CppParser::doFindStatementOf(const QString &fileName, const QStringLi
|
|||
if (memberOperator.isEmpty()) {
|
||||
return findStatementStartingFrom(fileName,phrase,currentScope);
|
||||
} else if (ownerExpression.isEmpty()) {
|
||||
return findMemberOfStatement(phrase,PStatement());
|
||||
return findMemberOfStatement(fileName, phrase,PStatement());
|
||||
} else {
|
||||
int pos = 0;
|
||||
PEvalStatement ownerEvalStatement = doEvalExpression(fileName,
|
||||
|
@ -674,7 +674,7 @@ PStatement CppParser::findStatementStartingFrom(const QString &fileName, const Q
|
|||
}
|
||||
|
||||
// Search all global members
|
||||
result = findMemberOfStatement(phrase,PStatement());
|
||||
result = findMemberOfStatement(fileName, phrase,PStatement());
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
|
@ -4239,6 +4239,46 @@ PStatement CppParser::findMemberOfStatement(const QString &phrase,
|
|||
return statementMap.value(s,PStatement());
|
||||
}
|
||||
|
||||
|
||||
PStatement CppParser::findMemberOfStatement(const QString& filename,
|
||||
const QString &phrase,
|
||||
const PStatement& scopeStatement) const
|
||||
{
|
||||
const StatementMap& statementMap =mStatementList.childrenStatements(scopeStatement);
|
||||
if (statementMap.isEmpty())
|
||||
return PStatement();
|
||||
|
||||
QString s = phrase;
|
||||
//remove []
|
||||
int p = phrase.indexOf('[');
|
||||
if (p>=0)
|
||||
s.truncate(p);
|
||||
//remove ()
|
||||
p = phrase.indexOf('(');
|
||||
if (p>=0)
|
||||
s.truncate(p);
|
||||
|
||||
//remove <>
|
||||
p =s.indexOf('<');
|
||||
if (p>=0)
|
||||
s.truncate(p);
|
||||
if (scopeStatement) {
|
||||
return statementMap.value(s,PStatement());
|
||||
} else {
|
||||
QList<PStatement> stats = statementMap.values(s);
|
||||
PFileIncludes fileIncludes = mPreprocessor.includesList().value(filename,PFileIncludes());
|
||||
foreach(const PStatement &s,stats) {
|
||||
if (s->fileName == filename || s->definitionFileName==filename) {
|
||||
return s;
|
||||
} else if (fileIncludes && (fileIncludes->includeFiles.contains(s->fileName)
|
||||
|| fileIncludes->includeFiles.contains(s->definitionFileName))) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return PStatement();
|
||||
}
|
||||
}
|
||||
|
||||
QList<PStatement> CppParser::findMembersOfStatement(const QString &phrase, const PStatement &scopeStatement) const
|
||||
{
|
||||
const StatementMap& statementMap =mStatementList.childrenStatements(scopeStatement);
|
||||
|
|
|
@ -273,6 +273,10 @@ private:
|
|||
const PStatement& statement,
|
||||
const PStatement& scopeStatement) const;
|
||||
PStatement findMacro(const QString& phrase, const QString& fileName) const;
|
||||
PStatement findMemberOfStatement(
|
||||
const QString& filename,
|
||||
const QString& phrase,
|
||||
const PStatement& scopeStatement) const ;
|
||||
PStatement findMemberOfStatement(
|
||||
const QString& phrase,
|
||||
const PStatement& scopeStatement) const ;
|
||||
|
|
|
@ -268,7 +268,7 @@ void ProjectFilesWidget::init()
|
|||
SettingsWidget::init();
|
||||
}
|
||||
|
||||
void ProjectFilesWidget::showEvent(QShowEvent *event)
|
||||
void ProjectFilesWidget::showEvent(QShowEvent */*event*/)
|
||||
{
|
||||
if (ui->cbEncoding->count()>0) {
|
||||
if (pMainWindow->project()->options().encoding==ENCODING_SYSTEM_DEFAULT) {
|
||||
|
|
Loading…
Reference in New Issue