Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
76ebb464
Commit
76ebb464
authored
Jul 05, 2010
by
Roberto Raggi
Browse files
Fixed: "Follow symbol" on constructor or destructor always jumps to class definition
Task-number: QTCREATORBUG-1776
parent
d209bd72
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppDocument.cpp
View file @
76ebb464
...
...
@@ -703,25 +703,17 @@ public:
};
}
// end of anonymous namespace
Symbol
*
Snapshot
::
findMatchingDefinition
(
Symbol
*
symbol
)
const
Symbol
*
Snapshot
::
findMatchingDefinition
(
Symbol
*
declaration
)
const
{
if
(
!
symbol
->
identifier
())
if
(
!
(
declaration
&&
declaration
->
identifier
())
)
return
0
;
Document
::
Ptr
thisDocument
=
document
(
QString
::
fromUtf8
(
symbol
->
fileName
(),
symbol
->
fileNameLength
()));
Document
::
Ptr
thisDocument
=
document
(
QString
::
fromUtf8
(
declaration
->
fileName
(),
declaration
->
fileNameLength
()));
if
(
!
thisDocument
)
{
qWarning
()
<<
"undefined document:"
<<
symbol
->
fileName
();
qWarning
()
<<
"undefined document:"
<<
declaration
->
fileName
();
return
0
;
}
LookupContext
thisContext
(
thisDocument
,
*
this
);
const
QList
<
Symbol
*>
declarationCandidates
=
thisContext
.
lookup
(
symbol
->
name
(),
symbol
->
scope
());
if
(
declarationCandidates
.
isEmpty
())
{
qWarning
()
<<
"unresolved declaration:"
<<
symbol
->
fileName
()
<<
symbol
->
line
()
<<
symbol
->
column
();
return
0
;
}
Symbol
*
declaration
=
declarationCandidates
.
first
();
Function
*
declarationTy
=
declaration
->
type
()
->
asFunctionType
();
if
(
!
declarationTy
)
{
qWarning
()
<<
"not a function:"
<<
declaration
->
fileName
()
<<
declaration
->
line
()
<<
declaration
->
column
();
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
76ebb464
...
...
@@ -1238,7 +1238,20 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
const
QList
<
LookupItem
>
resolvedSymbols
=
typeOfExpression
(
expression
,
scope
,
TypeOfExpression
::
Preprocess
);
if
(
!
resolvedSymbols
.
isEmpty
())
{
const
LookupItem
result
=
skipForwardDeclarations
(
resolvedSymbols
);
LookupItem
result
=
skipForwardDeclarations
(
resolvedSymbols
);
foreach
(
const
LookupItem
&
r
,
resolvedSymbols
)
{
if
(
Symbol
*
d
=
r
.
declaration
())
{
if
(
d
->
isDeclaration
()
||
d
->
isFunction
())
{
if
(
file
()
->
fileName
()
==
QString
::
fromUtf8
(
d
->
fileName
(),
d
->
fileNameLength
()))
{
if
(
unsigned
(
line
)
==
d
->
line
()
&&
unsigned
(
column
)
>=
d
->
column
())
{
// ### TODO: check the end
result
=
r
;
// take the symbol under cursor.
break
;
}
}
}
}
}
if
(
Symbol
*
symbol
=
result
.
declaration
())
{
Symbol
*
def
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment