Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
0daf22c7
Commit
0daf22c7
authored
15 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
Quickfix: Add a typeOf helper to conveniently get the type of an expr.
Reviewed-by: Erik Verbruggen
parent
77b59b02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/cppeditor/cppquickfix.cpp
+21
-2
21 additions, 2 deletions
src/plugins/cppeditor/cppquickfix.cpp
src/plugins/cppeditor/cppquickfix.h
+5
-1
5 additions, 1 deletion
src/plugins/cppeditor/cppquickfix.h
with
26 additions
and
3 deletions
src/plugins/cppeditor/cppquickfix.cpp
+
21
−
2
View file @
0daf22c7
...
@@ -841,7 +841,10 @@ Snapshot QuickFixOperation::snapshot() const
...
@@ -841,7 +841,10 @@ Snapshot QuickFixOperation::snapshot() const
{
return
_snapshot
;
}
{
return
_snapshot
;
}
void
QuickFixOperation
::
setSnapshot
(
const
CPlusPlus
::
Snapshot
&
snapshot
)
void
QuickFixOperation
::
setSnapshot
(
const
CPlusPlus
::
Snapshot
&
snapshot
)
{
_snapshot
=
snapshot
;
}
{
_snapshot
=
snapshot
;
_typeOfExpression
.
setSnapshot
(
snapshot
);
}
CPPEditor
*
QuickFixOperation
::
editor
()
const
CPPEditor
*
QuickFixOperation
::
editor
()
const
{
return
_editor
;
}
{
return
_editor
;
}
...
@@ -1032,7 +1035,7 @@ QString QuickFixOperation::textOf(int firstOffset, int lastOffset) const
...
@@ -1032,7 +1035,7 @@ QString QuickFixOperation::textOf(int firstOffset, int lastOffset) const
return
tc
.
selectedText
();
return
tc
.
selectedText
();
}
}
QString
QuickFixOperation
::
textOf
(
AST
*
ast
)
const
QString
QuickFixOperation
::
textOf
(
const
AST
*
ast
)
const
{
{
return
textOf
(
startOf
(
ast
),
endOf
(
ast
));
return
textOf
(
startOf
(
ast
),
endOf
(
ast
));
}
}
...
@@ -1054,6 +1057,22 @@ void QuickFixOperation::apply()
...
@@ -1054,6 +1057,22 @@ void QuickFixOperation::apply()
_textCursor
.
endEditBlock
();
_textCursor
.
endEditBlock
();
}
}
/**
* Returns a list of possible fully specified types associated with the
* given expression.
*
* NOTE: The fully specified types only stay valid until the next call to typeOf.
*/
const
QList
<
LookupItem
>
QuickFixOperation
::
typeOf
(
const
CPlusPlus
::
ExpressionAST
*
ast
)
{
unsigned
line
,
column
;
document
()
->
translationUnit
()
->
getTokenStartPosition
(
ast
->
firstToken
(),
&
line
,
&
column
);
Symbol
*
lastVisibleSymbol
=
document
()
->
findSymbolAt
(
line
,
column
);
return
_typeOfExpression
(
textOf
(
ast
),
document
(),
lastVisibleSymbol
,
TypeOfExpression
::
Preprocess
);
}
CPPQuickFixCollector
::
CPPQuickFixCollector
()
CPPQuickFixCollector
::
CPPQuickFixCollector
()
:
_modelManager
(
CppTools
::
CppModelManagerInterface
::
instance
()),
_editor
(
0
)
:
_modelManager
(
CppTools
::
CppModelManagerInterface
::
instance
()),
_editor
(
0
)
{
}
{
}
...
...
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppquickfix.h
+
5
−
1
View file @
0daf22c7
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include
<texteditor/icompletioncollector.h>
#include
<texteditor/icompletioncollector.h>
#include
<cplusplus/CppDocument.h>
#include
<cplusplus/CppDocument.h>
#include
<cplusplus/TypeOfExpression.h>
#include
<ASTfwd.h>
#include
<ASTfwd.h>
#include
<utils/changeset.h>
#include
<utils/changeset.h>
...
@@ -114,7 +115,7 @@ protected:
...
@@ -114,7 +115,7 @@ protected:
void
copy
(
const
CPlusPlus
::
AST
*
ast
,
int
to
);
void
copy
(
const
CPlusPlus
::
AST
*
ast
,
int
to
);
QString
textOf
(
int
firstOffset
,
int
lastOffset
)
const
;
QString
textOf
(
int
firstOffset
,
int
lastOffset
)
const
;
QString
textOf
(
CPlusPlus
::
AST
*
ast
)
const
;
QString
textOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
struct
Range
{
struct
Range
{
Range
()
{}
Range
()
{}
...
@@ -127,6 +128,8 @@ protected:
...
@@ -127,6 +128,8 @@ protected:
Range
createRange
(
CPlusPlus
::
AST
*
ast
)
const
;
// ### rename me
Range
createRange
(
CPlusPlus
::
AST
*
ast
)
const
;
// ### rename me
void
reindent
(
const
Range
&
range
);
void
reindent
(
const
Range
&
range
);
const
QList
<
CPlusPlus
::
LookupItem
>
typeOf
(
const
CPlusPlus
::
ExpressionAST
*
ast
);
private
:
private
:
CPlusPlus
::
Document
::
Ptr
_document
;
CPlusPlus
::
Document
::
Ptr
_document
;
CPlusPlus
::
Snapshot
_snapshot
;
CPlusPlus
::
Snapshot
_snapshot
;
...
@@ -134,6 +137,7 @@ private:
...
@@ -134,6 +137,7 @@ private:
Utils
::
ChangeSet
_changeSet
;
Utils
::
ChangeSet
_changeSet
;
CPPEditor
*
_editor
;
CPPEditor
*
_editor
;
CPlusPlus
::
AST
*
_topLevelNode
;
CPlusPlus
::
AST
*
_topLevelNode
;
CPlusPlus
::
TypeOfExpression
_typeOfExpression
;
};
};
class
CPPQuickFixCollector
:
public
TextEditor
::
IQuickFixCollector
class
CPPQuickFixCollector
:
public
TextEditor
::
IQuickFixCollector
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment