Commit Graph

24 Commits

Author SHA1 Message Date
Jarek Kobus
ccf1d17bfe Silence the warning about missing initializer for member
Silence the following warning:

warning: missing initializer for member
‘clang::tooling::IncludeStyle::IncludeCategory::SortPriority’
[-Wmissing-field-initializers]
  118 |     style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200}};

According to the docs of IncludeCategories, the SortPriority field
is optional, and when not set its value is set to the value of
Priority field. So in order to fix the warning we repeat the same
value for SortPriority field.

In addition we ensure that we require at least clang version 10.0.0.

Change-Id: I8baae7a33ad1a7a7f3afe66779f482b29a7396b4
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-13 12:11:41 +00:00
Christian Kandeler
eaea03ba42 ClangFormat: Adapt to clang 11 API changes
Change-Id: Id5d977e56017a80138f2c033e145b67446eff3ab
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-04 10:23:19 +00:00
Orgad Shaneh
44023c8f43 Clang: Fix build with Clang/LLVM 10
Change-Id: I740286c9dcfd325b1c31ab863fb5c91bf9c6ec70
Reviewed-by: hjk <hjk@qt.io>
2020-02-20 17:30:27 +00:00
Nikolai Kosjar
6ec8017bc6 Clang: Build against LLVM/Clang 9
Change-Id: I3608bca6541614bb55e67d35c87334957cd02761
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
2019-10-02 13:20:13 +00:00
hjk
c77cef5706 Avoid more deprecation warnings
Change-Id: Icc7bb7a4ccf7fc9f89f6f668c194ccd440e5231c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-05 07:49:48 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
hjk
0595e67c82 More FileName::pathAppended()
Change-Id: Ie20ec34ea9712b3ec49e6233b23cef84c2019f03
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 14:37:13 +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
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
07557016f8 ClangFormat: Use the global style if no configuration is found
If no .clang-format file can be found and the settings do not
override the configuration neither globally not in the project
then construct the global settings (if required) and use them
instead of constructing the style every time.

Task-number: QTCREATORBUG-22144
Change-Id: Ib59b7f166f030ce3fb085f105f30fbf0eb25b185
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-02 11:32:11 +00:00
Orgad Shaneh
d0867955af ClangFormat: Fix GCC8 warnings
* Missing return (false positive. All enum values are covered).
* Unused static function.

Amends commits 7f0589ef59 and
40fcc728b2.

Change-Id: I0e5c4ae09739a7ca9edbbbbe3f081d8a732245e7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-01 06:56:29 +00:00
Ivan Donchevskii
3017ee23e5 ClangFormat: Fix the filepath to actually pick the selected config
We've searched for the config we want to use but did not change
the path for the source file which is used internally by libformat
to find the configuration.

Fixes: QTCREATORBUG-22048
Change-Id: Ibdcc33ac338f06e966dfc5c06cdb38db3bb768b6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 10:10:37 +00:00
Ivan Donchevskii
40fcc728b2 ClangFormat: Use by default the same style as Qt Creator uses
Change-Id: Iae0f774873f66fcd4e297cfc260a8541f4373e36
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-07 14:03:45 +00:00
Ivan Donchevskii
243ba8d371 ClangFormat: Add context menu item to open current config file
Add the context menu item to C++ editor which allow you to open
the currently used .clang-format configuration file.

Change-Id: If9d6bec4f4085c18b13df15d78417aee82ddb4e4
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-03-07 10:45:46 +00:00
Ivan Donchevskii
dc9c9249fc ClangFormat: Try to use existing file to override settings
If there is a .clang-format file in the project use it as
a base for the custom file that creator uses to override
the project settings.

Change-Id: I0786dbdd6077b87d4dd428981e24d503668f1031
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-06 08:44:05 +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
Ivan Donchevskii
2501100c1f ClangFormat: Fix configuration files handling
1. Fallback to the base style from the invalid config file:
   If the .clang-format file from the earlier clang version is used
   and can't be parsed by LibFormat try to find a base style and
   generate the updated config based on that information.
2. Do not create new .clang-format configuration for each project.
   Rely on the global one until the user explicitly creates the
   configuration for the project.

Fixes: QTCREATORBUG-22004
Change-Id: I75bd89eebc3ebae57c1f1de94da2e78924ae510c
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-22 13:06:31 +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
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
f876a71fa1 ClangFormat: Improve current style detection
Check first if the current project already has .clang-format
configuration file.

Change-Id: Ic8cb5d37c32cd5b0c04485589caea95de933c264
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-13 08:38:17 +00:00
Ivan Donchevskii
cf816448ce ClangFormat: Set BreakBeforeBraces to Custom by default
If it's not set to custom some user settings are
continuously overridden which is not always expected.

Previously the default style caused some parameters
to be reset.

Change-Id: Ie0fedf6b9984116a86b7c588aed8c6b6cb35133e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-13 08:17:54 +00:00
Ivan Donchevskii
8dc566e902 CppTools: Allow to check whether project code style exists
The calling code can anyways fallback to the global style
without extra help if no project style exists.

It is useful when you want to get the project style if it exists
and understand at the same time that it is not a global one.

Change-Id: I265de3f436f90623385427fc8a1abad09c8c3577
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-12 08:56:20 +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