Commit Graph

459 Commits

Author SHA1 Message Date
Bernhard Beschow
ac61bfdc90 AutoTest: Free TestTreeItem from CppTools dependency
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>
2021-04-12 06:42:49 +00:00
Alessandro Portale
72d91dc94a Use qAsConst with non-const Qt containers in range-loops
... in various places

Change-Id: Ic6c0c1b9437a1ed402105c7a14a1f5f9454a68d4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-02-17 14:43:29 +00:00
Christian Kandeler
e735e95f06 "New Class" wizard: Check custom base class for QObject parent
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>
2021-01-25 08:58:24 +00:00
Eike Ziller
6d7e5eb8d1 Fix CppProjectUpdater cancelAndWaitForFinished
The code was pushing an additional QFutureInterface through the whole
chain of functions, which was used for canceling. But since it was never
started (and never finished, and never used for reporting results),
calling waitForFinshed on it never had any effect with Qt5 and locks up
with Qt6.

Instead of using a separate QFutureInterface, use the actual QFuture
that is available and intended for it.

Fixes: QTCREATORBUG-24902
Change-Id: I5a49bcecc9cf70fbffa93aee4293004f9369df58
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-11 12:49:33 +00:00
Christian Kandeler
a79b0c6558 C++: Offer only signals when completing in a connect() call
... at the second argument.
The logic is as follows: The clang code model checks whether the set of
completions contains any signals. If so, it instructs the built-in code
model to analyze the AST to find out whether the completion location was
at the second argument of a call to QObject::connect(). In that case, we
filter out all non-signals, because they are not valid at that location.

Fixes: QTCREATORBUG-13558
Change-Id: I9c7d0bd16161c723aef822280626cd06ece7df93
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-08-27 14:02:51 +00:00
Christian Kandeler
7938320291 TextEditor: Introduce shortcut for forcing a function hint proposal
... and support it in the ClangCodeModel.
This allows users to get function signature(s) displayed regardless of
where exactly the cursor is on the function call.

Fixes: QTCREATORBUG-19394
Change-Id: I033e8774db93680bfc3ee52610b817e0ef8ccc76
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-11 10:10:08 +00:00
Christian Stenger
7598018a7f CppEditor:CppTools: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098
Change-Id: Id1804a31162d0239659de33c1700354494c11689
Reviewed-by: hjk <hjk@qt.io>
2020-07-13 12:09:15 +00:00
Christian Kandeler
b9413bcec7 Cpp: Fix leaks in ClangCodeModel tests
Change-Id: I19d4dc445d82fd24361f1eb752d9f35ccadd3efb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-19 11:19:42 +00:00
Cristian Adam
b7bfcc3786 CppTools: Do not reindex all sources on project update
When CMake was run it would cause an update, which would have a
cancelAndWaitForFinished on the future interface.

The CppTools would have the future interface added on all updates, and
even though an indexing job would be finished, it would be picked up as
active and cancelled, which would be interpreted as action from the user
to cancel the indexing and cause a full reindex.

This patch makes sure that if an indexing job has finished, it doesn't
register as active, and only the jobs that actually do some work, and
will be finished will wait for the cancel signal.

Change-Id: If8a4db2a4a7a5707a360db84affe794ab0678d38
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-02-20 13:53:36 +00:00
hjk
e3e6cece89 CppTools: Use a normal plugin pimpl member for CppModelManager
Change-Id: Id2c4b098084808070ef91de13c8338184e52141d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-02-06 12:24:21 +00:00
hjk
e109b731ad Utils: Rename FilePathList to simply FilePaths
The exact storage type does not really matter here.

Change-Id: Iefec40f0f5909c8e7ba3415db4a11962694e1b38
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:43:18 +00:00
Eike Ziller
8452264a18 CppTools: Move QtVersion and BuildTargetType
QtVersion to utils/cpplanguage_details.h which already contains similar
flags.

BuildTargetType to ProjectExplorer, next to BuildTargetInfo (but not in the
same header to not pull that in everywhere).

Removes dependency on ProjectPart from RawProjectPart.

Change-Id: I5791065e4266f20c2657ee4b1b594df04b238a1c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-10 07:31:21 +00:00
Eike Ziller
857b299356 VcsBase: Make dependency on CppTools optional
The VcsBaseSubmitEditor uses CppModelManager to collect the symbol names
from the affected files for completion in the commit message.

Move the C++ code model code into CppModelManager, register it in the
plugin manager, and call it via QObject means from the submit editor.

This avoids a hard dependency from VcsBase to CppTools.

Change-Id: I2fb34dbef153c1414820d711e7fc5596bcac1691
Reviewed-by: hjk <hjk@qt.io>
2019-08-15 06:27:29 +00:00
hjk
e3b1106afa Compile fix with recent Qt dev
The reasoning in 1b4766e26c did not take into account that the scope
of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with
f70905448f6 in Qt base.

Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-29 08:54:18 +00:00
hjk
6a58666f44 More Utils::toSet/toList
... and unrelated cosmetic changes.

Change-Id: I591b17fd5289831e701b683f8fb47816efd1fa67
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-04 12:28:38 +00:00
Cristian Adam
60c2aae023 qtcreator: Set thread pool stack size to 2MiB
Visual C++ sets 1MiB as stack size, macOSX has 512KiB.
Both crash with a specified project.

MinGW sets 2MiB as stack size, the specified project loads
just fine.

Fixes: QTCREATORBUG-22496
Change-Id: I6f19e74a681977e4fe1dceee292ea9c838999a1a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-19 14:38:49 +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
Marco Bubke
f5c3007058 CppTools: Add sourceFilePath to AbstractEditorSupport
Provide the source path to track a generated file source. You can for
example get the modified time stamp for the source file and use it for the
generated file content.

Task-number: QTCREATORBUG-21876
Change-Id: Ia422e128c5cb7a3dce88960f126152c2f65afb41
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-24 10:03:45 +00:00
Ivan Donchevskii
d7058e1afe ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.

First simple unit-test proofs it builds and runs.

Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-22 09:52:15 +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
Marco Bubke
5dbaf387ba Utils: Move C++ language details from ProjectExplorer to Utils
We want to use them in the backend processes too so it's nice to share them
in Utils. A concrete size was added too because they should be serialized.

Change-Id: Id5eb8f46643d5159f034fc9559f68a08d7e5847a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-15 10:37:03 +00:00
Orgad Shaneh
c225216b93 Utils: Introduce GlobalFileChangeBlocker
Tracks application state, and signals when it is changed.

Supports forcing blocked state with reference counting.

Change-Id: Ic173d42446b1b08bd4a1e7c1acf38c68644d30b3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-08 14:21:39 +00:00
Bernhard Beschow
9ee785a4ef CppModelManager: Remove method overload used only in tests
Use (and therefore test) the method actually used in production code.

Change-Id: I4317517ef8a1779df4d46af3905790012ee98645
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-06 21:50:08 +00:00
Ivan Donchevskii
e57c1268ee ClangFormat: Move settings to the Code Style widget
It makes sense to unify the indenter creation by replacing
the CppCodeStylePreferencesFactory instead of removing it.
We are reusing the same options page but with different
kind of settings.

With this change wizards will no more be confused by missing
factory and will create the proper indenter.

Fixes: QTCREATORBUG-21516
Change-Id: I38964d5fa1f2257617c66a1441db723d239a3237
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-12-04 11:42:22 +00:00
Nikolai Kosjar
cfbf2559f4 Clang: Fix naming conventions for *ModelManagerSupport* classes
We use "Builtin" and "Clang" as prefixes, not suffixes.

Change-Id: I6926aeb8f005176ef420c4421c257e3df61ee0b7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-23 06:12:29 +00:00
Nikolai Kosjar
d67ddfb5d1 Clang: Avoid starting backend jobs for inactive app and during VCS operations
...to reduce file locking on Windows caused by clangbackend's
parse/reparse jobs.

Considering inactive application state should help for external VCS
operations, e.g. on the command line. However, activating Qt Creator
while such a VCS operation runs might still lead to undesired behavior,
but this should be the less common case.

VCS operations started from within Qt Creator should see less locking
conflicts as we know when they start and finish. However, we just avoid
starting new jobs - there might be still jobs running.

Pending or new jobs will be started once Qt Creator is activated again
and all VCS operations finished.

Task-number: QTCREATORBUG-15449
Change-Id: I5f04c34f006e66162368efbdd58bd822a706f35e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-16 06:40:43 +00:00
Nikolai Kosjar
6aa11eb75e CppTools/ProjectExplorer: Remove enum duplication
... between CppTools::ProjectPart and ProjectExplorer::ToolChain.

Change-Id: I8b448747e454adbed77547460383b8515462cc81
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-08 12:34:57 +00:00
Ivan Donchevskii
ca84a51f86 Clang: Use clang-format for indentation
This is the new experimental plugin based on LibFormat.

It replaces the default indenter for CppEditorDocument
and applies clang-format after the CR or the set of 'electric'
characters.

Uses the global .clang-format kept in QtC settings or
the one for current project. Both can be configured.

For indentation some style modifications and code manipulations
are done to prevent line shrinking when it's not expected.

Manual indentation uses unmodified style from .clang-format file.

Change-Id: I6279b805e418e1804b553efa615f5c843f395a58
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-12 07:59:30 +00:00
Marco Bubke
3abaf647d0 Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-09-10 09:31:32 +00:00
Eike Ziller
5c81a65422 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri

Change-Id: I29916313f12e25f3942ac926f8e4d4490074978e
2018-07-05 11:14:33 +02:00
Ivan Donchevskii
ef9c68798d CppTools: Fix getting locator filters from the object pool
They are no longer inside the global object pool.
Get them from CppModelManager instead.

Task-number: QTCREATORBUG-20678
Change-Id: Ifb3221a812295e1dcfe8b59ea693a4b350cbcc2e
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-28 07:42:27 +00:00
Hannes Domani
168e89e0a2 CppTools: Fix memory leak of QFutureWatcher when canceled
Change-Id: Ia9cd428e3bed193167903b6ffa080e4886193789
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-08 15:48:21 +00:00
Ivan Donchevskii
8936e51033 ClangTools: Always use CompilerOptionsBuilder for clang tools
We do not ship clang-cl anymore which makes it impossible
to run clang with MSVC options.
Secondly we used to we tweak compiler options quite a bit so
why not to switch to CompilerOptionsBuilder totally?

Change-Id: Id323cb554587afaea7d9aa530e947a45a03922d1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-13 12:34:35 +00:00
Ivan Donchevskii
08d1274ccc CppTools: Remove processEvents call from follow symbol
processEvents is a bad way of dealing with asynchronous
requests. Use QFutureWatcher for that purpose.

Change-Id: I3839cb9db80a6d391f6af1178e96986a325b7b99
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-03-19 13:37:46 +00:00
Ivan Donchevskii
6010fd855d CppTools: Remove resetFilters from CppModelManager
Without object pool resetting filters does nothing
and therefore is not needed anymore.

Change-Id: Id5439d11b0ee2564d7573b95c0c922d7fd7da59e
Reviewed-by: hjk <hjk@qt.io>
2018-03-09 08:35:10 +00:00
hjk
efbcf6308b CppTools: Do not add LocatorFilters to global object pool
Not needed anymore, they are more directly accessible nowadays.

Change-Id: Ibe16ab1281a16b05e02fb20c0722d87196d99365
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-08 11:43:43 +00:00
Ivan Donchevskii
7698d95576 CppTools: Get OverviewModel from model manager
Move ownership and add the placeholder for future clang based
OverviewModel.

Change-Id: Ia44d2c1d0db59b40239d1f7934bf37a02e4b14e6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-09 13:29:37 +00:00
hjk
87543118d5 CppTools: Apply 'static' pattern to StringTable
This also fixes a crash on loading (some?) projects introduced
in 577bf7c08a.

Change-Id: Ie35d466fa3b84b183118fe93f55393a4c59755de
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-07 13:32:08 +00:00
Ivan Donchevskii
7666db896d CppTools: move locators ownership to ModelManager
Move locator and find filters ownership and initialization
to ModelManager. Initialize builtin filters by default and
provide methods to set them from plugins.

Change-Id: I4cc82ecff3415329a5f97b1be9dcc45e6103bf5a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-01-17 11:33:24 +00:00
Nikolai Kosjar
5e861d2be6 CppTools: Move CppHoverHandler to CppTools
This is in preparation for clang code model to provide its own hover
handler.

Change-Id: Ifbdd96f427989bd5d1fbc4badb9c38108485c2f2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 08:31:11 +00:00
Nikolai Kosjar
53a744a6df CppTools: Improve a function name
Change-Id: I30f9048aff18440d8cc6a6247f5fd5bcdba5058d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 08:20:22 +00:00
Ivan Donchevskii
7a7123b1bc Clang: add globalFollowSymbol to RefactoringEngine
Allows to follow outside of current TU.

Change-Id: Ieea2fd72bfdf6d60a988b40efcf2f41c5a71d045
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-14 14:25:14 +00:00
Eike Ziller
4c8db5e9b7 Merge remote-tracking branch 'origin/4.5'
Change-Id: I32715e2fdbb14e4fccc4c58d3fd6052d7c1127f3
2017-11-24 10:03:38 +01:00
Orgad Shaneh
ec86bf8ca6 CppTools: Fix initial macro parsing for generic project
The extra macros in the config files are being read in
CppModelManager::internalDefinedMacros(), but they also affect the language
features in ProjectPart::updateLanguageFeatures().

Task-number: QTCREATORBUG-1478
Change-Id: Ic197b0b7d4cc6e6a74637da0c710b0630daae25c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-11-24 08:40:56 +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
Ivan Donchevskii
81f5c1c8ec Clang: implement globalRename based on clang Index
Has the same limitations as findUsages.

Change-Id: I8de4df2ecbfd8a4f3073666994398dc43af0d73c
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-10-25 13:35:48 +00:00
Ivan Donchevskii
050b4dd2f5 Clang: implement findUsages with existing index
Functionality is limited to the abilities of
current index which is not updated and is
generated only at project open.
Search box temporarily doesn't allow to "Search again".

Change-Id: Id1047f27ad0aafc901f06aa51ad38ceab95eaebb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-24 10:46:52 +00:00
Ivan Donchevskii
5c554c0de9 CppTools: add multiple refactoring engines support
Make model manager able to select the most functional
refactoring engine from the available ones.

Change-Id: I74031c910706fd694a0a7def022531501f1ea005
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-17 13:32:51 +00:00
Ivan Donchevskii
a959fe59da C++: remove builtin RefactoringEngine dependency from CppEditor
Move CppRefactoringEngine to CppTools and builtin member
ownership to model manager.

Change-Id: I3e72308559fd2928229f9f25d4dd09beb3f56c34
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:59:20 +00:00
Ivan Donchevskii
55a5ffc1ec C++: remove builtin FollowSymbol dependency from CppEditor
Move FollowSymbolUnderCursor to CppTools and
builtin member ownership to internal model manager.

Change-Id: I97a4f744ec1709ccc0b34fb67b58680973ef566f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:59:05 +00:00