forked from qt-creator/qt-creator
C++ editor: Fix follow symbol for member functions
Fix a regression introduced by ad53fa42b0
in which follow symbol takes you to the function declaration (instead
of to the type) for situations like the one below (the | indicates the
cursor):
void Ty|pe::function() {}
Change-Id: Iffd15b23bb0cd67eca5965cb22d9b60c4d024fb7
Reviewed-on: http://codereview.qt.nokia.com/1375
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
committed by
Leandro T. C. Melo
parent
b4b9ba7e2a
commit
b260bf1e73
@@ -1363,34 +1363,37 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
if (!m_modelManager)
|
if (!m_modelManager)
|
||||||
return link;
|
return link;
|
||||||
|
|
||||||
const Snapshot snapshot = m_modelManager->snapshot();
|
const Snapshot &snapshot = m_modelManager->snapshot();
|
||||||
|
Document::Ptr doc = m_lastSemanticInfo.doc;
|
||||||
|
if (!doc) {
|
||||||
|
doc = snapshot.document(file()->fileName());
|
||||||
|
if (!doc)
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_lastSemanticInfo.doc){
|
QTextCursor tc = cursor;
|
||||||
Link l = attemptFuncDeclDef(cursor, m_lastSemanticInfo.doc, snapshot);
|
QChar ch = characterAt(tc.position());
|
||||||
if (l.isValid()) {
|
while (ch.isLetterOrNumber() || ch == QLatin1Char('_')) {
|
||||||
return l;
|
tc.movePosition(QTextCursor::NextCharacter);
|
||||||
|
ch = characterAt(tc.position());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc->translationUnit() && doc->translationUnit()->ast()) {
|
||||||
|
int pos = tc.position();
|
||||||
|
while (characterAt(pos).isSpace())
|
||||||
|
++pos;
|
||||||
|
if (characterAt(pos) == QLatin1Char('(')) {
|
||||||
|
link = attemptFuncDeclDef(cursor, doc, snapshot);
|
||||||
|
if (link.isValid())
|
||||||
|
return link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int lineNumber = 0, positionInBlock = 0;
|
int lineNumber = 0, positionInBlock = 0;
|
||||||
convertPosition(cursor.position(), &lineNumber, &positionInBlock);
|
convertPosition(cursor.position(), &lineNumber, &positionInBlock);
|
||||||
Document::Ptr doc = snapshot.document(file()->fileName());
|
|
||||||
if (!doc)
|
|
||||||
return link;
|
|
||||||
|
|
||||||
const unsigned line = lineNumber;
|
const unsigned line = lineNumber;
|
||||||
const unsigned column = positionInBlock + 1;
|
const unsigned column = positionInBlock + 1;
|
||||||
|
|
||||||
QTextCursor tc = cursor;
|
|
||||||
|
|
||||||
// Make sure we're not at the start of a word
|
|
||||||
{
|
|
||||||
const QChar c = characterAt(tc.position());
|
|
||||||
if (c.isLetter() || c == QLatin1Char('_'))
|
|
||||||
tc.movePosition(QTextCursor::Right);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int beginOfToken = 0;
|
int beginOfToken = 0;
|
||||||
int endOfToken = 0;
|
int endOfToken = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user