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
67e2ecb6
Commit
67e2ecb6
authored
15 years ago
by
Christian Kamm
Browse files
Options
Downloads
Patches
Plain Diff
QuickFix: rename contains->isCursorOn, remove selectNode,selectToken
Reviewed-by:
Roberto Raggi
<
roberto.raggi@nokia.com
>
parent
ebfe9905
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/cppeditor/cppquickfix.cpp
+12
-28
12 additions, 28 deletions
src/plugins/cppeditor/cppquickfix.cpp
src/plugins/cppeditor/cppquickfix.h
+2
-4
2 additions, 4 deletions
src/plugins/cppeditor/cppquickfix.h
with
14 additions
and
32 deletions
src/plugins/cppeditor/cppquickfix.cpp
+
12
−
28
View file @
67e2ecb6
...
@@ -124,7 +124,7 @@ public:
...
@@ -124,7 +124,7 @@ public:
if
(
!
expression
)
if
(
!
expression
)
return
-
1
;
return
-
1
;
if
(
!
contains
(
expression
->
binary_op_token
))
if
(
!
isCursorOn
(
expression
->
binary_op_token
))
return
-
1
;
return
-
1
;
left
=
mk
.
UnaryExpression
();
left
=
mk
.
UnaryExpression
();
...
@@ -223,7 +223,7 @@ public:
...
@@ -223,7 +223,7 @@ public:
if
(
cursorPosition
>=
startOfDeclSpecifier
&&
cursorPosition
<=
endOfDeclSpecifier
)
if
(
cursorPosition
>=
startOfDeclSpecifier
&&
cursorPosition
<=
endOfDeclSpecifier
)
return
index
;
// the AST node under cursor is a specifier.
return
index
;
// the AST node under cursor is a specifier.
if
(
core_declarator
&&
contains
(
core_declarator
))
if
(
core_declarator
&&
isCursorOn
(
core_declarator
))
return
index
;
// got a core-declarator under the text cursor.
return
index
;
// got a core-declarator under the text cursor.
}
}
...
@@ -286,7 +286,7 @@ public:
...
@@ -286,7 +286,7 @@ public:
// show when we're on the 'if' of an if statement
// show when we're on the 'if' of an if statement
int
index
=
path
.
size
()
-
1
;
int
index
=
path
.
size
()
-
1
;
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
if
(
ifStatement
&&
contains
(
ifStatement
->
if_token
)
if
(
ifStatement
&&
isCursorOn
(
ifStatement
->
if_token
)
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
_statement
=
ifStatement
->
statement
;
_statement
=
ifStatement
->
statement
;
return
index
;
return
index
;
...
@@ -296,7 +296,7 @@ public:
...
@@ -296,7 +296,7 @@ public:
// ### This may not be such a good idea, consider nested ifs...
// ### This may not be such a good idea, consider nested ifs...
for
(;
index
!=
-
1
;
--
index
)
{
for
(;
index
!=
-
1
;
--
index
)
{
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
if
(
ifStatement
&&
contains
(
ifStatement
->
statement
)
if
(
ifStatement
&&
isCursorOn
(
ifStatement
->
statement
)
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
_statement
=
ifStatement
->
statement
;
_statement
=
ifStatement
->
statement
;
return
index
;
return
index
;
...
@@ -357,7 +357,7 @@ public:
...
@@ -357,7 +357,7 @@ public:
if
(
!
core
)
if
(
!
core
)
return
-
1
;
return
-
1
;
if
(
contains
(
core
))
if
(
isCursorOn
(
core
))
return
index
;
return
index
;
}
}
}
}
...
@@ -368,8 +368,8 @@ public:
...
@@ -368,8 +368,8 @@ public:
virtual
void
apply
()
virtual
void
apply
()
{
{
const
QString
name
=
selectNode
(
core
).
selectedText
(
);
const
QString
name
=
textOf
(
core
);
QString
declaration
=
selectNode
(
condition
).
selectedText
(
);
QString
declaration
=
textOf
(
condition
);
declaration
+=
QLatin1String
(
";
\n
"
);
declaration
+=
QLatin1String
(
";
\n
"
);
insert
(
startOf
(
pattern
),
declaration
);
insert
(
startOf
(
pattern
),
declaration
);
...
@@ -432,7 +432,7 @@ public:
...
@@ -432,7 +432,7 @@ public:
else
if
(
!
declarator
->
initializer
)
else
if
(
!
declarator
->
initializer
)
return
-
1
;
return
-
1
;
if
(
contains
(
core
))
if
(
isCursorOn
(
core
))
return
index
;
return
index
;
}
}
}
}
...
@@ -531,7 +531,7 @@ public:
...
@@ -531,7 +531,7 @@ public:
Token
binaryToken
=
tokenAt
(
condition
->
binary_op_token
);
Token
binaryToken
=
tokenAt
(
condition
->
binary_op_token
);
if
(
binaryToken
.
is
(
T_AMPER_AMPER
)
||
binaryToken
.
is
(
T_PIPE_PIPE
))
{
if
(
binaryToken
.
is
(
T_AMPER_AMPER
)
||
binaryToken
.
is
(
T_PIPE_PIPE
))
{
if
(
contains
(
condition
->
binary_op_token
))
if
(
isCursorOn
(
condition
->
binary_op_token
))
return
index
;
return
index
;
}
else
{
}
else
{
return
-
1
;
return
-
1
;
...
@@ -661,7 +661,7 @@ int QuickFixOperation::endOf(const CPlusPlus::AST *ast) const
...
@@ -661,7 +661,7 @@ int QuickFixOperation::endOf(const CPlusPlus::AST *ast) const
return
endOf
(
ast
->
lastToken
()
-
1
);
return
endOf
(
ast
->
lastToken
()
-
1
);
}
}
bool
QuickFixOperation
::
contains
(
unsigned
tokenIndex
)
const
bool
QuickFixOperation
::
isCursorOn
(
unsigned
tokenIndex
)
const
{
{
QTextCursor
tc
=
textCursor
();
QTextCursor
tc
=
textCursor
();
int
cursorBegin
=
tc
.
selectionStart
();
int
cursorBegin
=
tc
.
selectionStart
();
...
@@ -675,7 +675,7 @@ bool QuickFixOperation::contains(unsigned tokenIndex) const
...
@@ -675,7 +675,7 @@ bool QuickFixOperation::contains(unsigned tokenIndex) const
return
false
;
return
false
;
}
}
bool
QuickFixOperation
::
contains
(
const
CPlusPlus
::
AST
*
ast
)
const
bool
QuickFixOperation
::
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
{
{
QTextCursor
tc
=
textCursor
();
QTextCursor
tc
=
textCursor
();
int
cursorBegin
=
tc
.
selectionStart
();
int
cursorBegin
=
tc
.
selectionStart
();
...
@@ -689,22 +689,6 @@ bool QuickFixOperation::contains(const CPlusPlus::AST *ast) const
...
@@ -689,22 +689,6 @@ bool QuickFixOperation::contains(const CPlusPlus::AST *ast) const
return
false
;
return
false
;
}
}
QTextCursor
QuickFixOperation
::
selectToken
(
unsigned
index
)
const
{
QTextCursor
tc
=
_textCursor
;
tc
.
setPosition
(
startOf
(
index
));
tc
.
setPosition
(
endOf
(
index
),
QTextCursor
::
KeepAnchor
);
return
tc
;
}
QTextCursor
QuickFixOperation
::
selectNode
(
AST
*
ast
)
const
{
QTextCursor
tc
=
_textCursor
;
tc
.
setPosition
(
startOf
(
ast
->
firstToken
()));
tc
.
setPosition
(
endOf
(
ast
->
lastToken
()
-
1
),
QTextCursor
::
KeepAnchor
);
return
tc
;
}
QuickFixOperation
::
Range
QuickFixOperation
::
createRange
(
AST
*
ast
)
const
QuickFixOperation
::
Range
QuickFixOperation
::
createRange
(
AST
*
ast
)
const
{
{
QTextCursor
tc
=
_textCursor
;
QTextCursor
tc
=
_textCursor
;
...
@@ -768,7 +752,7 @@ QString QuickFixOperation::textOf(int firstOffset, int lastOffset) const
...
@@ -768,7 +752,7 @@ QString QuickFixOperation::textOf(int firstOffset, int lastOffset) const
QString
QuickFixOperation
::
textOf
(
AST
*
ast
)
const
QString
QuickFixOperation
::
textOf
(
AST
*
ast
)
const
{
{
return
selectNode
(
ast
).
selectedText
(
);
return
textOf
(
startOf
(
ast
),
endOf
(
ast
)
);
}
}
void
QuickFixOperation
::
applyChanges
(
AST
*
ast
)
void
QuickFixOperation
::
applyChanges
(
AST
*
ast
)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/cppeditor/cppquickfix.h
+
2
−
4
View file @
67e2ecb6
...
@@ -77,16 +77,14 @@ public:
...
@@ -77,16 +77,14 @@ public:
protected
:
protected
:
const
CPlusPlus
::
Token
&
tokenAt
(
unsigned
index
)
const
;
const
CPlusPlus
::
Token
&
tokenAt
(
unsigned
index
)
const
;
QTextCursor
selectToken
(
unsigned
index
)
const
;
QTextCursor
selectNode
(
CPlusPlus
::
AST
*
ast
)
const
;
int
startOf
(
unsigned
index
)
const
;
int
startOf
(
unsigned
index
)
const
;
int
startOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
startOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
endOf
(
unsigned
index
)
const
;
int
endOf
(
unsigned
index
)
const
;
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
bool
contains
(
unsigned
tokenIndex
)
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
;
bool
contains
(
const
CPlusPlus
::
AST
*
ast
)
const
;
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
;
void
move
(
int
start
,
int
end
,
int
to
);
void
move
(
int
start
,
int
end
,
int
to
);
void
move
(
unsigned
tokenIndex
,
int
to
);
void
move
(
unsigned
tokenIndex
,
int
to
);
...
...
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