Commit Graph

2772 Commits

Author SHA1 Message Date
Christian Kandeler
485bcc4b61 ClangCodeModel: Change default set of warnings
... to "warnings from build system".
It seems appropriate to respect the project settings by default.

Change-Id: I397c252409a012f4663f3752c5c097fa0e658da4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-19 16:09:37 +00:00
Christian Kandeler
d3deefc3a4 Core: Streamline SearchResultWindow interface
That is, make SearchResultItem the one data type for adding search
results.
This will allow us to add additional properties to search results
without adding more and more parameters to a bunch of functions.

Change-Id: Ic2740477ae47449cee75caa2525727fe2b460f91
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-18 16:46:08 +00:00
Jarek Kobus
d74edd2806 Remove unused includes of mutex classes
Change-Id: I5a34cda0b27786cb37e642479b11fbd24b8b5c36
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-02-18 07:02:07 +00:00
Christian Kandeler
7d4a632cb2 qbs build: Remove code for creating deployment packages
Not a use case anymore, and if it were, we'd do it using built-in
capabilities.

Change-Id: I4c588ad7fb282530880210cb4c5795677074b1e0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-17 16:11:49 +00:00
Alessandro Portale
72d91dc94a Use qAsConst with non-const Qt containers in range-loops
... in various places

Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:43:29 +00:00
Christian Kandeler
8dc4cb17c1 Designer: Re-use CppTools functionality
... for slot insertion logic.

Fixes: QTCREATORBUG-8220
Change-Id: I3516a62d62174b64d557c82ce38a9cc334790efc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-12 14:16:14 +00:00
Jarek Kobus
6a2088d8ec Provide empty implementation for ILocatorFilter::refresh()
Make this method just virtual, not a pure virtual.
Remove all empty reimplementations of this method.

Change-Id: Idf10e492355e8519172facd421ea0b2b13ce3b80
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-11 13:32:30 +00:00
Christian Kandeler
5f5f38e028 ClangCodeModel: Support "parentheses" matching for ternary operator
That is, show which ":" belongs to which "?" when the cursor is on one
of them.

Fixes: QTCREATORBUG-1410
Change-Id: Ie19360b3dfc82d92c264d99a5aa1864eda66e5c8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-11 08:52:17 +00:00
Christian Kandeler
058841e8de Locator: Enable to show C++ type aliases
These were not showing up in any global symbol list so far.

Fixes: QTCREATORBUG-5800
Change-Id: I8e5c3b9b26f09d8cbcd31431e28c103da05d9bf8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-09 10:00:56 +00:00
Christian Kandeler
33d2d736ea CppEditor: Do not add redundant access specifier
... when inserting a member function declaration for a definition.

Fixes: QTCREATORBUG-5591
Change-Id: Ie85b435a1595832d0085abdcc0a4187d939820e0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-08 15:19:31 +00:00
Christian Kandeler
aec6126634 CppTools: Add dedicated filter option for declarations
... to the "Find Usages" result widget.

Fixes: QTCREATORBUG-25302
Change-Id: If957cbffe55f6f9288ceae9d64847e8a4a367765
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-02-05 16:55:06 +00:00
Christian Kandeler
1e3f970181 CppTools: Fix unit test
Amends 84865016ea.

Change-Id: Ia815152d2c19b17b1d11dd5c82fd7a74d0ac03cb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-05 14:12:56 +00:00
Christian Kandeler
3d1b456dab CppTools: Fix parentheses mismatch
... when the ClangCodeModel is disabled.
The built-in highlighter's use of HighlightingResult::kind conflicted
with the ClangCodeModel's.
Amends d8c1e51bfe.

Change-Id: I79784679fd17d88cd543304de726f8576954b29c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-05 08:51:31 +00:00
Christian Kandeler
84865016ea Locator: Use extra info as secondary sorting criterion for C++
... classes and functions.
The extra info is usually the scope or the file, so this effectively adds
some helpful grouping.

Fixes: QTCREATORBUG-2538
Change-Id: I2404fee1df88fc51871a72db0dcc9c75d6ba6dcb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-04 16:20:55 +00:00
Eike Ziller
cb96b91dd4 Refactor Locator filter settings saving
Unify setting saving. Do not write settings that stay at the default, so
defaults could change and take effect.

For this we explicitly differentiate between default and user settings.
Make QJsonDocument the basis for saving settings, because QDataStream
cannot really handle structured data where parts could be missing.

Write locator settings to a different settings group, so we do not
destroy reading older settings from older Qt Creator versions.

Task-number: QTCREATORBUG-24762
Change-Id: I5909e2d79313f6fc26159bb644fdfb43781b6c38
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-04 07:33:10 +00:00
Jarek Kobus
8731325ce8 Use invokeMethod instead of single shot timer with 0 timeout
Change-Id: I3ffc4bfdbc6fc58d4b90aa53427eb80653c22b65
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-02 08:15:36 +00:00
Jarek Kobus
59718d7c4e Check if the document ptr is not null
Avoid a crash when double click in hierarchy view
after the session has been changed or when the filename
changed.

Change-Id: Iebd7a99c220737262c79ade43c4ee8d11dcc037f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-27 11:17:33 +00:00
Christian Stenger
9acde4f261 Fix a couple of cmake issues for testing
Correct expected paths, defines and dependencies.

Change-Id: Iae3fa708957e352012d0a6bb9cf97713b9a5c35e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-27 10:52:39 +00:00
Christian Kandeler
e735e95f06 "New Class" wizard: Check custom base class for QObject parent
That is, if the user specifies a custom base class, we check whether its
constructor takes a "QObject *parent" parameter, and if it does, we give
the derived class one as well.
This is technically a heuristic, but the pattern is pretty stable in the
Qt world.

Fixes: QTCREATORBUG-25156
Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-25 08:58:24 +00:00
Christian Kandeler
d8c1e51bfe ClangCodeModel: Support highlighting angle brackets
... in template declarations and instantiations.

Fixes: QTCREATORBUG-16799
Change-Id: I82bc6411ca980ecbe2a6c70ae37580166a4b89e9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-22 10:48:33 +00:00
Eike Ziller
8112a00432 Cpp: Use new settings API
Avoid writing defaults to the settings.

Task-number: QTCREATORBUG-24430
Change-Id: I8e1d5a5b8ca21ef96a68a4d71a7d97d138bd186b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-22 09:37:12 +00:00
Christian Kandeler
f3d7717b31 Core: Add infrastructure to do additional filtering on search results
... and make use of it to let users filter C++ "find references" results
by access type.

Fixes: QTCREATORBUG-19373
Change-Id: Ib5cadde1cfd235026d8e69da51daa6374808d3f3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-21 09:19:13 +00:00
Christian Kandeler
fd22787a69 CppTools: Do not wait for QFuture in ~BuiltinEditorDocumentProcessor()
This seems safe, as the arguments to the async function that the future
results from are values and shared pointers, so there does not appear to
be a need for this object to stay around while it finishes.

Fixes: QTCREATORBUG-25121
Change-Id: Ib498551856942bf7c3d05c3013e12ad6d90fd762
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-14 09:54:22 +00:00
Cristian Adam
98b92ed03e CMakeProjectManager: Fix issues with precompiled headers
Clang code model can break if CMake project uses precompiled headers.

QtCreator will make a copy of the precompiled header, this way it
will not conflict with the build system one.

Ammends 888ea6bbbb

Fixes: QTCREATORBUG-24945
Fixes: QTCREATORBUG-25213
Change-Id: I149fc416cd047683d095758a024de47c7baf681c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-14 08:08:40 +00:00
Jarek Kobus
0e7774e75d Refactor CppElementEvaluator
Separate the use of CppElementEvaluator for CppHoverHandler from
the use for CppTypeHierarchyWidget. They are in fact much
different things.

Fix CppHoverHandler (enabled when ClangCodeModel plugin is disabled)
showing tooltips for symbols other than class or template.
Fix CppHoverHandler showing full template arguments for typedefs.

Change-Id: I5c44016014749d0d958b91a9a1ee9b35d3ea5eaa
Reviewed-by: hjk <hjk@qt.io>
2021-01-13 07:13:27 +00:00
Jarek Kobus
661193f67b Show type hierarchy also for typedefs
Make it possible to show type hierarchy for
typedefs and unsings. Before, no type hierarchy
was shown.

Change-Id: I63ffa9c544072d66c42de8edf306c898d2fa90cb
Reviewed-by: hjk <hjk@qt.io>
2021-01-13 07:13:13 +00:00
Leander Schulten
c960f279e6 CppEditor: Add QuickFix to generate a constructor
Change-Id: Iba2ce3bfa1a1d1a325626a21f46b485d12cbb060
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-11 14:59:40 +00:00
Jarek Kobus
9462102245 Add cache to hierarchy visitor, fix following typedefs and usings
In case we already visited the same base class symbol in the same
scope we already know the fully qualified name for base class,
so no need to search it again. We store all visited symbols
with their scopes in cache. This speeds up building type hierarchy,
especially for large trees, like for creator project and showing
type hierarchy for QObject: build time before this change was
about 300 sec, now it's about 130 sec.

Sometimes the old code didn't follow properly base classes
that were typedefs to other classes (like in creator project:
Debugger::Internal::RegisterHandler is derived from RegisterModel,
and RegisterModel is a typedef to Utils::TreeModel). This caused
that some subclasses were omitted form resulting type hierarchy.
E.g. type hierarchy in creator project for QObject lacked
about 8 subclasses.

Change-Id: I03c5aef65b7d7cb0ed279d3558aebc8a55e856b4
Reviewed-by: hjk <hjk@qt.io>
2021-01-07 14:58:19 +00:00
Jarek Kobus
167651b537 Properly annotate templates with full scope in type hierarchy
Fix activation of template classes.

Change-Id: I811f505c1c01fa95d74847cb91dd1cf37476534b
Reviewed-by: hjk <hjk@qt.io>
2021-01-07 14:58:14 +00:00
Christian Stenger
f70e7e6c99 CppTools: Fix compile with Qt5.14 on Linux / macOS
Amends 1a09f816a3.

Change-Id: I76d7eb184504082ad5916bf3b54549e5b2872aef
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-07 06:19:23 +00:00
Christian Kandeler
1a09f816a3 ClangTools: Support clang-tidy check options
Fixes: QTCREATORBUG-24977
Change-Id: I33ea247ba98788245ae1264262f60d084b73778c
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-01-06 12:39:41 +00:00
Eike Ziller
45c2634166 Merge remote-tracking branch 'origin/4.14'
Change-Id: I62523c4733e617c46131048f5f62a2ca9be47d80
2021-01-06 08:42:15 +01:00
Christian Kandeler
d203032504 ClangTools: Re-add clang's own include path
Amends ef05f29940.

Fixes: QTCREATORBUG-25126
Change-Id: I1340916f3f3488b0d1171f04ae1c9f30149c0c5c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-05 12:57:56 +00:00
Jarek Kobus
353edf35e5 Remove unneeded include
Change-Id: Ia2d5482a15be28c3c8a3d63ba5c73a081e6ae571
Reviewed-by: hjk <hjk@qt.io>
2021-01-05 11:40:19 +00:00
Jarek Kobus
72f850df3a Open type hierarchy from Type Hierarchy editor
Make it possible to open type hierarchy for different
class selected from Type Hierarchy editor.
Make it available under context menu or on double click
on class name (single click opens the class in cpp editor window
as before). Double click doesn't expand / collapse items anymore
(expanding available when pressing the visual arrow).
Make navigation to editor more up to date - e.g. when linked location
changed in meantime (source file was edited), it tries to find
linked symbol quickly again (we introduce a small delay, up to
100-200 ms, depending on source file).

Change-Id: Ifb4fd58e853589a17cd14be465b3a7695fa48193
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2021-01-04 13:58:47 +00:00
Cristian Adam
5271a5c782 Utils: Add Qt6 to QtVersion enum
Change-Id: Idb00fde1459d00caaf263a21eecb96e6f6bd6fd9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-12-23 11:12:56 +00:00
Jarek Kobus
4654550ff4 Store path as FilePath instead of QString
This avoids conversions from FilePath to QString and
vice versa.

Change-Id: Ic0f610a9e90c206ff9557df6f46854e4805ce42f
Reviewed-by: hjk <hjk@qt.io>
2020-12-18 07:38:29 +00:00
Jarek Kobus
c732014821 A - (A - (B + 1)) = B + 1
Change-Id: I6ce320c0fd3958c1fef98b322bec8dbded2232cf
Reviewed-by: hjk <hjk@qt.io>
2020-12-18 07:35:18 +00:00
Jarek Kobus
265ee14c89 Make buildDerivedTypeHierarchy() a static method
Drop CppTools namespace when being in this namespace.
Move a call to filesDependingOn() into buildDerived().
Make filesDependingOn() a static method.

Change-Id: I6139f87597286bddf8298b06f8cf492066c8bedd
Reviewed-by: hjk <hjk@qt.io>
2020-12-17 11:07:06 +00:00
Eike Ziller
eaefcbd8f0 Use new, more evocative MessageManager API
At various places where semantics doesn't change.

Change-Id: Ib4d4a5c9f067e109126c6de88257f9e198a71447
Reviewed-by: hjk <hjk@qt.io>
2020-12-16 09:30:44 +00:00
Jarek Kobus
82b2735da4 Don't leak memory when canceling Type Hierarchy
Add QFutureSynchronizer for collecting all running
futures (including those already canceled, but not finished yet).
It could happen, that we cancel the future, while
the associated task still needs some time in order
to catch the cancel request. When a d'tor of synchronizer
is run it cancels and waits for all pending futures
to be finished.

Add extra check for isCanceled() after a call to
updateDependencyTable(). In case the cancel was detected
inside updateDependencyTable(), we should return immediately.

Don't leak CppClass object inside handleLookupItemMatch()
when the task was canceled.

Amends: c400923308

Change-Id: I709e14a0c8b563d522a8e8c32b087e5f83310b24
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-12-10 12:44:49 +00:00
Jarek Kobus
a0079b171f Make canceling of Type Hierarchy evaluation more responsive
On the beginning of the process of evaluating type hierarchy
the evaluating thread may freeze on a first call to
Snapshot::updateDependencyTable() for quite a long time
(e.g. when showing the type hierarchy for IPlugin class
inside Creator project - it may freeze up to about 3 seconds).
So, when we want to cancel the evaluation (e.g. when
we switch from "Type Hierarchy" into another view or when
closing Creator) we may freeze for this period. In order to
fix it we pass a future interface as an additional argument
for Snapshot::updateDependencyTable() and cancel the update
when cancellation of task was requested.

Change-Id: I2147f10a68989587476c30369ec2ac552a57d5ae
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-12-07 16:24:57 +00:00
Jarek Kobus
c400923308 Modernize Type Hierarchy
Don't freeze UI on request for show Type Hierarchy.
Move the lookup code into a separate thread.
Don't clear tree hierarchy when waiting for new one.
Show progress indicator on top of old hierarchy instead.
Add a task to ProgressManager when working on a new hierarchy.
Handle canceling the process of showing Type Hierarchy.
Implement simple progress reporting for this process.
Optimize a bit DerivedHierarchyVisitor.

Change-Id: I3894ac6ed3f4834831831f083f718f8385ca346f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-12-07 14:04:50 +00:00
Eike Ziller
d02afbe6b4 Merge remote-tracking branch 'origin/4.14'
Conflicts:
	src/plugins/projectexplorer/gcctoolchain.cpp

Change-Id: I2136ba89d3aa3c4c2a0e7a4f9d8ba9cec32924ce
2020-11-30 16:14:32 +01:00
Jarek Kobus
448cdb7bb5 Fix a crash when editing cpp file
std::mismach() overload taking 3 arg assumes, that
second string is at least as long as the first one.
We don't guarantee this, as somethimes filePath2 is
empty string. Use 4 arg overload instead, which
ensure we don't exceed the valid range.

Fixes: QTCREATORBUG-24970
Change-Id: I8b7b11d124f69c7c9cb3246ee969f134fa026e08
Reviewed-by: hjk <hjk@qt.io>
2020-11-30 12:43:54 +00:00
Christian Kandeler
370804c2ab CppTools: Work around problems with our definition of __FUNCSIG__
This basically extends the existing hack to cover one more case. It may
very well break again in some other context, in which case we will
remove the custom definitions entirely, as the reason they exist in the
first place does not seem terribly relevant.

Fixes: QTCREATORBUG-24580
Change-Id: I757ac23682c81c647a5d968fa549baac5716010c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-27 13:46:45 +00:00
Alessandro Portale
a3857a996a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Amends: b2a766a79a

Round #2: This time done with Qt Creator's Analyzer, which
found other occurences than run-clang-tidy.py

Change-Id: I479e280c7abcf2d24baccbb0af69ae4bda05198e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-27 13:26:07 +00:00
Christian Kandeler
ef05f29940 ClangTools: Use built-in header paths again
This was broken in 7b6ab79f3e.

Change-Id: I037474ecce62bfebfe167d8dce15a6e7dbf7a001
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-27 09:04:41 +00:00
Christian Kandeler
d3fafcde0f CppEditor: Support decl/def switch for conversion operators
Fixes: QTCREATORBUG-21168
Change-Id: I515fe146a679e007c96fa8d23f1457dadf07db3c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 10:07:20 +00:00
Eike Ziller
5ca70bdcb3 Merge remote-tracking branch 'origin/4.14'
Change-Id: Iea84f23cf394de13e99a9ed777c8c113e4eff473
2020-11-19 15:38:13 +01:00