Commit Graph

1332 Commits

Author SHA1 Message Date
Ivan Donchevskii
a91956f300 Utils: Move common positionInText function to Utils::Text
Change-Id: I5d74a73058ca457b0fb3f13eaf945f224d5699fb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-06-19 09:20:53 +00:00
Ivan Donchevskii
e1111d4570 Clang: Use built-in follow symbol for virtual methods
ClangCodeModel currently does not provide a list of overrides.
Therefore it makes sense to use ClangCodeModel result for
virtual method only if built-in code model does not find anything.

Task-number: QTCREATORBUG-20584
Change-Id: I5b4fac7974f990e741d3438ab61827670a8ce8d8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-15 12:15:22 +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
Christian Stenger
cab82a94c7 Clang: Fix accessing nullptr
Change-Id: I204ff9263520dee70a89adf99182d198e4dd1036
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-11 09:55:33 +00:00
Nikolai Kosjar
b30926cea4 Clang: Minor renaming
This completes

    commit f01fbcb789
    Clang: Clean up some IPC names

Change-Id: Ic747ca4a01e5c693bd59626eef516ae4a42bf9fc
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-08 06:32:33 +00:00
Nikolai Kosjar
e1e11ae15d Clang: Fix testCompleteFunctions()
With recent clang versions we can show default arguments properly.

Change-Id: I6028db183b0413650a32928d0051afb9402c5e32
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-07 13:46:08 +00:00
Ivan Donchevskii
4f51b89d65 Clang: Do not duplicate operator entries
Do not show the same operator twice in symbol outline and
current document filter.

Extract common checks to TokenInfoContainer class.

Change-Id: I3b48aa949d678564c952a71f650b7ba601570fa2
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-06 13:16:05 +00:00
Ivan Donchevskii
bb0c681ff8 Clang: Do not show any function internals in symbol outline
Treat everything inside function scope the same way
as local variables.

Change-Id: I038d84e5e90057d65a08afc742ebcdf2de55ff85
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-06 13:15:57 +00:00
Nikolai Kosjar
f01fbcb789 Clang: Clean up some IPC names
This is long overdue since some names were simply wrong and/or
misleading. Also, some of the old names were long enough to almost get
crazy.

The renaming starts from ClangCodeModelServerInterface and
ClangCodeModelClientInterface and affects usages and related functions.

For the ClangCodeModelServerInterface, categorize the messages in
 - messages that require a response (request*)
 - notification messages (the remaining ones)

Change-Id: I5342ed8e0d87404ee72f3c3766fd8ef7505defb1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-04 09:54:01 +00:00
Ivan Donchevskii
4e4bd4909a Clang: Use follow symbol result from clang when global fails
When built-in code model fails to follow symbol under cursor
fall back to the clang result even if it only follows
to the decalration.

Change-Id: I22d8c5fee6ab7594b1d1b7ce8104414db28383c7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:48:33 +00:00
Ivan Donchevskii
52bd5173fb Clang: Remove extern and static declarations from symbol outline...
... in case they appear within the function body.

Task-number: QTCREATORBUG-20434
Change-Id: I6d12ab857cca5fe8479ac3fb426329ae7d732567
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:46:25 +00:00
Ivan Donchevskii
b0c0119345 CppTools: Use cursor range for better outline navigation
Clang provides cursor range for each declaration in
symbol outline. Use that information to search for
more accurate correspondence between a cursor position
in editor and an entry in symbol outline.

For example skip indexes with not matching ranges to
prevent pure declarations from automatically become
parents of everything coming after them.

Change-Id: I0ef95c26772050cd6655e830288c46118aba38bb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:43:44 +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
a809462c91 ClangTools: Avoid warnings from Q_OBJECT, too
Change-Id: I4540c1e2d9123af12e9f96976d6e37fe25aaf728
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-23 10:48:06 +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
Ivan Donchevskii
5288f35523 Clang: Enable Clazy fix-its
Only extra command-line options were required.

Change-Id: Id67b0cb29db4539ebec7facd07b53942f5900099
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-14 13:31:52 +00:00
Nikolai Kosjar
20d2d76824 Clang: Do not flash issues pane when switching editor
Previously, when swichting to a file with errors, the Issues pane button
would flash.

Stop this for the clang code model issues as it is rather annoying since
the issues pane is updated for the current document.

Change-Id: I403a8b8cd0deef586c53769d0b646855a7fc9278
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-05-14 09:32:28 +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
Ivan Donchevskii
53d7906061 CppTools: Merge diagnostic selection widgets together
QComboBox, QLabel and QPushButton are always used
together. Therefore it makes sense to put them in one
custom widget.

Change-Id: Ie21675530fbadd7071f2a362567dadb6f09bb68d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-14 09:05:37 +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
Ivan Donchevskii
3737b6a124 CppTools: Split diagnostic settings and selection
Now selection is only consists of combobox and
a "Manage" button to diagnostic configurations.
Diagnostic configurations are moved to the modal dialog
which is shown by clicking the mentioned "Manage" button.

Change-Id: I607fb923c97e8730448548708f3aaf32ce1983c8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-14 07:02:53 +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
Ivan Donchevskii
52ac74b61c ClangTools: Remove clang executable settings
We use custom clang executable and it does not make
sense anymore to give a choice of changing it.

Change-Id: Icf86042ac3fcd08c320ef2bbdaabef1102b023b5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-04 09:58:37 +00:00
Orgad Shaneh
80ae992c91 Clang: Fix another crash when closing document
Task-number: QTCREATORBUG-20191
Change-Id: Iae9d96827f5b84b727a838aae1fcc08eeacb909e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-04 09:46:15 +00:00
Nikolai Kosjar
4861f5c183 Clang: Fix heap-use-after-free in ClangCurrentDocumentFilter
...when closing editors fast (e.g. holding Ctrl+W).

Due to the queued connection the slot was invoked after the deletion of
the editor. There is no point in having a queued connection here, so
remove it.

Task-number: QTCREATORBUG-20191
Change-Id: I3872f8046b56f93c9aac832feccfd911d39e5995
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-03 11:02:35 +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
Hugo Holgersson
142ae0cdf9 Clang: Add semantic C++ operator-token styling
We used to style overloaded operators in the same way
as C++'s built-in operators. There was no way to tell
if a + token would call a operator+() function or not.

Now, if an operator is overloaded (redefined),
we give it the "Overloaded Operator"-mixin so users
can style it differently.

Note: Calls to overloaded 'new' and 'delete' are not
highlighted by "Overloaded Operator". This is because
clang today always maps these to CXCursor_CXXNewExpr
and CXCursor_CXXDeleteExpr with cursor.spelling == ""
(empty string). So there is no (?) quick way for us
to tell if a new/delete-token was overloaded or not.

After follow-ups, follow symbol will work for operator
overload usages in current translation unit.
Commit is appended by Ivan Donchevskii.

Task-number: QTCREATORBUG-19659
Change-Id: I157855d482a61ad2059642a1ee982089fcb7d312
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-30 15:10:12 +00:00
Ivan Donchevskii
219e23332e ClangTools: Add tool that runs clang-tidy and clazy
... over the whole project.
Generate and read serialized files to get diagnostics.

Change-Id: Iafc25fc70443107a040a995efc038aed35102bbf
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-26 13:02:19 +00:00
Eike Ziller
c1bfc9d0a4 Merge "Merge remote-tracking branch 'origin/4.6'" 2018-04-26 12:28:00 +00:00
Ivan Donchevskii
7b2774dea1 Clang: Use current TranslationUnit follow symbol based on clang code model
It might be quite a safe replacement which can fix builtin
code model issues.

If clang code model fails to follow symbol or does not find
a definition when it's required we fall back to the built-in
code model to proceed with project-wide follow symbol.

To make it almost a full replacement tweak include paths underline
on cursor hover to match what we have in built-in code model.

SIGNAL/SLOTS macros are not yet supported but can be handled
in follow up patch.

Task-number: QTCREATORBUG-19477
Change-Id: Id1611511d661a8aaf3e93502b4e03e1792c7c1d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-26 10:27:42 +00:00
Eike Ziller
62050437c3 Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp

Change-Id: Ia723411f4b5c9c90f9786223ac6a7346d7ab9b99
2018-04-26 10:16:32 +02:00
Ivan Donchevskii
feac99c9ac Clang: Fix possible future watcher issues in local renaming
Use the same code pattern as in asynchronous branch of
CppUseSelectionsUpdater::update.

Change-Id: I7c06b883a5abe1324cb63fa410247ef7f50321ae
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-24 10:06:17 +00:00
Nikolai Kosjar
787f0498ca Clang: Fix wrong QTC_ASSERTS
If the last editor is closed, "editor" becomes a nullptr, which is valid
value in this case.

Change-Id: Id5f92cb4367199d782e33acc37077103e9986644
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-24 08:16:53 +00:00
Ivan Donchevskii
ef660d8bd0 Clang: Simplify name and type in FullTokenInfo for functions
Take Cursor displayName instead of token name.
From now on type spelling can serve the return type
role for functions because together with 'token' member
they form the full type.

Change-Id: Ic8eec533f4a11458f99f070b6a6aa80714097b4d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-23 07:59:40 +00:00
David Schulz
20e67865ea CodeAssist: Store processor state in specialized objects
Change-Id: I19de64b948599c833496ab8caabf3eaafc845658
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-04-19 05:52:21 +00:00
Nikolai Kosjar
7be7d26814 Clang: Show current editor diagnostics in issues pane
This helps to deal with many diagnostics.

Error diagnostics precede warning diagnostis to have them on top.
If no CppEditor is active, no diagnostics are displayed.

Previously one had to scroll the document up and down to locate the
diagnostics. Now they are in a list and can be easily navigated with
F6/Shift-F6. Also, at least for some diagnostics "Get Help Online" from
the context menu seems to provide useful results. For example,
triggering the action on clang tidy issues will open the web browser
with some good hits explaining the issues.

Change-Id: Idabe30b0961d893bee39ccee431e92aeeda1cc26
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-16 09:37:06 +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
Ivan Donchevskii
f9d95c9205 Clang: Optimize clang overview model
Build the tree in only one loop.

clangbackend generates tokens almost as fast as it
did before (about 10% slower in general).
Broken documents are more affected and take much more
time (about 300%) but it's better to have this time spent
on backend side then in QtC itself.

Task-number: QTCREATORBUG-20205
Change-Id: I34c58bca30c4494005a029abd82c7e612ecd6fb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 09:15:12 +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
Ivan Donchevskii
84b983617f Clang: Support anonymous types in tokens
Add extra data to Keyword tokens.
Does not affect highlighting.

Change-Id: I206499ea35ee4ece5fe442665c904090cf5d90fc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 06:51:07 +00:00
Nikolai Kosjar
8441bb0933 Clang: Avoid warnings about unknown warning options
...as they are generated by e.g. Q_OBJECT use.

Previously we have avoided Q_OBJECT warnings by using
-Wno-unknown-pragmas (Qt Creator build with libclang 3.9). With the
upgrade to libclang 5.0 GCC pragmas can now be parsed by clang and the
related warning option thus changed to -Wunknown-warning-option.

Note that previously -Wno-unknown-pragmas was part of every built-in
configuration and visible in the UI. Now that option and the new one are
added behind the scenes (not visible in the UI anymore) so that every
diagnostic configuration, also the copied/customized ones, will profit
from it. Still, by putting this hidden options first on the command
line, the user can overwrite them with his own configuration if desired.

Task-number: QTCREATORBUG-17460
Change-Id: I68aaec1b4791522bd8dc4e5fdb405cc5b9c9f514
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-11 07:15:35 +00:00
Orgad Shaneh
eea6a7c3b3 Utils: Purge qtcfallthrough.h
No longer needed.

Change-Id: I9b0bee014df89d4c567f1d2431b5ff9404f5f925
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:13 +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
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
Orgad Shaneh
704a70810d Clang: Add a missing break
Detected by GCC8.

Change-Id: I64e399a006c9ad93af4798f0e6cf48f1ca391f39
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-05 06:19:51 +00:00
Robert Loehning
d424fb36f1 Clang: Don't dereference nullptr
Change-Id: Ib36c2d18fd01684cad45042b9f1a6901a028b345
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-03-28 13:12:15 +00:00
Eike Ziller
5cc24f9ac1 Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/projectexplorer/msvctoolchain.cpp

Change-Id: If2116aa2dbfdb9d07088595e791f8fa706b39e00
2018-03-28 10:01:44 +02:00
Marco Bubke
9c4bfbe20a Clang: Improve interfaces
The interfaces should never used to handle ownership. So it is now using
protected destructors. Copy operations are forbidden too.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-nonvirtual

Change-Id: Ib0b60a73a7ec130973b5cb0095cc5b2f10fa0758
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-26 13:39:36 +00:00