Commit Graph

39 Commits

Author SHA1 Message Date
Christian Kandeler
b52fac7148 ClangCodeModel: Remove libclang-based diagnostics and highlighting
Change-Id: Ib7c423884b76c27a6350ddea611919d3352fb80e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-02 07:51:51 +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
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
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
Christian Kandeler
782779f8f4 ClangCodeModel: Remove outdated code
Diagnostics from clang-tidy and clazy do not take this route anymore.

Change-Id: Ifca2d9861d69dda94638277ec1210d28a3350b12
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 12:56:58 +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
Nikolai Kosjar
1b4de8d769 ClangTools: Add help context menu entry
...that opens the documentation page for the current diagnostic.

Change-Id: I398fdc82bb118a80536acbb12420a9bac84e66c9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-01-13 14:33:55 +00:00
Eike Ziller
cc47a525f1 Remove some unused QDesktopWidget includes
Change-Id: Ie369124e2202a79261d08ce9c756499acd552ac9
Reviewed-by: hjk <hjk@qt.io>
2019-08-05 10:37:58 +00:00
Eike Ziller
7f4c6e38bf Merge remote-tracking branch 'origin/4.9'
Change-Id: I0d3db14e583628b906d7fdeb800e004d98e52632
2019-02-20 10:05:07 +01: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
Alessandro Portale
88d1d92728 Bump minimum Qt version (to build Qt Creator) to 5.11
Recent adaptations to Qt 5.13's API deprecations require using APIs
which were introduces in Qt 5.11.

Change-Id: I6c077d824c9ce716e019543b290c355a5d512fad
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-15 14:39:12 +00:00
Christian Stenger
6ae786bcc8 TextEditor: Fix build for Qt5.9
Do not use functions that are not supported with
the minimum supported Qt for building QC.
Partially reverts 963dc84cc5.

Change-Id: Ife03143a7cf5a8f428754040e7004efe42d70a8a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 13:39:21 +00:00
Friedemann Kleint
e7ab1182a0 clangdiagnostictooltipwidget.cpp: Fix compilation
Add missing include.

Amends 963dc84cc5.

Change-Id: Ida93a63dbc8ad3155834901ac2cdf7186bc7deb2
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-02-11 09:45:28 +00:00
Friedemann Kleint
963dc84cc5 Fix some deprecation warnings in basic plugins
Fix warnings apppearing in 5.13, for example:
warning: ‘QDir& QDir::operator=(const QString&)’ is deprecated: Use QDir::setPath() instead [-Wdeprecated-declarations]
...
warning: ‘static QRgb QColorDialog::getRgba(QRgb, bool*, QWidget*)’ is deprecated: Use getColor() [-Wdeprecated-declarations]
warning: ‘Qt::DropAction QDrag::start(Qt::DropActions)’ is deprecated: Use QDrag::exec() instead [-Wdeprecated-declarations]
warning: ‘void QProcess::finished(int)’ is deprecated: Use QProcess::finished(int, QProcess::ExitStatus) instead [-Wdeprecated-declarations]
...
warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::foreground() const’ is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
...
warning: ‘void QTextOption::setTabStop(qreal)’ is deprecated [-Wdeprecated-declarations]
warning: ‘void QList<T>::swap(int, int) [with T = ProjectExplorer::BuildStep*]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]
warning: ‘void QProcess::setReadChannelMode(QProcess::ProcessChannelMode)’ is deprecated: Use QProcess::setProcessChannelMode() instead [-Wdeprecated-declarations]
...
warning: ‘QString QFileInfo::readLink() const’ is deprecated: Use QFileInfo::symLinkTarget() instead [-Wdeprecated-declarations]

Change-Id: I1d893d42d372245892f2de8406f52dbe7bbd552a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 09:32:06 +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
Eike Ziller
d58c0a9ac8 Work around crash when dragging text from tool tip
Disallow text selection for the code model tool tips because dragging
the selection somewhere crashes.

Task-number: QTCREATORBUG-21430
Change-Id: I3aed4e16bf429162258d2dfafaa45fff25ba700a
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-09 08:42:44 +00:00
Nikolai Kosjar
8dacae8eb5 Clang: Fix showing option in tooltip for diagnostic from clang itself
Change-Id: I84972c7b206741e9040e4654e6bc031251aa478c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-13 08:33:31 +00:00
Ivan Donchevskii
95aa52707d Clang: Add links to web pages in Clang-Tidy configuration
Each Clang-Tidy check get the separate link except
clang-analyzer which has only a whole group page.

Change-Id: I0b63cce8475109812280d9d44ac2d36aaa66e03b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-31 12:43:45 +00:00
Nikolai Kosjar
8c8033b438 Clang: Link to documentation for tidy/clazy checks
...in the diagnostic tooltips.

The "enable option" in the top right of the tooltip (e.g.
"-Wclazy-range-loop") is now clickable and will open the documentation
page for clazy and tidy checks.

Change-Id: I6e7e2d1fc39b3b6ccee328276b7a52ae4809b567
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-24 12:37:09 +00:00
Nikolai Kosjar
8639cfcc50 Clang: Fix empty category/option header in diagnostic tooltip
We assumed that diagnostics from clang itself (not tidy, clazy) have
always an enable option set, but this is not true as can be easily
observed with invalid code:

    bla // error: unknown type name 'bla'

Due to the assumption we were running into the
conclude-category-and-option-for-tidy-and-clazy code path, which failed
and resulted in an empty category and thus an empty line in the tooltip.

Change-Id: Ic21629a637a7b0e5736ac514dc826bdc4c0cf91d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-24 12:34:09 +00:00
Nikolai Kosjar
6afd9ecaf3 Clang: Improve diagnostic tooltips for tidy/clazy
Introduce the header for tidy/clazy issues showing "Clang-Tidy Issue" / "Clazy
Issue" and the option that led to the warning, as for normal clang
diagnostics.

Having that, chop off the option in the text to avoid redundancy.

Change-Id: I30a87dc739faa38c51d9e1fb5b9dfc7ffb7055c5
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-14 09:32:09 +00:00
Eike Ziller
428fcb476b Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/libs/utils/settingsaccessor.cpp
	src/plugins/autotest/autotestplugin.cpp
	src/plugins/git/gitclient.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.h

Change-Id: I65f143cad18af509a2621d6c5925abbd038ea70f
2018-04-13 10:54:42 +02: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
Nikolai Kosjar
56a8cd6835 Clang: Remove pointless empty line in diagnostic tooltip widget
...for diagnostics coming from clazy/tidy.

Change-Id: I73a1db74f075c1ec15ff16fc07da012451729097
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-06 06:57:34 +00:00
Nikolai Kosjar
b26143561a Clang: Make diagnostic display adapt to size of the info bar
Change-Id: Ibc7431234b8a68c8e2b0c3f25387de96b203c4c5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-27 08:13:10 +00:00
Nikolai Kosjar
1074d97432 Clang: Avoid fragmentation in diagnostic display
A "diagnostic row" is displayed in two columns with the help of table,
one cell being the location, the other cell the diagnostic text. At
times, the location is wrapped too, which makes the whole diagnostic
display look fragmented/broken.

It looks like there is no way to avoid the wrapping of the location
column because Qt's CSS does not support the needed

    style='white-space:nowrap'

Avoid the columns for a consistent display at all times.

Change-Id: I35e4a1c831f18e2bce6a4c9ed891fcae439d1a1b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-24 10:52:12 +00:00
Nikolai Kosjar
dca76c9889 Clang: Leave space between category and option in diagnostic display
For some diagnostics ("#include_next is a language extension"), the text
has a smaller width than the category and option together. In this case,
there is no space between category and option, which looks terse.

Change-Id: I27e4736a0d2aa527d5733c6115bc8d40fe7794e0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-24 10:52:06 +00:00
Nikolai Kosjar
e373061119 Clang: Explicitly add extra space in diagnostic widget
...otherwise the one that is there will be ignored for long diagnostic
messages.

Change-Id: If9327f40b2af3315941cdb7cdf40d9e44854408b
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-25 08:31:56 +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
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
Nikolai Kosjar
ed8b910202 Clang: Honor fixits own locations in ClangFixItOperation
The fixits have own ranges/locations and thus might address more than
one file.

Change-Id: I5ee59944bef588e763a91f054a60823593373a0e
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-07-08 08:22:37 +00:00
Nikolai Kosjar
a1071b5066 Clang: Handle fixits of main diagnostic in tooltip
So far we have assumed that:
 1) The main diagnostic explains the issue.
 2) The child diagnostics might have fixits attached that use the
    imperative in the text. Because of this we made the fixit texts
    clickable.

As it turns out, the main diagnostic itself also might have fixits
attached, as the following example shows.

  // Parse solely with the warning option "-Weverything"
  template <typename T> struct C {};
  C<C<int>> bla;

...which leads to

  warning: consecutive right angle brackets are incompatible with C++98
  (use '> >')

...which has no further child diagnostics, but provides a fixit.

The problem with this case is that it is not obvious for the user that
clicking the text will fix the issue since no imperative is used at
start of the text. For now, handle this case by making the text of the
main diagnostic clickable, too. But if we encounter more cases like
this, we probably should visualize the "you can apply the fix by
clicking here" concept differently.

Change-Id: Ia64e9821df783cba13d32395fab19251feca0398
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2016-02-18 13:01:44 +00:00
Nikolai Kosjar
985309afbd Clang: Limit number of child diagnostics in tooltips
The number of child diagnostics (notes) can get quite high, consider:

 error: no matching function for call to 'someFunction'
  note: candidate function not viable: no known conversation from 'X' to 'Y1'
  note: candidate function not viable: no known conversation from 'X' to 'Y2'
  ...

If there are more than 10 child diagnostics (notes), show only the first
7, an ellipsis and the last 3 of them.

Change-Id: Id74e60f5872fb9aab0cfcb956e9b740456937dac
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2016-02-16 13:08:52 +00:00
Nikolai Kosjar
b064b06759 Clang: Display also child diagnostics in tooltips
...by introducing a custom tooltip widget for diagnostics.

Locations and fixits of child diagnostics are presented as clickable
links, leading to that position in the editor or to the execution of
that fix it.

Change-Id: I83e801e22d0421dd29275e333e5dd91587885cf1
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2016-02-12 11:54:09 +00:00