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>
Follow-up fix for 8d0391a4f9.
Do not complete after '{' coming not after an identifier.
Take constructor completions only for '{' and function
completions only for '('. Filter constructor completions by
class/struct type.
Task-number: QTCREATORBUG-21004
Change-Id: I7ae2d6bee23cf907648c42b93eb12742942833f6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Both completion kinds have the same name. Do not merge them
together when looking for constructor overloads.
Task-number: QTCREATORBUG-21010
Change-Id: I4c851033d63ad4e242b6179491f1fba00af466f6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Try to complete constructor after left brace with fallback
to normal completion.
Task-number: QTCREATORBUG-20957
Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
In preperation for the language server protocol support.
Change-Id: Iee4ccd53a86d9afdb357972ea62b75ace2edcb1d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Follow up for 0f96f735f0. Constructors have worse support
in Clang for their definitions but have proper overloads
for the references.
Change-Id: Ie002ae74b0d15f0fe00126042a7f61172b82946b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
When we complete a function definition with the parameter list
it is important to have multiple entries to select.
Change-Id: I25e94b58cfe4831387d66eecdec74712addb7ec5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Each completion coming from libclang now has it's own
list of fix-its which are required to be applied before
completion itself.
This saves one extra reparse cycle and gives an ability
to provide both kinds of completion (initial and corrected
one) for cases like shared_ptr, unique_ptr or any other
class with overloaded arrow operator.
Each of these extra fix-its is applied together with
corresponding completion dircetly before completion itself.
Change-Id: Ide37e45bb15fa2f1375cd6b86ecd43ced3593046
Reviewed-by: David Schulz <david.schulz@qt.io>
This is long overdue since some names were simply wrong and/or
misleading. Also, some of the old names were long enough to almost get
crazy.
The renaming starts from ClangCodeModelServerInterface and
ClangCodeModelClientInterface and affects usages and related functions.
For the ClangCodeModelServerInterface, categorize the messages in
- messages that require a response (request*)
- notification messages (the remaining ones)
Change-Id: I5342ed8e0d87404ee72f3c3766fd8ef7505defb1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
The patch is mostly mechanical, but contains also a few spurious changes
from values references for some local variables, foreach -> ranged for
etc that I coulnd't resist.
Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Use new clang_getFileContents to efficiently convert
utf8 byte offsets from line start to column numbers.
Also provide simplier backwards convertion to pass
resulting utf8 offset to clang.
Task-number: QTCREATORBUG-16941
Change-Id: If0e58fe01ad3e281b7e952e972b9e86f6e75aadb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Allows to use this header without texteditor dependency.
Change-Id: I706f42799c3ea42473a716fa9ef9f3cfbef6fdd4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
... to reuse this position in backend (instead of
searching the function start again)
Change-Id: I02818dce4fc37ed6e7ecfb533191dbfe60610204
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
We already share same classes there which has nothing to do with IPC and
I want to more for sharing. So we should use a name which fits better.
Change-Id: Idfb12b6de714206117b92634ad719c6a0e290e78
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Correct columns in clang diagnostics and completion
Task-number: QTCREATORBUG-16775
Change-Id: I7260a0e52007fe261e83492dca5d457c34476497
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
For "foo(|" [1] we requested a completion from libclang with the cursor
position just before "foo" and then filtered the function declarations
for functions matching the name "foo". This worked fine for ordinary
functions, but obviously not for constructors and functors.
Recent versions of libclang support proper function call completion with
XCursor_OverloadCandidate, so make use of that.
[1] '|' represents the cursor position
Task-number: QTCREATORBUG-14882
Task-number: QTCREATORBUG-14884
Change-Id: I9d31b3960ccff6a8b9440dbcb7ff9f5ca9f61266
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
To avoid repeating the 'MimeDatabase mdb; mdb.something(); ' mantra
all over the place.
Change-Id: I4bfef62e73275a991455141671d6071162788e9d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reproduce with:
1. Create a new class named Foo with the wizard.
2. Close foo.h
3. In foo.cpp, add some class member function.
4. In foo.cpp, trigger the refactoring action "Add public Declaration"
for the just defined member function. As a result, foo.h will be
opened.
==> While the declaration was added, the header file is not yet
reparsed with the new content - this can be verified by setting
a custom color for "Function".
In this use case, the refactoring action opens the editor and
immediately modifies the document (RefactoringFile::apply).
Fix by sending the document content along for the very first
RegisterTranslationUnitForEditorMessage if the document was already
modified.
Change-Id: If20615a45b72dd0bef87e1870e403d0b277bc5d6
Reviewed-by: David Schulz <david.schulz@qt.io>
The order is 0 by default and thus the snippet items were at the very
top, e.g.:
enum EnumType { EnumValue };
void f()
{
EnumType et = // Complete here and see snippet items at top
}
Change-Id: I70a160d102b91a2589972354c50aa5f0b29323e8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
...on the plugin side by removing a left over calculation. We construct
the detail in the virtual ClangAssistProposalItem::detail(), that is, on
demand.
Test:
1. Open src/plugins/clangstaticanalyzer/unit-tests/qt-essential-includes.pro
2. Open main.cpp
3. Complete in the main function
Measured with a timer in IpcReceiver::codeCompleted.
On Linux, for 20637 completion items:
Before: 119ms (avg)
Now: 81ms (avg)
Gain: 32%
Change-Id: I9617cb9651a8367c31cd40e965175b5b37e10730
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
If there are no completion items, do not add snippets since these will
otherwise pop-up at undesired positions, e.g. when:
1) Typing float/doubles: 0.
2) Typing file suffix in include directives: #include "stdio.
Task-number: QTCREATORBUG-16188
Change-Id: Ie1c29826dc62dc447b2ff57b0c5537eb9d9511ef
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This avoids multiple instatiations and reloading of the same image files.
Change-Id: I4d0bb955e23c1cb817671c25bff4e74fb7b3d0f4
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
There are two versions of startOfOperator:
* InternalCppCompletionAssistProcessor::startOfOperator
* ClangCompletionAssistProcessor::startOfOperator
The latter started as a copy of the former, but the former got some bug
fixes in the meantime. Adjust both versions to each other, so it's easy
to diff them and to extract the duplication in a follow-up change.
Change-Id: Icf48386bf1ad0fa473bec476c5412be9b1890139
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
There are three cases that must be handled:
1. Completion in C++ style comment
2. Completion in first line of a C style comment
3. Completion in non-first line of a C style comment
This change fixes case 1 + 2. Case 3 will be addressed in a follow-up
change, same goes for the duplication.
Task-number: QTCREATORBUG-15143
Change-Id: I449711f965ddcbbe6158870a8a5ae33218e0d238
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
For unit test we need to break every dependency to the TextEditor
Widget etc.. With an abstract interface we can implement it in clang
without relying on unwanted dependencies. It makes it also easier to
compute the values deferred.
Change-Id: I1b313a1625f4e80bd324ab4bf1a7c4f6b690abe9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
E.g. "dynamic_cast<>()" showed up as item.
Let CompletionChunksToTextConverter default to plain text format and
explicitly request HTML where needed.
Change-Id: Iebce85cb888a5bd697ffdce364118b6dc65a435d
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
1 struct Foo { int member; };
2 void f(Foo *foo)
3 {
4 foo.<REQUEST COMPLETION> // correct '.' to '->' and provide results
5 }
The preferred approach would be to check if "foo" in line 4 is of
pointer type, but there is no suitable cursor (only CompoundStmt) at
that position since the code is usually not yet parsed and thus invalid.
Thus, just run the completion as is. If there are not any results for a
dot completion, re-run the completion with "." exchanged by "->". This
approach is inherently slower than the preferred approach implemented in
the built-in code model.
The following rare cases are not handled:
1) Requesting completion after white space:
Works: foo.<COMPLETE HERE>
Fails: foo. <COMPLETE HERE>
2) Opening a file and requesting completion (ctrl+space) without prior
editing. No editing before triggering completion means that no
unsaved file is generated on the backend side, which is a
requirement for the correction.
Task-number: QTCREATORBUG-11581
Change-Id: I6bc8e8594778774ab342755fdb01a8a3e5c52ba0
Reviewed-by: Marco Bubke <marco.bubke@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>
If we send already a completion we should test if there is already one
sent for the same position.
Change-Id: Ie88f89bff0e1da1c5e747827a45154c7ccaecabc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
...for consistency and to avoid future file name clashes.
Change-Id: If595c8debfa1ceb01a1bb0ed34649fa513660503
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
If an editor is changing all translation units independent of their project
part they must be updated too. So we introduce a new message to update all
translation units with the same file path.
Change-Id: I70d0ea2bbca9fa880111ff7219573e54f3277026
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reparsing a document is expensive so we should avoid it by all means. In
this patch we prevent that the same document is send again. It isn't send
too in advance of a code completion if there was no changes before the
the completion position.
Change-Id: I0bb786ba1d4e7ce08611a518cb32f8cf8f4d0037
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
We have auto generated buffers from ui files which are not open but have no
file representation. So we need to provide them as unsaved files only.
Change-Id: I48a426c18e06eeda2fa707864f32f293e17ac651
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
It reflects that the translation units and projects have a tied
relationship with an editor.
Change-Id: I3c01d5776980fe079af1fdef82feded83fdf5463
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>