Commit Graph

3169 Commits

Author SHA1 Message Date
Christian Stenger
344ac9813d CMakePM: Fix crash in rstparser
Change-Id: I5a9e456214581800c977e69da01aab1053cc554f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-12 04:44:47 +00:00
Cristian Adam
c929b71acd CMakePM: Add cache variables to code completion
Change-Id: I5ac4fcf3ca7755ab52ffecafd83922e4e380363e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-10 18:29:06 +00:00
Cristian Adam
524634f124 CMakePM: Add support for "$ENV{" code completion and help
CMake has a few environment variables that are documented and this
commit adds support for them.

Change-Id: Iaa31bdc97b343581fcf519d19e66bc6ce8ace150
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-10 18:08:13 +00:00
Cristian Adam
afc6d555b3 CMakePM: Do not copy the PerformInputData structure
I needed to add more members to the structure, and will get static
analyser to complain that the number of bytes is to high.

Amends 3984108c0c

Change-Id: I162b9ef615dc7f6f76b08c5599eed24488bf7e88
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-10 10:04:14 +00:00
Marcus Tillmanns
f1c3482e0d CMake: Fix default cmake tool
If Boot2Qt devices are registered, their CMake tool would often end up
as the default. Instead now we only auto select a cmake tool on the
local machine.

Change-Id: I677ab06ae88ff36209e691ea0fadb356436e973c
Reviewed-by: hjk <hjk@qt.io>
2023-10-10 08:20:14 +00:00
Cristian Adam
45fb2c0986 CMakePM: Remove pointer check for null
The pointer contains the parent class passed with "this" and will never
be null.

Coverity-Id: 1568097 Dereference after null check (FORWARD_NULL)
Coverity-Id: 1568100 Uninitialized pointer field (UNINIT_CTOR)
Coverity-Id: 1568111 Dereference before null check (REVERSE_INULL)
Change-Id: I40e32d162689c749d498c4a63c073c0e336a3626
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-10-10 07:30:36 +00:00
Cristian Adam
a5f8214c23 CMakePM: Consider local CMAKE_PREFIX|MODULE_PATH for code completion
If projects are using a local "cmake" directory containing
Find<Package>.cmake modules the common practice is to use something like
this:

  ## Add paths to check for cmake modules:
  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

This commit makes sure that these packages are taken into consideration
for code completion.

Change-Id: I152ccce0c97ab2385eda93ff6bc5fc4e7cefb6c4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-09 14:41:45 +00:00
Cristian Adam
ad13144cc0 CMakePM: Search after packages in CMAKE_PREFIX|MODULE_PATH
This way code completion will have Qt6 package suggestions for
find_packages.

Change-Id: I9ab64425f850a0d990e77a559ce9f121bc9cf2d7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-09 14:41:35 +00:00
Jarek Kobus
d278923dd4 CMakeParser: Ensure the details list isn't empty
Amends bda5c6a228

Fixes: QTCREATORBUG-29732
Change-Id: Iac518227df42c4d22b808028958210485a9c02ff
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-09 12:15:22 +00:00
Cristian Adam
399e12c973 CMakePM: Fix crash in findLinkAt
Fixes: QTCREATORBUG-29715
Change-Id: I4db919c8858631beb573789d1888b3dbee606c50
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-09 10:26:10 +00:00
Cristian Adam
ad680902b2 CMakePM: Fix condition for filtering out non CMake parameters
Coverity-Id: 1515708
Change-Id: I97de84f4db79977d7833337be87ae4877c10136b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-09 10:25:43 +00:00
Cristian Adam
cbeeec2dc6 CMakePM: Fix Coverity issue "Arguments in wrong order"
Coverity-Id: 1526499
Change-Id: I4b5d7c4d12eca39b9c4e60b45ea3e67bce069069
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-10-09 09:14:40 +00:00
Jarek Kobus
3984108c0c CMakeFileCompletionAssist: Limit the size of PerformInputData
The size should drop down to 184 (from 264) bytes.

Amends 07e758147b

Change-Id: Ia07b153f3f75b9e7b6199d857d58bffbb7b3e7d4
Reviewed-by: hjk <hjk@qt.io>
2023-10-09 08:12:41 +00:00
Cristian Adam
1d2c942360 CMakePM: Only process cmake files for include and modules
... and not for every function. Just the CMake files.

Change-Id: I6e361f4913f8334942a3135adaa0480fdc0cee31
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-06 19:41:59 +00:00
Jarek Kobus
ee48dba19e FileApiReader: Make shutdown faster
Check more often for canceled future.

Make more functions static.

Fixes: QTCREATORBUG-27729
Change-Id: I8dd787acea6343008c7515fb6a4fdfde50b37aee
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-06 15:37:12 +00:00
Jarek Kobus
e4ae894c96 FileApiReader: Make stopping faster
On the session switch we are busy waiting for the running async task,
started before by the FileApiReader::endState(). This blocks the main
thread for considerable amount of time. E.g. when switching
between sessions both containing Qt project, it may block
the main thread up to 10 seconds.

Instead, we employ the future synchronizer and move the awaiting
to the shutdown phase.

The next patch is going to limit the awaiting in shutdown phase.

Task-number: QTCREATORBUG-27729
Change-Id: I956ed26edcd699d8a4e2b9309d109963f1d4bb20
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-06 15:37:06 +00:00
Cristian Adam
162f9f59d7 CMakePM: print newline before the message
This way we'll get:
  [cmake]
  [cmake] Elapsed time: 00:05.

And not the other way around.

Change-Id: Ica7352cd112b9017c8a39b98618be69494527be9
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-06 15:25:48 +00:00
Cristian Adam
9ab9c88e0a CMakePM: Include the last error/warning line from call stack
This was the first one reported by CMake, and we need to make sure it's
also included.

Change-Id: I5becfffc1afb35a4f69fd26d8563aa1ea6eaea60
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-05 16:23:41 +00:00
Cristian Adam
224b409013 CMakePM: Fix opening context help via F1 in hover tooltip
Change-Id: I9ebd6a6ec8e00c63bd6f9182ba8530944f3437ea
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-05 15:16:48 +00:00
Alessandro Portale
4d4bc2de7e CMakePM: Theme the CMake output prefix
Change-Id: Ic762867cb7249ae8f4e54e801dc5b6319f3f3e72
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-05 15:15:53 +00:00
Cristian Adam
16dfd2d374 CMakePM: Add "[cmake] " prefix to all output messages
With this one could easily filter the "[cmake] " messages from all the
messages in the "Generate Messages" pane.

Change-Id: I690650f0ccb0372c9361b95cfec41809737720d7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-05 15:15:32 +00:00
Cristian Adam
edf4280bd9 CMakePM: Support errors with call stack
This is usually the case when using a custom CMake API e.g.
qt_add_executable.

The topmost function is highlighting the error now, presenting the
callstack in the tooltip.

Change-Id: Ic8b8f60e8fe94d88dfa0b384639172370382a421
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-05 15:15:20 +00:00
Cristian Adam
bda5c6a228 CMakePM: Preserve newlines in multi-line error messages
This way the popup message is not spanning the whole screen.
Testable with find_package(Qt7 REQUIRED).

Change-Id: I3f1943b603baa02c55f2f8f63c75908468e69d9a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-05 09:59:39 +00:00
Cristian Adam
08cebc7e08 CMakePM: Fix crash when runing qtcreator -test CMakeProjectManager
Change-Id: I3535c1edd0c72eba3c1bcd50234baeb4c1acecc5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-05 09:25:48 +00:00
Cristian Adam
4875b25e31 CMakePM: Use the cmake logo for actions
Change-Id: Id19c8405e44218ad62da4d60b3d6eb71637033ad
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-04 15:15:24 +00:00
Cristian Adam
f81bf72924 CMakePM: Fix assert with non CMake projects
Amends 7028e27a81

Change-Id: I5d1e29abf19135aea8a401f2b971767f8a308c28
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-04 13:56:47 +00:00
Marcus Tillmanns
34fdac0d84 CMake: Improve remote parsing speed
To improve the speed of parsing the result of a remote
cmake call, we move the file fetching and parsing into a
mapped concurrent call.

We also first uniquify the list of files to remove duplicates.

Fixes: QTCREATORBUG-29618
Change-Id: I18108928ba3b5f4f8ec3d5610b216c5ccf060877
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-04 13:40:36 +00:00
Cristian Adam
7028e27a81 CMakePM: Add Debugger -> Start Debugging -> Start CMake Debugging
This is where the user would expect it.

It is an action, so the user can assign a keyboard shortcut if needed.

Change-Id: I4c6db3b1dafb5fb173a07c21d271715310a2b091
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2023-10-04 09:32:23 +00:00
Cristian Adam
298921be2d CMakePM: Do not show the same tooltip on mouse pointer change
Let's say you move the mouse left and right on the keyword, we shouldn't
flicker showing the same tooltip to the new position.

Change-Id: I45b69578d377384422535ce5f33f81bc916a42e2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-02 21:32:50 +00:00
Cristian Adam
3956d5b279 CMakePM: Remove caching of CMakeTool
No need to cache the value of the CMakeTool, since it causes issues with
the update mechanism.

Task-number: QTCREATORBUG-29683
Change-Id: Id5925b9a90d6010aa09b4a2f7b5ed3d447f5cd7a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-02 15:56:55 +00:00
Jarek Kobus
07e758147b CMakeFileCompletionAssist: Fix a crash on completion
Avoid calling not-thread safe functions from inside
the CMakeFileCompletionAssist::performAsync().

Move calling these functions before the asyncRun, collect
the needed data inside the PerformInputData structure
and pass it to the other thread instead.

Fixes: QTCREATORBUG-29683
Change-Id: I56127163a47339bc45d47f3a7d2c76d518b640f7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-10-02 15:47:51 +00:00
Cristian Adam
3705b4b609 CMakePM: Navigate to find_package CMake files
Fixes: QTCREATORBUG-25524
Change-Id: I6dc7dc1b2d0da06ceba0314438d3bd12467a3223
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-02 12:50:32 +00:00
Cristian Adam
762b0518a2 CMakePM: Handle include(CMakeFileWithoutSuffix) navigation
Check that the function operating upon is "include" and then match the
word under cursor with a file from the project.

Change-Id: Ia0131f08515c56582a1fb02a59d6b2e41ac04288
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-10-02 11:05:36 +00:00
Cristian Adam
15903ad17a CMakePM: Allow http(s) Url navigation
The CMake snippets do have comments with the origin of the snippet and
this patchset allows navigation to the url in question.

Change-Id: I6eb2565e8f7b9100a1cc19dbf8ccda430c698613
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-29 17:03:45 +00:00
Cristian Adam
7235e977ff CMakePM: Fix concurrent access crash
Change-Id: I9ea11619860d4066cb06dfd4a60def8208f21add
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-28 13:51:31 +00:00
Cristian Adam
776c8670d7 CMakePM: Handle project FindPackage package variables
For example find_package(ZLIB QUEIT) will result in the package
variables ZLIB_LIBRARY ZLIB_INCLUDE_DIR.

The variables are available for both code completion and navigation.

Change-Id: I4ea6090f44a980dc91632fcabbda16987b0f0285
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-28 10:49:56 +00:00
Cristian Adam
d08f1c6e94 CMakePM: Allow navigation to project targets
They were available via Ctrl-K and "cmo <target_name>". But they should
be working also in the text editor.

Change-Id: Iaad72b784485364776b67d6dfdef7ba73dd2df70
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-28 10:36:40 +00:00
Cristian Adam
d915e22adb CMakePM: Add imported targets to code completion / navigation
This allows e.g. Qt6::Core to be specified as argument for
target_link_libraries and navigation via F2.

Also fixes a bug introduced with
695952f84b which removed the project
specific features due to project being nullptr.

Change-Id: I5efa28c498d337e6bab564533a5445e6c364b26b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-28 10:36:29 +00:00
Cristian Adam
695952f84b CMakePM: Integrate RSTParser into hover help / code completion
Change-Id: I1618be1aff83e8164c53040bb2c7230bcc1ec8ee
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-27 14:14:43 +00:00
Cristian Adam
94d7c76d67 CMakePM: Add missing features to RSTParser
To be able to parse the rst help files from CMake

Change-Id: Ibec21e8571324276d2080f81728b1268581601d0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-27 14:14:31 +00:00
Alessandro Portale
4924e5afec CMakeProjectManager: Fix warnings
Change-Id: I190646684a1cadbcc1a5906642ed48e9dd84ed88
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-09-27 12:57:12 +00:00
Jarek Kobus
4e90ca1b59 CMakeToolManager: Add static readFirstParagraphs()
Reuse it in CMakeEditor and CMakeFileCompletionAssistProvider.

Amends d04585b519

Change-Id: I8dbd59c815e017404ff215ca1ff68740d6653e91
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-09-27 11:21:50 +00:00
Jarek Kobus
d04585b519 CMakeProjectManager: Remove unused arg
Make some methods static.

Amends 05614ab740

Change-Id: Ia72a95c0c3bf0acf7a94e1bac0a162db23aa0c77
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-09-27 08:17:19 +00:00
Cristian Adam
ec13beff1c CMakePM: Initial import of the RSTparser
Change-Id: I45bc3d53df3358c1f52ca219b53a1dec8e85a4ca
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-26 10:43:34 +00:00
Christian Stenger
658e2a3197 CMakePM: Fix build with Qt6.2
Change-Id: Iac128851da0aa7895d5c2352be550702fbc1e7f9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-09-26 07:49:03 +00:00
Cristian Adam
cd94514dbb CMakePM: Add hover help for CMakeEditor
Fixes: QTCREATORBUG-25780
Change-Id: I954023f701e6c1c6ca5e25190b37f8b9a8becfb5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-09-25 13:41:44 +00:00
Cristian Adam
05614ab740 CMakePM: Display help details for code completion
The first 1024 bytes from the CMake .rst files are displayed raw data.

A .rst to html or markdown would be needed for nicer user experience.

Change-Id: Ie6adbb404d844ae88b868b465d4125c2177e6cfe
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-25 13:41:34 +00:00
Cristian Adam
53b8f0e495 CMakePM: Speed up CMake introspection
By listing files instead of running cmake and asking CMake to provide
the information.

For properties and modules now the information is taken from the active
CMake version and not from the Syntax-highlighting file.

Change-Id: I0974cc816d990fd382d9e855eb08416b50d0368b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-22 15:26:07 +00:00
Cristian Adam
45a8dc4e44 CMakePM: Support local functions and variables for code completion
... and also navigation via F2.

Change-Id: I0f1242c6ff502973de180643b369c635636b0112
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-22 13:26:10 +00:00
Cristian Adam
0632648be6 CMakePM: Remove the CMake introspection after CMake project load
Will be done in the CMake editor. No need to slow the project loading
when you don't do any editing of CMake files.

Initially I wanted to have it already loaded when code completion is
done, but doing once when a CMake editor is opened is better.

Change-Id: I1eda2a64e708bfa4fab5ab749059a08769800eba
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-09-22 10:33:36 +00:00