Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
97c6671e
Commit
97c6671e
authored
Oct 09, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark the usages of a symbol using the semantic highlighter.
parent
659a231a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
32 deletions
+36
-32
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+35
-32
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+1
-0
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
97c6671e
...
...
@@ -737,6 +737,9 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
)
const
{
if
(
!
doc
)
return
0
;
QTextCursor
tc
=
cursor
;
int
line
,
col
;
convertPosition
(
tc
.
position
(),
&
line
,
&
col
);
...
...
@@ -768,16 +771,10 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
void
CPPEditor
::
findUsages
()
{
updateSemanticInfo
(
m_semanticHighlighter
->
semanticInfo
(
currentSource
()));
SemanticInfo
info
=
m_lastSemanticInfo
;
if
(
!
info
.
doc
)
return
;
if
(
Symbol
*
canonicalSymbol
=
findCanonicalSymbol
(
textCursor
(),
info
.
doc
,
info
.
snapshot
))
{
if
(
Symbol
*
canonicalSymbol
=
markSymbols
())
{
m_modelManager
->
findUsages
(
canonicalSymbol
);
}
}
void
CPPEditor
::
renameUsages
()
...
...
@@ -790,7 +787,15 @@ void CPPEditor::renameUsages()
void
CPPEditor
::
renameUsagesNow
()
{
Core
::
EditorManager
::
instance
()
->
hideEditorInfoBar
(
QLatin1String
(
"CppEditor.Rename"
));
if
(
Symbol
*
canonicalSymbol
=
markSymbols
())
{
Core
::
EditorManager
::
instance
()
->
hideEditorInfoBar
(
QLatin1String
(
"CppEditor.Rename"
));
m_modelManager
->
renameUsages
(
canonicalSymbol
);
}
}
Symbol
*
CPPEditor
::
markSymbols
()
{
updateSemanticInfo
(
m_semanticHighlighter
->
semanticInfo
(
currentSource
()));
m_currentRenameSelection
=
-
1
;
...
...
@@ -798,35 +803,33 @@ void CPPEditor::renameUsagesNow()
SemanticInfo
info
=
m_lastSemanticInfo
;
if
(
info
.
doc
)
{
if
(
Symbol
*
canonicalSymbol
=
findCanonicalSymbol
(
textCursor
(),
info
.
doc
,
info
.
snapshot
))
{
TranslationUnit
*
unit
=
info
.
doc
->
translationUnit
();
const
QList
<
int
>
references
=
m_modelManager
->
references
(
canonicalSymbol
,
info
.
doc
,
info
.
snapshot
);
foreach
(
int
index
,
references
)
{
unsigned
line
,
column
;
unit
->
getTokenPosition
(
index
,
&
line
,
&
column
);
Symbol
*
canonicalSymbol
=
findCanonicalSymbol
(
textCursor
(),
info
.
doc
,
info
.
snapshot
);
if
(
canonicalSymbol
)
{
TranslationUnit
*
unit
=
info
.
doc
->
translationUnit
();
if
(
column
)
--
column
;
// adjust the column position.
const
QList
<
int
>
references
=
m_modelManager
->
references
(
canonicalSymbol
,
info
.
doc
,
info
.
snapshot
);
foreach
(
int
index
,
references
)
{
unsigned
line
,
column
;
unit
->
getTokenPosition
(
index
,
&
line
,
&
column
);
const
int
len
=
unit
->
tokenAt
(
index
).
f
.
length
;
if
(
column
)
--
column
;
// adjust the column position.
QTextCursor
cursor
(
document
()
->
findBlockByNumber
(
line
-
1
));
cursor
.
setPosition
(
cursor
.
position
()
+
column
);
cursor
.
setPosition
(
cursor
.
position
()
+
len
,
QTextCursor
::
KeepAnchor
);
const
int
len
=
unit
->
tokenAt
(
index
).
f
.
length
;
QTextEdit
::
ExtraSelection
sel
;
sel
.
format
=
m_occurrencesFormat
;
sel
.
cursor
=
cursor
;
selections
.
append
(
sel
);
}
setExtraSelections
(
CodeSemanticsSelection
,
selections
);
QTextCursor
cursor
(
document
()
->
findBlockByNumber
(
line
-
1
));
cursor
.
setPosition
(
cursor
.
position
()
+
column
);
cursor
.
setPosition
(
cursor
.
position
()
+
len
,
QTextCursor
::
KeepAnchor
);
m_modelManager
->
renameUsages
(
canonicalSymbol
);
QTextEdit
::
ExtraSelection
sel
;
sel
.
format
=
m_occurrencesFormat
;
sel
.
cursor
=
cursor
;
selections
.
append
(
sel
);
}
}
setExtraSelections
(
CodeSemanticsSelection
,
selections
);
return
canonicalSymbol
;
}
void
CPPEditor
::
renameSymbolUnderCursor
()
...
...
src/plugins/cppeditor/cppeditor.h
View file @
97c6671e
...
...
@@ -232,6 +232,7 @@ private Q_SLOTS:
void
updateSemanticInfo
(
const
SemanticInfo
&
semanticInfo
);
private:
CPlusPlus
::
Symbol
*
markSymbols
();
bool
sortedMethodOverview
()
const
;
CPlusPlus
::
Symbol
*
findDefinition
(
CPlusPlus
::
Symbol
*
symbol
);
virtual
void
indentBlock
(
QTextDocument
*
doc
,
QTextBlock
block
,
QChar
typedChar
);
...
...
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