Commit Graph

89 Commits

Author SHA1 Message Date
Tim Jenssen
399f7a1968 Merge remote-tracking branch 'origin/qds/dev'
Change-Id: I5d593fc74785958886453dc0b452c25356a8c65f
2024-01-18 11:15:29 +00:00
Artem Sokolovskii
34e537a063 ClangFormat: Fix formatting for LineEnding CRLF
Change-Id: I10abc07f5d178a7114faba7174ea1bfc80965174
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-17 13:13:35 +00:00
Artem Sokolovskii
2d96d1a39f ClangFormat: Add parseConfigurationFile utility function
Change-Id: I7824e6bb77e9976aa212cdef478c4d40c4d8c56c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-01-10 10:26:51 +00:00
Artem Sokolovskii
f2cb979aa3 ClangFormat: Rename override checkbox
It improves the UX design of CodeStyle page.

Change-Id: I4458896d6787df462de18025d292bdb481d03c89
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-08 13:50:38 +00:00
Eike Ziller
10d389f59f Merge remote-tracking branch 'origin/12.0'
Conflicts:
	src/plugins/clangformat/clangformatconfigwidget.cpp

Change-Id: I84fba4e6f952e9aca606951e7fb7763b451e35d9
2024-01-03 13:05:56 +01:00
Artem Sokolovskii
a0cc2e3c3e ClangFormat: Fix preview update
Fixes: QTCREATORBUG-30089
Change-Id: Id89e8b2ee0439c5235755256e8410f42ad94b432
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-21 12:02:50 +00:00
Jarek Kobus
86d0ff1b61 CppEditor: Fix a warning about unused arg
Amends 0e04f40fa7

Change-Id: I5acd596670bb3332f6e6d1984ec5ccb75c3e161a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-12-13 18:45:49 +00:00
Christian Kandeler
3b7d29d2a1 Utils: Add formatting information to ChangeSet::EditOp
... and make use of that in TextEditor::RefactoringFile.
This allows calling code to have fine-grained control over which parts of
a refactoring should get re-formatted, while also providing sensible
default values that are "almost always" right, so things typically work
as expected out of the box.

Change-Id: I9200c2135b7477c33bc5a61c5d410b34853e4b61
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-13 12:29:08 +00:00
Christian Kandeler
0e04f40fa7 CppEditor: Fix "testInsertAndFormatDefsFromDecls" test
Amends 240748c106.

Change-Id: I13a4eb28737636dbb5f5f5c1c7ab771a4518a701
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-12-13 12:27:54 +00:00
Artem Sokolovskii
ee75c7276b ClangFormat: Fix utf8 symbol indentation
Fixes: QTCREATORBUG-29927
Change-Id: I5a5a326e13cbe3a874a66e275ded0c6dea9964d7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-12-08 17:48:39 +00:00
hjk
75d9dc2d31 CppEditor: Apply 'static pattern' to CppToolsSettings
Change-Id: I1632787e1a1ebf60427c92b302b25a1a2550853f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-07-26 13:35:28 +00:00
David Schulz
4743724d4c Editor: replace Utils::Text::Replacement with Utils::ChangeSet::EditOp for formatting
Removes the last usage of Utils::Text::Replacement with a more commonly used pattern.

Change-Id: I0912bf61388a58ddaba424380ec139f9aa15fc4c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-07-04 11:39:30 +00:00
David Schulz
61fc1fd452 ClangFormat: remove identical prefix and suffix from replacement text
To reduce the changes done to the document iterate from the start and
back of the replacement text and check whether the document already contains
the proposed changes.

This also fixes the misplaced snippet part in the if else snippet.

Change-Id: I4519ed101cc03e7c49b3a9b775087361c3fd158d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-07-03 09:24:00 +00:00
Christian Kandeler
a39119669c CppEditor: Format quickfix code only if formatting is enabled
... in the ClangFormat settings (rather than the default of just
indenting).
As opposed to files generated by the wizard, quickfixes are often touching
existing code, and since ClangFormat works on line granularity, users
will experience unexpected re-formattings when ClangFormat is in indent-
only mode.
Therefore, do the formatting only if the user has enabled it in the
ClangFormat settings.

Change-Id: Icb30f166f2b6fb94113a8f25c4a5f92ff8bca9b0
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-03 08:47:42 +00:00
Eike Ziller
e7870f736d Merge remote-tracking branch 'origin/11.0'
Conflicts:
	src/plugins/clangformat/clangformatutils.cpp

Change-Id: Ide285cc25fca9101843ab9dca01c5a33644aca7f
2023-06-14 08:43:08 +02:00
Artem Sokolovskii
6a20e588bf ClangFormat: Use pre-existing code style settings
Instead using of default code style settings, this commit
modifies the ClangFormat plugin to use the code style
settings that were set before applying ClangFormat.
By doing so, we preserve the previously defined code style.

Fixes: QTCREATORBUG-29185
Change-Id: I347d44d5ed49a2c50e130a983b62c844c8964391
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-06-13 08:10:46 +00:00
Artem Sokolovskii
74f77f6407 ClangFormat: Add caching of current style
Previously, ClangFormat was getting the style for a file
every time styleForFile was called, which could cause
unnecessary delays and impact performance. This commit
adds caching of the current style with a timeout of 1s,
so that ClangFormat can quickly access the cached style
instead of recalculating it each time.

Change-Id: I33c114d51d6ce1acd0b6d9d2a28e2b6712e149dd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-06-12 09:30:55 +00:00
Eike Ziller
51df19270b Merge remote-tracking branch 'origin/10.0'
Change-Id: I7cfdfc13097d5037fea597ecba98ae902a0c5afb
2023-05-12 12:24:39 +02:00
Artem Sokolovskii
b28df28660 ClangFormat: Remove redundant KeepLineBreaks property
Change-Id: I74250bde4a224d89b078f127da4e7b63454b03a6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-12 07:49:40 +00:00
David Schulz
1acd2499e2 Utils: replace LineColumn with Text::Position
Change-Id: Ia69547374efec7412717cbed1eb4162162a89d39
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-05-11 17:00:28 +00:00
David Schulz
74c311d68f ClangFormat: column of Position is 0-based
Amends 5b0c3258bb
Amends e9cd4dd439
Amends a631a0441e

Change-Id: I9dd542dfdf7936bdaf1fb05152228aff3895bccf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-05-11 13:20:39 +00:00
Jarek Kobus
a631a0441e ClangFormatBaseIndenter: Fix build
Bring back the utf16LineColumn function locally.

Amends e9cd4dd439

Change-Id: Ic10ea0355b75498217e7bc057a3666a276a18a11
Reviewed-by: hjk <hjk@qt.io>
2023-05-11 12:03:17 +00:00
hjk
a69f58180c ClangFormat: Compile fix related to LineColumns
Change-Id: I645d448bea8ee22db54b110cf83e58b7b2e20660
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-05-11 11:23:26 +00:00
hjk
3e7d93c788 ProjectExplorer: Move some not-fully-session related bits
... out of SessionManager.

The idea is to later move SessionManager into the Core plugin,
which both is sensible conceptually and also prerequisite to
merge the Bookmark plugin into TextEditor plugin.

Currently, only the interface is split, as the load/save
implemetations are non-mechanical to disentangle.

Change-Id: I31631db3094ea192825a2ccaa6add6188662940b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-03-01 09:26:50 +00:00
Jarek Kobus
a423caba13 ClangFormatBaseIndenter: Initialize llvmFileSystemAdapter
Otherwise memory analyzer reports use of uninitialized value.

Amends eeeb5f0aad

Change-Id: Ic0cb0a40062a82caef73987109e8970fc57f93b6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-02-06 10:25:51 +00:00
Christian Stenger
e20bdfae4d ClangFormat: Adapt to changes in LLVM 16
Change-Id: Ia4a2cf21e351095609d8858f1f9355c6607470f3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-31 13:17:58 +00:00
Artem Sokolovskii
34638aa497 ClangFormat: Add use global settings check box for a project
Change-Id: Ie2872de3574aaad058a9fca17247db00e9559ba7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-13 12:55:42 +00:00
Artem Sokolovskii
e193d02a72 ClangFormat: Fix no style for a new project
Fixes: QTCREATORBUG-28655
Change-Id: I44794125cfb0e4f24dc9a573fa0f9bb29f4c2e2b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-09 13:25:56 +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
Marcus Tillmanns
d63b2ca51f ClangFormat: Parse clang-format file when needed
Previously the .clang-format was parsed even if there is an override
active.

Fixed .clang-format to follow style-guide more closely.

Change-Id: I39c5e5793cfe9e8a996e084e4ba169231a9bcebb
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-12-20 11:39:33 +00:00
Eike Ziller
3f4c3a3db4 Merge remote-tracking branch 'origin/9.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/texteditor/texteditor.cpp

Change-Id: I9c8f1331be3f5442f1fd28aeb0a9bc07128629d1
2022-12-20 11:05:01 +01:00
Artem Sokolovskii
3904539e0d ClangFormat: Fix crash when m_fileName is empty
Fixes: QTCREATORBUG-28600
Change-Id: I3e0d64eb892daa5c63abe7ec81b258bf96fcdb1b
Reviewed-by: hjk <hjk@qt.io>
2022-12-16 12:15:37 +00:00
Marcus Tillmanns
eeeb5f0aad ClangFormat: Support remote filesystems
Change-Id: Ic5c06a826154e1bee92e3c283ab508177e86c428
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
2022-12-15 12:43:40 +00:00
Artem Sokolovskii
c0f3ef9a82 ClangFormat: Refactor for remote file system support
Change-Id: If44af32e2b3534fb350de9c657b99edd6bb6923a
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-12-09 11:17:05 +00:00
Björn Schäpers
f4545807de clang-format: Adapt to LLVM 16
Change-Id: I2e35f92db6de10b1e4bf173f0864f0cd893a011f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-06 18:56:32 +00:00
Artem Sokolovskii
afed126ba1 ClangFormat: Fix wrong comment indentation
Fixes: QTCREATORBUG-25539
Change-Id: Ifecc4bc2c0984319d858720d5bcd1788a9008e90
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-26 07:21:07 +00:00
hjk
bcb4db927b ClangFormat: Avoid warning about unused parameter
Style follows precedent in the file.

Change-Id: Id7e5ca3f4e9536cb803e8e0ff36db59fda3c41d5
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-20 11:06:49 +00:00
David Schulz
c9dc54802c ClangFormat: do not remove trailing spaces on indent calculation
Fixes: QTCREATORBUG-28150
Change-Id: I6f7b18e1afefb96da28295a2c3654d1c1ced4308
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-14 11:09:12 +00:00
Eike Ziller
2c51e4bc17 FilePath: Return optional bytearray for file contents
For differentiating between "error" and "empty file".

Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d
Reviewed-by: hjk <hjk@qt.io>
2022-09-12 11:57:04 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +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
Artem Sokolovskii
17693bc415 ClangFormat: Fix list declaration
Fixed list declaration indentation.
Fixed function declaration with parameters on the new line.
Added tests for both cases.

Fixes: QTCREATORBUG-25011
Change-Id: Ida4f6ec4f407c5e5b015dc2c0afff110262d9645
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-08-23 09:07:59 +00:00
Artem Sokolovskii
176c3906fe ClangFormat: Fix ignoring DisableFormat option
Task-number: QTCREATORBUG-27261
Change-Id: Ib9671f5c4499a39eb40e2a269dc73328fa5ad12f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-09 09:01:54 +00:00
Artem Sokolovskii
2f18256633 Clangformat: Brings back some of checkboxes
Brought back checkboxes: format while typing, format on save.
Brought back format while typing feature.
Global checkboxes will be hidden in project settings,
and visible for global.

Change-Id: I193cf9e13b10de22091edb5fe04aef957dd74586
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-30 10:36:49 +00:00
Artem Sokolovskii
8f1a9ea6d7 Revert "ClangFormat: Remove format while typing feature"
This reverts commit 323ba720db.

Reason for revert: The feature is needed

Change-Id: Iaf09ef91c49ff0c85c1b5906a1c1464bd8e4cae6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-29 11:53:04 +00:00
Artem Sokolovskii
323ba720db ClangFormat: Remove format while typing feature
Change-Id: I6737c429694218d39fc06c9ef3ce502228e26a2a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-25 17:51:32 +00:00
Artem Sokolovskii
b634ec77fc ClangFormat: Fix override checkbox doesn't affect behavior
Override checkbox allows use clangFormat settings
from widget even if there is .clang-format file in
file's folder or parent folder.
It works for global settings and for project settings.

Change-Id: I03152f4b0e1b62b3ac038024e76cc9082fa37ec3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-16 07:00:07 +00:00
Artem Sokolovskii
9afe4f958a ClangFormat: Remove unneeded warning
- Remove warning when .clang-format file is absent
- Remove warning when a page is nullptr in addTab function

Change-Id: I4232bc77eaac56c78707fc37aaf75b00b8af9006
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-04-26 09:10:05 +00:00
Artem Sokolovskii
72dd90e512 ClangFormat: Start to use new file management
- Indenter uses .clang-format file from a dir of
editing file or from a parent dir. If there is no
such file then indenter starts to use file from a dir
with the name current CodeStyle settings.
- Test fixed

ToDo: Add file absentness processing in case of import

Change-Id: If09ef0c598899856b948c214e524bcfd5dad76e2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-04-20 07:52:17 +00:00
Artem Sokolovskii
4022ed547d [ClangFormat] Remove redundant checkboxes
- Removed redundant checkboxes
- Removed apply button
- Combined checkboxes to combobox

ToDo:
- Specify behavior for global and project settings

Change-Id: I39a00ac8439ae7be3041890f7fc882849685d102
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-03-25 14:17:48 +00:00