Commit Graph

480 Commits

Author SHA1 Message Date
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
Ivan Donchevskii
a137b08eaa CppEditor: refactor FollowSymbol
Create an interface to get the ability to use
another FollowSymbol implementation

Change-Id: I5802f62523ff3ee47b8a14e487adf43edcb6c9b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-15 14:14:01 +00:00
Marco Bubke
b6e12f4a1c Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.

Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-14 15:23:56 +00:00
Nikolai Kosjar
b2e537baaa ProjectExplorer: Move built-in parser workarounds to built-in code model
...so that only the built-in code model parser sees them, but not the
clang code model, which has problems with them. The specific case here
is due to definition of __int32:

  winnt.h:3077:1: error: functions that differ only in their return type
                  cannot be overloaded
  intrin.h:357:31: note: previous declaration is here

While moving, drop __MSVCRT__, which seems to be a predefined macro of
ancient MSVC versions, see

https://sourceforge.net/p/mpg123/mailman/mpg123-devel/?viewmonth=201010&viewday=24

Change-Id: I4b8c49ed4bdc942a2190dbae3c260f3a1a8078a4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-16 16:18:44 +00:00
Nikolai Kosjar
45b7c5ac29 Revert "CppTools: Do not put configuration document into global snapshot and working copy"
This reverts commit 05942b63f8 because it
breaks refactoring, e.g. Q_PROPERTY generators.

Change-Id: I9a14b912ba72663f08ea99e7e066d824b18da4b0
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-03-07 11:54:16 +00:00
Nikolai Kosjar
8c90998fff CppTools/ProjectManagers: Reduce ui blocking when loading projects
${AnyProject}::updateCppCodeModel() did two potentially not that cheap
operations in the ui thread:
 (1) Querying the MimeDatabase for the mime type for the source files of
     the project. In 99.9% of the cases no files need to be read for
     this as the file extension will resolve the type. The expensiveness
     comes from the sheer number of files that can occur.
 (2) Calling compilers with the "(sub)project's compiler command line"
     to determine the macros. While the caches avoid redundant calls,
     the number of the unique compiler calls makes this still a
     ui-freezing experience.

These two operations are moved into a worker thread. For this, the
expensive compiler calls are encapsulated in thread safe lambdas
("runners") in order to keep the "mutexed" data minimal. The original
API calls of the toolchains are implemented in terms of the runners.

While adapting the project managers, remove also the calls to
setProjectLanguage(). These are redundant because all of the project
managers already set a proper value in the constructor. Also, currently
there is no need (client) to report back detection of C sources in
project parts. This also keeps CppProjectUpdater simple.

There is still room for improvement:
 * Run the compiler calls in parallel instead of sequence.
 * Ensure that the mime type for a file is determined exactly once.

Change-Id: I2efc4e132ee88e3c8f264012ec8fafe3d86c404f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-20 09:18:13 +00:00
Ulf Hermann
c70b689526 Unify projectexplorer language IDs
We don't need two IDs for C++ and the QmlJS ID should look the same as
as the others.

Change-Id: Ib9747f6b36a90bb652951d85eec69666615670c4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-30 15:34:46 +00:00
Nikolai Kosjar
7415964819 CppTools: Fix choosing project part after project open
As long as there are project parts for a source file, always determine
the best project part, instead of trying to stick to the previous one.
This ensures the best project part at all times and simplifies the code.

Change-Id: I25ea3eb43a5a3e6d93688d4b8965f596dc9ae22b
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-01-26 07:52:54 +00:00
Nikolai Kosjar
602c873d3e CppTools: Reparse editor documents after active project change
Change-Id: I010709c866291bf59c27f4a05765e1ab0efd28af
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:56:31 +00:00
Nikolai Kosjar
02d8e2af1b CppTools: Clean up ProjectInfo
Change-Id: I5d0db45d9fdb624bb6cc55d7f04061d553f13bce
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-13 09:15:25 +00:00
Nikolai Kosjar
a10bfb8400 CppTools: Do not hardcode default language version
...instead, use the latest we support.

Change-Id: I7e7768bc4bc31de1fe0f441c03f3ab5d677d76e8
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-13 08:33:09 +00:00
Nikolai Kosjar
05942b63f8 CppTools: Do not put configuration document into global snapshot and working copy
These are remnants of the time when we had only one snapshot.

Change-Id: I6ff4db645d1065a0ef195834890e0774e2e2c60e
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-12-08 08:52:17 +00:00
Nikolai Kosjar
521423b433 CppTools: Call ProjectInfo::finish when we get it
No need to require the project managers to do this. Also, it is easy to
forget.

Change-Id: I96f7a5e5547418678af9653e5753c372f0880e5a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-12-06 14:34:39 +00:00
Nikolai Kosjar
83ea1f4deb CppTools: Add UI for file size limit of indexer
Task-number: QTCREATORBUG-16712
Change-Id: I92db8cbcac9669cbd5e4ee5f7ef6f613797c753a
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-08-31 07:47:27 +00:00
Nikolai Kosjar
f06a5db22b CppTools: Fix condition in file size check
Change-Id: I71d67f1273bad025b8dff45b3903b458f5cda2a2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-08-16 13:38:13 +00:00
Marco Bubke
4cdb5bab15 Clang: Add clang refactoring
Change-Id: I2e3f36f810276da3f8dc7dcc587b06f8edb586d3
GPush-Base: d02f51b48fc752fddcdef6dcb32b3f7f6c0195a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-04 14:37:19 +00:00
Nikolai Kosjar
d63e27d877 CppTools/Clang: Announce only removed project parts
...and not all projects parts of a project if it is closed.

Re-produce with:
  open a project A with subdirs (e.g. qtcreator.pro)
  open a subdir project from project A (e.g. cppeditor.pro)
  close project A
  --> The project part representing the subdir is announced as removed
      although it is still open.

The clang code model was the only affected user - affected translation
units were not parsed/updated anymore
("ERROR: ProjectPartDoesNotExistMessage").

Change-Id: Ia79341ce201e3b4aefff9f597920dbc6f7d67634
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-28 07:48:18 +00:00
Orgad Shaneh
46cacd901a CppTools: Use Qt5-style connects
Mostly done by clazy.

Change-Id: I0fbbbe1a2d28b79bcb83093d608bca6e2f927ebb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-23 09:02:21 +00:00
Nikolai Kosjar
1cbb4cc954 QbsProjectManager: Fix SOFT ASSERT: "future.isFinished()"
...in file qbsproject.cpp, line 940.

The assert can be triggered with e.g.:
 1. Load a bigger qbs project, e.g. qtcreator.qbs.
 2. Trigger project build as soon as possible.
 3. Cancel the "Parsing C/C++" operation.
 4. Wait until the build finished and the assert occurs.

This happens because CppModelManager::updateProjectInfo() since

  commit  536ccc8a87
  CppTools: Fix incompletely indexed project

will check whether the previous indexer run was canceled or not. If it
was canceled, it will trigger a full-reindexing of the project.

Updating the compiler call data is a special case and it should never
trigger an indexing operation, so introduce a dedicated update function
for this case.

Change-Id: I456945ccf2bf697aaeada572ed87f3acb21a5eaf
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-05-03 08:03:24 +00:00
Nikolai Kosjar
536ccc8a87 CppTools: Fix incompletely indexed project
Use case to reproduce:
 1. Open some bigger project, e.g. qtcreator.pro
 2. As soon as "Parsing C/C++ files" is reported, add a character to
    qmake's additional arguments in project mode (indexing should not be
    finished at this point).
 3. The indexing gets canceled.
 ==> ...but reindexing is not triggered.

Fix by checking whether the future was canceled.

Task-number: QTCREATORBUG-16134
Change-Id: I520c6a64a6adc1cb04cafb5e0aa56c8bf41d7b14
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-04-25 12:41:42 +00:00
Nikita Baryshnikov
5f91cb0d68 CppTools: fix metatype registration macro usage
in places where we do not need it

Change-Id: Ibf35f8144da859fffa3e0a7b6bb262284ec2292a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-03-24 08:15:44 +00:00
Eike Ziller
74cdce071f Merge remote-tracking branch 'origin/3.6'
Conflicts:
	src/shared/qbs
	tests/manual/proparser/main.cpp

Change-Id: I13654bf10c14eb6b1d6805fe86b67ac73b2e4d75
2016-02-24 10:08:37 +01:00
Orgad Shaneh
6234511a2c CppTools: Use a shared thread pool
Without this, too many threads are spawned, and loading a project takes
forever.

Change-Id: I3c22557ddd7bfb0c70f7b089c276432e3b003097
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2016-02-19 10:21:40 +00:00
Nikolai Kosjar
e1b14565fa CppTools: Do not clear project state on session unload
Affected functionality was, among others:
 * Getting the correct project part when opening a file
 * Fallback project part (merged defines/includes) not up to date
 * Fallback for "Switch Header/Source" not up to date

In the early days sessions switching was probably implemented by "close
all projects of session X, open all projects of session Y". That's not
the case anymore today.

Change-Id: I4c6a80e2eb219615d3ea6fcf07be7c05072c8832
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-12 07:48: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
Marco Bubke
2b4cadf1fe CppTools: Move ProjectPart in its own header file
Also extracting inline HeaderPath class and change projects list in vector
because the size is  larger than a pointer.

Change-Id: I885fdff3fe9bccc877634d1615249755f5b674fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:46:56 +00:00
Nikolai Kosjar
f89d3dca8b Clang: Activate code model automatically if plugin is loaded
This removes also the need to close editor documents.

Change-Id: I96c68105bceb37841053f3dbd8a264e059a02cb8
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 12:23:58 +00:00
Nikolai Kosjar
7bb2d833f1 CppTools: Predefine __func__ and friends
...so the built-in parser can handle them.

Change-Id: Iff69638f8939c3c4dced99699a3357dd94b23c71
Task-number: QTCREATORBUG-15431
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-12-15 09:57:28 +00:00
Marco Bubke
d579608e8a Clang: Prioritize current and visible translation units
We reparse first the current and then the visible translation units before
we reparse all other units.

The signals connections are queued to wait for the visible editor update.

Change-Id: I5e2b8bc80568450268ca24e26720b3f5af640995
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-01 11:14:39 +00:00
Nikolai Kosjar
48952084a6 Clang: Remove per-mimetype settings
Related to

    commit c47079f97f7d42db0c581525a2ce6fddbc0995f2
    Clang: Activate the code model with a check box

Change-Id: Ief11768ba0dd27788032e2dd3ad9b7ae39a8f52b
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-16 14:08:25 +00:00