Commit Graph

387 Commits

Author SHA1 Message Date
Jarek Kobus
b14c07eed6 TextEditor: Reuse qScopeGuard instead of ExecuteOnDestruction
Change-Id: I2ca7d4676bb4f34fbf59fd45bcd01d7857cb7e4e
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-06-05 08:35:14 +00:00
David Schulz
95b4da9ba9 TextEditor: add tests for the code assistant
Task-number: QTCREATORBUG-28989
Change-Id: Id76d5df589ab50c7deb96b8ad29d1f29bc368e59
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-05-31 13:38:13 +00:00
Eike Ziller
55dadd4f95 Merge remote-tracking branch 'origin/10.0' into 11.0
Change-Id: I27e2c1c764f955d14bfece6cd580b4c2d2988396
2023-05-25 08:29:27 +02:00
David Schulz
d63c57ef47 CodeAssistant: do not schedule processor deletion too early
Calling displayProposal might spawn another eventloop that potentially
deletes the processor before the async proposal handler finished.

Fixes: QTCREATORBUG-28989
Change-Id: I3a8ddb9180cb7737a37ea39dc59d922e83615ed6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-05-23 08:47:45 +00:00
David Schulz
edeea10e6a CodeAssistant: block suggestions while proposal is visible
Change-Id: I78068306252c5c32304ea97e3abb2d87fdee7832
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-11 05:50:24 +00:00
Eike Ziller
7724f8653f Merge remote-tracking branch 'origin/10.0'
Change-Id: I7a3925ad8e4f97461b64a70217102ed900430253
2023-05-05 10:39:47 +02:00
Jarek Kobus
a3a5b8f806 Utils: Rename asynctask.{cpp,h} -> async.{cpp,h}
Follows AsyncTask -> Async rename.

Change-Id: I37f18368ab826c9960a24087b52f6691bb33f225
Reviewed-by: hjk <hjk@qt.io>
2023-05-03 13:24:20 +00:00
David Schulz
ba5e09f03f TextEditor: always return a valid assist interface
It is required for updating currently visible proposals. Also guard
against potential null assist interfaces.

Amends 0bd6d7a69f

Fixes: QTCREATORBUG-29096
Change-Id: Ic34d70561b471e7e529f2fb7c239b49712aca502
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-02 12:08:04 +00:00
David Schulz
d5d7b1d192 TextEditor: avoid showing suggestion and completion simultaneously
If the use erxplicitly requested the completion hide the suggestion
otherwise ignore the completion.

Change-Id: I52485e322b0521b0af10ae6945437bf96642ad89
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-03-16 11:56:11 +00:00
David Schulz
8247d578c7 TextEditor: skip auto completion while suggestion is visible
The use can still explicitly request completions in that case via the
keyboard shortcut.

Change-Id: I4ed47232a24288c540d1357c0f876a1cdfcfec08
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-03-16 11:56:02 +00:00
Jarek Kobus
209b591eac TextEditor: Use QtConcurrent invocation for async run
Change-Id: I4b40e2e3591a9a74570e318e216c4ad74c01ca6b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-10 07:08:39 +00:00
Jarek Kobus
62e0b4052f Remove unneeded includes of utils/runextensions.h
BTW, spotted some other unused includes marked with yellow.

Change-Id: I364e4b6fae73a2be2cfd3a63c1100be4a91aa49a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-27 13:16:44 +00:00
David Schulz
41294e70b4 TextEditor: prevent crash on updating the completion model
Prevent updating the model with something other than a generic proposal
model.

Change-Id: I3880c1ce4ae7cf0aa4fb72d59b75a40db3f53482
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-19 06:28:41 +00:00
hjk
17b20e0622 TextEditor: Tr::tr
Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-18 07:02:12 +00:00
Kai Köhne
4e9c1d126c Replace GPL-3.0 with GPL-3.0-only
GPL-3.0 is deprecated by SPDX.

Change done by

 find . -type f -exec perl -pi -e 's/LicenseRef-Qt-Commercial OR GPL-3.0(?!-)/LicenseRef-Qt-Commercial OR GPL-3.0-only/g' {} \;

Change-Id: If316a498e3f27d2030b86d4e7743b3237ce09939
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-10 08:05:04 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Jarek Kobus
131ecdd3ec TextEditor: Pass context object to lambda connections
Remove some unneeded lambda () brackets.
Glue lambda brackets with parameters brackets.

Change-Id: I66da839573a1633104f689834740bc2953f5868f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-12 06:54:59 +00:00
David Schulz
69ce2a4047 Editor: ensure something is selected after model update
Change-Id: I3fbf14cb7aa60caef43340302e74e80ed5e3ba4c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-12-08 06:16:33 +00:00
David Schulz
0bd6d7a69f LanguageClient: move completion rerequest logic
...from the code assistant to the language client specific assist
implementation. This further reduces the complexity of the code
assistant.

Change-Id: I08ba5eecea826d3ccfe7f1f5a8791a085299d6ef
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-11-29 06:04:30 +00:00
David Schulz
0e4b0a26d3 Editor: move ownership of assist interface to processor
This way the base class can manage the lifetime of the interface object
and it doesn't need to be done in each implementation of perform.

Change-Id: Ie1ce742e31b688a337533ee6c57d376146e25ace
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-17 13:23:55 +00:00
David Schulz
f297b3f1b5 Editor: always configured assistant
A code assistant is not usable without a text editor widget and is
always created as part of one, so make the dependency obvious by require
it in the construction of the code assistant. This removes a bunch of
functions and cheks.

Change-Id: I96556430082ff729d99d2ae2516599f9b8cbc704
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-16 05:24:06 +00:00
David Schulz
09ee528c40 Editor: unify assist processor handling
Define the run type of the processor by its implementation instead of a
enum value of the provider. The execution of a processor inside the
assist now follows a unified procedure.

Change-Id: Ibe9fab324c6072e77702c2663946d7a9f562a085
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-14 13:02:51 +00:00
David Schulz
5eca1ff873 LanguageClient: use internal filtering if we got all completions
... at the current position. This reduces the amount of requested
completions.

Change-Id: I0fa35269bc123513217e3b3abd2c921bd92d8d10
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-11 10:11:33 +00:00
David Schulz
63a8218680 Editor: consider all providers with matching activation chars
Amends 45317da25a

Change-Id: I6bc748f2be54f47c0e23788352f74cecdd5d730f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-11 05:22:51 +00:00
Eike Ziller
10dca6b37f Merge remote-tracking branch 'origin/9.0'
Change-Id: Ie069f3b2a1200b3e665341b1d56ce836024b0d29
2022-11-10 13:22:43 +01:00
David Schulz
08002c6278 Editor: delete assist interface in lsp/clangd support
The complete memory management in the code assistant needs an overhaul.
For now just delete or at least track the assist interface with scoped
pointers.

Fixes: QTCREATORBUG-28408
Change-Id: I0bd4cfaa36a660b6fd5bb467af3b13414ed76e63
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-08 12:07:56 +00:00
Christian Kandeler
13f40f5471 Utils: Add sorted() function
For simpler calling code.

Change-Id: Ia0a16a28770fd172f74d06a626148248bf5d3c0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-25 14:29:45 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
bc8ebd3bc7 CodeAssistant: Avoid using sender()
Change-Id: I8483b368ebf5dca684d817390e1138362bf11d6f
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-01 14:47:42 +00:00
Jarek Kobus
44f1fd6498 Drop Qt5: Cpp/TextEditor: Get rid of QOverload
Change-Id: I010f211b40f876c0f033fd717aaa094f775ea214
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-26 16:58:45 +00:00
David Schulz
13af74a4e8 LanguageClient: remove fragile flag from lsp proposals
Those proposals are not fragile anymore since they reuse the old
completion widget. This fixes vanishing of none idle editor completions
on backspace if there are less than 3 characters to complete.
Additionally this removes the double completion request if there are
more than 3 characters typed in.

Change-Id: Id47d341adf954dfaaaeb70c17f6774ba38cc8bdf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-11 12:15:09 +00:00
David Schulz
d3a40b1d04 CodeAssist: Fix disapearing completion list after update
Change-Id: I3e35fe53a69e7806c0c8a5959ef8c16344aace8d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-08 10:19:23 +00:00
Artem Sokolovskii
0087bd492f Clangd: Fix autocompletion for old style SIGNAL and SLOT
Fixes: QTCREATORBUG-20737
Change-Id: If6d3c6ea5924537386eca81d90d4bb1e8f1a1466
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-07-04 10:33:37 +00:00
Orgad Shaneh
4180e1b84f CodeAssist: Fix Coverity issues
* Initialize m_reason in IAssistProposal.
* Remove superfluous null validations.

Change-Id: Icb9b7a7a98db719540586142e30be75f37a4ab92
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-07-04 04:42:22 +00:00
David Schulz
8130d895c8 Revert "Editor: Update current argument in function hint"
This reverts commit 7d4d57165c.

The change signal should be send from the editor widget, so no need to
call it again from the function hint widget, since it also cancels the
automatic proposal timeout that triggers the automatic completion
request.

Fixes: QTCREATORBUG-27305
Fixes: QTCREATORBUG-26959
Change-Id: I37810e0a6083396bd0375b4ae28aa07389a5079c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-29 04:43:56 +00:00
David Schulz
84ef111847 Editor: only close proposal widgets after updates
To prevent closing function hint widgets after the completion processor
did not return a proposal.

Change-Id: I1901f3f21917d348ef12a6db846739e3c54752fb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-28 11:47:34 +00:00
David Schulz
c3cb262154 Editor: Fix dangling completion widgets
Set the correct assist reason when rerequesting a code assist to be able
to detect perfect matches. Also destroy the code assist context when the
processor is not running and has not returned a proposal after perform.

Change-Id: Ieb04203269076655ac3d7ffc54ea8a1d055194a4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-24 04:15:57 +00:00
Jarek Kobus
7dd51acdfa Utils: Get rid of UTILS_DELETE_MOVE_AND_COPY
Use Q_DISABLE_COPY_MOVE, it exactly the same.

Change-Id: I574d52a0abdf9101f86054f881f6ce0cd498bb36
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:13:43 +00:00
hjk
d41fc4b329 Remove or replace a few unnecessary #includes
Change-Id: I0545533baab57a4383fda5fd680603fdc6459a01
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-20 16:57:26 +00:00
Artem Sokolovskii
66f132dd9b TextEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464
Change-Id: Ie9594bf661dbeecf22589c1580648252f0bfb7fb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-19 07:33:27 +00:00
David Schulz
59a77a4965 TextEditor: add text cursor to assist interface
This will allow us to request assistance for a specific selection
instead of just the position.

Change-Id: Ib8e5b32d4a8f2936e5a6f1b7ac968d7f1d8d9de6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 09:18:53 +00:00
Andre Hartmann
d979bd8da9 DocumentContentCompletion: Work with non-ASCII words
Fixes: QTCREATORBUG-26165
Change-Id: I9a72d36cf64accc32f71dfd5627302960558c69c
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-22 13:17:19 +00:00
David Schulz
9f7c822197 CodeAssist: reset flag before starting new processor
If a new processor is started while waiting for a result of a still
running procesor reset the flag whether content was received while
waiting.

Change-Id: I21a254681050d1db077deec88706f0010670e0ac
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-07 11:50:04 +00:00
David Schulz
fa53849b4a Editor: prevent using function hint widget while it is deleted
Task-number: QTCREATORBUG-26872
Change-Id: I634b488073670476ee3d5b53296e77b6779e5715
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-17 10:45:17 +00:00
David Schulz
b01be64963 Editor: fix crash in function hint widget
Fixes: QTCREATORBUG-26872
Change-Id: I0c79af2a74af96bfba350b62b5072b874e6efcd2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-14 13:56:40 +00:00
David Schulz
f349de45f4 TextEditor: correctly initialize automatic proposal timeout
Change-Id: I53db54b51361ce3389bb25c420880a117ede7c2d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-12-09 10:48:29 +00:00
David Schulz
a442d275fc Editor: hide old proposal if new proposal is empty
amends 28447355ba

Change-Id: Ica1b95e205be4328e675714dbf81f813a76ec9a3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-28 12:18:02 +00:00
Orgad Shaneh
3871e40f43 Fix qHash-related size compatibility warnings by MSVC
Change-Id: I3b7981ce78b67db4b996f99682284a0b911d8cd7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-20 15:03:51 +00:00
David Schulz
c00330f905 Editor: multi cursor support
Adding a way to create multiple cursors that can insert/remove text at
arbitrary positions in the document. Adding cursors is done by pressing
alt + up/down or by clicking into the editor while holding the alt key.

Fixes: QTCREATORBUG-16013
Change-Id: I495d27d95a3d277220946616ef30efc241da0120
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-27 10:56:54 +00:00