summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
Commit message (Collapse)AuthorAgeFilesLines
...
* | ICore: Change some path API to use FilePathEike Ziller2021-04-261-1/+1
| | | | | | | | | | | | Change-Id: Id841d6177206a021c9e606ce560b47d1ae6e52b9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* | ClangCodeModel: Add experimental clangd supportChristian Kandeler2021-04-2213-14/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | If the user has enabled clangd (default is off), we start up one instance per project when it is opened/changed (including build config switches), and trigger background indexing. So far, the index is used to provide results for locators and "Find Usages". Per-document functionality such as semantic highlighting and completion is still provided by libclang. Change-Id: I12532fca1b9c6278baab560e7238cba6189cde9f Reviewed-by: David Schulz <david.schulz@qt.io>
* | Merge remote-tracking branch 'origin/4.15'Eike Ziller2021-04-202-4/+12
|\ \ | |/ | | | | Change-Id: I1d13f3543ab4bb17f0cbfe26bbea3f154f856ca6
| * CppTools: Another parentheses highlighting fixChristian Kandeler2021-04-201-1/+3
| | | | | | | | | | | | | | Amends c80c724b52. Change-Id: I2691791d40c84bbc1fa6c2525676ef3955b4ffd3 Reviewed-by: David Schulz <david.schulz@qt.io>
| * ClangCodeModel: Fix template highlighting bugChristian Kandeler2021-04-162-4/+10
| | | | | | | | | | | | | | | | | | We need to take into account that the ">>" in constructs such as std::vector<std::pair<int, int>> is only one token on the clang side. Change-Id: I90f002ca56f236032f6d39c338593a2ff7590061 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* | StringTable: Ensure only one GC() thread is running at a timeJarek Kobus2021-04-191-31/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The possible issue with the current implementation is that in theory many possible GC() are being executed in parallel. In this case just one of them is really working and others are waiting on the locked mutex (first line of the GC() method). In such a scenario when a call to StringTablePrivate::insert() is being executed from one more thread, it may happen that the working GC() thread is stopped (since m_stopGCRequested.fetchAndStoreAcquire(true) was executed from insert()) and later the mutex lock may be granted to the other awaiting GC() thread instead to the thread which executes insert() method. In this unlikely scenario the GC() thread won't be canceled and the lock inside the insert() method may be locked for considerable amount of time, what is not desired. The goal of this patch is to resolve the possible issue above and to simplify the code by eliminating the m_stopGCRequested variable and make use of QFuture.cancel() / QFuture.isCanceled() API instead. In addition, since we control now only one possible thread that executes the GC(), there is no need for future synchonizer anymore. GC() function can't be run in parallel in different threads, as the whole body of GC() is protected with mutex. This means that whenever a new scheduled call to GC() is being executed, this new call waits on the mentioned mutex at the beginning of GC(). So, instead of protecting the whole body of GC() with a mutex, we ensure that the old call to GC() is already finished (if not, we also cancel the old call) while preparing an asynchronous call to start a new GC() from inside startGC() method. Whenever we are calling the insert() method, we still protect the access to m_strings with a mutex (as insert() is designed to be called from different threads in parallel). Just after locking the mutex we are canceling any possible ongoing call to GC(). After canceling the GC() call, we are sure that no new call to GC() will be executed until we unlock the mutex, so it's safe now to modify the m_string data. Change-Id: If72d0a6f98fb414c6c63117bc9baa667d17e1ffe Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | AutoTest: Free TestTreeItem from CppTools dependencyBernhard Beschow2021-04-122-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | Makes TestTreeItem programming language agnostic. By moving the "query" methods to CppTools, the cohesion within these methods is improved, i.e. information crosses the AutoTest <-> CppTools border fewer times. Furthermore, it allows the CppTools plugin to see how its data is being used, allowing it to optimize its queries behind the scenes. Change-Id: I0a60140abaca1193d500605dfa2812b4d937d94c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* | Fix a possible crash in StringTable on shutdownJarek Kobus2021-04-091-11/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue is that when a GC() function is being executed in a separate thread, the main thread may delete the StringTable (on shutdown) in the same time. The destructor of StringTable didn't check in any way that the other thread is still executing GC() method. In order to fix it we employ runAsync method, returning the handle to the running task. We store the handle in futureSynchronizer, and in destructor of StringTablePrivate we safely wait for all futures to be finished. Fixes: QTCREATORBUG-25417 Change-Id: I0039d6041276c521c221e8dfc3894e84e47b82a2 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | CppTools: Do not pre-select "external" files in "rename symbol" widgetChristian Kandeler2021-04-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | It's unlikely that the user wants to change files that are not part of the currently loaded projects, so opt-in is the right approach for those. Fixes: QTCREATORBUG-8561 Change-Id: I1812a3e64de66828ac07dea7bbb63acdb4dd40d8 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* | Merge remote-tracking branch 'origin/4.15'Eike Ziller2021-04-061-5/+4
|\ \ | |/ | | | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs qtcreator_ide_branding.pri src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp Change-Id: I403b236c40d73a61ae22304e289e9d4374366395
| * StringTable: Use QElapsedTimer instead of QTimeJarek Kobus2021-03-261-5/+4
| | | | | | | | | | Change-Id: I75065cbe32dcd4405360b90f3f51387f286d6186 Reviewed-by: hjk <hjk@qt.io>
* | Merge remote-tracking branch 'origin/4.15'Eike Ziller2021-03-251-4/+4
|\ \ | |/ | | | | | | | | | | Conflicts: src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp Change-Id: I722a94f37bdd1d78625cfae503ba6d02ff083c63
| * Fix lupdate issuesEike Ziller2021-03-221-4/+4
| | | | | | | | | | | | | | | | | | 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>
* | Locator: Add longer description to filtersEike Ziller2021-03-231-0/+4
|/ | | | | | | | | | This is shown as tool tips in the location options, and if any platform supports this also as tool tips on the menu actions of the locator input field. Change-Id: I8b439e45e6097a16a5f932d25d4e5d3e9bddb6ad Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
* CppLocatorData: Don't use recursive mutexJarek Kobus2021-03-152-13/+3
| | | | | | | | | | | | | | Don't use recursive mutex in CppLocatorData class, as this is more expensive to construct than simple QMutex. Refactor the code so that every call to flushPendingDocument() is done with already locked m_pendingDocumentsMutex. This eliminates the need for recursive mutex. Remove unused allIndexItems() method. Change-Id: Ic7cb45bc3301d83768e69ee52f84ae159cb731a5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Fix search result font for symbol searchesEike Ziller2021-03-021-0/+2
| | | | | | | | | | | | SearchResultItem defaults to the standard application font, we need to tell it to use the text editor font explicitly, like the specialized addResult method did that was removed. Amends d3deefc3a4306e5b8882c7388f2ef1684dc0d922 Fixes: QTCREATORBUG-25396 Change-Id: Id8d41d93c96fbfd6d993568a37d42509da452665 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* CppTools: Clear outdated "semantic parentheses"Christian Kandeler2021-03-011-5/+43
| | | | | | | | | | For instance, if the user types "template<", then the next operator> in the source code will be temporarily classified as the closing angle bracket for that template. Therefore, we have to clear out any previous information of that kind. Change-Id: Ib6d64415b2f6294661e2b8ec48cbaea5893d8fd0 Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangCodeModel: Change default set of warningsChristian Kandeler2021-02-193-2/+3
| | | | | | | | ... to "warnings from build system". It seems appropriate to respect the project settings by default. Change-Id: I397c252409a012f4663f3752c5c097fa0e658da4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Core: Streamline SearchResultWindow interfaceChristian Kandeler2021-02-184-13/+20
| | | | | | | | | | That is, make SearchResultItem the one data type for adding search results. This will allow us to add additional properties to search results without adding more and more parameters to a bunch of functions. Change-Id: Ic2740477ae47449cee75caa2525727fe2b460f91 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Remove unused includes of mutex classesJarek Kobus2021-02-181-1/+0
| | | | | Change-Id: I5a34cda0b27786cb37e642479b11fbd24b8b5c36 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* qbs build: Remove code for creating deployment packagesChristian Kandeler2021-02-171-2/+0
| | | | | | | | Not a use case anymore, and if it were, we'd do it using built-in capabilities. Change-Id: I4c588ad7fb282530880210cb4c5795677074b1e0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Use qAsConst with non-const Qt containers in range-loopsAlessandro Portale2021-02-172-6/+6
| | | | | | | ... in various places Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Designer: Re-use CppTools functionalityChristian Kandeler2021-02-124-1/+404
| | | | | | | | ... for slot insertion logic. Fixes: QTCREATORBUG-8220 Change-Id: I3516a62d62174b64d557c82ce38a9cc334790efc Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Provide empty implementation for ILocatorFilter::refresh()Jarek Kobus2021-02-114-12/+0
| | | | | | | | Make this method just virtual, not a pure virtual. Remove all empty reimplementations of this method. Change-Id: Idf10e492355e8519172facd421ea0b2b13ce3b80 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* ClangCodeModel: Support "parentheses" matching for ternary operatorChristian Kandeler2021-02-112-3/+13
| | | | | | | | | That is, show which ":" belongs to which "?" when the cursor is on one of them. Fixes: QTCREATORBUG-1410 Change-Id: Ie19360b3dfc82d92c264d99a5aa1864eda66e5c8 Reviewed-by: David Schulz <david.schulz@qt.io>
* Locator: Enable to show C++ type aliasesChristian Kandeler2021-02-095-5/+11
| | | | | | | | These were not showing up in any global symbol list so far. Fixes: QTCREATORBUG-5800 Change-Id: I8e5c3b9b26f09d8cbcd31431e28c103da05d9bf8 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* CppEditor: Do not add redundant access specifierChristian Kandeler2021-02-082-16/+30
| | | | | | | | ... when inserting a member function declaration for a definition. Fixes: QTCREATORBUG-5591 Change-Id: Ie85b435a1595832d0085abdcc0a4187d939820e0 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: Add dedicated filter option for declarationsChristian Kandeler2021-02-051-0/+7
| | | | | | | | ... to the "Find Usages" result widget. Fixes: QTCREATORBUG-25302 Change-Id: If957cbffe55f6f9288ceae9d64847e8a4a367765 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CppTools: Fix unit testChristian Kandeler2021-02-051-1/+2
| | | | | | | Amends 84865016ea. Change-Id: Ia815152d2c19b17b1d11dd5c82fd7a74d0ac03cb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppTools: Fix parentheses mismatchChristian Kandeler2021-02-052-2/+4
| | | | | | | | | | ... when the ClangCodeModel is disabled. The built-in highlighter's use of HighlightingResult::kind conflicted with the ClangCodeModel's. Amends d8c1e51bfe. Change-Id: I79784679fd17d88cd543304de726f8576954b29c Reviewed-by: David Schulz <david.schulz@qt.io>
* Locator: Use extra info as secondary sorting criterion for C++Christian Kandeler2021-02-041-14/+14
| | | | | | | | | | ... classes and functions. The extra info is usually the scope or the file, so this effectively adds some helpful grouping. Fixes: QTCREATORBUG-2538 Change-Id: I2404fee1df88fc51871a72db0dcc9c75d6ba6dcb Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Refactor Locator filter settings savingEike Ziller2021-02-045-10/+10
| | | | | | | | | | | | | | | | Unify setting saving. Do not write settings that stay at the default, so defaults could change and take effect. For this we explicitly differentiate between default and user settings. Make QJsonDocument the basis for saving settings, because QDataStream cannot really handle structured data where parts could be missing. Write locator settings to a different settings group, so we do not destroy reading older settings from older Qt Creator versions. Task-number: QTCREATORBUG-24762 Change-Id: I5909e2d79313f6fc26159bb644fdfb43781b6c38 Reviewed-by: David Schulz <david.schulz@qt.io>
* Use invokeMethod instead of single shot timer with 0 timeoutJarek Kobus2021-02-021-3/+1
| | | | | Change-Id: I3ffc4bfdbc6fc58d4b90aa53427eb80653c22b65 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Check if the document ptr is not nullJarek Kobus2021-01-271-0/+5
| | | | | | | | | Avoid a crash when double click in hierarchy view after the session has been changed or when the filename changed. Change-Id: Iebd7a99c220737262c79ade43c4ee8d11dcc037f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Fix a couple of cmake issues for testingChristian Stenger2021-01-271-0/+1
| | | | | | | Correct expected paths, defines and dependencies. Change-Id: Iae3fa708957e352012d0a6bb9cf97713b9a5c35e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* "New Class" wizard: Check custom base class for QObject parentChristian Kandeler2021-01-255-4/+110
| | | | | | | | | | | | That is, if the user specifies a custom base class, we check whether its constructor takes a "QObject *parent" parameter, and if it does, we give the derived class one as well. This is technically a heuristic, but the pattern is pretty stable in the Qt world. Fixes: QTCREATORBUG-25156 Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* ClangCodeModel: Support highlighting angle bracketsChristian Kandeler2021-01-221-0/+23
| | | | | | | | ... in template declarations and instantiations. Fixes: QTCREATORBUG-16799 Change-Id: I82bc6411ca980ecbe2a6c70ae37580166a4b89e9 Reviewed-by: David Schulz <david.schulz@qt.io>
* Cpp: Use new settings APIEike Ziller2021-01-224-41/+69
| | | | | | | | Avoid writing defaults to the settings. Task-number: QTCREATORBUG-24430 Change-Id: I8e1d5a5b8ca21ef96a68a4d71a7d97d138bd186b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Core: Add infrastructure to do additional filtering on search resultsChristian Kandeler2021-01-211-1/+56
| | | | | | | | | ... and make use of it to let users filter C++ "find references" results by access type. Fixes: QTCREATORBUG-19373 Change-Id: Ib5cadde1cfd235026d8e69da51daa6374808d3f3 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* CppTools: Do not wait for QFuture in ~BuiltinEditorDocumentProcessor()Christian Kandeler2021-01-141-1/+0
| | | | | | | | | | This seems safe, as the arguments to the async function that the future results from are values and shared pointers, so there does not appear to be a need for this object to stay around while it finishes. Fixes: QTCREATORBUG-25121 Change-Id: Ib498551856942bf7c3d05c3013e12ad6d90fd762 Reviewed-by: David Schulz <david.schulz@qt.io>
* CMakeProjectManager: Fix issues with precompiled headersCristian Adam2021-01-142-37/+18
| | | | | | | | | | | | | | | Clang code model can break if CMake project uses precompiled headers. QtCreator will make a copy of the precompiled header, this way it will not conflict with the build system one. Ammends 888ea6bbbb0f4c6bb6b5616046e600b9520e4faf Fixes: QTCREATORBUG-24945 Fixes: QTCREATORBUG-25213 Change-Id: I149fc416cd047683d095758a024de47c7baf681c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Refactor CppElementEvaluatorJarek Kobus2021-01-132-241/+280
| | | | | | | | | | | | | Separate the use of CppElementEvaluator for CppHoverHandler from the use for CppTypeHierarchyWidget. They are in fact much different things. Fix CppHoverHandler (enabled when ClangCodeModel plugin is disabled) showing tooltips for symbols other than class or template. Fix CppHoverHandler showing full template arguments for typedefs. Change-Id: I5c44016014749d0d958b91a9a1ee9b35d3ea5eaa Reviewed-by: hjk <hjk@qt.io>
* Show type hierarchy also for typedefsJarek Kobus2021-01-133-66/+89
| | | | | | | | | Make it possible to show type hierarchy for typedefs and unsings. Before, no type hierarchy was shown. Change-Id: I63ffa9c544072d66c42de8edf306c898d2fa90cb Reviewed-by: hjk <hjk@qt.io>
* CppEditor: Add QuickFix to generate a constructorLeander Schulten2021-01-112-128/+221
| | | | | Change-Id: Iba2ce3bfa1a1d1a325626a21f46b485d12cbb060 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Add cache to hierarchy visitor, fix following typedefs and usingsJarek Kobus2021-01-072-31/+57
| | | | | | | | | | | | | | | | | | | | | In case we already visited the same base class symbol in the same scope we already know the fully qualified name for base class, so no need to search it again. We store all visited symbols with their scopes in cache. This speeds up building type hierarchy, especially for large trees, like for creator project and showing type hierarchy for QObject: build time before this change was about 300 sec, now it's about 130 sec. Sometimes the old code didn't follow properly base classes that were typedefs to other classes (like in creator project: Debugger::Internal::RegisterHandler is derived from RegisterModel, and RegisterModel is a typedef to Utils::TreeModel). This caused that some subclasses were omitted form resulting type hierarchy. E.g. type hierarchy in creator project for QObject lacked about 8 subclasses. Change-Id: I03c5aef65b7d7cb0ed279d3558aebc8a55e856b4 Reviewed-by: hjk <hjk@qt.io>
* Properly annotate templates with full scope in type hierarchyJarek Kobus2021-01-071-3/+22
| | | | | | | Fix activation of template classes. Change-Id: I811f505c1c01fa95d74847cb91dd1cf37476534b Reviewed-by: hjk <hjk@qt.io>
* CppTools: Fix compile with Qt5.14 on Linux / macOSChristian Stenger2021-01-071-0/+1
| | | | | | | Amends 1a09f816a38. Change-Id: I76d7eb184504082ad5916bf3b54549e5b2872aef Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangTools: Support clang-tidy check optionsChristian Kandeler2021-01-062-0/+72
| | | | | | Fixes: QTCREATORBUG-24977 Change-Id: I33ea247ba98788245ae1264262f60d084b73778c Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Merge remote-tracking branch 'origin/4.14'Eike Ziller2021-01-061-1/+1
|\ | | | | | | Change-Id: I62523c4733e617c46131048f5f62a2ca9be47d80
| * ClangTools: Re-add clang's own include pathChristian Kandeler2021-01-051-1/+1
| | | | | | | | | | | | | | | | Amends ef05f29940. Fixes: QTCREATORBUG-25126 Change-Id: I1340916f3f3488b0d1171f04ae1c9f30149c0c5c Reviewed-by: David Schulz <david.schulz@qt.io>