aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppquickfix_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CppEditor: Fix some "convert to camel case" edge casesChristian Kandeler2020-10-201-0/+33
| | | | | | Fixes: QTCREATORBUG-16560 Change-Id: I8573ae6c5dce0956c868addc69a921c62f1d571a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix Typedef Handling with 'Remove Using Directive' QuickFixLeander Schulten2020-10-121-0/+43
| | | | | | | | Previously, typedefs were ignored and the new code became invalid after applying the quickfix. Change-Id: I0d4295e90d02dfacc3edac5ac3f96d9edbeaf662 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Consider templates in "complete switch" quickfixChristian Kandeler2020-10-121-0/+26
| | | | | | Fixes: QTCREATORBUG-24752 Change-Id: I39bc007e5f493a9826adb4575eb210bf9ec21159 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Implement remove using namespace QuickfixLeander Schulten2020-08-121-0/+246
| | | | | | Fixes: QTCREATORBUG-24392 Change-Id: Iaf4df4ebf161a4a757f59f22e692e0f9b99cd63c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Do not re-indent existing codeChristian Kandeler2020-08-101-2/+2
| | | | | | | | ... in "Complete Switch Statement" quickfix. Fixes: QTCREATORBUG-12445 Change-Id: Ic168f5b434b81d2b5f5a0d344d6c6786a75d07a5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Work around cmake bugChristian Kandeler2020-07-301-3/+0
| | | | | | | | If you mention "Q_OBJECT" in a raw string literal, the cmake build fails... Change-Id: I9004184b48dea9a77b9303c3fd871cef747ade4c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Let users create implementations for all member functionsChristian Kandeler2020-07-291-0/+131
| | | | | | | | ... in one go. Fixes: QTCREATORBUG-12164 Change-Id: Ifc81c8b1caf4319ce57882375f513d72e4c0ea52 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Don't create 'namespace xyz{}' if there is 'using namespace xyz'Leander Schulten2020-07-281-0/+79
| | | | | Change-Id: Idc08de5f44ccac0de8490158199c4e44f7efe79e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* CppEditor: Add class member from member initializationChristian Kandeler2020-07-231-0/+87
| | | | | | | | | That is, if a class member being initialized is not yet declared, offer to add the declaration. Fixes: QTCREATORBUG-11842 Change-Id: I1d2a56ab99543e996e220aa26b7923023dd163f7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix trailing whitespace after extracting a functionChristian Kandeler2020-07-231-0/+20
| | | | | | | | | | | ... from a block of code. We must not insert an empty line into the newly created function, because it gets indented in the first indent operation, resulting in trailing characters after the actual code has been inserted later. Fixes: QTCREATORBUG-12118 Change-Id: If438d4de379cae90baa846c112866f2777b44fce Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Extend Q_PROPERTY quickfixChristian Kandeler2020-07-221-2/+67
| | | | | | | | ... to also generate the RESET function. Fixes: QTCREATORBUG-11809 Change-Id: I94789227230a67f074ff5fdc76ad8113d2870dd6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Fix possible wrong location for function definitionsChristian Stenger2020-07-161-0/+32
| | | | | | | | | | Having no namespace when inserting generated functions may insert explicitly at the end of a header which is not always desired as we need to take care of e.g. header guards as well. Change-Id: I3b154ae936a96f2f8e7e34cda6b5bcdfcbc83faf Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Ensure "inline" specifierChristian Kandeler2020-07-151-11/+36
| | | | | | | | | ... when creating functions in header files. Otherwise, we will likely cause linker failures in non-trivial projects. Fixes: QTCREATORBUG-15052 Change-Id: Ic0fff8779ba924f8b9943ab233a0cda409e73e9d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Ensure proper namespace for new getter/setter functionsChristian Kandeler2020-07-141-0/+150
| | | | | | | | | | If the class is in a namespace and the cpp file does not yet have any implementations in that namespace, then we would erroneously put the getters in the global namespace. Fixes: QTCREATORBUG-14886 Change-Id: I836537abddfdd92ced783d60e1226b082bbc238e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Offer to create getters and setters for all class membersChristian Kandeler2020-07-101-0/+91
| | | | | | Fixes: QTCREATORBUG-14504 Change-Id: I12c687492b12c6997064eb7f137b6ccb189d2009 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Make "Add curly braces" quickfix more robustChristian Kandeler2020-07-071-0/+25
| | | | | | | | | | Anchor the opening brace at the closing parenthesis, rather than at the statement. This way, we won't get troubled by macro weirdness in the statement part. Fixes: QTCREATORBUG-13921 Change-Id: I05af24d1642e6b62c78bb2f47a1ef0b1fea326d0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* TextEditor: Sort indent ranges before applyingChristian Kandeler2020-06-151-0/+34
| | | | | | | | | | It can easily happen that callers insert indent ranges out of order, and without sorting the indentation done earlier in the file is not considered for the later parts, leading to inconsistent results. Fixes: QTCREATORBUG-18929 Change-Id: Ice2abe92d54446bcdd102c6a1f822262a8533543 Reviewed-by: David Schulz <david.schulz@qt.io>
* CppEditor: Extend "Add Include" quickfixChristian Kandeler2020-06-051-0/+14
| | | | | | | | ... so it works for all kinds of symbols, not just Qt classes. Fixes: QTCREATORBUG-21 Change-Id: I2d329c09b64cd8f7eef8cce7d9f022aca8586c0d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Do not treat friend declaration as member functionChristian Kandeler2020-06-051-0/+13
| | | | | | | | | | | ... when trying to create definitions from declarations. Instead, we completely ignore friends in this context, arguing that the respective function normally should have a proper declaration somewhere else. Fixes: QTCREATORBUG-7164 Change-Id: I3ddb89cefecbc494f9c7e63600b65fd6288b7169 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CplusPlus: Fix type information for anonymous enumsChristian Kandeler2020-06-041-0/+25
| | | | | | | | | | Variables declared like this: enum { E1, E2 } e; would not get assigned a proper type. Task-number: QTCREATORBUG-7487 Change-Id: I4362f22feb0f2e4e1e754e9c623e5576fa31f4bc Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CPlusPlus: Add missing type information for enum variablesChristian Kandeler2020-06-041-0/+25
| | | | | | | | | | | | | | Consider these two variable declarations: enum EX { EX1, EX2}; EX ex; emum EY { EY1, EY2} ey; The ex variable would correctly get assigned type EX, but the ey variable would not have any type. This is now fixed. Task-number: QTCREATORBUG-7487 Change-Id: I3e09c5766fdb9e6baf3a8d7bc6f2fc581f2d824b Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CppEditor: Consider namespaces in "extract function" quickfixChristian Kandeler2020-05-291-0/+28
| | | | | | Fixes: QTCREATORBUG-23256 Change-Id: I99b1271907767c3607e35adb49bd4109f3eca18c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Add quickfix for creating a forward declarationChristian Kandeler2020-05-271-0/+182
| | | | | | | | | In header files, a forward declaration is often preferable to including another header file, so let's offer this as a quickfix. Fixes: QTCREATORBUG-23444 Change-Id: Ib50550abb5337098e4122e65e2af42a66742d6f6 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: generate valid code via "Convert to Pointer/Stack Variable"David Schulz2020-01-081-3/+42
| | | | | | | | | | | | Adding a "= new <TypeName>" after converting a stack variable without assignment or initializer to pointer. Also remove the assignment when converting from pointer to stack variable as this works better with explicit constructors. Fixes: QTCREATORBUG-23181 Change-Id: I377ec32a1b66cf4b96db14cfcb4b71fb96c80c98 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* C++: Transfer noexcept specifier for refactoring actionsNikolai Kosjar2019-10-081-0/+23
| | | | | | | | | | | | | | This applies for e.g. * "Add Definition..." (on function decl) * "Move Definition..." (on function decl) * "Insert Virtual Functions of Base Class" (on class specifier) Fixes: QTCREATORBUG-11849 Fixes: QTCREATORBUG-19699 Change-Id: I0d259bc1782470f3b3f19617230005a5594a5cca Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* ProjectExplorer: Rename IncludePathType to HeaderPathTypeTobias Hunger2018-09-131-2/+2
| | | | | | | | | | | | | It is the type used by the HeaderPath class, so reflect that in the name. I also considered to rename HeaderPath to IncludePath, but that name is reflected in a lot of users, which would also need to be adjusted for consistency. That would blow up the patch size for little value IMHO. Change-Id: I51421dbd3ab8b2874dc32fc82dc394c9b93ce5e9 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Add system include path to HeaderPath and merge ProjectPartHeaderPathMarco Bubke2018-09-101-19/+18
| | | | | | | | | | | | | System include paths are appended after other includes by the compiler. So we should set them as system includes and not as normal includes. Otherwise we change the include order. Headers in system include paths are not cluttering the screen with unwanted warning and by the way improve performance too. ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them. Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
* CppEditor: Do not add QuickFixFactories to object pool anymorehjk2018-02-021-0/+1
| | | | | | | | | Not needed anymore. Also some cleanup, no 'using' in headers etc. Change-Id: I8c4547d80d0c0ffd989d1efbc74687c9f56096a4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: split CppEditor and CppEditorWidgetIvan Donchevskii2017-09-121-0/+2
| | | | | Change-Id: Id3c815184f7f3bace0276e947f6b6f76e61ec6de Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Fix quickfix for adding include for static functionsPrzemyslaw Gorszkowski2017-06-231-1/+31
| | | | | | Task-number: QTCREATORBUG-14499 Change-Id: Id3e962ed310f43c33b91c7834a1f9ca074519a38 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Fix InsertQtPropertyMembers testNikolai Kosjar2017-02-271-1/+1
| | | | | | | | | | Broken by commit d6e81eb49ec48645b1f78517521f8ac572db9d6a CppEditor: Emit member variable for qproperty refactoring Change-Id: I5e86f0fb1942a497c4242b6f1890e74eb55b687c Reviewed-by: David Schulz <david.schulz@qt.io>
* Replace a few occurrences of QStringList() << ...hjk2017-02-081-1/+1
| | | | | | | ... by something shorter. Change-Id: I363b4e509adb07997517b2d233246a333aea4aea Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Compile fix after 3b1308bbhjk2016-11-181-1/+1
| | | | | Change-Id: I55f8f175e8cd49b455b94872770a7bd02baa7492 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CppEditor: Fix GenerateGetterSetter for reference typesLorenz Haas2016-10-311-0/+60
| | | | | | Change-Id: Iad332cf023c6bff0c7f5ae46fb56f0393c9c7b29 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Add enclosing template on "Move Definition Outside"Orgad Shaneh2016-09-061-2/+2
| | | | | | | | | | | | | | | | | | | | | The template id for the class name is missing, but it's better than nothing. For example: template<class T> class Foo { void func() {} // Move Definition Outside Class }; // The following lines are added template<class T> void Foo::func() {} // Should be Foo<T>::func Task-number: QTCREATORBUG-16649 Change-Id: Icb560e0b87f563cbda18f4742f44bb8ef4d8a900 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Add enclosing template on "Add Definition"Orgad Shaneh2016-09-061-0/+50
| | | | | | | | | | | | | | | | | | | | | | The template id for the class name is missing, but it's better than nothing. For example: template<class T> class Foo { void func(); // Add Definition }; // The following lines are added template<class T> void Foo::func() // Should be Foo<T>::func { } Change-Id: I60a0cbd348985def3dfb7037067786e942278593 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Add template enclosing scope on "Insert Declaration"Orgad Shaneh2016-08-191-0/+50
| | | | | Change-Id: Iff4893193b56c2ed86b4b9515a1a1df847528369 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Prevent "Add Declaration" for existing template functionsOrgad Shaneh2016-08-191-0/+16
| | | | | | | | | | | | | | class Foo { template<class T> void func(); }; template<class T> void Foo::func() {} // Add Declaration should not be triggered at all Change-Id: Ifff733d8381177300dae017ae419200cfdf5c425 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Fix "Move Definition to Class" for template member functionsOrgad Shaneh2016-08-191-0/+23
| | | | | | | | | | | | | | | | class Foo { template<class T> void func(); }; template<class T> void Foo::func() {} // Move to class It currently doesn't trigger at all. Change-Id: I63d561771a8dd455f01e99dd836abbd23eec71b7 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Fix "Move Definition to Class" for function in template classOrgad Shaneh2016-08-191-0/+17
| | | | | | | | | | | | | | | | | | | | | | template<class T> class Foo { void func(); }; template<class T> void Foo<T>::func() {} // Move to class Prior to this change, this currently leaves behind `template<class T>` where the definition used to be: template<class T> class Foo { void func() {} }; template<class T> Task-number: QTCREATORBUG-14354 Change-Id: I8e1f75a3ae50619a7bae9c63d3798b16bcfea545 Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de> Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppEditor: Add a failing test for move outside class with templateOrgad Shaneh2016-07-221-0/+17
| | | | | | Task-number: QTCREATORBUG-16649 Change-Id: I29c42c23f4dc44b0401fb07c0dc6d0008dcaf096 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppTools: Allow prefering getter names with "get" prefixNikolai Kosjar2016-06-221-0/+79
| | | | | | | | | We default to "foo()" for e.g. a member variable "m_foo", but other coding styles require "getFoo()". Task-number: QTCREATORBUG-16452 Change-Id: I9ccfdf88e4c469bc1c06fde855ad754faf2bd238 Reviewed-by: André Hartmann <aha_1980@gmx.de>
* CppTools: fix metatype registration macro usageNikita Baryshnikov2016-03-241-2/+0
| | | | | | | | in places where we do not need it Change-Id: Ibf35f8144da859fffa3e0a7b6bb262284ec2292a Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* Update License according to agreement with Free Qt FoundationTobias Hunger2016-01-191-17/+12
| | | | | | | * Update files in src/plugins Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
* CppTools: Move ProjectPart in its own header fileMarco Bubke2016-01-131-18/+18
| | | | | | | | Also extracting inline HeaderPath class and change projects list in vector because the size is larger than a pointer. Change-Id: I885fdff3fe9bccc877634d1615249755f5b674fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CppEditor: Fix ConvertQt4Connect for different namespaceOrgad Shaneh2015-12-151-0/+33
| | | | | Change-Id: I152d7cda02bb034bf817eeeb4b467667e1188b2f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CppEditor: Add a failing test for add include for static functionOrgad Shaneh2015-08-211-0/+32
| | | | | | Task-number: QTCREATORBUG-14499 Change-Id: I21d4281a01028d8c4cd5462d64da6428133219a4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
* CppEditor: Fix crash with invalid switch/case statementNikolai Kosjar2015-08-181-0/+15
| | | | | | | Task-number: QTCREATORBUG-14925 Change-Id: Iea2cf17070d9db48924e76f6c7febca0d52e4686 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: Do not let ASTPath calculate line/column for generated tokensNikolai Kosjar2015-07-311-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | ASTPath uses TranslationUnit::getPosition(), which returns reasonable results for: 1. non-expanded tokens 2. expanded but not generated tokens The expanded *and* generated tokens case is not handled since there is no reasonable mapping from generated tokens to a continuous line/column information. Consider: #define DECLARE_FOO int foo; // Multiple generated tokens DECLARE_FOO // ...can be mapped to this line, but to which columns? Since the result where not valid for the expanded and generated case, ASTPath took the wrong branches. Avoid this by skipping generated tokens. Change-Id: I33a2e0f62917f87d691b19feaeef67b09ea8d563 Task-number: QTCREATORBUG-13386 Task-number: QTCREATORBUG-13390 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* CppEditor: Add a failing test for ConvertToPointer with macroOrgad Shaneh2015-07-281-0/+18
| | | | | | Task-number: QTCREATORBUG-14801 Change-Id: Ie34b131de4e6f701aeac29567a09be54e2e63bd8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>