Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
4d6b7c4e
Commit
4d6b7c4e
authored
Dec 10, 2010
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved follow symbol under cursor when searching for macro definitions.
Reviewed-by: Christian Kamm
parent
edeb4159
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
12 deletions
+64
-12
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+60
-12
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+4
-0
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
4d6b7c4e
...
...
@@ -1323,6 +1323,55 @@ CPPEditor::Link CPPEditor::attemptFuncDeclDef(const QTextCursor &cursor, const D
return
result
;
}
CPPEditor
::
Link
CPPEditor
::
findMacroLink
(
const
QByteArray
&
name
)
const
{
if
(
!
name
.
isEmpty
())
{
if
(
Document
::
Ptr
doc
=
m_lastSemanticInfo
.
doc
)
{
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
QSet
<
QString
>
processed
;
return
findMacroLink
(
name
,
doc
,
snapshot
,
&
processed
);
}
}
return
Link
();
}
CPPEditor
::
Link
CPPEditor
::
findMacroLink
(
const
QByteArray
&
name
,
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
QSet
<
QString
>
*
processed
)
const
{
if
(
doc
&&
!
name
.
startsWith
(
'<'
)
&&
!
processed
->
contains
(
doc
->
fileName
()))
{
processed
->
insert
(
doc
->
fileName
());
foreach
(
const
Macro
&
macro
,
doc
->
definedMacros
())
{
if
(
macro
.
name
()
==
name
)
{
Link
link
;
link
.
fileName
=
macro
.
fileName
();
link
.
line
=
macro
.
line
();
return
link
;
}
}
const
QList
<
Document
::
Include
>
includes
=
doc
->
includes
();
for
(
int
index
=
includes
.
size
()
-
1
;
index
!=
-
1
;
--
index
)
{
const
Document
::
Include
&
i
=
includes
.
at
(
index
);
Link
link
=
findMacroLink
(
name
,
snapshot
.
document
(
i
.
fileName
()),
snapshot
,
processed
);
if
(
!
link
.
fileName
.
isEmpty
())
return
link
;
}
}
return
Link
();
}
QString
CPPEditor
::
identifierUnderCursor
(
QTextCursor
*
macroCursor
)
const
{
macroCursor
->
movePosition
(
QTextCursor
::
StartOfWord
);
macroCursor
->
movePosition
(
QTextCursor
::
EndOfWord
,
QTextCursor
::
KeepAnchor
);
return
macroCursor
->
selectedText
();
}
CPPEditor
::
Link
CPPEditor
::
findLinkAt
(
const
QTextCursor
&
cursor
,
bool
resolveTarget
)
{
...
...
@@ -1507,20 +1556,19 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
link
.
end
=
endOfToken
;
return
link
;
}
}
else
{
// Handle macro uses
const
Document
::
MacroUse
*
use
=
doc
->
findMacroUseAt
(
endOfToken
-
1
);
if
(
use
&&
use
->
macro
().
fileName
()
!=
QLatin1String
(
"<configuration>"
))
{
const
Macro
&
macro
=
use
->
macro
();
link
.
fileName
=
macro
.
fileName
();
link
.
line
=
macro
.
line
();
link
.
begin
=
use
->
begin
();
link
.
end
=
use
->
end
();
return
link
;
}
}
return
link
;
// Handle macro uses
QTextCursor
macroCursor
=
cursor
;
const
QByteArray
name
=
identifierUnderCursor
(
&
macroCursor
).
toLatin1
();
link
=
findMacroLink
(
name
);
if
(
!
link
.
fileName
.
isEmpty
())
{
link
.
begin
=
macroCursor
.
selectionStart
();
link
.
end
=
macroCursor
.
selectionEnd
();
return
link
;
}
return
Link
();
}
void
CPPEditor
::
jumpToDefinition
()
...
...
src/plugins/cppeditor/cppeditor.h
View file @
4d6b7c4e
...
...
@@ -261,6 +261,10 @@ private:
const
CPlusPlus
::
Document
::
Ptr
&
doc
,
CPlusPlus
::
Snapshot
snapshot
)
const
;
Link
findLinkAt
(
const
QTextCursor
&
,
bool
resolveTarget
=
true
);
Link
findMacroLink
(
const
QByteArray
&
name
)
const
;
Link
findMacroLink
(
const
QByteArray
&
name
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
,
QSet
<
QString
>
*
processed
)
const
;
QString
identifierUnderCursor
(
QTextCursor
*
macroCursor
)
const
;
bool
openCppEditorAt
(
const
Link
&
);
QModelIndex
indexForPosition
(
int
line
,
int
column
,
const
QModelIndex
&
rootIndex
=
QModelIndex
())
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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