Commit Graph

222 Commits

Author SHA1 Message Date
Artem Sokolovskii
72991ea5c1 [ClangFormat] Fix bax with BasedOnStyle field
Behavior was: The field became "LLVM" after a change to another style.
Fixed behavior: BasedOnStyle field becomes and stays chosen style.

Change-Id: I0d41a216f7f06c5681cc20a52c736406307a3724
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-03-03 13:26:40 +00:00
Artem Sokolovskii
ab5fdd94f3 [ClangFormat] Add test checkking indentation after Q_OBJECT
Added test checking behavior when after Q_OBJECT all class structure
have correct indenting and redundent tabs doesn't appear before key words
such as  public:, private: , etc.
Made automatic addition Qt defines to StatementMacro to .clang-format files.

Fixes: QTCREATORBUG-26776
Change-Id: I3490421a9caf2831b593939597940358f7ce8f01
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-10 13:37:05 +00:00
Alexander Drozdov
3869487a47 Allow to build ClangFormat plugin with CLANGTOOLING_LINK_CLANG_DYLIB
Some Linux distributives provides moders clang without separate libs
compiled, like libClangTooling and so on. Just provide libclang.so and
libclang-cpp.so.

Qt Creator provides way to handle such clang installation by
pointing flag CLANGTOOLING_LINK_CLANG_DYLIB=On for CMake. But
ClangFormat still keeps from building. Fixed it.

Change-Id: Id420f82c47c4205c8cd631aa04be6771628984be
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-27 22:20:58 +00:00
Orgad Shaneh
707e7ba41f ClangFormat: Suppress warnings from llvm
Change-Id: Id79abc3ea87576a681d86a7c1bd3be957acc299f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-01-27 20:15:15 +00:00
Eike Ziller
9d8a419d10 Remove qmake build files
Removes qmake as a build system for building Qt Creator itself.
Keep them for some tests that are not completely moved to CMake yet.

Change-Id: I846c6ef65626b6dfae6375fdc85d00677aa8c2fb
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-20 12:18:15 +00:00
Christian Kandeler
ead181e385 ClangFormat: Move tests into plugin
That's where they belong

Change-Id: I78e33e76a2f42f05961f6fab31da5f3dd583a2e9
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-20 10:27:13 +00:00
Christian Kandeler
b2d63bf79e Fix various compiler warnings
Change-Id: Ib64f04f154b2c44dad3248ef038449c2ac628686
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2021-12-02 15:48:52 +00:00
Christian Stenger
857ca05ac3 ClangFormat: Fix compile for old LLVM
Using LLVM10 is minimum supported, but some format style
elements have been introduced later, so guard access to
members that are not present in LLVM10.
Amends a997161dd6.

Change-Id: I9513b4fdc1fa5247cd67beaf0122b1b1d5494bbf
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-25 09:34:23 +00:00
Artem Sokolovskii
a997161dd6 ClangFormat: Synchronize ClangFormat settings with CppEditor codestyle
Added synchronization between ClangFormat codestyle settings and
CppEditors codestyle settings. All changes which will be done in
ClangFormat settings tab settings tabs will be automatically
retranslated to CppEditor codestyle settings tabs and vice versa.

Change-Id: I408d726c12552856e3c1b72d3ba09b77fff83321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-24 21:35:31 +00:00
Eike Ziller
195abefe7d EditorManager: Remove QString openEditor(At) overloads
In favor of the FilePath/Link ones.

Change-Id: I5caf9e0f8de304ff4ee12329557aa50a6f3a0c69
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-02 08:11:14 +00:00
Eike Ziller
bb9774de92 Merge remote-tracking branch 'origin/6.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: If8baed5564470e550a0ba5c7720915217eec2412
2021-10-21 09:13:03 +02:00
Christian Kandeler
38b97b404a Fix various compiler warnings
Change-Id: I59db57e8501bbd0d0293ccce1b520df8acc07413
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-13 13:56:11 +00:00
Eike Ziller
2ae0d4d0b1 Merge remote-tracking branch 'origin/6.0'
Change-Id: I655155b35747082ac891a4b95e1680871d9b3234
2021-10-08 16:00:32 +02:00
Artem Sokolovskii
9cb0bd94f0 ClangFormat: Move ClangFormat settings page
- Move ClangFormat settings page to TabWidget in the dialog
that opens when a user press "Edit" button in the CodeStyle tab

Change-Id: Ibd285344f07a6b2b20e275f2134976c50f91a019
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-08 13:09:12 +00:00
Artem Sokolovskii
d02155f24a ClangFormat: Fix bug with reload of settings
- Fixed behavior when saved data from file doesn't load
in the first opening of the code style options

Change-Id: I1c72845cbf8119f9eb402a2f40bcc816c5590c25
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-06 13:17:04 +00:00
Artem Sokolovskii
8b263b4ae5 ClangFormat: Rework clangformatconfigwidget
- Move logic work with clang-format file to
additional class to make clangformatconfigwidget
responsible only for work with ui elements.
- Fix functionality: when new BasedOnStyle was
chosen all fields were empty or set in default,
now it fills with the corresponding value.

Change-Id: I2ee42a502e87da761274d293a7f0a38fda98804d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-06 06:59:17 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 14:53:58 +00:00
hjk
21b1bfc73c ClangFormat: Spread FilePath
Change-Id: Iedddd78b183b2290f98411e7c70807c1828f1c25
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-19 08:41:52 +00:00
hjk
54b372a082 ClangFormat: Code cosmetics
Change-Id: I2aa83d4121a2c255547e14a32b0fe4bfd11dc72b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-17 09:44:33 +00:00
Christian Kandeler
264fa85f50 Fix a number of compiler warnings
Change-Id: I3e71bffb2099d896742a6fca77febe20e2076464
Reviewed-by: hjk <hjk@qt.io>
2021-07-12 15:24:59 +00:00
Christian Kandeler
8cc4bbe4d8 ClangFormat: Prepend a space character to our inserted line comment
Otherwise, we could introduce unwanted syntactical constructs, for
instance if the previous character is an asterisk.

Fixes: QTCREATORBUG-25966
Change-Id: Ic0b535861bc1cb4f5f93d06bb11d0f3c7c583893
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-07-05 15:44:51 +00:00
Christian Kandeler
de2c26f7f5 ClangFormat: Prevent adding/removing lines when indenting
In indentation-only mode, any edit that adds or removes newlines is
wrong by definition.

Change-Id: Ida6e729f4d5e8dcd7893fb2bb9407e596661f942
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-05 11:26:20 +00:00
Björn Schäpers
55b91a7617 clangformat: Fix build with LLVM 13
Change-Id: Ia9db10696fd129c8b989ecc4c9ecbb7f1f10e68c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-17 10:17:38 +00:00
Christian Kandeler
b1dbeafd44 clang-format: Add more default statement macros
To prevent unwanted indentation of Qt code.

Change-Id: I9dac81c3bbda5e1e7635f93f096b49df9ee92265
Reviewed-by: hjk <hjk@qt.io>
2021-05-14 14:11:15 +00:00
hjk
8e352af0ec Core: Add a default parameter to various ICore::*path functions
Saves some code on the user side.

Change-Id: I32cd220b6e533f5497a1865f9c34ab9db4cfda79
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-04-27 06:52:05 +00:00
Eike Ziller
c1f90aeca2 ICore: Change some path API to use FilePath
Change-Id: Id841d6177206a021c9e606ce560b47d1ae6e52b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-04-26 08:03:47 +00:00
Christian Kandeler
b88b73d9c1 ClangFormat: Sprinkle some more magic pixie dust
Apparently, we can prevent clang-format from removing line breaks by
adding an empty comment at the end of the line.

Change-Id: Ia78ecb9e7351d059c544cbda11d33af5734e2218
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-12 09:28:55 +00:00
Christian Stenger
aa96b07853 ClangFormat: Fix compile
Amends 14eb5b382c.

Change-Id: I9bbd34d1d90d2cf27edd74037be5a3a061691456
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-11 12:11:18 +00:00
Björn Schäpers
14eb5b382c clangformat: Fix build with LLVM 13
Change-Id: I5eaad17a6f240aa1e3f246492b69f093b4f59fee
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-11 07:50:30 +00:00
Eike Ziller
91db1b51ab Fix compilation by not using optional from std
Amends 874029809f

Change-Id: I7eee4700a67b429fa2012389c39a0c965443a065
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-02 11:03:45 +00:00
Jarek Kobus
874029809f Compile fix: use Utils::optional instead of std::optional
Amends d9cd74f06d

Change-Id: Ic4a971fa2fb4659784afdc19f5b8db6a378f611e
Reviewed-by: hjk <hjk@qt.io>
2021-02-02 07:34:46 +00:00
Björn Schäpers
25e7b2c5d6 clangformat: Fix build with LLVM 12
Change-Id: I493afce92b16291cf66fc510129f2154a7162847
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-01 21:04:47 +00:00
Björn Schäpers
d9cd74f06d Texteditor: Add ability to get margin from indenter
And implement it in the clang-format plugin to use the ColumnLimit from
the style. This would be quite useful if you're working on different
projects with a different ColumnLimit. This way you get an visual
representation and do not only have to rely on clang-format.

Change-Id: Ib0258e3fba6f45f0f46ce612f806527a47868ad9
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-29 17:03:07 +00:00
Tim Jenssen
b801a9339d Merge remote-tracking branch 'origin/4.14'
Change-Id: I70504e096be620434f38cd990c593950da8b24ba
2021-01-07 14:23:46 +00:00
Christian Stenger
41982acec3 ClangFormat: Fix missing return value warning
Amends f7d8f8b704.

Change-Id: I3e509769a8ef206f295b3b5d8db4448375e62cbb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-07 10:08:50 +00:00
Eike Ziller
9b4e2aa71d cmake build: Avoid other LLVM libraries interfering with ClangFormat plugin
Make the static LLVM in ClangFormat really internal to the ClangFormat
plugin on Linux by not exporting symbols from it.

This was missed during the conversion of the qmake project to CMake.

Fixes: QTCREATORBUG-24998
Change-Id: If483f3c45d5cf7f63e7b8dde58efab6371414bdd
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-01-06 14:15:48 +00:00
Christian Kandeler
f7d8f8b704 ClangFormat: Do not refuse to build against unpatched clang
The plugin builds just fine and should be mostly (fully?) functional with
upstream clang, so it seems excessive to force-disable it entirely for
everybody not using our custom patch.

Change-Id: Id6a179c20325290a8205218c9514a16c1adc9076
Reviewed-by: hjk <hjk@qt.io>
2021-01-06 11:00:02 +00:00
Eike Ziller
f74b317598 Fix compilation of ClangFormat plugin against LLVM with clang-cpp
The ClangFormat plugin needs to link against clang-cpp in that
case as well.

Fixes: QTCREATORBUG-25138
Change-Id: I84b1784b291d8944a9dee66ec14db32ad72ff8b5
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-18 15:29:45 +00:00
Christian Stenger
6b62a99a8a cmake: Fix building debug with release libclang
Parts of QC cannot be linked against a release build of clangTooling
libs and vice versa when building on Windows.
Check whether the provided libs match the current build mode and
disable respective parts if necessary.
Re-use this information to decide whether unittest should be build
or not.

Change-Id: Ibc2aab0d7886e78ebbf8f15a43152efad49f1eff
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-23 11:07:49 +00:00
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
hjk
086a4be734 More Qt6 porting
Change-Id: I96bef1772149eb718e250563c65bf5da7259d9d6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-22 15:06:54 +00:00
Christian Kandeler
31f427a3a6 qbs build: Fix linking ClangFormat on Windows
Apparently, the MSVC linker gets confused if an input library
("clangFormat.lib") has the (almost) same file name as an output library
("ClangFormat.lib"), even though the latter is specified with an
absolute path.

Change-Id: Ia76e60fd10e16ce8daff880f4005d40d7f20d08c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-09 09:31:30 +00:00
hjk
e1c88116b3 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
(cherry picked from commit 430a33dcd9)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-06 11:15:18 +00:00
Tim Jenssen
b8cd87dea0 Merge remote-tracking branch 'origin/qds-1.59' into 4.13
Conflicts:
	src/plugins/clangformat/clangformatplugin.cpp
	src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
	src/plugins/qmldesigner/qmldesigner.qbs

Change-Id: Ie4a0beeb9fd32ac9683f4e8769988a9c3f3e369a
2020-06-26 16:51:22 +02:00
Marco Bubke
9a0acda2c9 ClangFormat: Fix warning
Change-Id: Ifdf4bfb7662017b2ba2e28074808919f7a726a8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-15 09:46:36 +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
Cristian Adam
0366a8aadb ClangFormat: Compile fix for MSVC
When vanilla LLVM/Clang is used the #warning statement
causes actually an error on MSVC.

Change-Id: Id3f36efc1b21d48e52a9c44036b99a5b4d9a0d5c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-24 09:50:45 +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
hjk
299d34d547 Remove apparently unneeded QtPlugin includes
Change-Id: I511c0318a72dbf2a92e4749dee02eabfc9826139
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-12 16:03:37 +00:00
hjk
a44bfdd779 Provide an empty default IPlugin::extensionsInitialized()
And remove all empy re-implementations.

Change-Id: I19f0b4e55c042c96693ecb89766f97f0a97b54ae
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-07 10:21:34 +00:00