Commit Graph

79 Commits

Author SHA1 Message Date
Erik Verbruggen
f2631ad031 C++: do not strip trailing newlines in the preprocessor output.
Doing so resulted in an incorrect position for the EOF token when the
preprocessed output would be parsed. That in turn leads to incorrect
insertion positions for refactoring actions.

This is especially true when a file contains only preprocessor
directives: the EOF token would point to line 1 column 1, which is
usually not the place where code should be inserted.

Change-Id: I7d359aa7a6c04bc52c8b873fd49ad6afc3a77319
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-05-30 16:42:29 +02:00
Lorenz Haas
bddaab248b CppEditor: Consider base class namespace in "Insert Virtual Methods"
Change-Id: Ife5f34d410781d3c1ae75a3bf1c412f7d76dca80
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-24 11:40:13 +02:00
Lorenz Haas
20a23ec72b CppEditor: Do not show InsertDefFromDecl if triggered on a statement
Change-Id: Ib0b110ac80d9519461a6ba6cf5b7c77925ed2ea5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-24 11:12:32 +02:00
Lorenz Haas
276e2bccaa CppEditor: Hide "Assign to Local Variable" if signatures don't match
Task-number: QTCREATORBUG-9321

Change-Id: I31ac75a480b30ef26f343557088c4bbe5e95c4c6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-24 10:22:21 +02:00
Lorenz Haas
d25c5f35ca CppEditor: InsertDefFromDecl: Hide when definition already exists
"Add Definition Inside/Outside Class" was wrongly shown when there was
already an definition outside the class.

Change-Id: I6409080c6a1a3abdd4511f7db14ecb4f63458411
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-15 13:39:32 +02:00
Nikolai Kosjar
4fb5277834 Fix warning about unused variable
Change-Id: I2699fdab3b8a586e61270d4853121c131b2a0ebf
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-05-14 11:05:00 +02:00
Nikolai Kosjar
11f1e365f0 CppEditor: Tests: Remove superfluous output
Change-Id: Ia1d9d04f5417c4816c07f3e60ab4be237d27e0d4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-05-14 09:34:06 +02:00
Lorenz Haas
d288e3999b CppEditor: Quick fix "Insert (Pure) Virtual Methods"
This quick fix inserts (pure) virtual functions of base classes to the
current class. For selecting the functions which should be inserted and
for choosing the insertion mode (only declarations or with definitions
inside, outside or in the implementation file) a dialog is shown.

Task-number: QTCREATORBUG-2210
Task-number: QTCREATORBUG-2692
Task-number: QTCREATORBUG-3908
Task-number: QTCREATORBUG-5868
Task-number: QTCREATORBUG-7982
Change-Id: I8e94905afcae4778986f4c3925a494e0c6b3b8ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-14 09:14:25 +02:00
Lorenz Haas
7ef611047f CppEditor: Improve insert position for AddIncludeForUndefinedIdentifier
Includes of moc files are not considered while determining the new
include's position. Further the new include is inserted at its
"alphabeticaly sorted" position.

Task-number: QTCREATORBUG-8871
Change-Id: I67b40a6f538112753298b960da488e24f4643808
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-14 08:51:30 +02:00
Lorenz Haas
15f90404aa CppEditor: InsertDefFromDecl: choose insert position
Now one can decide where the new definition should go: Inside the class,
outside the class or to the implementation file. Further the text cursor
is positioned inside the new created definition body.

Task-number: QTCREATORBUG-6973
Change-Id: I593955dd1e44e35240fa1e9b9a5c1a67eb119456
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-10 11:33:05 +02:00
Lorenz Haas
7ae31f2ea9 CppEditor: Add quick fix for "Assign to Local Variable"
Adds a local variable which stores the return value of a function call
or new expression.

Task-number: QTCREATORBUG-9052
Change-Id: I1fccbdd5b9f28c8409a4b0fa24610e406de61b24
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-29 08:49:31 +02:00
Nikolai Kosjar
a2b2857b44 CppEditor: Rename CppPlugin to CppEditorPlugin
Change-Id: Icebf85ae425f413ed0d3dfc873869665233ec58c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-19 12:09:45 +02:00
Lorenz Haas
39d000430e CppEditor: Quick fix "move definition" keeps ctor-initialization list
Task-number: QTCREATORBUG-9157

Change-Id: Ic46086ba07a86292bbf48de62b69e3f33628fd86
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-18 15:54:13 +02:00
Andrey M. Tokarev
72e0ded3c4 CppEditor: add more sections (protected, ...) for declaration (refactoring)
You can write definition of function, type Alt+Enter, as usual,
and select not only public but also other possible sections
like private, public slots and so on.

Change-Id: I2faefc3833c6f05c9e2e5a2a41328bcdbe17ba14
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-18 15:08:19 +02:00
Lorenz Haas
6f3b41214b CppEditor: Add refactoring operation to move definition of a function
With this new operation it is possible to move a function definition
from a cpp file to the header file or vice versa. One can also move a
function definition outside the class body.

Task-number: QTCREATORBUG-516
Task-number: QTCREATORBUG-5364
Change-Id: Id3daefe79284bd9086282369c9d251e003951c11
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-15 17:03:49 +02:00
Lorenz Haas
61ddf16689 CppEditor: Rearrange quick fix files
Moved content of cppinsertdecldef.(cpp|h) cppcompleteswitch.(cpp|h)
cppinsertqtpropertymembers.(cpp|h) and ApplyDeclDefLinkChanges to
cppquickfixes.(cpp|h).

Made msgQtStringLiteralDescription private member function of
WrapStringLiteral, added anonymous namespace, "extracted" useful
functions to the top of cppquickfixes.cpp.

Change-Id: I4f82a005a62be3c29d4b96902667bd3a2b9397cc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-15 13:32:42 +02:00
Lorenz Haas
2e8d471c3b CppEditor: Fix insert position of AddIncludeForUndefinedIdentifier
If there are no includes, add new include at the top of file but skip
possible comments at the beginning.

Task-number: QTCREATORBUG-8799
Change-Id: Ie2be644f6ad0a948cf3d8700efa00087753d9863
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-10 16:42:29 +02:00
Friedemann Kleint
d61bc4fcec Clean headers in CppEditor.
Ran script to remove inludes on a trial-and-error basis and
manually corrected it.

Change-Id: I61a5c2fff02616f6883ddf3923e4361fca6bf92b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-10 11:04:22 +02:00
Tobias Hunger
ea23948efb CppTools: Use namespace CppTools consistently
There were quite a few classes using CPlusPlus namespace in the
CppTools plugin. Rename them and do some other small namespace
related coding style fixups.

Change-Id: I093fc1f3fc394fd9923e3f18d5f66522e288f21d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-08 13:21:31 +02:00
Oswald Buddenhagen
7923032022 fix include style relating to cplusplus libraries
... and adjust INCLUDEPATH accordingly.

while i'm at messing with include statements, also re-order the include
blocks according to policy and sort them within bigger blocks.

Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-04-03 13:40:39 +02:00
Nikolai Kosjar
06b5f62a61 C++: Let "Add Definition" quick fix work with free function declarations
It was restricted to member functions declarations, but works well with
free functions, too.

Change-Id: I8513e67e426185e7e08aebc2f1b5bfd08f79887f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-03-04 10:28:05 +01:00
Nikolai Kosjar
77a66c2639 C++: Tests: Add basic tests for quick fix InsertDefFromDecl
Change-Id: I668754607c9c1764b9387a7899994c88c17886cd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-03-04 10:27:54 +01:00
Nikolai Kosjar
9443945901 C++: Tests: Handle multiple files for quickfix tests
Change-Id: I5a712c7dbf58465cd0a675be03ba22a73c57bb12
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
2013-02-25 15:08:48 +01:00
Nikolai Kosjar
8a0139dfcb C++: Tests: Make quick fix tests independent of config file
Change-Id: Idf064b7bc80cca5d0da8bb7c0803c9dde499d87f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-19 10:18:49 +01:00
Nikolai Kosjar
30da7ad3e2 C++: Pass only reasonable ASTs to pointer declaration formatter
Change-Id: Ide829a8084d3fef79f252dc7724bd90ce8ebba04
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-14 12:25:32 +01:00
Nikolai Kosjar
c6a7fb8ccf C++: Refactor quick fixes
- Put declarations into quickfixes.h to simplify testing
 - Give the factories more meaningful names

Change-Id: If74c29a8c17819d5369ffa3df94d146b14e53af9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-14 12:25:20 +01:00
Nikolai Kosjar
f10b978f86 C++: Improve GetterSetter quick fix
- Prefix getter name with 'get' if there is a conflict between
  the getter name and the member variable name.
- When possible, use base name of member variable as setter parameter
  name instead of 'value'.
- Generate static getters/setters for static members.
- Fix case "class C { char *@s; };" - the quick fix was not offered for
  this particular cursor position (right after pointer sign).
- Fix case "class C { char c, *@s; };" - the quick fix was done for the
  wrong type (char instead of char *).
- Do not generate a setter for const member variables.
- Do not get triggered on member functions and arrays.
- Do not offer the quick fix if there is already a member with the
  getter or setter name we would generate.

Change-Id: I4530467518ea0bf6368e47eb32d5faafbf8cd928
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-02-01 14:01:47 +01:00
Robert Loehning
a040424d2a Incremented year in copyright info
Change-Id: Ia11f4d7a94465de7f12cc390855e54e3256e5455
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-02-01 09:19:26 +01:00
Erik Verbruggen
72db7a8f52 CppEditor: quick fix to generate getters and setters
This does not take namespaces on the implementation side
into account and does not properly position/indent things.

Task-number: QTCREATORBUG-1890
Change-Id: I779d12fefc79521bce38361729d4f66dada71147
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-01-24 16:18:16 +01:00