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
5d13a206
Commit
5d13a206
authored
May 12, 2010
by
Roberto Raggi
Browse files
Reimplemented switch declaration/definition.
parent
3c6ad0d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
5d13a206
...
...
@@ -1227,56 +1227,45 @@ static bool isCompatible(Function *definition, Symbol *declaration,
void
CPPEditor
::
switchDeclarationDefinition
()
{
int
line
=
0
,
column
=
0
;
convertPosition
(
position
(),
&
line
,
&
column
);
if
(
!
m_modelManager
)
if
(
!
m_modelManager
)
return
;
#warning implement CPPEditor::switchDeclarationDefinition
qWarning
()
<<
Q_FUNC_INFO
<<
__LINE__
;
#if 0
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
Document::Ptr doc = snapshot.document(file()->fileName());
if (!doc)
return;
Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol || !lastSymbol->scope())
return;
if
(
Document
::
Ptr
thisDocument
=
snapshot
.
document
(
file
()
->
fileName
()))
{
int
line
=
0
,
column
=
0
;
convertPosition
(
position
(),
&
line
,
&
column
);
Function *f = lastSymbol->asFunction();
if (!f) {
Scope *fs = lastSymbol->scope();
if (!fs->isFunctionScope())
fs = fs->enclosingFunctionScope();
if (fs)
f = fs->owner()->asFunction();
}
if (f) {
LookupContext context(doc, snapshot);
Scope
*
scope
=
thisDocument
->
scopeAt
(
line
,
column
);
Symbol
*
lastVisibleSymbol
=
thisDocument
->
findSymbolAt
(
line
,
column
);
const QualifiedNameId *q = qualifiedNameIdForSymbol(f, context.control());
const QList<Symbol *> symbols = context.lookup(q, lastSymbol); // ### FIXME
Scope
*
functionScope
=
0
;
if
(
scope
->
isFunctionScope
())
functionScope
=
scope
;
else
functionScope
=
scope
->
enclosingFunctionScope
();
Symbol *declaration = 0;
foreach (declaration, symbols) {
if (isCompatible(f, declaration, q))
break;
if
(
!
functionScope
&&
lastVisibleSymbol
)
{
if
(
Function
*
def
=
lastVisibleSymbol
->
asFunction
())
functionScope
=
def
->
members
();
}
if (
! declaration && ! symbols.isEmpty())
declaration = symbols.first(
);
if
(
functionScope
)
{
LookupContext
context
(
thisDocument
,
snapshot
);
if (declaration)
openCppEditorAt(linkToSymbol(declaration));
} else if (lastSymbol->type()->isFunctionType()) {
if (Symbol *def = findDefinition(lastSymbol, snapshot))
openCppEditorAt(linkToSymbol(def));
Function
*
functionDefinition
=
functionScope
->
owner
()
->
asFunction
();
const
QList
<
Symbol
*>
declarations
=
context
.
lookup
(
functionDefinition
->
name
(),
functionDefinition
->
scope
());
foreach
(
Symbol
*
decl
,
declarations
)
{
// TODO: check decl.
openCppEditorAt
(
linkToSymbol
(
decl
));
break
;
}
}
else
if
(
lastVisibleSymbol
&&
lastVisibleSymbol
->
isDeclaration
()
&&
lastVisibleSymbol
->
type
()
->
isFunctionType
())
{
if
(
Symbol
*
def
=
snapshot
.
findMatchingDefinition
(
lastVisibleSymbol
))
openCppEditorAt
(
linkToSymbol
(
def
));
}
}
#endif
}
static
inline
LookupItem
skipForwardDeclarations
(
const
QList
<
LookupItem
>
&
resolvedSymbols
)
...
...
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