Commit Graph

2674 Commits

Author SHA1 Message Date
Christian Kandeler
d65ef60ea2 clang: Fix include/resource dir confusion
The getClangResourceDirAndVersion() function in ClangTools could return
the actual resource dir or the include dir, depending on the input. This
mistake happened because of misleading names spread all around the code.
Now the function returns what it says, and the other names are accurate
as well.

Change-Id: I0a8600857ee7b9fafb16256e0d1ad203ac3273d2
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-24 10:18:30 +00:00
Christian Kandeler
f852cfe284 CppEditor: Skip over access specifier when inserting a doxygen comment
That is, also do function-specific magic on typing "/**<return>" in front
of a function if there is an access specifier such as "public:" in
between.
This use case is rather weird, but it's also pretty easy to support and
it should not hurt anyone.
Note that depending on the indentation of the access specifier, the
indentation of the inserted comment will probably not be what the user
expects, but this is not easily fixable.

Fixes: QTCREATORBUG-20311
Change-Id: Ie32a71eede91ef64a19381c8e379a183a91fd27d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-21 12:23:18 +00:00
Miklos Marton
3299239095 C++ Refactoring: Fix the include macros in header files after renaming
Fixes: QTCREATORBUG-4686
Change-Id: If22078bb183910941d8e2a94b0e8629baa2fa8de
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-08-21 06:50:42 +00:00
Christian Kandeler
86728b84f1 CppEditor: Properly handle multiple inheritance
... in "Insert Virtual Functions" quickfix.

Fixes: QTCREATORBUG-12223
Change-Id: I7dad7c219017a8c7b10b08190e35d1899ca5dfe6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-20 10:34:53 +00:00
Christian Kandeler
ddf7f5f232 CppTools: Do not indent within string literals
Multi-line strings must be kept as the user wrote them.

Fixes: QTCREATORBUG-20180
Change-Id: I141eff52b55d31215e6f5c6c5a0e026689db877a
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-20 08:10:22 +00:00
Christian Kandeler
414561e4cc CppTools: More consistent fuzzy matching behavior
There were annoying inconsistencies, for instance:
    - A not fully matching declaration was found from the definition,
      but not vice versa.
    - An implementation MyClass::foo(int) would fall back to a
      declaration foo(), but an implementation MyClass::foo() would
      not fall back to a declaration foo(int).
These cases behave consistently now. To this end, the clang code model
now forwards to the built-in code model if a function lookup has failed.

Fuzzy matching for free functions has been limited, as the cons appear
to outweigh the pros. For instance:
    void foo(int);
    void foo(double) {}
Following the definition would lead to the non-matching declaration,
which the user most likely does not want.

As a side effect, redundant code has been removed in the SymbolFinder
class.

Fixes: QTCREATORBUG-20279
Change-Id: Ib97d6710c7e12fb0fdbc30b51a0067e09bfc2190
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-14 13:21:36 +00:00
Christian Kandeler
760d91665f TextEditor: Make threshold for automatic completion configurable
Fixes: QTCREATORBUG-19920
Change-Id: Id6be79485b1fb8c2ab4cce2706816949ae5e217b
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-13 13:49:44 +00:00
Christian Kandeler
7938320291 TextEditor: Introduce shortcut for forcing a function hint proposal
... and support it in the ClangCodeModel.
This allows users to get function signature(s) displayed regardless of
where exactly the cursor is on the function call.

Fixes: QTCREATORBUG-19394
Change-Id: I033e8774db93680bfc3ee52610b817e0ef8ccc76
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-11 10:10:08 +00:00
Eike Ziller
3944162039 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/cmakeprojectmanager/cmakebuildstep.cpp
	src/plugins/cmakeprojectmanager/cmakebuildstep.h
	tests/auto/debugger/tst_namedemangler.cpp
	tests/auto/qml/codemodel/check/tst_check.cpp

Change-Id: Iefd5f71c03c0078513b76a92af764a4fb22ee4c2
2020-08-10 15:56:54 +02:00
hjk
52b2ca55c9 Replace QT_USE_FAST_{OPERATOR_PLUS,CONCATENTION} by QT_USE_QSTRINGBUILDER
QT_USE_FAST_CONCATENATION doesn't do anything nowadays.

Using QT_USE_QSTRINGBUILDER is the same as QT_USE_FAST_OPERATOR_PLUS
for QStrings and enables more QStringBuilder use for QByteArrays.

Change-Id: Ibd297817c50d86661d47822799f989447249af1b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-08-07 12:45:03 +00:00
Christian Kandeler
89eb33dd67 CppTools: Use consistent sorting in the two outlines
Use case-sensitive sorting in the side bar outline, just like in
the editor outline.

Fixes: QTCREATORBUG-12714
Change-Id: I9d8243c61fcceb6e3d7b55e3b27fa5d20accccea
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-06 14:04:57 +00:00
Christian Kandeler
3f9427200b CppTools: Fix formatting for lambdas with trailing return type
After the arrow, the state is still the same, as now a type is expected.
Only after the opening brace does the actual function start.

Fixes: QTCREATORBUG-18497
Change-Id: I7bf18fbd6907d36f8869af3a78ad617cf0ee9dbb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-31 08:15:18 +00:00
Christian Kandeler
77d13f08ba CppEditor: Let users create implementations for all member functions
... in one go.

Fixes: QTCREATORBUG-12164
Change-Id: Ifc81c8b1caf4319ce57882375f513d72e4c0ea52
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-29 11:56:07 +00:00
Alessandro Portale
6c45c3fb1c CppTools: Bump TIDY_DOCUMENTATION_URL_TEMPLATE from 8.0.1 to 10.0.0
Change-Id: I198f805768984eb060b2a72f705e618e6a7a53ff
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-07-28 19:37:51 +00:00
Leander Schulten
755659e663 CppTools: Prevent SegFault in the ClangFormatIndenter
If you create a ClangFormatIndenter but do not set the
fileName, the indenter will SegFault while indenting.

Change-Id: I93a56d7916bc1a02da9ee21a116bd48b4405edb1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-28 14:17:54 +00:00
hjk
43b658e9e7 Utils: Drop Utils::SkipEmptyParts again
We require Qt 5.14 nowadays.

Change-Id: Iff245257d3cb19207007c0445ee13814e66152dd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 12:42:27 +00:00
Christian Kandeler
c41847ce5d CppEditor: Find implementations for pure virtual declaration
Clearly, if a user presses F2 on the declaration of an (unimplemented)
pure virtual function, they want to go to an implementation in a derived
class.

Fixes: QTCREATORBUG-10160
Change-Id: Ie8c4ff0001ab2c98a2d0e2ebc8d954cc928578c0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 10:13:43 +00:00
Christian Kandeler
45dd017853 Wizards: Offer auto-completion in "New C++ Class" wizard
That is, offer existing namespaces for the class name line edit and
existing classes for the base class line edit.

Fixes: QTCREATORBUG-10066
Change-Id: I276036864626eff92997e40e4e22ab16c4f4d617
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 10:11:37 +00:00
Christian Kandeler
f905fcea71 Wizards: Fix function parameter type in CppToolsJsExtension
We did not notice because the JS array was auto-converted into a string.
Amends bcc2b5e08d.

Change-Id: I06ee43f78cb3081bdff0a02f8d446326a01bc2d1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-17 07:46:08 +00:00
hjk
9b0b86297e CppTools: Qt6: Drop use of QTextStream::setEncoding from CppFileSettings
This now requires license templates file to be Unicode compatible,
effectively restricting it to plain ASCII in non-Unicode codebases.

Task-number: QTCREATORBUG-24098
Change-Id: I713fed1ddb288360abbdbb40c6ca67444eb62ef3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-17 07:33:48 +00:00
Leander Schulten
d51a419458 CppTools: Use indenter from TextDocument or create one
So if you use the ClangFormat Plugin, the ClangFormatIndenter is used
and not the CppQtStyleIndenter.

Change-Id: I7e71867cd4b48525ddc2f9b2dce8f13a65c3ad88
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-07-14 09:03:17 +00:00
Christian Stenger
7598018a7f CppEditor:CppTools: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098
Change-Id: Id1804a31162d0239659de33c1700354494c11689
Reviewed-by: hjk <hjk@qt.io>
2020-07-13 12:09:15 +00:00
Christian Kandeler
782ca5d8d8 Clang: Fix error when including float.h with mingw
Prevent mingw from trying to #include_next a private header from a path
we cannot add to our list of includes.

Fixes: QTCREATORBUG-24251
Task-number: QTCREATORBUG-24027
Change-Id: I18a9db130b9c2265cd208c3506d08d2e1c4cee45
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-07-09 17:24:16 +00:00
Christian Kandeler
8bd6453d76 CppTools: Fix warning about fall-through
Change-Id: I6984265c4678b70e2684908b144560b6fbd542dd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-06 14:11:02 +00:00
hjk
e1c88116b3 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
(cherry picked from commit 430a33dcd9)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-06 11:15:18 +00:00
Christian Kandeler
b9413bcec7 Cpp: Fix leaks in ClangCodeModel tests
Change-Id: I19d4dc445d82fd24361f1eb752d9f35ccadd3efb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-19 11:19:42 +00:00
Christian Kandeler
a0764603d0 CppTools: Also look up definitions for variables
... not just functions.
This includes global variables and static members.

Fixes: QTCREATORBUG-18828
Change-Id: Iee9f83a4f955a859c6fc4038c61997b30afdaec8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-18 12:02:00 +00:00
hjk
1c81a3b3e8 All: Use Utils::SkipEmptyParts
Task-number: QTCREATORBUG-24098
Change-Id: Iab45de9a9c17ddc39a0e343b1175d4f6cb94b098
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-17 05:55:25 +00:00
Christian Stenger
6e798401a0 Fix plugin unit tests when using projects
The ClangTools and the AutoTest plugins use an internal
mechanism to load and configure a project when performing
their integrated unit tests.
Both assumed to have exactly one kit present for these
tests.
Make it possible to have more kits present when starting
with existing settings or if more kits get automatically
generated when starting with clean settings.

Change-Id: If2bc66320c4854f1d34a19d17107e8f0b7d64d39
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-17 04:13:30 +00:00
Christian Kandeler
8a697cde64 Fix Qt 5.15 deprecation warnings for QString::SkipEmptyParts
Task-number: QTCREATORBUG-24098
Change-Id: I03ee6811df4346754bbd652f2c3c97477f9cdb7e
Reviewed-by: hjk <hjk@qt.io>
2020-06-16 16:00:22 +00:00
hjk
328c0cf809 CppTool: Avoid a use of QStringRef
Change-Id: I2a82bad7d91e059915526f0cf7b89f0d8367463a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-16 11:57:07 +00:00
hjk
361b80cb9b ExtensionSystem: Remove PluginSpec::isHiddenByDefault
Not used anymore.

Change-Id: Ic73ba3024b9e6157ff044cb23450fc9dad3c4c02
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-16 09:08:36 +00:00
Christian Kandeler
48be20cf48 Fix clang warnings about copies in range-for constructs
Change-Id: If50553964483626e72a816b1d23fa81b45ed9ca7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-06-15 12:38:17 +00:00
Alessandro Portale
0be309bcf1 Various places: performance-for-range-copy
Change-Id: I475990d32a5211d31a77782667a2dfedba134137
Reviewed-by: hjk <hjk@qt.io>
2020-06-15 05:58:46 +00:00
Christian Kandeler
02f2841a41 CppTools: Fix formatting for new-style function declaration
Fixes: QTCREATORBUG-23502
Change-Id: Ie80fe9aa77ffbf0b9ecc531841e78f2bd80de37e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 07:21:39 +00:00
Eike Ziller
aa2aa9bf2a Merge remote-tracking branch 'origin/4.12'
Change-Id: Id1c063ae716c3acf5e6201c15663637040aa9a35
2020-06-03 12:22:18 +02:00
Christian Kandeler
c5ce38f046 CppTools: Add missing serialization
... for ClangDiagnosticConfig::useBuildSystemWarnings().

Fixes: QTCREATORBUG-24084
Change-Id: Id06cc44f1aa690ea0ae5a808a3b8c95f83c62950
Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
2020-05-29 14:46:58 +00:00
Volodymyr Zibarov
9ee693ee22 C++: fix built-in code model to work with shared_ptr on MSVC 2017
These changes target Find Usages feature to work with shared_ptr.
Improve libs/3rdparty/cplusplus and plugins/cplusplus:
parse __declspec() attribute,
call to variadic function template without specified template arguments,
if constexpr,
c++11 attributes [[value]],
function templates with default parameters,
resolve order for function vs template with default parameter,
template operator->() with default arguments,
template specialization with numeric values,
find best partial specialization,
fix partial specialization for non-first specialized argument

Fixes: QTCREATORBUG-7866
Fixes: QTCREATORBUG-20781
Fixes: QTCREATORBUG-22857
Fixes: QTCREATORBUG-17825
Change-Id: I31a080f7729edfb2ee9650f1aff48daeba5a673b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
2020-05-29 12:39:28 +00:00
Nikolai Kosjar
9dafc323b5 CppTools/ClangTools: Fix saving diagnostic configs for code model
As ClangDiagnosticConfig() has tidy and clazy enabled by default now,
the ClangTools' importDiagnosticConfigsFromCodeModel() takes diagnostic
configs on start up away from CppCodeModelSettings.

Ensure that built-in configs do not have tidy/clazy enabled by default.
Also, when importing, look at the actually enabled checks.

Fixes: QTCREATORBUG-23717
Change-Id: Id8370ae2fff2392fc94aa957fd33c1954aff5594
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-05-28 09:20:06 +00:00
Christian Kandeler
949bb0e67b ClangCodeModel: Show value in tool tips, if possible
When hovering over a constant expression, it's probably helpful
to show that value to the user.
Requires clang 11 to fully work. For now, it only shows the value for
variable initializations.

Fixes: QTCREATORBUG-23967
Change-Id: I6b844231bac50993c2fa2fa82c552ad9cef590df
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-26 08:50:58 +00:00
Eike Ziller
227904d4a6 Merge remote-tracking branch 'origin/4.12'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: Ic39945a0e3e140a9467b4b4f572929257ff3a324
2020-05-26 09:00:05 +02:00
Christian Kandeler
4ecb87f2f9 C++: Do not mis-align function arguments that are initializer lists
Fixes: QTCREATORBUG-24035
Change-Id: I93598ff64fc6fd74008c942b8755da5e481c63c7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-25 09:22:30 +00:00
Christian Kandeler
d4c31cef74 C++: Fix wrong formatting
... when using a shift operator inside an initializer list.

Fixes: QTCREATORBUG-16977
Change-Id: I8992162c05345b713c665e3601ae593af5007211
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2020-05-25 08:54:47 +00:00
hjk
036e8611eb CppTools: Fix license file path persistence
Broke with ea6da69e8.

Fixes: QTCREATORBUG-24024
Change-Id: If097c4bc824c1a6b6c005bcf32aef09229804be2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-05-22 08:49:44 +00:00
David Schulz
309702d945 Find: Add additional replace widget setter
Allows adding arbitrary widgets in front of the replace button

Change-Id: I0a9a16ca1e06c217639f458dd7946db8a43f98b1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-05-19 09:16:27 +00:00
Eike Ziller
20ef5c6de3 Merge remote-tracking branch 'origin/4.12'
Change-Id: Ibbf9f16677a58bdcdd3ce63701ffa34db6f44916
2020-05-11 11:36:22 +02:00
Eike Ziller
fe1d758943 CppTools: Fix crash when loading pre 4.11 settings
If pre 4.11 settings are present, this might lead to updated settings
being written at startup.
The code that writes settings indirectly uses the CppToolsPluginPrivate
instance via the "d" member of CppToolsPlugin. So this code path crashes
if triggered in the constructor of CppToolsPluginPrivate, since at that
point "d" cannot be assigned yet. Separate construction and
initialization to avoid this.

Fixes: QTCREATORBUG-23916
Change-Id: I0cb8a08bd9aa051679b71b06f569c44d2faab5a8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-05-06 12:44:10 +00:00
Eike Ziller
e9661e43cb Merge remote-tracking branch 'origin/4.12'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp

Change-Id: If6963d1ef7b5a1ea6343f68c8e7ce6fb5f482f21
2020-04-28 15:48:36 +02:00
Leander Schulten
794f3a5f55 DoxygenGenerator: Ignore attributes in declarations
Otherwise the doxygen generation will not work.

Change-Id: I07889d84c179ec0ad931d9790f9270ebbd6d259d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-04-28 09:41:49 +00:00
hjk
68c539bb9d Utils: Replace FileChooser::path() by filePath().toString()
Keep the old method for now to ease downstream porting.

The change is kept mechanical, there's a lot of cleanup possible now
on the user code side.

Change-Id: I936baedd45b7ba057f1c789a1bec896886f48eff
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-04-09 17:45:06 +00:00