Commit Graph

93 Commits

Author SHA1 Message Date
Eike Ziller
6ac8bf2f0a Algorithm: Do not derive from std::iterator
MSVC throws warnings that this is deprecated.

Change-Id: I010c54a923f395a04a4c84cfcd01848a42752e2e
Reviewed-by: hjk <hjk@qt.io>
2020-07-14 07:07:56 +00:00
Eike Ziller
d400dce35d Require GCC 7 and enable C++17
Fix MSVC2019
- result type of conditional expression is ambiguous:
  types 'const char [1]' and 'QByteArray' can be converted
  to multiple common types

Fix MinGW 8.1
- undefined reference to SemanticHighlightNotification::methodName

Fix Utils::transform with std::vector for GCC & MSVC

Unfortunately we cannot get rid of the special variant and optional
implementations, because Apple Clang requires deployment target >= 10.14
for the functions that can throw std::bad_optional_access.

Fixes: QTCREATORBUG-20520
Change-Id: I5c36a70f21f8b0215d2f4fc5c0653a022778d928
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-07-10 11:52:24 +00:00
hjk
faf9c883f2 Utils: Disable the QVector overloads in algorithm in Qt 6
Not the QList one.

Change-Id: I05ad3401b8d3abf3ee413ed518574b4362502996
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-18 14:01:39 +00:00
Alessandro Portale
0be309bcf1 Various places: performance-for-range-copy
Change-Id: I475990d32a5211d31a77782667a2dfedba134137
Reviewed-by: hjk <hjk@qt.io>
2020-06-15 05:58:46 +00:00
hjk
e5d1e9d274 Work around QHash::unite deprecation
Change-Id: Ibf199b5e3f2ca99b7e0cafe20893a509d9eab906
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-25 10:43:10 +00:00
hjk
0120e462b2 Partial compile fix for current Qt dev and/or Qt 6
This does not cover Utils::MapReduceOption with QVector, and code
that's not compiled on my machine.

Change-Id: Ib63923985c52b1bb74e5ec2068a2bb37469ac618
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-11-12 10:50:51 +00:00
Tobias Hunger
d13307b5bf Project: Add signal triggered by project files becoming dirty
Add a signal triggered by project files becoming dirty and add
a way to register more project files than just the default with the
project.

This change enables getting rid of filesystemwatchers in derived
classes.

Change-Id: If985b46edf7cb88dd49f1c574f35cf13b5ce82d4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-08-16 12:43:21 +00:00
Tim Jenssen
1df6443d4a Merge remote-tracking branch 'origin/4.10'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/libs/utils/synchronousprocess.cpp
	src/plugins/baremetal/iarewtoolchain.cpp
	src/plugins/cmakeprojectmanager/cmakeproject.cpp
	tests/unit/unittest/CMakeLists.txt

Change-Id: I124ad492df403286751e175d27fe36487ddf6d07
2019-07-04 15:17:55 +02:00
Friedemann Kleint
a27b50dcaf algorithm.h: Fix compilation with Qt 5.13.1
Fix the version check for the developer branch.

Amends c2fd7743e0.

Change-Id: I552330bcbbd00367d8b7044d3bf5dc6952d1a469
Reviewed-by: hjk <hjk@qt.io>
2019-07-03 13:44:43 +00:00
hjk
c2fd7743e0 Fix compilation with Qt 5.13
Change-Id: I6e95bf74dc3a123aa635f0a44a2ea357a6dd7da2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2019-07-03 13:26:53 +00:00
hjk
36fcd52136 Utils: Add toSet/toList functions
As replacement for functionality that's being deprecated
in Qt but still useful or needed, or that cannot easily be handled
without resorting to #if QT_VERSION checks in user code.

Change-Id: Id3575a54ff944bf0e89d452d13944fcaee270208
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-02 12:48:54 +00:00
David Schulz
307f1d8e6e LanguageClient: add support for proposed semantic highlight
implements the current proposal for the semantic highlighting
via the language server protocol.
https://github.com/microsoft/vscode-languageserver-node/pull/367

Change-Id: I857d606fcf5c782e0ea8e18e5d098edd26286aed
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-06-21 08:37:11 +00:00
David Schulz
2bca6847ba Utils: reserve result container size in partition
Change-Id: I0f5bf8d7c4ee0d4eec23ba63d73522d2be7f2711
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-19 05:45:47 +00:00
Eike Ziller
50b12945b7 Algorithm: Put declarations at top of file
It contains so much nowadays, and parts of it require internal
functions, so it became hard to actually find out what algorithms we
provide.

Put declarations of the "public" functions at the top of the file, to
make them more discoverable.

Change-Id: I99456e1023a6f39223d09a2936995b8fa6dc5cb0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-05-13 13:13:20 +00:00
Marco Bubke
eb53b183ba Clang: Fix set_union bug
std::set_union in libC++ is broken for move iterators. We has to use
temporarily our own implementation which can be removed if we move to a
newer version of XCode.

Task-number: QTCREATORBUG-22246
Change-Id: I8fccc8aab5f8af738aa2e589ba65924363cd818d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-04 10:49:20 +00:00
Eike Ziller
18bd816161 Algorithm: Add missing include
filteredUnique uses QSet

Change-Id: Ia53552ced5fd2262136c91ba3baa85904ebb7029
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-29 11:03:41 +00:00
Marco Bubke
8bea373729 Utils: Add size functions to algorithms
So you can type Utils::usize(qVector) == Utils::usize(stdVector) without a
warning. You can write qVector.reserve(Utils::ssize(stdVector) etc..

Change-Id: If5b93b7daa8d4126cf588b0f025b99444bc8e8af
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-14 11:29:38 +00:00
Marco Bubke
be9537667f Use Utils::setUnionMerge
And fix some details of the implementations.

Change-Id: I8e77fee4b95658a69ef1656bb406811de091ce16
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 12:14:16 +00:00
Marco Bubke
6386cd54eb Utils: Add container wrapper for setUnionMerge
It works with contiguous arrays like std::vector but it is not so useful
for other containers anyway. Use the iterator interface for std::array.

Change-Id: I9f5dd665d38ca642bbd81e1925445127ea579c22
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-08-29 10:54:58 +00:00
Marco Bubke
6775347cd2 Utils: Add setUnionMerge to algorithms
Utils::setUnionMerge is an extension of std::set_union. It is not assigning
but merging equal matching values. For example two project part with the
same id will be merged in one by the merge function.

Change-Id: Ia244a7c1ff84dfdbd30f7101ed1ccbfb88393c7d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-08-27 13:46:21 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Orgad Shaneh
7cee991c70 Utils: Remove superfluous qualifications
Change-Id: I36e17dac0cff87f82f0ddaf97bc613389110f218
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-07-19 08:21:29 +00:00
Eike Ziller
bb28b10add Introduce static_container_cast
Casting all elements of a container, similar to qobject_container_cast.

Change-Id: Ib455fe8c7fa0d4acda7e29685c3100638a0152f8
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-05-29 13:44:51 +00:00
Eike Ziller
547ecf757d Get rid of size type conversion warning in Utils::transform
When transforming between containers with different size_type, like
QList and std::vector.

Change-Id: Ife28aacdc8627e81901579cde8b563da1408d084
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2018-05-04 13:06:55 +00:00
Tobias Hunger
0bc100911d Utils: Add pointeralgorithm.h
Change-Id: I3e81bdbf22808efbe1fb5fab13bef24c8f73f404
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-03-12 14:14:10 +00:00
Tobias Hunger
831b84a6fd Utils: Add take
Add a new algorithmn to take the first match in a container out of the container.

It takes a pointer to something and will try to match against a smart pointer
stored in the container. Besides that it also accepts the usual like a predicate,
member variable or member function.

Change-Id: I4aabd4d43aa076a534da6488d0f9c3695ba79c09
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-03-12 14:14:01 +00:00
Eike Ziller
8944ba0391 Utils::transform: Add support for various map types as result
Add support for output as std::map/unordered_map/set and QMap and QHash,
when giving the full result type as template argument. For std::
(unordered_)map, the function must return a std::pair<Key,Value>, for
QMap and QHash it can also be QPair<Key,Value>.

Change-Id: If3dff17ab6aa5d1b11abc244813fd885d10c75a4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-12-20 09:58:50 +00:00
Eike Ziller
f62b24c475 Utils::transform: Support containers without reserve()
Support containers without reserve() as result container, for example
std::set/deque/list

Change-Id: Ia96b834c67d5ee74bfb9de2cf6b86639f6b3d5d7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-12-20 09:58:27 +00:00
Marco Bubke
91e40e12db Utils: Converter to raw pointer and references
Sometimes you want to get raw pointer container from smart pointer
container and reference container from value container.

Change-Id: Ia018d572ac0a7bf742f3937dc38ee30670a3ca73
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-20 09:58:17 +00:00
Eike Ziller
e0a23664aa Utils::transform: Allow usage with non-const source containers
Makes it possible to e.g. transform to list of reference_wrappers.

Change-Id: Ib608034fc3f296824c289edd27563bc7a196ac6d
Reviewed-by: hjk <hjk@qt.io>
2017-12-19 07:35:38 +00:00
Eike Ziller
6b48beeeb0 Support specifying complete result type in Utils::transform
Can come in handy when the function or member does not directly return
the right value type for the result list, but is implicitly convertable
to it. For example from pointer to class to pointer to superclass, or
from int to double.

const auto result
    = Utils::transform<QVector<double>>(v, &ValueType::intMember)

Change-Id: I0e1914d70bb2580b91098dd37e85a31ca14b0ae6
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-12-12 14:44:15 +00:00
Eike Ziller
6d05ba7bfc Algorithm: Fix compilation with Xcode 7.2.1
Change-Id: I4413841adc00156a4c8877c00ba6929262ae8e8f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-12-07 09:55:49 +00:00
Eike Ziller
fb4f7e7420 Simplify transform and add support for more input container types
Change-Id: Ib75cfcc7741be686c0117fbb27df869e14db4f69
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-12-07 09:55:42 +00:00
Tobias Hunger
769afa9f97 Utils: Move variadice template arguments to the end
Move variadic template arguments to the end for all users in algorithm.h.

Change-Id: I7c8f1254e7de6ee9737e73d1a4721e71c188438e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 14:41:22 +00:00
Tobias Hunger
2c09424c13 Utils: Clean up Utils::findOr and Utils::findOrDefault
Change-Id: I638e68480d3985b6df9a18aa96a067ee68484b12
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 14:41:15 +00:00
Tobias Hunger
b81d788793 Utils: Support more containers with Utils::transform
Support std::vector and similar classes as input and output.

Change-Id: I1d202d54c18e868ce0e71e4c2b6288565710baa8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 14:11:28 +00:00
Tobias Hunger
b712b1bc7c Utils: Make Utils::indexOf work with all iterator types
Change-Id: I5b9b577bdfb26bd03583ca8349b960625124a929
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 13:16:51 +00:00
Tobias Hunger
33fc20ab51 Utils: Improve Utils::contains
* Consistently use anyOf to implement contains.
* Support contains over an container of std::unique_ptr matching a pointer.

Change-Id: I0180f3ec3d5935d8afeeac67a745d4b38a01674d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 13:16:43 +00:00
Tobias Hunger
9b832f670d Utils: Implement more Utils::anyOf variations
Change-Id: I0cba5b58dde6003f5c5cb399142f985cbe83f0a7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-12-01 13:16:37 +00:00
Eike Ziller
c90e5b50dc Algorithm: Support std::vector<std::unique_ptr> with contains and findOr
Change-Id: I01cb71c06b405f071498ed8752f9acac44d2b223
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 08:59:52 +00:00
Tobias Hunger
566b118a87 Utils: Make algorithms take more containers
Change-Id: I05bd1052bbc2c6481fdec8a3763d9ae4f3dc8f44
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-11-27 15:00:16 +00:00
David Schulz
2453d20dd0 Utils: add filter and transform function for qobject container
Add function that casts QObjects of a given container to a desired type
and return the result via the same container with the desired value
type.

Change-Id: I45949c982c8dbdd0cce069d62cd2db5c8517f9f5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-11-14 14:29:27 +00:00
Marco Bubke
4911d5bea3 Utils: Add predicates for comparison to constant values
Many STL algorithms have value version. So you can only use a predicate:

std::stable_partition(std::begin(list), std::end(list), [](int entry) {
     return entry < 20;
});

With this predicates you can write it in a shorter form:

std::stable_partition(std::begin(list), std::end(list), lessThan(20));

The find helpers are moved to predicates too.

Change-Id: I791b3105ca84ef7c5a519d22589a91b5548cf3e4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-10-27 09:28:07 +00:00
Eike Ziller
cf57965ebc Simplify text format handling in syntax highlighters
Pass the mapping from custom enum to text style in form of a function,
which then can use a switch which is checked by compilers, and
avoids the need to lookup a different enum somewhere else to find
out what the mapping actually is.
That mapping is cached to keep performance as before.

Also, most highlighters created an enum just for the purpose of mapping
to text styles, basically creating duplicated subsets of text style like
enums everywhere. Instead provide a default, identity mapping from text
styles to text styles.

Change-Id: I2ea1ca702b99e36b8742dfda510b1b2753f0a1c2
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-23 07:47:22 +00:00
Eike Ziller
06250531db Simplify Utils::transform (again)
Change-Id: I14690b55e9eeeac0aff243a6dfd6b83e7325179b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
2017-03-29 09:05:42 +00:00
Orgad Shaneh
4136e36c6f Algorithm: Add a member variant for transform
Change-Id: I329ee764cc13dd8b794c6769a2baf2f41d6a9983
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-03-10 11:37:03 +00:00
Marco Bubke
38b6f4ff85 Utils: Reserve a container before you use transform
It is seen as good practice to use Container::reserve if you know the size
in advance.

Change-Id: If1398eaa099f4d3f657778aca46516f9bdec14c9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-02-08 14:24:45 +00:00
Orgad Shaneh
e3eee3b2b9 Utils: Eradicate Q_FOREACH in algorithm.h
Change-Id: I16cbe1896091e6677341dd954f58f69db1d61530
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-02-06 09:37:36 +00:00
Eike Ziller
af8812b248 Algorithm: Use decltype(auto)
Avoids some code duplication. Available with C++14 / GCC>=4.9.

Change-Id: Iae90466ec9620ffc84b7a45a55490f5fbc8c5b74
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-30 10:46:30 +00:00
Eike Ziller
63f66f28ac Use _t versions of various type traits
Available now after switching to C++14 and GCC>=4.9

Change-Id: I44e9859a6abe66db16d77b228466b65eadced8ae
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-30 10:46:22 +00:00