Commit Graph

274 Commits

Author SHA1 Message Date
Alessandro Portale
951eb885af GenericProjectManager: Modernize
modernize-use-auto
modernize-use-equals-default
modernize-use-nullptr
modernize-use-override

Change-Id: I67c9895f46efe8646176718949561240c7175c53
Reviewed-by: hjk <hjk@qt.io>
2018-11-09 08:03:13 +00:00
Nikolai Kosjar
5900766ecb Toolchains: Detect unspecified language version
We checked the command line from the project manager for "-std=X" and
friends to figure out the language version to use. However, if such a
flag was not provided, we assumed the latest version we support. This
could conflict with the actual version of the compiler and its
predefined macros.

Figure out the version by inspecting __cplusplus/__STDC_VERSION__ in the
predefined macros of the toolchain. The MSVC compiler is an exception to
this, as it does not seem to properly set the value - check for
_MSVC_LANG if possible, otherwise simply assume some versions as before.

While at it, add also support for C17/C18 and the upcoming C++2a.

Task-number: QTCREATORBUG-20884
Task-number: QTCREATORBUG-21188
Change-Id: I464ffcd52d2120c0208275a050e82efda44fae1c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-08 09:07:56 +00:00
Andre Hartmann
c29e483607 GenericProject: fix sorting file list when appending an entry
pos was -1 for a value that should have been appended as
last element to the list. Unfortunately, list->insert
treats -1 as prepending in front of the list, which lead
to incorrectly sorted lists.

The function got broken during the review process of
the introducing commit 758544c058.

Change-Id: I693e4d79b0d493deeac0ea8781d637fe50d008b8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-10-05 13:52:47 +00:00
Eike Ziller
0db5f13dd1 Move generic make step to project explorer
As a first step of creating a generic base for the 3 existing
implementations.

Change-Id: I2456db74cb635316f97a247e2a2b6bdb34931440
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-05-16 12:04:40 +00:00
Tobias Hunger
d332954567 ProjectExplorer: Add and use addNestedNode(...) that takes unique_ptr
Change-Id: Ieb26721d053111fb350494e31d1f6da3fe642420
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-05-02 14:55:15 +00:00
Tobias Hunger
5754d5accf ProjectExplorer: Use unique_ptr for Project::setRootProjectNode
Change-Id: If63a49d0eecfb93adcc6076fcb3208c87603af10
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-05-02 11:34:35 +00:00
hjk
b2a16190e8 Use project id uniformly as project context
The possibly intented flexibility e.g. to have different project types
share the same idea of a common context was never used, in all cases
we had a 1:1 relation ship between project ids and ids that were used
as context. This led to oversights like the one fixed in 60fb35a2.

This patch here uses the project id unconditionally as context and
drops all context ids. If we'll ever have the situation where the
original flexibility was needed, Project::projectContext() could be
made virtual and overridden were needed.

Also, the context was never modified for any given project, so the
updating machinery is not needed.

Change-Id: I3f7fac0ed5e4704e126558987c48577f26082dfd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-20 12:35:14 +00:00
hjk
9792547ef9 ProjectExplorer: Implement RunConfiguration::do{Clone,Restore} in base
It's possible now.

Change-Id: I49ed73312aea1627a9543890431e2e379e3fb3ec
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2017-11-16 14:08:33 +00:00
hjk
02157d77bc CustomExecutable: standardize RunConfiguration::initialize() signature
Most other signatures look like {...}RunConfiguration::initialize(Core::Id),
make this here the same, even if the Id is unused (or, rather always
the same) so we can use a virtual function in the base RunConfiguration
at some time.

Change-Id: I5d3d4a7bf856bb0cc31f8e26bc0e5a80fd1a4066
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2017-11-14 10:59:18 +00:00
hjk
890c1906e6 ProjectExplorer: Re-organize RunConfiguration constructors
The idea is to massage the setup in a way to make implementation
of new configurations less error prone by identifying recurring patterns
and sharing repetitive code that tends to be forgotten (see Android cloning).

The former two lines of constructors (owner-and-id, owner-and-source)
are split into a simple, shared, constructor and new setId() and
copyFrom() functions.

The change is mostly mechanical, some multiple calls to fromMap
have been removed, though, some consts added.

Otherwise, to keep the patch small it temporarily introduces two
helper templates in IRunConfigurationFactory. Also, setId() signatures
have not been unified yet. These won't be needed in the final setup.

Change-Id: I8c0734496caae744a9883fe6d92c1d8f8e0234ea
Reviewed-by: hjk <hjk@qt.io>
2017-09-13 09:24:26 +00:00
Eike Ziller
ca959d8063 Merge remote-tracking branch 'origin/4.4'
Change-Id: Ic9a1cf3b40b259d9c77f2f542405d189171e0fbf
2017-09-05 12:15:42 +02:00
Ivan Donchevskii
410e31c665 CppTools: set default -std=c++11 for Qt4
qmake from Qt4 does not provide C++ standard and
clang can't properly compile Qt4.8.6 and earlier
with c++1z. Behavior in this commit mimics qmake
from Qt5 which also provides c++11 as a default
standard.

Task-number: QTCREATORBUG-16441
Change-Id: I3d29891d6e47f2367f2b3b2bf4be4d86661924e9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-05 09:37:14 +00:00
Tobias Hunger
45046f7071 ProjectNodes: Do not derive Project Nodes from QObject
That should save some memory per node, and since creator has a lot of nodes
(e.g. opening the LLVM project adds about 1 000 000 nodes) this should be
noticeable:-)

Calling update inside ProjectTree::currentNode() and rename it to
findCurrentNode() to make sure it is an still existing pointer.
Also, try to reduce the somehow more expensive currentNode() calls
and sprinkle some const around that usage.

Change-Id: I6a7c5db01a71d53d39544d3013cad557d5b96cdc
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-08-01 11:24:53 +00:00
Tobias Hunger
09b127f9f1 Project: Move signalling of parsing state into Project
Get rid of duplicated code to do such signaling in derived Project types.

Change-Id: I26914a1d751d72ee65c15a7943e0e7f34978f042
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-26 09:29:21 +00:00
Eike Ziller
88897f3a87 Merge remote-tracking branch 'origin/4.3'
Conflicts:
	src/plugins/genericprojectmanager/genericproject.cpp
	src/plugins/genericprojectmanager/genericproject.h
	src/plugins/genericprojectmanager/genericprojectnodes.cpp
	src/plugins/genericprojectmanager/genericprojectnodes.h

Change-Id: Ie0c870f68c8d200a75489b75860987655b2f6175
2017-04-19 09:56:14 +02:00
Tobias Hunger
0951589420 Project: Unify handling of displayName
Unify the handling of displayName with a proper changed signal across
all projects.

Change-Id: I7e503528854b85f6f38de4b0943775f82a0d6123
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2017-04-07 14:49:51 +00:00
Eike Ziller
bac2e6c17a Merge remote-tracking branch 'origin/4.3'
Conflicts:
	src/plugins/cmakeprojectmanager/servermodereader.cpp

Change-Id: I58e7b33d32c41cb48a24a5638ddb256212dd6107
2017-03-30 13:59:12 +02:00
Tobias Hunger
b0c7bb0f7b Project: Move ProjectDocument setup into Project class
Change-Id: I5c0ec79ddf066e37660fb9a6b24f9d882355d511
Reviewed-by: hjk <hjk@qt.io>
2017-03-29 11:53:24 +00:00
Tobias Hunger
348aa12eaa ProjectExplorer: Provide ProjectDocument and use it in all projects
Change-Id: I6e054ebf1043bd1f6748f1567f35c68394bd6528
Reviewed-by: hjk <hjk@qt.io>
2017-03-29 11:03:34 +00:00
Eike Ziller
016767b2a6 Merge remote-tracking branch 'origin/4.3'
Conflicts:
	src/plugins/genericprojectmanager/genericproject.cpp
	src/plugins/genericprojectmanager/genericproject.h
	src/plugins/projectexplorer/projectmodels.cpp

Change-Id: I290cba328212cadd3c12909d1f2f3642d326a1ca
2017-03-28 09:56:16 +02:00
Tobias Hunger
fc5ce1e710 ProjectExplorer: Handle project file list globally
Handle the generation of the list of files in a project globally, based
on the project tree.

Creator now has the concept of TreeManagers which can enrich the project
tree with additional data (e.g. the files found in a resource file), which
the project does not necessarily know about. So use that tree to find
the files that belong to a project instead of implementing similar features
in each project.

Change-Id: Ia375a914a1f2c0adaa427f9eda834eec2db07f68
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2017-03-27 15:32:13 +00:00
hjk
4d3c297d02 GenericProject: Code cleanup
Remove unused code from project node, access own members
directly, etc.

Change-Id: Icbffb4d3328757ffe3aa756ca1448fefba9bb00a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-21 17:23:58 +00:00
hjk
4d8352a6c1 ProjectExplorer: Add a FolderNode::addNestedNode() function
Also, rename buildTree() to addNestedNodes(), it's really
adding things, not recompletely (re-)building the subtree.

Use it whenever possible to avoid intermediate lists of items
to insert.

Change-Id: I5fde41e5b164a8a292410bd381a85f5efadf3471
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-14 12:26:22 +00:00
Tobias Hunger
49fef0ae24 ProjectExplorer: Create initial project tree
Create an initial project tree with a ProjectNode and a FileNode for
the project file itself.

Fix the Projects to not implement their own tree before they have
better data.

Change-Id: I147ccd5603d22d1d60880a97f30fd8c271eac88c
Reviewed-by: hjk <hjk@qt.io>
2017-03-10 16:22:31 +00:00
Tobias Hunger
2fde3fffa9 Make all projects generate a fresh project tree
Do not update the existing project tree anymore: Start a fresh one
and throw the old one away.

Change-Id: Ifabe293b6ca668b0672516a6d81acd5346d98fe5
Reviewed-by: hjk <hjk@qt.io>
2017-03-10 16:22:26 +00:00
Nikolai Kosjar
8a076e3f4b CppTools: De-duplicate and rename function in ProjectPart
Change-Id: I675ce4c9059d8ae4046f6a13aa7c04b88141d443
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-09 14:35:29 +00:00
hjk
c1bfc5d8ec ProjectExplorer: Follow up on too-much-magic in IProjectManager
Use a ProjectManager::registerProjectType<Project>(MimeType) function,
removing cryptic IProjectManager object ownership.

Change-Id: I212cd25bd4ee757022a8cb0decb4b8de3a112d12
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-09 10:41:33 +00:00
hjk
8fd17a84b5 ProjectManagers: Cleanup
Remove unused class members, declarations, includes, unneeded
::projectManager overloads etc.

Change-Id: I0f4ae87414faca226554722e2a9147cb5512495d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-28 16:15:03 +00:00
hjk
4d3d2d0dfb ProjectExplorer: Remove Project manager parameter from some constructors
Can be done generically when creating projects. The only wart is
the use from BaseQmakeProjectWizardDialog::writeUserFile.

Change-Id: Ie98c9f88ec142e82443e204a0075e3ae9e163752
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-28 14:56:21 +00:00
Tobias Hunger
9e8b427a70 ProjectExplorer: Nodes: Do not makeEmpty() as part of buildTree()
Do not call makeEmpty() as part of buildTree(). That makes it
impossible to combine buildTree with manual tree setup.

Change-Id: If0a0d9432fe39870917a6ba31594e8dcd6d31868
Reviewed-by: hjk <hjk@qt.io>
2017-02-24 08:40:04 +00:00
Nikolai Kosjar
d201571a2d {Auto,Generic}Project: Fix setting ProjectPart::displayName
Before

    commit 8c90998fff
    CppTools/ProjectManagers: Reduce ui blocking when loading projects

the displayName was set in the ProjectPartBuilder constructor. Now this
needs to be done explicitly.

Change-Id: I67655a3a5b8052344084e467bb08efd07ab86ab4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-02-21 14:40:13 +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
Tobias Hunger
fcc9ccaf6e Report better projectFileName to ProjectPart
Change-Id: I6ebf030869db7b6ce66eecce313524d8c56df259
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-27 14:53:23 +00:00
Eike Ziller
b1f1ccb32e Merge remote-tracking branch 'origin/4.2'
Conflicts:
	src/plugins/android/androidbuildapkstep.cpp
	src/plugins/genericprojectmanager/genericproject.cpp

Change-Id: I3484b668f9323ed0c05de99f8dfed07c9e65ab98
2017-01-11 09:29:37 +01:00
Andreas Pakulat
69159ab483 Refresh generic project when build config changes
Now that the generic manager can use data from the target or the build
configuration for expanding entries in its projects files it is
important that it reacts to changes of these entities. A change in the
build configuration can change the include directories or even compile
flags stored in the project configuration and hence the C++ code model
needs to be updated to reflect such changes.

The code is based on the qmake's project manager which has similar
functionality as far as I understood. The only difference is that the
generic manager won't attempt to refresh its state in the background (as
it simply can't do that right now) so the ui will be blocked for a bit.

Change-Id: I0a85e1ff0deeb876a7934b9a193a5d0f020047c7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-04 11:08:49 +00:00
Andreas Pakulat
c79d290ca2 Expand macros in generic projects configuration files
This adds the ability to use macro's provided by various parts of
QtCreator inside the .includes or .files file. In particular the build
directory of the current build configuration or Qt variables of the
current kit (accessible through the active target's macro expander) can
be useful but I suspect its possible to find other use-cases as well.

Fall back to the project's own macro expander if there's no active
build target to allow this to happen some day, even if that expander does
not have many useful variables.

Change-Id: Ic3b7b744b5d0ae24247ad929b73d7c72abfb8bb3
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-04 11:08:36 +00:00
Przemyslaw Gorszkowski
3c9c76c6f3 GenericProject: show project files in "Project" tree
This missing project files(*.files, *.includes, *.config) in "Project"
tree is a regression.

Change-Id: Ib7380b1627a0f31045a25bc152352f5d2c82342a
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-01-03 08:29:34 +00:00
Andre Hartmann
5d3cabb4e6 GenericProject: Remove unneeded check
toAdd is a QSet, so insert does nothing if directory is already
in the set.

Change-Id: Ic7d593414bef95a84f624c39208e29b0ec8c01f1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-01-02 21:53:44 +00:00
Andre Hartmann
70556e8495 GenericProject: Cleanup and modernize
* Use nullptr instead 0
* Remove QLatin1{String|Char} where possible
* Use C++11 list init and auto
* Add some const as drive-by-change

Change-Id: Ife4c9c7b0869bcf2c864b88b8061ac6b7c3f33c0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-01-02 21:53:23 +00:00
Andreas Pakulat
82dcd1dadb Replace lookup in process environment with build environment
The generic manager looked up entries from the .includes and .files
configuration files in the process (i.e. QtCreators) environment. In
particular for the .includes file this is a problem, since it makes it
impossible to use environment variables specific to a particular build
environment.

In my case I'd like to access the QTDIR variable added by QtCreator to the
build environment to provide the generic manager with the Qt include
directories. Of course this is different when working with two kits that
have different Qt versions associated and hence its not possible to
hardcode a particular path in the .includes file.

This will break existing files that use the generic-manager-specific
syntax for environment variables ($$(VARNAME)) as the BuildEnvironment
uses the platform's native way to refer to such variables.

Change-Id: I1a684db82fdbfd163b6a215f9591c8e4bb57b25c
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-12-21 16:05:11 +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
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
Tobias Hunger
ce3e586198 ProjectExplorer: Shorten space needed to store a FileType
Use class enum to shorten the FileType to quint16. This frees up a couple
of bytes per FileNode and we can have many of those.

Change-Id: I3a9ae25059690fefa15305a4268269647d6dc1c9
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-03 15:55:39 +00:00
Nikolai Kosjar
6e6d5b5309 ClangStaticAnalyzer: Tests: Rely on projects telling when they finished parsing
We relied on the CppModelManager to tell us whether a project was reparsed
after a kit change. While this worked, it was not guaranteed that the project
is really finished (and ready for e.g. building) after pushing new ProjectInfos
to the CppModelManager.

Rely on the projects telling when they are finished with parsing. This is more
accurate and future-proof.

The introduced signals in Project and SessionManager are (at the moment)
only for tests.

Change-Id: I1b368ec4585ffa8755eb28fac6d187cce31243ee
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2016-10-31 15:09:01 +00:00
Tobias Hunger
655496bc4a GenericProject: Use helpers from FolderNode to generate project tree
Change-Id: Ie9b3c9381cc59c7e1c1b32d9c63c46db0aaa7984
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-10-06 09:51:47 +00:00
Andre Hartmann
758544c058 GenericProject: Keep file list sorted when adding or renaming files
Change-Id: I064e9a00039671fbf626efa5227678800615ff1d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-08-16 09:33:59 +00:00
Tobias Hunger
84f1466b01 Use FileChangeBlocker
Use FileChangeBlocker over expecting/unexpecting file changes manually.

Change-Id: I8428841f966d81be477260416c75e91dee795425
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-07-18 09:07:23 +00:00
hjk
602d899e0f Move CustomExecutableRunConfiguration to ProjectExplorer
There's nothing QtSupport specific in there.

Change-Id: I616a37ed56f1853cdbb16f483de5682d5ea63715
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-05-13 11:03:06 +00:00
Orgad Shaneh
a5a4f02ced Core: Make IDocument concrete
Change-Id: I8290943614ea4a2060cf09a71fb4f957852ab705
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2016-03-17 07:43:55 +00:00