Commit Graph

57 Commits

Author SHA1 Message Date
David Schulz
967b1d237b ClangCodeModel: remove ClangdTextMark safety net
Since all text mark created by the diagnostic manager get deleted
properly on destruction now, there is no need to react on the client
destruction in ClangdTextMark.

Task-number: QTCREATORBUG-26585
Change-Id: Ifb9b8546c8f0d94debdcf2c8de6081e4e731cfab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-25 05:34:30 +00:00
Christian Kandeler
0a9acad18c ClangCodeModel: Fix tooltip for clangd text mark copy action
Change-Id: Ie551971a114f1f45004a0eac0283507627c26be2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-02-04 13:50:26 +00:00
David Schulz
dc4b9e48dc Clangd: clean up text marks after deleting client
This is a blindshot and more a workaround than a fix.
Assert and try to cleanup dangling text marks after a client got
deleted. In theory those marks should get deleted by the
DiagnosticManager but somehow, they are still alive and happy after the
client was deleted.

Task-number: QTCREATORBUG-26585
Change-Id: I9d5d708db3fbbe30a09d322400d97184fe40a518
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-01-14 13:19:35 +00:00
Christian Kandeler
f72ea01c65 ClangCodeModel: Properly display clangd auxiliary diagnostic messages
... in text marks.
The main message can be followed by additional messages, separated by
pairs of newlines. Properly parse their contents and also display them
as clickable links, if applicable.

Change-Id: I341ce0a6bf0e628dfabdb3806fb8ef1b8ca019c6
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-12-15 16:40:57 +00:00
David Schulz
2405ccb271 clangd: Assert on generating tooltip for deleted client
Text marks for diagnostics should be deleted when the client dies. If
they somehow survive assert when creating a tooltip for those text
marks.

Task-number: QTCREATORBUG-26585
Change-Id: Iaebf0d2aba66d2a6c250f8dad7856ef03b1dcacd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-07 13:54:34 +00:00
David Schulz
897fbd8317 ClangCodeModel: show specific client name in diagnostic
Task-number: QTCREATORBUG-26585
Change-Id: I5edbe3ab40e91e2e5f8455b7a8d484a82c5cf6e6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-19 12:29:00 +00:00
Christian Kandeler
c92deea33f ClangCodeModel: Provide source of diagnostics in tooltip
It's helpful to know whether a particular issue came from clangd,
libclang, or somewhere else.

Change-Id: I9e00d79ffe630a91028c2aeff219571e9979dbee
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-14 08:26:36 +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
Christian Kandeler
a952500e90 CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of
use that these data structures are immutable.

Change-Id: Iea615c090bde462c445d15223caccc561b0c713d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-27 10:53:54 +00:00
Christian Kandeler
33108795d6 CppTools: Turn some classes into pure value types
ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.

Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-13 12:35:49 +00:00
Christian Kandeler
861d24bbd8 Clangd: Make code model warnings less intrusive in fallback client
Just like we do for project-less files in the non-clangd case.

Change-Id: I88c9c856fb524c6eab8289b8890f7fb4d8dc8645
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-30 09:42:48 +00:00
Christian Kandeler
f9083cc6ad ClangCodeModel: Keep a QPointer to the ClangdClient in ClangdTextMark
Apparently, the pointer might already be invalid when
addToolTipContent() is called.

Change-Id: I649bdca0945247b2b8ce4f709721c4d0bf96a11b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-30 12:29:44 +00:00
Christian Kandeler
7bf52b0c0d ClangCodeModel: Provide diagnostics via clangd
Change-Id: Ib45a62ebe200c2b56a1bb1a66f8a92103e60d092
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 13:22:36 +00:00
Eike Ziller
e9bf841dc9 Fix lupdate issues
Some wrong tr calls / missing tr functions.
Some places where we need to bring lupdate to the right track with
regard to namespace resolution.

Change-Id: Idf552054a34e24d9671db68c816bf37f4d403dbc
Reviewed-by: hjk <hjk@qt.io>
2021-03-22 15:00:37 +00:00
Christian Kandeler
765f518de3 TextEditor: Support tooltips for buttons in text mark tooltips
In case users don't find the icon self-explanatory.

Task-number: QTCREATORBUG-25150
Change-Id: I481b1ea7f510f065f83badcb91e127ac1c81f5a1
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-02-05 12:43:17 +00:00
Christian Kandeler
a1c5dd93f5 TextEditor: Let TextMark subclasses provide a settings page
Task-number: QTCREATORBUG-25150
Change-Id: Id5bbdcf2db7afacb823140d77ebd5bc141ac7f81
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-20 14:17:35 +00:00
Christian Kandeler
bcf900e29b ClangCodeModel: Prevent outdated fix-its from getting applied
The code locations might no longer be correct.

Fixes: QTCREATORBUG-21818
Change-Id: I866a29d2fd63ff65cf33168024f7788c5f6e3547
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-24 11:24:08 +00:00
hjk
f0628cca29 ClangCodeModel: Replace nested ClangCodeModel::Utils namespace
... by the customary ::Internal.

It adds only noise on the user side and conflicts regularly with
the top-level ::Utils namespace.

Remove a (now) duplicated definition of setLastSentDocumentRevision().

Plus minor namespace related fixes.

There are still minor conflicts between Utils::Text and
ClangCodeModel::Text

Change-Id: I2e8df6b3c6c3599192774032822ee7e778355bba
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 15:12:28 +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
hjk
36f23df6c3 CppTools: Use unshared object for CppCodeModelSettings
There's nothing shared here, only ever one copy. Ideally, this
should be const outside CppToolsPlugin, but some settings
are modified directly.

Change-Id: I775b9151a244b3cc44d28bc992a041c42d234a18
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-04 07:55:01 +00:00
Nikolai Kosjar
dcb35676df Clang: Clean up TidyMode/ClazyMode enumerators
Change-Id: Ie3ff0d629fd3c115df9c527e9ae8d7962fcfa156
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2019-12-03 13:23:38 +00:00
Nikolai Kosjar
b895dfa382 Clang/ClangTools: Separate custom diagnostic configs
Add a separate pool of custom diagnostic configs for the
ClangTools plugin. That is, the diagnostic configs in

  Menu: Tools > C++ > Code Model

are not shared anymore with the configs at

  Menu: Tools > Analyzer > ClangTools

On plugin initialization of ClangTools, move tidy/clazy related configs
to ClangTools.

Change-Id: Id06087a58b53e466a3d7bbac669550c5fbe9899d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-10-01 14:10:28 +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
Nikolai Kosjar
4e2c3a7d72 Clang: Do not suggest to remove warning from tidy
...if the tidy configuration is read from a file.

Do not show the corresponding text mark action in this case.

Change-Id: I6114304f41e3946d4041233031a9bc83eee13bba
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-20 08:29:55 +00:00
Nikolai Kosjar
8089107927 Clang: Remove some namespace noise in clangtextmark.cpp
Change-Id: I870338821f106b1066e43b76451ed79b130e612b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-20 08:29:49 +00:00
Nikolai Kosjar
0f8612f20f Clang: Move unexported classes to Internal
Change-Id: I3ea197b734f146d4b11431aaf927aed9be7d8756
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-19 14:09:43 +00:00
Nikolai Kosjar
4b26a8c66e ClangCodeModel: Fix some clazy level0 warnings
Use QString instead of an empty QStringLiteral
  [-Wclazy-empty-qstringliteral]

Use the static QFileInfo::exists() instead. It's documented to be
  faster. [-Wclazy-qfileinfo-exists]

Unused CppTools::ClangDiagnosticConfigs
  [-Wclazy-unused-non-trivial-variable]

Change-Id: Ia4098d1191d6fcfc6e0774f71c39acdea3f0f36c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-08 07:19:29 +00:00
Nikolai Kosjar
f6c46ce35d Clang: Add tooltip action to remove specific warnings/checks
...from the diagnostic configuration.

If no custom diagnostic configuration is set in Projects Mode > Clang,
one is created and set for the current project. Otherwise the current
custom diagnostic set in the project settings is modified.

Change-Id: I5c48280c90f0e807e7333122d504dda302a8b0a9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-05 15:22:20 +00:00
Nikolai Kosjar
0df7468e51 Clang: Add tooltip action to copy to clipboard
...as selecting text in the tooltip was difficult and eventually got
disabled due to other problems - see
d58c0a9ac8.

This adds support for actions in TextMarks. They are displayed as
QToolButtons in a dedicated column in the tooltip.

Change-Id: I84ee3c3e4af573a80953786881d1333b00e4200c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-01 08:15:36 +00:00
Nikolai Kosjar
e5fbeb6219 Clang: Add API to convert diagnostics to plain text
This is for a follow-up change that will allow to copy the diagnostic
text from the tooltip to the clipboard.

Change-Id: Iad5343a819c84ca83d562f69dcf2f50e1d4785c4
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-01-28 14:00:05 +00:00
David Schulz
d4c7814e9e Utils: remove Clang from ClangCodeModel_*_TextMarkColor
They are also used by the qml code model, and may be used by additional
code models in the future.

Change-Id: If216cbeb7b77be0f3b6f31671c71d913206315cb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-17 05:55:53 +00:00
Nikolai Kosjar
f46fb39f3c Clang: Reduce diagnostic visualization for non-project files further
We already avoided showing inline annotations for diagnostics in
non-project files. But given many diagnostics the visualization is still
quite noisy. E.g. consider opening not self-contained header files or
files for which we do not have any project open, as it can happen if the
debugger jumps to such a file.

So leave only the text mark icon on the left and avoid all the rest:
underlines and refactoring icons in the editor, marks in the scrollbar
and task hub issues.

Change-Id: I05245981b21b38be650489a006593922dcb6896d
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-14 09:04:42 +00:00
Nikolai Kosjar
6b70c27e3b Clang: Do not show diagnostic category in inline annotations and issues pane
For build system diagnostics they are not displayed either.

Also, the error/warning is already encoded in the icon and the color.

However, the category is still shown in the tooltip.

Change-Id: I190ab17691c32786cefc20d058010c65cda5ace9
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-14 07:01:46 +00:00
Eike Ziller
45f8d221bf Use FileName in TextMark
Change-Id: I3666d95dc8ef3b7da099d6d30f5cb4678a349493
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-03 06:51:47 +00:00
Orgad Shaneh
070b5fdbbb Clang: Fix minor style issues
Change-Id: I040e3f6fcd717b4ffae2f0ded8bfebada67888fb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 07:21:29 +00:00
hjk
cf4dbb4bb6 ClangSupport: Use simpler structures in some cases
The patch is mostly mechanical, but contains also a few spurious changes
from values references for some local variables, foreach -> ranged for
etc that I coulnd't resist.

Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-06 12:55:23 +00:00
David Schulz
97053d9f2f Utils: Move code model icons to utils
Using the already established icons for code model errors and warnings
to Utils to mak them accessible for other code models.

Change-Id: If9f8efde60cf20411e043aeb2831a9254398bcaf
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-11-16 13:55:35 +00:00
Nikolai Kosjar
e1de989e16 Clang: Show inline diagnostics only for project files
When navigating to headers that are not part of the project, avoid
showing the inline diagnostics. In most cases, these files can't be
changed.

This helps also for the session-load case where files are opened/parsed
when no project information is available yet.

Change-Id: I7fce24af78b3b1efbf64dd27d8ca2a053e02d4ec
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-07-10 12:32:07 +00:00
Nikolai Kosjar
2747985358 Clang: Gray out diagnostics on document change
When reparses take a while, this is helpful.

Change-Id: Ie2003a3d65b30d944d20fa19dd4161412182851c
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-07-05 08:47:34 +00:00
David Schulz
6591a01452 TextEditor: Add line annotations
Displaying short descriptive text of a TextMark at line end.
Currently implemented for ClangTextMark and BookMark.

Change-Id: Idc6b579bda0382ad94b2e236b715696396b10460
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-30 08:27:16 +00:00
David Schulz
4322990926 Editor: Simplify text marks
Moving defaultToolTip and color from TextMarkRegistry to TextMark.
Allowing every instance of a TextMark object to define these
information.

Change-Id: Iec1794372cf902b34d343402074e3999e7f9faf7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-06-22 08:42:40 +00:00
Nikolai Kosjar
4a08f14cf6 Clang: Fix removing text marks on line deletion
Task-number: QTCREATORBUG-17270
Change-Id: I582015597a65141e420622dcdb50e82f9791b189
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-11-23 11:52:31 +00:00
Nikolai Kosjar
07c5cf3a83 Clang: Clean up diagnostic widget
* Use a single QLabel - No need for all the QLabels we used. Also, a
  single QLabel enables selecting and copying all the diagnostics, which
  is handy when displayed in the info bar.
* Avoid call to Utils::ToolTip::hideImmediately() if the location is
  clicked from the info bar.
* Simplify code and API

Change-Id: Ib991364e4d6f40ef02dada8ebbb90fe6ff8ae1a1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-21 07:33:16 +00:00
Nikolai Kosjar
9d55d8485c Clang: Show info bar for parse errors in header files
...because those errors can lead to a substantial performance/functional
regression.

The actual diagnostics (possibly with children) are shown as details in
the info bar.

The info bar can be hidden with the "Do Not Show Again" button.
Re-enabling the info bar is possible with the new editor tool bar
button.

Change-Id: I03394ff8e3c84127946b0b791930b28a385f5a46
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-11 14:01:14 +00:00
David Schulz
50a6c47830 Use icons and default tool tips in text mark popup
Change-Id: I4487d642e066479e8e344ed77e539de92fbca651
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-06 09:12:36 +00:00
hjk
728b914727 CppEditor: Use full tooltip in ClangTextMark
Change-Id: I39cc64acbdbcd5e5156e1514acaf9674a91e81a4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-07-25 13:25:16 +00:00
hjk
6edfb66908 TextEditor: Enable tooltips for textmarks
Adjust bookmark code, add tooltips for clang diagnostics.

Change-Id: I489d499f5431fcb29f27611d4350298acb30baac
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-07-19 10:45:23 +00:00
Alessandro Portale
9d9f003e0f Clang: Distinct warning/error icons
Similar shapes, but hollow.

Change-Id: I72f39d1bc701c28c8bc0b038f646904efe1e67b0
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-08 12:41:28 +00:00
Tobias Hunger
397e7f4843 Update License according to agreement with Free Qt Foundation
* Update files in src/plugins

Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:57:01 +00:00
Nikolai Kosjar
ca63359386 CppTools/Clang: Clean-up of includes
Change-Id: I0ba340dcf0ee23e61588f17262d07e7088751836
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 13:15:38 +00:00