In header files, a forward declaration is often preferable to including
another header file, so let's offer this as a quickfix.
Fixes: QTCREATORBUG-23444
Change-Id: Ib50550abb5337098e4122e65e2af42a66742d6f6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Adding a "= new <TypeName>" after converting a stack variable without
assignment or initializer to pointer.
Also remove the assignment when converting from pointer to stack
variable as this works better with explicit constructors.
Fixes: QTCREATORBUG-23181
Change-Id: I377ec32a1b66cf4b96db14cfcb4b71fb96c80c98
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This applies for e.g.
* "Add Definition..." (on function decl)
* "Move Definition..." (on function decl)
* "Insert Virtual Functions of Base Class" (on class specifier)
Fixes: QTCREATORBUG-11849
Fixes: QTCREATORBUG-19699
Change-Id: I0d259bc1782470f3b3f19617230005a5594a5cca
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
It is the type used by the HeaderPath class, so reflect that in
the name.
I also considered to rename HeaderPath to IncludePath, but
that name is reflected in a lot of users, which would also need
to be adjusted for consistency. That would blow up the patch size
for little value IMHO.
Change-Id: I51421dbd3ab8b2874dc32fc82dc394c9b93ce5e9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
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>
Not needed anymore.
Also some cleanup, no 'using' in headers etc.
Change-Id: I8c4547d80d0c0ffd989d1efbc74687c9f56096a4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Broken by
commit d6e81eb49e
CppEditor: Emit member variable for qproperty refactoring
Change-Id: I5e86f0fb1942a497c4242b6f1890e74eb55b687c
Reviewed-by: David Schulz <david.schulz@qt.io>
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>
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>
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>
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>
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>
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>
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>
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>
ASTPath uses TranslationUnit::getPosition(), which returns reasonable
results for:
1. non-expanded tokens
2. expanded but not generated tokens
The expanded *and* generated tokens case is not handled since there is
no reasonable mapping from generated tokens to a continuous line/column
information. Consider:
#define DECLARE_FOO int foo; // Multiple generated tokens
DECLARE_FOO // ...can be mapped to this line, but to which columns?
Since the result where not valid for the expanded and generated case,
ASTPath took the wrong branches. Avoid this by skipping generated
tokens.
Change-Id: I33a2e0f62917f87d691b19feaeef67b09ea8d563
Task-number: QTCREATORBUG-13386
Task-number: QTCREATORBUG-13390
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
As a nice side effect superfluous new lines - introduced by quick fixes
that are using InsertionPointLocator::methodDefinition - vanished.
Task-number: QTCREATORBUG-13872
Change-Id: Ib3df2b2acbc22449f16f4444092a57ae93d53d35
Reviewed-by: Jochen Becher <jochen_becher@gmx.de>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
The "Convert to Stack Variable" quick fix generated invalid code for
the following snippet: QString s = new QString();
Task-number: QTCREATORBUG-14279
Change-Id: I1f5e33d2089bc2d5713eae1e9f4dc5986523112c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
With a simple check GenerateGetterSetter looks for symbols starting with
"get". If such symbols are found it is most likely that the current
class uses "getFoo" for getters and thus the quick fix uses this coding
style for generating the getter name.
Change-Id: I9ff8ef8bb936572abaaf9e671b8985553c1018f1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Since the Q_PROPERTY's name equals the typical getter name the "Generate
Getter" quick fix was not offered.
Q_PROPERTY(int a ...) // <-- a is "recognized" as "int a();"
int m_a;
Task-number: QTCREATORBUG-14166
Change-Id: I35709a1b6492b68309d02427d60251df4fd76cfa
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
In addition to create both getter and setter member functions at once it
can now be decided to only create a getter or setter member function.
Task-number: QTCREATORBUG-13874
Change-Id: I9127a31b7d87dc91619abb2e2335bd8221f170a2
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Instead of using "arg" for the generated getter/setter/signal argument
try to detect a proper name.
Task-number: QTCREATORBUG-12656
Change-Id: Iddaeb1f1d490af003d172d515033d85d778c10df
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Mostly done using the following ruby script:
Dir.glob('**/*.cpp').each { |file|
next if file =~ %r{src/shared/qbs|/qmljs/}
s = File.read(file)
s.scan(/^using namespace (.*);$/) {
ns = $1
t = s.gsub(/^(.*)\b#{ns}::((?!Const)[A-Z])/) { |m|
before = $1
char = $2
if before =~ /"|\/\/|\\|using|SIGNAL|SLOT|Q_/
m
else
before + char
end
}
if t != s
puts file
File.open(file, 'w').write(t)
end
}
}
Change-Id: I6fbe13ddc1485efe95c3156097bf41d90c0febac
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This QuickFix behaves like MoveFuncDefOutside except it moves all
member function definitions. It is triggered on the class name.
Change-Id: I1393a51cad521a7bb58a1ed6223ab0fe4db0e592
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Make calls like a->b()->c() assignable to a local variable.
Task-number: QTCREATORBUG-10355
Change-Id: If4a55b435c99150710d00567188f901acb2c1a89
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Trust the matcher to do the job.
Task-number: QTCREATORBUG-13564
Change-Id: I4ff14608a1ce12d3f4424242e50ba71233ac9bfd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>