Commit Graph

62 Commits

Author SHA1 Message Date
hjk
430a33dcd9 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 06:07:13 +00:00
Nikolai Kosjar
c5e43d86d1 Clang: Make diagnostic tooltips consistent
Fix that triggering a diagnostic tooltip from the diagnostic
location/range itself (underlined text) did not show the icon on the
left and the actions/toolbuttons on the right in the tooltip.

Instead of showing the tooltip content itself, request the tooltip for
the corresponding text mark to get the extra decoration and actions.

Change-Id: I5e94aca117a761f7a798d4f4b33db6e386e54d84
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-05 11:22:27 +00:00
Alessandro Portale
1d3d18a969 CppTools: modernize
Change-Id: Iaf02e4d026f1ac8b216833d83cd7a735e21ff60a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-21 09:00:18 +00:00
Nikolai Kosjar
d52ac9a708 Clang: Fix unresolved #includes for ui_*.h headers
...with an extra parse.

Previously, the creation of an e.g. "Qt Widgets Application" from the
wizard could show code model errors in mainwindow.cpp. Depending on
timing issues, the first error is either

  1. 'ui_mainwindow.h' file not found (QTCREATORBUG-15187)
    The parse happened before the in-memory ui_mainwindow.h was
    generated by uic. The file system watcher can't help here as the
    #include was not resolved successfully. And libclang's reparse does
    not handle this case (it would need to remember all failed #include
    stats...).
    ==> Detect this case with the help of the include paths and trigger
    a full parse.

  2. or: allocation of incomplete type... (QTCREATORBUG-15187)
    The parse happened after the generation of the in-memory
    ui_mainwindow.h, but before the clangbackend received the unsaved
    file.
    ==> Fix this by also writing the content of the unsaved file to our
    behind-the-scenes-created ui_mainwindow.h.

Fixes: QTCREATORBUG-15187
Fixes: QTCREATORBUG-17002
Change-Id: I4f3a81adaa3d604746977a402c29f83fbc5b0e44
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-31 10:38:27 +00:00
Nikolai Kosjar
aa290912b8 Clang: Remove project tracking on clangbackend side
...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-26 10:45:41 +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
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
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
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
Ivan Donchevskii
99bd0ed2a4 Clang: Rebuild overview model tree when token data is updated
In release builds overview model tree is built earlier
then the job with token information is completed.

Change-Id: I1a563551e813996001fb97924ac441e2b7d599b9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-03-23 14:15:45 +00:00
Ivan Donchevskii
d81580b7a3 Clang: extra clangbackend job to collect full token info
Limit document annotations job to only highlighting data
collection and move more expensive calls into separate job
that runs after it.

Change-Id: Ie792a3f741ac45c81033dd5b3a20ed061604f927
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-02 07:01:59 +00:00
Nikolai Kosjar
5b1ae09fbf Clang: Auto reparse if diagnostic config changes
On diagnostic config change, affected documents are closed behind the
scenes. Visible ones are parsed immediately, invisible ones are tagged
for parse once they become visible.

Task-number: QTCREATORBUG-16263
Change-Id: Id4dcc69f1a4bfccc597e798d6821f8718f86e352
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-01-29 08:14:08 +00:00
Nikolai Kosjar
6b38c73205 Clang: Centralize gathering file argument into one class
Similar to CompilerOptionsBuilder.

Change-Id: Ifac0efe37608562912af20a1c22f85e5e9308094
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-24 11:51:45 +00:00
Nikolai Kosjar
b31978a2f7 Clang: Use reference instead of pointer in editor processor
...because the pointer can't be null.

Change-Id: I318f5d7ff2d2ac7de188718ec6281b083965dfd4
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-24 11:51:40 +00:00
Nikolai Kosjar
764925eb3a Clang: Send less data on unregisterTranslationUnit
For unregisterTranslationUnit only the file path and the project part id
is needed.

Change-Id: I882d2fe07af094c07ea42413d6874539535a48ea
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-19 14:54:27 +00:00
Nikolai Kosjar
4875e07efb Clang: Add 'override' to related destructors
Change-Id: I763ec2d3462f9a3d1a1afc4270c5f1015bee758f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-19 14:54:19 +00:00
Nikolai Kosjar
76c25bcd6a Clang: Provide tooltips
This includes also the query data for the help system (F1) for an
identifier under cursor.

Regressions (libclang changes necessary):
 - Function signatures do not contain default values.
 - Aliases are not resolved for/at:
   - template types
   - qualified name of a type

Fixes/Improvements:
 - Resolve "auto"
 - On a template type, show also the template parameter.
 - For a typedef like
     typedef long long superlong;
   the tooltip was "long long superlong", which was confusing.
   Now, "long long" is shown.

New:
 - Show first or \brief paragraph of a documentation comment.
 - Show size of a class at definition.
 - Show size of a field member in class definition.

Task-number: QTCREATORBUG-11259
Change-Id: Ie1a07930d0e882015d07dc43e35bb81a685cdeb8
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-16 15:32:15 +00:00
Ivan Donchevskii
affc652b7b Clang: Rename HighlightingMark to TokenInfo
Before adding additional members into that class it
makes sense to rename it to better represent its content.

Other classes serving the same purpose are also renamed
to keep the names consistent.

Change-Id: I3c8517e42aae29779d71ec9c85b713cff581a473
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-11 15:00:24 +00:00
Ivan Donchevskii
32bae7ef6c Clang: use local renaming based on ClangCodeModel
Provide refactoring engine for ClangCodeModel and
implement missing methods.

Change-Id: If5c913e0c5a7941cd2ced54d0fcfa4d625eadc93
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-11-20 10:24:47 +00:00
Nikolai Kosjar
917592970d Clang: Extract and rename backend classes
IpcCommunicator -> BackendCommunicator
IpcSender -> BackendSender
IpcReceiver -> BackendReceiver

Change-Id: I110ebe8d185db7ff47d2d5de9b786262520926d0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-28 12:45:31 +00:00
Ivan Donchevskii
f130de2400 Clang: use HighlightingMarks for hover with Ctrl highlighting
Make this highlighting work without builtin code model
but based on the HighlightingMarks that we already have
from ClangCodeModel.
Redundant parameters are removed by this change.

Change-Id: I73b5dab46ba59d2f813236831818f0a9bc94c5bc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:58:46 +00:00
Ivan Donchevskii
e6a50fd44a Clang: implement requestFollowSymbol plug-in side
Invoke follow symbol in clang backend
if env variable QTC_CLANG_FOLLOW_SYMBOL is 1.
Does not include backend implementation.

Change-Id: Ia20a677830ebdd7f24800af5c5d6e8b1bf579205
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-08-15 07:32:16 +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
Nikolai Kosjar
ca72c29462 Clang: Provide highlighting for identifier under cursor
Change-Id: I80ffe23cbcc84ab7323124581d9dd6afbe974fd0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:49:05 +00:00
Nikolai Kosjar
fdf0a104ec CppEditor: Generalize CppUseSelectionsUpdater
Let CppUseSelectionsUpdater delegate the work to
*EditorDocumentProcessor so that the clang code model can also provide
results.

Change-Id: I6872afbfeea1a5c4a64fdf19fcb1992f134dde08
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:24:59 +00:00
Orgad Shaneh
8b5867dd8e ClangCodeModel: De-slot
Change-Id: I9e4520a1a1baec9a900a659931686fbc99123d3c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-03-20 10:43:01 +00:00
Nikolai Kosjar
38ba61ec4f CppEditor: Rework showing/switching parse configurations
* Move the combox box for switching the parse configurations out of the
  "Additional Preprocessor Directives" dialog ('#'-button) to make it
  better visible/accessible. Also, decouple the extra preprocessor
  directives from the concrete parse context since this is not anymore
  in same dialog.
* The combo box appears only if multiple parse configurations are
  available for a file.
* The first time multiple parse configurations are detected, an info bar
  is shown that points the user to the combox box. A "Do Not Show Again"
  button is provided.
* Upon selecting an entry, the preferred parse configuration is saved as
  part of the session. The setting can be cleared with the context menu
  entry on the combo box.

Follow-up changes need to ensure that the display name and/or tooltip is
unambiguous, e.g. for qbs and cmake projects.

Change-Id: I9e9773704187291524ad7b605bfdddd83ef5b19d
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-02-03 11:58:27 +00:00
Nikolai Kosjar
bd66d5ac05 CppTools: Remove some duplication
Change-Id: I8c84660b28c3e76b2cedd08ff3b44a38583f38a0
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:56:26 +00:00
Nikolai Kosjar
6cf1f7968f Clang: Fix initial document parse with modified content
Reproduce with:

  1. Create a new class named Foo with the wizard.
  2. Close foo.h
  3. In foo.cpp, add some class member function.
  4. In foo.cpp, trigger the refactoring action "Add public Declaration"
     for the just defined member function. As a result, foo.h will be
     opened.
     ==> While the declaration was added, the header file is not yet
         reparsed with the new content - this can be verified by setting
         a custom color for "Function".

In this use case, the refactoring action opens the editor and
immediately modifies the document (RefactoringFile::apply).

Fix by sending the document content along for the very first
RegisterTranslationUnitForEditorMessage if the document was already
modified.

Change-Id: If20615a45b72dd0bef87e1870e403d0b277bc5d6
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-11-23 11:50:39 +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
Nikolai Kosjar
380d756a03 Clang: Hook up supportive translation unit on first edit
Parsing happens rotationally on the translation units.

The recently parsed translation unit is used for completion jobs while
the older version is used for parse jobs.

Advantages:
  A1. A completion job cannot be blocked anymore by currently running
      parse job.
  A2. Faster triggering of parse jobs. A reparse was triggered about
      1650ms after the last keystroke. This is down to 500ms now since we
      do not have a blocking translation unit for the completion anymore.

Disadvantages:
  D1. Memory consumption is doubled for an edited document.
      This could be addressed by suspending the second translation unit
      after some time of inactivity.
  D2. Setup of the supportive translation unit takes some time.

Change-Id: I958c883c01f274530f5482c788c15cd38d6f4c3e
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:36:59 +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
39a38d5679 Wholesale conversion to #pragma once
Kudos to cgmb and https://github.com/cgmb/guardonce

Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-03-30 15:20:19 +00:00
Nikolai Kosjar
9a4284d666 Clang: Use CppHoverHandler for diagnostic tooltips
We used to call QTextCharFormat::setToolTip from the ExtraSelection to
install the diagnostic tooltip. Since this allows to set only text
tooltips and we would like to introduce a custom tooltip widget for
diagnostics, make use of CppHoverHandler, which is more flexible.

Change-Id: Ia1b2c3c50810596ce4a3a025002e6e4efd8789db
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2016-02-12 11:20:27 +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
802f9f47e9 Clang: Pass IpcCommunicator directly to ClangEditorDocumentProcessor
Change-Id: I666c56f304522a3edc2a21055df4ef70aecb0e0e
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 13:29:17 +00:00
Nikolai Kosjar
a12a8c95f9 Clang: Request diagnostics/highlighting only if needed
Most of the time, the updated diagnostics/highlightings will be send by
the backend on translation unit update.

The other use case is changing the font settings (e.g. color), here we
need to request the highlightings explicitly.

Change-Id: I17a574eaf972c8bef12900241e7b33fe6ffd9dbd
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-30 16:50:49 +00:00
Marco Bubke
7ce9ef9db4 Clang: Integrate highlighting results from backend
Change-Id: I2c3fb69aabfe075bde76d63eafc2ca370f17493c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-26 15:19:27 +00:00
Marco Bubke
bd10e9b020 Clang: Only apply fixits to the corresponding revision
Change-Id: I4f4136369e1b261338d444670c212565e0c6b824
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-25 14:15:39 +00:00
Nikolai Kosjar
56f37f78b2 Clang: Speed up requesting diagnostics
Register the translation unit and request diagnostics from the
clangbackend as soon as the project part is determined. There is no
reason to wait until the parser is finished for the highlighter.

Change-Id: Iebccbf59ebd205389462dcee97363746fb651bb2
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:55:39 +00:00
Marco Bubke
6cbee0ede3 Clang: Add fileContainer getter
File containers were generates in many places. To reduce the noise this
getters are introduced.

Change-Id: I059745c27ac2dd0515bc23b3438d6d264ba071d7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-05 10:37:26 +00:00
Nikolai Kosjar
a5674be613 Clang: Unregister file with project immediately on project close
Ensure that first the editors unregister with the removed project part,
then unregister the project part.

This makes testing and following the message logs easier.

It also fixes the following race condition:
 * Unload project of opened file
 * Immediately close the editor before a new project part is calculated
 ==> The editor is closed, but the translation unit is not properly
     unregistered.

Change-Id: I618930d221323435ba60ac6c051380bccc9fdaf1
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-10-01 13:44:48 +00:00
Marco Bubke
25bb8411a4 Clang: Add ClangEditorDocumentProcessor::hasProjectPart
Change-Id: Ie08c44315c9d03434384a1fa0b276e22f45a2107
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-09-30 11:38:36 +00:00
Nikolai Kosjar
a7928b4b0b Clang: Integrate clang's fixits as refactoring actions
They are invokable by the usual means (Alt+Enter, editor's context menu
> Refactor) plus by the context menu of the editor's left margin for the
related line.

The fixit text comes directly from libclang and is thus not translated.
We modify the text slighty by stripping the diagnostic category prefix
("note:", "error:", ...) and capitalizing the first letter.

A follow-up change should properly indicate available refactorings with
a refactoring icon in the editor's left margin.

Task-number: QTCREATORBUG-14868
Change-Id: I86157c9f824d2a9dedf19087476d02ad1e6cc854
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-29 11:39:21 +00:00
Nikolai Kosjar
de6d7f0617 Clang: Refactor handling of diagnostics
...by introducing ClangDiagnosticManager and the helper class
ClangDiagnosticFilter.

ClangDiagnosticManager will get more state in a follow-up change.

Change-Id: Id2c312bc897ea41ed67292b56b24dcfb7975ff4a
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-29 11:38:53 +00:00
Eike Ziller
c868b9f3ed Merge remote-tracking branch 'origin/3.5'
Change-Id: Ife5fdcd71b0adc99d4297a28a64515e9e93d7864
2015-09-04 09:19:28 +02:00
Nikolai Kosjar
169556db2f C++: Fix crash after triggering completion and closing editor
Fix use-after-free for the following case:
  1. Open an editor
  2. Trigger a long processing completion
     (e.g. simulate with QThread::msleep in
      CppCompletionAssistInterface::getCppSpecifics)
  3. ...and immediately close the editor (e.g. with Ctrl+W)
  4. Wait until it crashes.

The completion thread relied on the BuiltinEditorDocumentParser object,
which is deleted once the editor is closed. Fixed by sharing the
ownership of that object between the *EditorDocumentProcessor and the
completion assist interface.

This case came up when doing tests for the bug report below.

Task-number: QTCREATORBUG-14991
Change-Id: I0b009229e68fc6b7838740858cdc41a32403fe6f
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2015-09-02 12:37:23 +00:00
Marco Bubke
6e14eb6940 Clang: Rename ForCodeCompletion in ForEditor
It reflects that the translation units and projects have a tied
relationship with an editor.

Change-Id: I3c01d5776980fe079af1fdef82feded83fdf5463
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 15:02:02 +00:00
Marco Bubke
b278dc87ca Clang: Add diagnostics
Diagnostics are now moved to the clang backend process. Fixits are
supported too.

Change-Id: I20faacf466bbf78dec479220c3d7b336a47bc453
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 14:59:16 +00:00