Commit Graph

267 Commits

Author SHA1 Message Date
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
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00
hjk
0ec860009a Replace uses of QString::sprintf()
There are patches appearing on gerrit for Qt 6 to remove the functions.

Change-Id: Ic189c0a19ddc0f84eb34a56c0861532303de5129
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-20 12:03:00 +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
Nikolai Kosjar
e0c7722441 CppEditor: Modernize
modernize-orgad
modernize-return-braced-init-list
modernize-use-auto
modernize-use-default-member-init
modernize-use-equals-default
modernize-use-nullptr
modernize-use-override
modernize-use-using

Change-Id: Ifa862782fb7b56ed3f93d9f98685c3af616797c2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-02-08 08:39:58 +00:00
Nikolai Kosjar
55f4c28889 CppEditor: modernize-loop-convert
Change-Id: I80382880a3c35ef0b59729bd222a626bc5c4a32b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-08 07:52:23 +00:00
Nikolai Kosjar
612393889a CppEditor: Fix some clazy level0 warnings
Use leftRef() instead [-Wclazy-qstring-ref]
Use multi-arg instead [-Wclazy-qstring-arg]

Change-Id: I4aa67e0d518060cdec4f96cb7a03a9a499f28f27
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-02-08 07:51:36 +00:00
Alessandro Portale
f5974ad993 Fix warning: "Don't call QVector::first() on temporary QList/QVector"
[-Wclazy-detaching-temporary]

Change-Id: I23f5cbd80bb92d3f9f1bfb5ae07493818958c5b0
Reviewed-by: hjk <hjk@qt.io>
2019-01-28 11:03:39 +00:00
Eike Ziller
3d1d9aae2e Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/winrt/winrtdevicefactory.cpp

Change-Id: I33b8697e2ebf2bea051d7f1144449e0743ee16a5
2018-11-19 10:00:18 +01:00
Ivan Donchevskii
8dc566e902 CppTools: Allow to check whether project code style exists
The calling code can anyways fallback to the global style
without extra help if no project style exists.

It is useful when you want to get the project style if it exists
and understand at the same time that it is not a global one.

Change-Id: I265de3f436f90623385427fc8a1abad09c8c3577
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-12 08:56:20 +00:00
Frank Meerkoetter
ffc070a3f2 Replace call to a long obsolete QtAlgorithms function
Change-Id: I1e07649d7d1153400951ae734c7f78e03ff8fe32
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-10-08 07:47:23 +00:00
Eike Ziller
049291504d Fix function extraction for nested classes
If the function is added to a class inside a class, these must be
prepended before the inner class name.

Fixes: QTCREATORBUG-7271
Change-Id: I07042cdd4927af3b630c6ab1b5587971754e1199
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-02 13:31:48 +00:00
Eike Ziller
7a7898e2c9 Reduce priority of "Convert to Camel Case" refactoring
Otherwise this is too annoying in case the function is called the way it
should be.

Fixes: QTCREATORBUG-8114
Change-Id: I51063a11e7979e24fc9020344aa5ff800b5064a9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-02 13:31:02 +00:00
Frank Meerkoetter
6f56feef29 CppEditor: better detection of the system a numeric literal is in
Fixes:
The literal 1 (or any decimal of length 1) was misdetected as not
already a
decimal literal which resulted in a quickfix "Convert to decimal".

Improves:
More consistent handling of 0. Octal is now handled like the other
cases. The user is offered to turn 0, 0x0, or 0b0 into 00.

Change-Id: I9a559fc328d0b49bfe0e53b933e8b4fee5af27a5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-09-27 07:01:39 +00:00
Frank Meerkoetter
d7be70afd4 CppEditor: binary literal support for ConvertNumericLiteral
Extend the ConvertNumeric literal quickfix to support
C++14 binary literals.

Change-Id: Ia1cf8633e80ddf7d968a881d17ce2a07c5de89d3
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2018-09-20 19:29:03 +00:00
Frank Meerkoetter
17fdb595a0 cppeditor: remove misleading Qt4/Qt5 label in WrapStringLiteral
QStringLiteral and QLatin1String play a different role and have
different properties. QLatin1String isn't strictly Qt4. Qt4 had
QLatin1Literal (for which QLatin1String is nowadays a compat alias).

Change-Id: Ie2a5f7d9d29ad8db735743a9d9579c4c0828cd45
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-09-20 07:02:32 +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
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
Orgad Shaneh
eea6a7c3b3 Utils: Purge qtcfallthrough.h
No longer needed.

Change-Id: I9b0bee014df89d4c567f1d2431b5ff9404f5f925
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:13 +00:00
hjk
289f2b170a CppEditor: Do not add QuickFixFactories to object pool anymore
Not needed anymore.

Also some cleanup, no 'using' in headers etc.

Change-Id: I8c4547d80d0c0ffd989d1efbc74687c9f56096a4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-02 12:26:32 +00:00
hjk
0e687d6a4f CppEditor: Normalize WrapStringLiteral and RewriteLogicalAnd interface
Slims down publicly visible interface and could be one step towards
replacing the CppQuickFixFactory derived classes by plain
stand-alone functions.

Change-Id: I9c6a8bcbd8481e14fb21dd41b11a1e6153a35e4b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-01-03 07:36:11 +00:00
hjk
479ab4ef22 TextEditor: Split the global QuickFixFactory list
It's only ever used in the filtered Cpp/QmlJs variants. Splitting
the class simplifies the code and avoids re-doing filtering over
and over again.

Also inline QuickFixFactory::matchingOperations() into callers

Change-Id: I730756315f2e0321649259ef229631233b12fbdd
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-18 15:39:51 +00:00
Ivan Donchevskii
74570e833d CppEditor: fix class refactoring crash
... when class contains functions with incorrect AST.

Task-number: QTCREATORBUG-19180
Change-Id: Ie60c27ccec6d664e7ba76b8862326dbb9576a1bb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-11-03 12:12:32 +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
96ef6c797b CppEditor: split CppEditor and CppEditorWidget
Change-Id: Id3c815184f7f3bace0276e947f6b6f76e61ec6de
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-12 15:05:38 +00:00
Ulf Hermann
47886969cc Drop unused variables and lambda captures
Also, add context to connect() expressions where we are or were
capturing "this".

Change-Id: I6e006ba6f83d532478018550d148ee93eca59605
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2017-09-08 09:06:53 +00:00
Jochen Becher
91dec7fe7a CppEditor: Minor refactoring quickfix
Change-Id: I978d79f081749cef58ca9be7387892dbca71683c
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-07-21 11:54:23 +00:00
Christian Kandeler
be2b3c91ae Add Q_FALLTHROUGH for Qt < 5.8
... and make use of it.
With gcc 7, the new option -Wimplicit-fallthrough is introduced and
added to the -Wextra set, triggering dozens of warnings in our sources.
Therefore, we annotate all obviously intended fall-throughs. The ones
that are still left are unclear and need to be checked by the respective
maintainer.

Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-07-17 07:51:23 +00:00
Przemyslaw Gorszkowski
c6771c39c1 CppEditor: Fix quickfix for adding include for static functions
Task-number: QTCREATORBUG-14499
Change-Id: Id3e962ed310f43c33b91c7834a1f9ca074519a38
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-23 11:47:24 +00:00
Nikolai Kosjar
39dea09794 CppEditor: Fix uninitialized value warnings
...from coverity scan.

Change-Id: I1b1fb919e77f1407fe2e4319392c28413a296493
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2017-06-01 13:33:21 +00:00
Christian Gagneraud
972b48ef24 CppEditor: Use qFuzzyCompare when comparing member variable for qproperty refactoring
For a line like

    Q_PROPERTY(qreal foo READ foo WRITE setFoo NOTIFY fooChanged)

the generated setter will now use "if(qFuzzyCompare(m_foo, foo))" instead of "if (m_foo == foo)"
for types that are supported by qFuzzyCompare (that is: qreal, double and float).

A warning stating that "Floating point comparison needs context sanity check" is as well added
to remind the user to check/fix the generated code.

Change-Id: I8d274d5c072d107f0d04b1e153b5cc183e6317fc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-03-07 23:33:05 +00:00
Nikolai Kosjar
d6e81eb49e CppEditor: Emit member variable for qproperty refactoring
For a line like

    Q_PROPERTY(bool foo READ isFoo WRITE setFoo NOTIFY fooChanged)

the generated setter will now "emit fooChanged(m_foo)" instead of "emit
fooChanged(foo)".

Change-Id: I417607ea614bfde0aafa6de401ffa888daf37c4c
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-02-24 13:57:36 +00:00
Nikolai Kosjar
1aaf840f3f CppEditor: Remove superfluous "..." for qproperty refactoring
Change-Id: I79229b47514f0a420c13351673f018bbf564ae56
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-02-24 13:57:31 +00:00
Montel Laurent
cb8d0f0678 Remove last Q_NULLPTR usage
Change-Id: I8a55a9f1927e6db979d61eb4702f2ebde8d27572
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-02-22 10:27:26 +00:00
Tobias Hunger
78ced14c4c CppEditor: Remove dead code
Change-Id: If65f43e232c83924a746bcbb30ced5db57dd547b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-11-30 09:48:59 +00:00
Tobias Hunger
81401ace26 CppEditor: Fix possible use of uninitialized values
Change-Id: I138309e5e85c839250f5f93448530b9e12c5f6af
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-29 15:13:26 +00:00
Friedemann Kleint
3b1308bb43 TextEditor: Remove exported class QuickFixOperations
Define an operator << that accepts a raw pointer for the list of
QuickFixOperation::Ptr instead.

Fixes MSVC 17 warnings

src/corelib/tools/qlist.h(423): warning C4661: 'QVector<T> QList<T>::toVector(void) const': no suitable definition provided for explicit template instantiation request        ]
src/corelib/tools/qlist.h(389): note: see declaration of 'QList<TextEditor::QuickFixOperation::Ptr>::toVector'
src/corelib/tools/qlist.h(423): warning C4661: 'QSet<T> QList<T>::toSet(void) const': no suitable definition provided for explicit template instantiation request
src/corelib/tools/qlist.h(390): note: see declaration of 'QList<TextEditor::QuickFixOperation::Ptr>::toSet'
src/corelib/tools/qlist.h(423): warning C4661: 'QList<TextEditor::QuickFixOperation::Ptr> QList<TextEditor::QuickFixOperation::Ptr>::fromVector(const QVector<T> &)': no suitable definition provided for explicit template instantiation request
...

Task-number: QTBUG-57086
Change-Id: I879511656c39eb7a3eae54ea7daca3eca8ebe8d7
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-11-18 11:47:59 +00:00
Nikolai Kosjar
745fc30277 CppEditor: Fix null pointer access
Task-number: QTCREATORBUG-17253
Change-Id: Ide3d15508a2e310c307fef68457848e869c4d2de
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-11-15 11:21:25 +00:00
Lorenz Haas
49c6710b42 CppEditor: Fix GenerateGetterSetter for reference types
Change-Id: Iad332cf023c6bff0c7f5ae46fb56f0393c9c7b29
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-10-31 16:00:17 +00:00
Orgad Shaneh
34baa3ec47 CppEditor: Add enclosing template on "Move Definition Outside"
The template id for the class name is missing, but it's better than
nothing.

For example:

template<class T>
class Foo
{
    void func() {} // Move Definition Outside Class
};

// The following lines are added
template<class T>
void Foo::func() {} // Should be Foo<T>::func

Task-number: QTCREATORBUG-16649
Change-Id: Icb560e0b87f563cbda18f4742f44bb8ef4d8a900
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-06 13:23:18 +00:00
Orgad Shaneh
d0d1f43e8f CppEditor: Add enclosing template on "Add Definition"
The template id for the class name is missing, but it's better than
nothing.

For example:

template<class T>
class Foo
{
  void func(); // Add Definition
};

// The following lines are added
template<class T>
void Foo::func() // Should be Foo<T>::func
{
}

Change-Id: I60a0cbd348985def3dfb7037067786e942278593
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-06 13:23:12 +00:00
Orgad Shaneh
39aff55d8a C++: Enable showEnclosingTemplate also for function type
Do not require directly passing the enclosing template.

Change-Id: Ie03bc58338fe003677a5f5311d86d70f499373ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-06 09:33:48 +00:00
Orgad Shaneh
5a40bddf08 CppEditor: Add template enclosing scope on "Insert Declaration"
Change-Id: Iff4893193b56c2ed86b4b9515a1a1df847528369
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-19 14:41:25 +00:00
Orgad Shaneh
2890966ec3 CppEditor: Prevent "Add Declaration" for existing template functions
class Foo
{
    template<class T>
    void func();
};

template<class T>
void Foo::func() {} // Add Declaration should not be triggered at all

Change-Id: Ifff733d8381177300dae017ae419200cfdf5c425
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-19 14:41:17 +00:00
Orgad Shaneh
65dc6d0fc2 CppEditor: Fix "Move Definition to Class" for template member functions
class Foo
{
    template<class T>
    void func();
};

template<class T>
void Foo::func() {} // Move to class

It currently doesn't trigger at all.

Change-Id: I63d561771a8dd455f01e99dd836abbd23eec71b7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-19 14:41:11 +00:00
Orgad Shaneh
e920921f27 CppEditor: Fix "Move Definition to Class" for function in template class
template<class T>
class Foo { void func(); };

template<class T>
void Foo<T>::func() {} // Move to class

Prior to this change, this currently leaves behind `template<class T>`
where the definition used to be:

template<class T>
class Foo { void func() {} };

template<class T>

Task-number: QTCREATORBUG-14354
Change-Id: I8e1f75a3ae50619a7bae9c63d3798b16bcfea545
Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-19 13:00:42 +00:00
Nikolai Kosjar
1ea6404337 CppTools: Allow prefering getter names with "get" prefix
We default to "foo()" for e.g. a member variable "m_foo", but other
coding styles require "getFoo()".

Task-number: QTCREATORBUG-16452
Change-Id: I9ccfdf88e4c469bc1c06fde855ad754faf2bd238
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2016-06-22 12:22:57 +00:00
Nikolai Kosjar
b928a1ce46 CppEditor: Extract determineGetterSetterNames()
...and make it a bit more readable since we are going to make some
changes there.

Change-Id: Ic1d0c47a36ef4547a4842508c2404e9fc12f5220
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-22 12:20:25 +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