Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
67e2ecb6
Commit
67e2ecb6
authored
Nov 23, 2009
by
Christian Kamm
Browse files
QuickFix: rename contains->isCursorOn, remove selectNode,selectToken
Reviewed-by:
Roberto Raggi
<
roberto.raggi@nokia.com
>
parent
ebfe9905
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppquickfix.cpp
View file @
67e2ecb6
...
...
@@ -124,7 +124,7 @@ public:
if
(
!
expression
)
return
-
1
;
if
(
!
contains
(
expression
->
binary_op_token
))
if
(
!
isCursorOn
(
expression
->
binary_op_token
))
return
-
1
;
left
=
mk
.
UnaryExpression
();
...
...
@@ -223,7 +223,7 @@ public:
if
(
cursorPosition
>=
startOfDeclSpecifier
&&
cursorPosition
<=
endOfDeclSpecifier
)
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.
}
...
...
@@ -286,7 +286,7 @@ public:
// show when we're on the 'if' of an if statement
int
index
=
path
.
size
()
-
1
;
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
if
(
ifStatement
&&
contains
(
ifStatement
->
if_token
)
if
(
ifStatement
&&
isCursorOn
(
ifStatement
->
if_token
)
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
_statement
=
ifStatement
->
statement
;
return
index
;
...
...
@@ -296,7 +296,7 @@ public:
// ### This may not be such a good idea, consider nested ifs...
for
(;
index
!=
-
1
;
--
index
)
{
IfStatementAST
*
ifStatement
=
path
.
at
(
index
)
->
asIfStatement
();
if
(
ifStatement
&&
contains
(
ifStatement
->
statement
)
if
(
ifStatement
&&
isCursorOn
(
ifStatement
->
statement
)
&&
!
ifStatement
->
statement
->
asCompoundStatement
())
{
_statement
=
ifStatement
->
statement
;
return
index
;
...
...
@@ -357,7 +357,7 @@ public:
if
(
!
core
)
return
-
1
;
if
(
contains
(
core
))
if
(
isCursorOn
(
core
))
return
index
;
}
}
...
...
@@ -368,8 +368,8 @@ public:
virtual
void
apply
()
{
const
QString
name
=
selectNode
(
core
).
selectedText
(
);
QString
declaration
=
selectNode
(
condition
).
selectedText
(
);
const
QString
name
=
textOf
(
core
);
QString
declaration
=
textOf
(
condition
);
declaration
+=
QLatin1String
(
";
\n
"
);
insert
(
startOf
(
pattern
),
declaration
);
...
...
@@ -432,7 +432,7 @@ public:
else
if
(
!
declarator
->
initializer
)
return
-
1
;
if
(
contains
(
core
))
if
(
isCursorOn
(
core
))
return
index
;
}
}
...
...
@@ -531,7 +531,7 @@ public:
Token
binaryToken
=
tokenAt
(
condition
->
binary_op_token
);
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
;
}
else
{
return
-
1
;
...
...
@@ -661,7 +661,7 @@ int QuickFixOperation::endOf(const CPlusPlus::AST *ast) const
return
endOf
(
ast
->
lastToken
()
-
1
);
}
bool
QuickFixOperation
::
contains
(
unsigned
tokenIndex
)
const
bool
QuickFixOperation
::
isCursorOn
(
unsigned
tokenIndex
)
const
{
QTextCursor
tc
=
textCursor
();
int
cursorBegin
=
tc
.
selectionStart
();
...
...
@@ -675,7 +675,7 @@ bool QuickFixOperation::contains(unsigned tokenIndex) const
return
false
;
}
bool
QuickFixOperation
::
contains
(
const
CPlusPlus
::
AST
*
ast
)
const
bool
QuickFixOperation
::
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
{
QTextCursor
tc
=
textCursor
();
int
cursorBegin
=
tc
.
selectionStart
();
...
...
@@ -689,22 +689,6 @@ bool QuickFixOperation::contains(const CPlusPlus::AST *ast) const
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
{
QTextCursor
tc
=
_textCursor
;
...
...
@@ -768,7 +752,7 @@ QString QuickFixOperation::textOf(int firstOffset, int lastOffset) const
QString
QuickFixOperation
::
textOf
(
AST
*
ast
)
const
{
return
selectNode
(
ast
).
selectedText
(
);
return
textOf
(
startOf
(
ast
),
endOf
(
ast
)
);
}
void
QuickFixOperation
::
applyChanges
(
AST
*
ast
)
...
...
src/plugins/cppeditor/cppquickfix.h
View file @
67e2ecb6
...
...
@@ -77,16 +77,14 @@ public:
protected:
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
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
endOf
(
unsigned
index
)
const
;
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
bool
contains
(
unsigned
tokenIndex
)
const
;
bool
contains
(
const
CPlusPlus
::
AST
*
ast
)
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
;
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
;
void
move
(
int
start
,
int
end
,
int
to
);
void
move
(
unsigned
tokenIndex
,
int
to
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment