Skip to content
GitLab
Menu
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
4c427aec
Commit
4c427aec
authored
Nov 26, 2009
by
Christian Kamm
Browse files
Quickfix: Be more efficient when looking up token start/end positions.
parent
43129a29
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppquickfix.cpp
View file @
4c427aec
...
...
@@ -639,6 +639,15 @@ int QuickFixOperation::endOf(const CPlusPlus::AST *ast) const
return
endOf
(
ast
->
lastToken
()
-
1
);
}
void
QuickFixOperation
::
startAndEndOf
(
unsigned
index
,
int
*
start
,
int
*
end
)
const
{
unsigned
line
,
column
;
CPlusPlus
::
Token
token
(
tokenAt
(
index
));
_document
->
translationUnit
()
->
getPosition
(
token
.
begin
(),
&
line
,
&
column
);
*
start
=
_textCursor
.
document
()
->
findBlockByNumber
(
line
-
1
).
position
()
+
column
-
1
;
*
end
=
*
start
+
token
.
length
();
}
bool
QuickFixOperation
::
isCursorOn
(
unsigned
tokenIndex
)
const
{
QTextCursor
tc
=
textCursor
();
...
...
@@ -690,7 +699,9 @@ void QuickFixOperation::move(int start, int end, int to)
void
QuickFixOperation
::
move
(
unsigned
tokenIndex
,
int
to
)
{
move
(
startOf
(
tokenIndex
),
endOf
(
tokenIndex
),
to
);
int
start
,
end
;
startAndEndOf
(
tokenIndex
,
&
start
,
&
end
);
move
(
start
,
end
,
to
);
}
void
QuickFixOperation
::
move
(
const
CPlusPlus
::
AST
*
ast
,
int
to
)
...
...
@@ -705,7 +716,9 @@ void QuickFixOperation::replace(int start, int end, const QString &replacement)
void
QuickFixOperation
::
replace
(
unsigned
tokenIndex
,
const
QString
&
replacement
)
{
replace
(
startOf
(
tokenIndex
),
endOf
(
tokenIndex
),
replacement
);
int
start
,
end
;
startAndEndOf
(
tokenIndex
,
&
start
,
&
end
);
replace
(
start
,
end
,
replacement
);
}
void
QuickFixOperation
::
replace
(
const
CPlusPlus
::
AST
*
ast
,
const
QString
&
replacement
)
...
...
@@ -725,7 +738,9 @@ void QuickFixOperation::remove(int start, int end)
void
QuickFixOperation
::
remove
(
unsigned
tokenIndex
)
{
remove
(
startOf
(
tokenIndex
),
endOf
(
tokenIndex
));
int
start
,
end
;
startAndEndOf
(
tokenIndex
,
&
start
,
&
end
);
remove
(
start
,
end
);
}
void
QuickFixOperation
::
remove
(
const
CPlusPlus
::
AST
*
ast
)
...
...
@@ -750,7 +765,9 @@ void QuickFixOperation::copy(int start, int end, int to)
void
QuickFixOperation
::
copy
(
unsigned
tokenIndex
,
int
to
)
{
copy
(
startOf
(
tokenIndex
),
endOf
(
tokenIndex
),
to
);
int
start
,
end
;
startAndEndOf
(
tokenIndex
,
&
start
,
&
end
);
copy
(
start
,
end
,
to
);
}
void
QuickFixOperation
::
copy
(
const
CPlusPlus
::
AST
*
ast
,
int
to
)
...
...
src/plugins/cppeditor/cppquickfix.h
View file @
4c427aec
...
...
@@ -92,6 +92,7 @@ protected:
int
startOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
int
endOf
(
unsigned
index
)
const
;
int
endOf
(
const
CPlusPlus
::
AST
*
ast
)
const
;
void
startAndEndOf
(
unsigned
index
,
int
*
start
,
int
*
end
)
const
;
bool
isCursorOn
(
unsigned
tokenIndex
)
const
;
bool
isCursorOn
(
const
CPlusPlus
::
AST
*
ast
)
const
;
...
...
Write
Preview
Supports
Markdown
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