Commit Graph

32 Commits

Author SHA1 Message Date
Eike Ziller
e0b0a08e50 ExtensionSystem: Move away from QList
Qt 6 API will move away from it.
Use QVector for API and some std container for internal things.

Change-Id: Iff14d48a47d5ac52ade875d9c8c84ad8a4f577d8
Reviewed-by: hjk <hjk@qt.io>
2019-05-27 14:21:00 +00:00
hjk
dc9cbd8f57 More FileName::appendPath() -> .pathAppended() changes
Change-Id: Ibc7eb4eb3ffb64658e441aafa240b1ddc0061930
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-27 09:10:19 +00:00
hjk
1e9636ab8a Some more FileName::appendPath() -> pathAppended() changes
Change-Id: Ie494f7ae8a96d97c9497b3ef38d774d2cf787b7f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-17 07:46:56 +00:00
Ivan Donchevskii
1ae98c3595 ClangFormat: Add the interaction with Beautifier
Do not allow ClangFormat plugin to format on file save
when the Beautifier has the same checkbox selected.

Change-Id: I655d77a888cc444ccb02c4e72f11a93b3ab9bbd5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-29 12:32:31 +00:00
Ivan Donchevskii
c2ab89cc12 ClangFormat: Do not reinitialize the configuration and preview
Initialize them only once and only show/hide widgets later on.

Change-Id: I5ebad504709e34aeb6ce5bf1ead7d8e2ee0b2056
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-29 11:22:12 +00:00
Christian Stenger
75112c4b59 ClangFormat: Fix compile with older gcc and MSVC
Amends 2d8ce380c9.

Change-Id: I44e7079ae40550e4d80a1717d4803d6864af99eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-04-29 06:08:47 +00:00
Ivan Donchevskii
2d8ce380c9 ClangFormat: Fix UI issues
- 'Default' values remain so after save/load
 - the language is fixed to C++
 - the project settings are shown correctly
 - fix parsing configuration file
 - do not trigger slots when we fill the table

Change-Id: I91b477721b5084803324cd38d0cfeb9d5650dd9f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-26 07:55:00 +00:00
Ivan Donchevskii
e9d443b1c7 ClangFormat: Improve the configuration UI
Use QComboBox, QLineEdit and QPlainTextEdit to edit
different option types.

Show changes in the preview without pressing 'Apply' button.

The clangformatchecks.ui file is generated with the python
script that is a part of this commit.

Change-Id: If5ff0acab6edd74f2e087e31fbd3ad1b9f847030
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-25 07:52:48 +00:00
Ivan Donchevskii
d46ce1705f ClangFormat: Show the global fallback style
Fixes: QTCREATORBUG-22144
Change-Id: I201dbccb8b1f1738451f760af34cf588afb5f4d5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-25 07:51:34 +00:00
Ivan Donchevskii
17f87a6d82 ClangFormat: Disable configuration UI instead of hiding
This is the first step without strings change.
The next step is I201dbccb8b1f1738451f760af34cf588afb5f4d5.

Change-Id: Ic0ce6a5ab3e74303a71a7c0bd8188d0284a241eb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-03 12:02:31 +00:00
Ivan Donchevskii
c1d03e610c ClangFormat: Fix showing the warning text
The call to show() was lost at some point, let's restore it.

Change-Id: I83f551d26e6c4f658426b1196ff3a0935aea7047
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-02 11:31:35 +00:00
Ivan Donchevskii
0abcf7b618 ClangFormat: Fix path for the overridden project configuration
Change-Id: I4748c994016851293a6ad5490208fb4e4bbc7999
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 15:07:49 +00:00
Ivan Donchevskii
5bb8e67846 ClangFormat: Do not save settings if they are not overridden
Apply only settings from checkboxes in that case.

Change-Id: Ic6740ab9d769730bba4d04dcdde7ad1e2a464614
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 08:43:28 +00:00
Ivan Donchevskii
bf972bcb01 ClangFormat: Change the logic how configuration is picked
Let's use by default the configuration that clang-format picks itself
for the source file. The Qt Creator configuration will now only
override the default one with global or project settings and can be
turned off with the checkbox.

This behavior is clearer than always picking some configuration
which Qt Creator prefers best.

Change-Id: If5ed3d67eb6b4b47a6d0fd5259f7efbb608914d1
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-03-05 14:48:59 +00:00
Orgad Shaneh
a53032d6a5 CppTools: Move code style snippets to a separate header
Include it only where used.

Resolves many "unused static variable" warnings.

Change-Id: Ie1e578d9b9511f963e359d87f7740b4981975dbd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-26 06:06:51 +00:00
Ivan Donchevskii
956543e462 ClangFormat: Add the preview text editor to the settings
Allows the user to see how the current style applies to
the code snippet. The action is triggered by the 'Apply' button.

Change-Id: I820d989519cfdfb6e617ed6e8e9e5751be6619ea
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-02-22 14:31:05 +00:00
Ivan Donchevskii
c6b58a063f ClangFormat: Show .clang-format file as text instead of the table
Change-Id: I8b912ec6f29dfe7059ac6ab3888a6c3698769fc1
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-22 14:30:56 +00:00
Ivan Donchevskii
308a48323e ClangFormat: Fix handling more complex styles
Change-Id: I8c30c90a81bef786cdd0946351bf2cf46cc906ee
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-22 13:05:54 +00:00
Ivan Donchevskii
1a65acf639 ClangFormat: Warn about invalid option and restore the last style
Do not save the configuration which contains errors.

Change-Id: I050b22f7e589e5c39909fe1f611e56ead03d49ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-22 13:05:32 +00:00
Ivan Donchevskii
5792291520 ClangFormat: Format edited chunks of file on save
The similar implementation to the one in Beautifier plugin
with the difference that the clangformat indenter logic is used
and only modified chunks are formatted.

That means that all code which was not touched will stay in the
initial condition.

Change-Id: I47b11eb99852454ed0031ef6cfc6dbed1ecd390d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-05 08:36:16 +00:00
Ivan Donchevskii
536b733f29 ClangFormat: Format more code while typing
With the extra option "Format while typing" checked try to format
text before the current position without breaking the current input.
To accomplish that we make proper choices which replacements to apply.

The advantage of this change is to decrease the need to manually
format code which is just written.

Some minor bugs are fixed during the testing of this change.

Change-Id: Ibed569042e6c46a881e7a83b1882cf2bb23b3626
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-05 08:36:06 +00:00
Ivan Donchevskii
80fb0178fd ClangFormat: Introduce check to format code instead of indenting
Ctrl+I with the new check will reformat the selected code or
the current line instead.

Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-01-31 10:25:05 +00:00
Ivan Donchevskii
2e19352177 ClangFormat: Fix applying global settings
The actual apply() method was never called for the widget.

Change-Id: Idff194a36591db437cbe5695377005ed5a0b25d4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-24 08:36:05 +00:00
Nikolai Kosjar
843da50d5d ClangFormat: Remove unused variable
Change-Id: Iaaf0e1f34d76842b82827be4079ffd666755ab5b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-12-05 08:13:09 +00:00
Ivan Donchevskii
e57c1268ee ClangFormat: Move settings to the Code Style widget
It makes sense to unify the indenter creation by replacing
the CppCodeStylePreferencesFactory instead of removing it.
We are reusing the same options page but with different
kind of settings.

With this change wizards will no more be confused by missing
factory and will create the proper indenter.

Fixes: QTCREATORBUG-21516
Change-Id: I38964d5fa1f2257617c66a1441db723d239a3237
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-12-04 11:42:22 +00:00
Ivan Donchevskii
9a85ce88a7 ClangFormat: Use relevant settings for each file
Existing Clang Format settings may not follow the
project/global pattern but can be expected to be used
for the indentation/formatting.

So let's proceed with UI for global/project settings
but use global settings only if there's no configuration
found for the current file.

Change-Id: I87c25ab3feb7e2e3deb0290848088657783cf972
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-11-14 09:29:30 +00:00
Ivan Donchevskii
cc118a16e6 ClangFormat: Use the constant for the configuration filename
It is unlikely that this name changes but let's follow good
coding practices.

Change-Id: I12adbf155f26b1b3a02d07092fcc113e0c5157e6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-13 09:21:30 +00:00
Ivan Donchevskii
0e5c7f51fa ClangFormat: Synchronize with C++ code style settings
And remove UI for default code style settings because
it does not affect anything when ClangFormat plugin is
enabled.

Change-Id: Ie348b7d2691b09ea2b4868da987f2a27347ea0f3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-11-08 14:23:06 +00:00
Robert Loehning
f633801790 Clang: Remove superfluous white space
Change-Id: I4a37e18ca18c673ab5d0906ebb59823baa1b2879
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-24 10:25:24 +00:00
Ivan Donchevskii
cafd5ced1a Clang: Significantly improve ClangFormat plugin usability
What's new:
1. New LibFormat option is used to prevent lines shrink,
   which allows to drop most of tricks used before for that purpose.
2. Cached UTF-8 source code is used to improve performance
3. Improved error handling.
4. Slightly improved UI.

Change-Id: I4605200fa103167369a40650b2e1ad2c61e8133b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-17 07:16:04 +00:00
Tobias Hunger
f73e53b169 ClangFormat: Fix warning about initialization order
Change-Id: I83858454b5654924be502b249d3b355af7aab1b8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-12 13:58:26 +00:00
Ivan Donchevskii
ca84a51f86 Clang: Use clang-format for indentation
This is the new experimental plugin based on LibFormat.

It replaces the default indenter for CppEditorDocument
and applies clang-format after the CR or the set of 'electric'
characters.

Uses the global .clang-format kept in QtC settings or
the one for current project. Both can be configured.

For indentation some style modifications and code manipulations
are done to prevent line shrinking when it's not expected.

Manual indentation uses unmodified style from .clang-format file.

Change-Id: I6279b805e418e1804b553efa615f5c843f395a58
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-12 07:59:30 +00:00