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
Q
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
Tobias Hunger
qt-creator
Commits
ace380ec
Commit
ace380ec
authored
Sep 30, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the symbols used in the current editors.
parent
3b280a3a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
23 deletions
+107
-23
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+47
-10
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+4
-0
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+36
-8
src/plugins/cpptools/cppfindreferences.h
src/plugins/cpptools/cppfindreferences.h
+5
-5
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+7
-0
src/plugins/cpptools/cppmodelmanager.h
src/plugins/cpptools/cppmodelmanager.h
+4
-0
src/plugins/cpptools/cppmodelmanagerinterface.h
src/plugins/cpptools/cppmodelmanagerinterface.h
+4
-0
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
ace380ec
...
...
@@ -830,11 +830,11 @@ void CPPEditor::reformatDocument()
c
.
insertText
(
QString
::
fromUtf8
(
str
.
c_str
(),
str
.
length
()));
}
void
CPPEditor
::
findReferences
()
CPlusPlus
::
Symbol
*
CPPEditor
::
findCanonicalSymbol
(
const
QTextCursor
&
cursor
,
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
)
const
{
QTextCursor
tc
=
textCursor
();
m_currentRenameSelection
=
-
1
;
QTextCursor
tc
=
cursor
;
int
line
,
col
;
convertPosition
(
tc
.
position
(),
&
line
,
&
col
);
++
col
;
...
...
@@ -843,10 +843,9 @@ void CPPEditor::findReferences()
ExpressionUnderCursor
expressionUnderCursor
;
const
QString
code
=
expressionUnderCursor
(
tc
);
qDebug
()
<<
"code:"
<<
code
;
//
qDebug() << "code:" << code;
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
Document
::
Ptr
doc
=
snapshot
.
value
(
file
()
->
fileName
());
const
QString
fileName
=
const_cast
<
CPPEditor
*>
(
this
)
->
file
()
->
fileName
();
TypeOfExpression
typeOfExpression
;
typeOfExpression
.
setSnapshot
(
snapshot
);
...
...
@@ -857,9 +856,47 @@ void CPPEditor::findReferences()
lastVisibleSymbol
,
TypeOfExpression
::
Preprocess
);
if
(
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
results
))
{
Symbol
*
canonicalSymbol
=
LookupContext
::
canonicalSymbol
(
results
);
return
canonicalSymbol
;
}
void
CPPEditor
::
findReferences
()
{
m_currentRenameSelection
=
-
1
;
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
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
);
if
(
column
)
--
column
;
// adjust the column position.
const
int
len
=
unit
->
tokenAt
(
index
).
f
.
length
;
QTextCursor
cursor
(
document
()
->
findBlockByNumber
(
line
-
1
));
cursor
.
setPosition
(
cursor
.
position
()
+
column
);
cursor
.
setPosition
(
cursor
.
position
()
+
len
,
QTextCursor
::
KeepAnchor
);
QTextEdit
::
ExtraSelection
sel
;
sel
.
format
=
m_occurrencesFormat
;
sel
.
cursor
=
cursor
;
selections
.
append
(
sel
);
}
setExtraSelections
(
CodeSemanticsSelection
,
selections
);
m_modelManager
->
findReferences
(
canonicalSymbol
);
}
}
}
void
CPPEditor
::
renameSymbolUnderCursor
()
...
...
@@ -2015,7 +2052,7 @@ SemanticInfo SemanticHighlighter::semanticInfo(const Source &source)
doc
=
source
.
snapshot
.
documentFromSource
(
preprocessedCode
,
source
.
fileName
);
doc
->
check
();
snapshot
=
source
.
snapshot
.
simplified
(
doc
)
;
snapshot
=
source
.
snapshot
;
}
Control
*
control
=
doc
->
control
();
...
...
src/plugins/cppeditor/cppeditor.h
View file @
ace380ec
...
...
@@ -223,6 +223,10 @@ protected:
bool
isInComment
(
const
QTextCursor
&
cursor
)
const
;
CPlusPlus
::
Symbol
*
findCanonicalSymbol
(
const
QTextCursor
&
cursor
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
)
const
;
private
Q_SLOTS
:
void
updateFileName
();
void
jumpToMethod
(
int
index
);
...
...
src/plugins/cpptools/cppfindreferences.cpp
View file @
ace380ec
...
...
@@ -67,8 +67,8 @@ namespace {
struct
Process
:
protected
ASTVisitor
{
public:
Process
(
QFutureInterface
<
Core
::
Utils
::
FileSearchResult
>
&
future
,
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
)
Process
(
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
QFutureInterface
<
Core
::
Utils
::
FileSearchResult
>
*
future
)
:
ASTVisitor
(
doc
->
control
()),
_future
(
future
),
_doc
(
doc
),
...
...
@@ -79,12 +79,14 @@ public:
_snapshot
.
insert
(
_doc
);
}
void
operator
()(
Symbol
*
symbol
,
Identifier
*
id
,
AST
*
ast
)
QList
<
int
>
operator
()(
Symbol
*
symbol
,
Identifier
*
id
,
AST
*
ast
)
{
_references
.
clear
();
_declSymbol
=
symbol
;
_id
=
id
;
_exprDoc
=
Document
::
create
(
"<references>"
);
accept
(
ast
);
return
_references
;
}
protected:
...
...
@@ -123,10 +125,13 @@ protected:
if
(
col
)
--
col
;
// adjust the column position.
int
len
=
tk
.
f
.
length
;
const
int
len
=
tk
.
f
.
length
;
_future
.
reportResult
(
Core
::
Utils
::
FileSearchResult
(
QDir
::
toNativeSeparators
(
_doc
->
fileName
()),
if
(
_future
)
_future
->
reportResult
(
Core
::
Utils
::
FileSearchResult
(
QDir
::
toNativeSeparators
(
_doc
->
fileName
()),
line
,
lineText
,
col
,
len
));
_references
.
append
(
tokenIndex
);
}
bool
checkCandidates
(
const
QList
<
Symbol
*>
&
candidates
)
const
...
...
@@ -351,7 +356,7 @@ protected:
}
private:
QFutureInterface
<
Core
::
Utils
::
FileSearchResult
>
&
_future
;
QFutureInterface
<
Core
::
Utils
::
FileSearchResult
>
*
_future
;
Identifier
*
_id
;
// ### remove me
Symbol
*
_declSymbol
;
Document
::
Ptr
_doc
;
...
...
@@ -361,6 +366,7 @@ private:
Semantic
_sem
;
QList
<
PostfixExpressionAST
*>
_postfixExpressionStack
;
QList
<
QualifiedNameAST
*>
_qualifiedNameStack
;
QList
<
int
>
_references
;
};
}
// end of anonymous namespace
...
...
@@ -378,6 +384,28 @@ CppFindReferences::~CppFindReferences()
{
}
QList
<
int
>
CppFindReferences
::
references
(
Symbol
*
symbol
,
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
)
const
{
Identifier
*
id
=
0
;
if
(
Identifier
*
symbolId
=
symbol
->
identifier
())
id
=
doc
->
control
()
->
findIdentifier
(
symbolId
->
chars
(),
symbolId
->
size
());
QList
<
int
>
references
;
if
(
!
id
)
return
references
;
TranslationUnit
*
translationUnit
=
doc
->
translationUnit
();
Q_ASSERT
(
translationUnit
!=
0
);
Process
process
(
doc
,
snapshot
,
/*future = */
0
);
references
=
process
(
symbol
,
id
,
translationUnit
->
ast
());
return
references
;
}
static
void
find_helper
(
QFutureInterface
<
Core
::
Utils
::
FileSearchResult
>
&
future
,
const
QMap
<
QString
,
QString
>
wl
,
Snapshot
snapshot
,
...
...
@@ -429,7 +457,7 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
if
(
Identifier
*
id
=
control
->
findIdentifier
(
symbolId
->
chars
(),
symbolId
->
size
()))
{
doc
->
check
();
TranslationUnit
*
unit
=
doc
->
translationUnit
();
Process
process
(
future
,
doc
,
snapshot
);
Process
process
(
doc
,
snapshot
,
&
future
);
process
(
symbol
,
id
,
unit
->
ast
());
}
}
...
...
src/plugins/cpptools/cppfindreferences.h
View file @
ace380ec
...
...
@@ -35,16 +35,12 @@
#include <QtCore/QFuture>
#include <QtCore/QFutureWatcher>
#include <utils/filesearch.h>
#include <cplusplus/CppDocument.h>
namespace
Find
{
class
SearchResultWindow
;
}
// end of namespace Find
namespace
CPlusPlus
{
class
Snapshot
;
class
Symbol
;
}
// end of namespace CPlusPlus
namespace
CppTools
{
namespace
Internal
{
...
...
@@ -58,6 +54,10 @@ public:
CppFindReferences
(
CppModelManager
*
modelManager
);
virtual
~
CppFindReferences
();
QList
<
int
>
references
(
CPlusPlus
::
Symbol
*
symbol
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
)
const
;
Q_SIGNALS:
void
changed
();
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
ace380ec
...
...
@@ -739,6 +739,13 @@ void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport)
m_addtionalEditorSupport
.
remove
(
editorSupport
);
}
QList
<
int
>
CppModelManager
::
references
(
CPlusPlus
::
Symbol
*
symbol
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
)
{
return
m_findReferences
->
references
(
LookupContext
::
canonicalSymbol
(
symbol
),
doc
,
snapshot
);
}
void
CppModelManager
::
findReferences
(
CPlusPlus
::
Symbol
*
symbol
)
{
if
(
symbol
->
identifier
())
...
...
src/plugins/cpptools/cppmodelmanager.h
View file @
ace380ec
...
...
@@ -102,6 +102,10 @@ public:
virtual
void
addEditorSupport
(
AbstractEditorSupport
*
editorSupport
);
virtual
void
removeEditorSupport
(
AbstractEditorSupport
*
editorSupport
);
virtual
QList
<
int
>
references
(
CPlusPlus
::
Symbol
*
symbol
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
);
virtual
void
findReferences
(
CPlusPlus
::
Symbol
*
symbol
);
void
setHeaderSuffixes
(
const
QStringList
&
suffixes
)
...
...
src/plugins/cpptools/cppmodelmanagerinterface.h
View file @
ace380ec
...
...
@@ -95,6 +95,10 @@ public:
virtual
void
addEditorSupport
(
AbstractEditorSupport
*
editorSupport
)
=
0
;
virtual
void
removeEditorSupport
(
AbstractEditorSupport
*
editorSupport
)
=
0
;
virtual
QList
<
int
>
references
(
CPlusPlus
::
Symbol
*
symbol
,
CPlusPlus
::
Document
::
Ptr
doc
,
const
CPlusPlus
::
Snapshot
&
snapshot
)
=
0
;
virtual
void
findReferences
(
CPlusPlus
::
Symbol
*
symbol
)
=
0
;
};
...
...
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